[xiph-cvs] cvs commit: speex/libspeex arch.h ltp.c ltp.h nb_celp.c testenc.c

Jean-Marc Valin jm at xiph.org
Mon Nov 24 22:58:12 PST 2003



jm          03/11/25 01:58:11

  Modified:    libspeex arch.h ltp.c ltp.h nb_celp.c testenc.c
  Log:
  fixed-point: done quantizing open-loop pitch

Revision  Changes    Path
1.3       +2 -0      speex/libspeex/arch.h

Index: arch.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/arch.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- arch.h	21 Nov 2003 03:06:42 -0000	1.2
+++ arch.h	25 Nov 2003 06:58:10 -0000	1.3
@@ -35,6 +35,8 @@
 #ifndef ARCH_H
 #define ARCH_H
 
+#define ABS(x) ((x) < 0 ? (-(x)) : (x))
+
 #ifdef FIXED_POINT
 
 typedef signed short spx_word16_t;

<p><p>1.99      +4 -8      speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- ltp.c	21 Nov 2003 03:06:42 -0000	1.98
+++ ltp.c	25 Nov 2003 06:58:10 -0000	1.99
@@ -59,7 +59,7 @@
 }
 #endif
 
-void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack)
+void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack)
 {
    int i,j,k;
    spx_word32_t *best_score;
@@ -169,17 +169,13 @@
    /* Compute open-loop gain */
    for (j=0;j<N;j++)
    {
-      spx_word32_t g;
+      spx_word16_t g;
       i=pitch[j];
       g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),8));
       /* FIXME: g = max(g,corr/energy) */
       if (g<0)
          g = 0;
-#ifdef FIXED_POINT
-      gain[j]=0.0039062*g;
-#else
       gain[j]=g;
-#endif
    }
 }
 
@@ -444,14 +440,14 @@
    int N;
    ltp_params *params;
    int *nbest;
-   float *gains;
+   spx_word16_t *gains;
 
    N=complexity;
    if (N>10)
       N=10;
 
    nbest=PUSH(stack, N, int);
-   gains = PUSH(stack, N, float);
+   gains = PUSH(stack, N, spx_word16_t);
    params = (ltp_params*) par;
 
    if (N==0 || end<start)

<p><p>1.37      +1 -1      speex/libspeex/ltp.h

Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- ltp.h	8 Oct 2003 04:40:41 -0000	1.36
+++ ltp.h	25 Nov 2003 06:58:10 -0000	1.37
@@ -40,7 +40,7 @@
 } ltp_params;
 
 
-void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, float *gain, int N, char *stack);
+void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack);
 
 
 /** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */

<p><p>1.154     +11 -4     speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -r1.153 -r1.154
--- nb_celp.c	14 Nov 2003 19:16:22 -0000	1.153
+++ nb_celp.c	25 Nov 2003 06:58:10 -0000	1.154
@@ -295,7 +295,7 @@
           SUBMODE(lbr_pitch) != -1)
       {
          int nol_pitch[6];
-         float nol_pitch_coef[6];
+         spx_word16_t nol_pitch_coef[6];
          
          bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
          bw_lpc(st->gamma2, st->interp_lpc, st->bw_lpc2, st->lpcSize);
@@ -309,9 +309,13 @@
          /*Try to remove pitch multiples*/
          for (i=1;i<6;i++)
          {
-            if ((nol_pitch_coef[i]>.85*ol_pitch_coef) && 
-                (fabs(nol_pitch[i]-ol_pitch/2.0)<=1 || fabs(nol_pitch[i]-ol_pitch/3.0)<=1 || 
-                 fabs(nol_pitch[i]-ol_pitch/4.0)<=1 || fabs(nol_pitch[i]-ol_pitch/5.0)<=1))
+#ifdef FIXED_POINT
+            if ((nol_pitch_coef[i]>MULT16_16_Q15(nol_pitch_coef[0],27853)) && 
+#else
+            if ((nol_pitch_coef[i]>.85*nol_pitch_coef[0]) && 
+#endif
+                (ABS(2*nol_pitch[i]-ol_pitch)<=2 || ABS(3*nol_pitch[i]-ol_pitch)<=3 || 
+                 ABS(4*nol_pitch[i]-ol_pitch)<=4 || ABS(5*nol_pitch[i]-ol_pitch)<=5))
             {
                /*ol_pitch_coef=nol_pitch_coef[i];*/
                ol_pitch = nol_pitch[i];
@@ -335,6 +339,9 @@
          }
 #endif
 
+#ifdef FIXED_POINT
+         ol_pitch_coef *= 0.0039062;
+#endif
       } else {
          ol_pitch=0;
          ol_pitch_coef=0;

<p><p>1.53      +1 -1      speex/libspeex/testenc.c

Index: testenc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- testenc.c	8 Nov 2003 06:52:00 -0000	1.52
+++ testenc.c	25 Nov 2003 06:58:10 -0000	1.53
@@ -49,7 +49,7 @@
    speex_decoder_ctl(dec, SPEEX_SET_ENH, &tmp);
    tmp=0;
    speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
-   tmp=4;
+   tmp=1;
    speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
    tmp=5;
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list