[xiph-cvs] cvs commit: speex/libspeex filters.c filters.h lsp.c lsp.h nb_celp.c sb_celp.c sb_celp.h

Jean-Marc Valin jm at xiph.org
Wed Oct 8 15:31:42 PDT 2003



jm          03/10/08 18:31:42

  Modified:    libspeex filters.c filters.h lsp.c lsp.h nb_celp.c sb_celp.c
                        sb_celp.h
  Log:
  fixed-point: QMF entirely in fixed-point now

Revision  Changes    Path
1.49      +3 -16     speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- filters.c	8 Oct 2003 05:12:37 -0000	1.48
+++ filters.c	8 Oct 2003 22:31:41 -0000	1.49
@@ -282,7 +282,7 @@
    fir_mem2(y, awk2, y, N, ord, mem);
 }
 
-void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack)
+void qmf_decomp(short *xx, spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack)
 {
    int i,j,k,M2;
    spx_word16_t *a;
@@ -293,13 +293,9 @@
    x = PUSH(stack, N+M-1, spx_word16_t);
    x2=x+M-1;
    M2=M>>1;
-#ifdef FIXED_POINT
-   for (i=0;i<M;i++)
-      a[M-i-1]=floor(.5+65536*aa[i]);
-#else
    for (i=0;i<M;i++)
       a[M-i-1]= aa[i];
-#endif
+
    for (i=0;i<M-1;i++)
       x[i]=mem[M-i-2];
    for (i=0;i<N;i++)
@@ -323,13 +319,12 @@
 
 
 /* By segher */
-void fir_mem_up(spx_sig_t *x, float *aa, spx_sig_t *y, int N, int M, float *mem, char *stack)
+void fir_mem_up(spx_sig_t *x, spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack)
    /* assumptions:
       all odd x[i] are zero -- well, actually they are left out of the array now
       N and M are multiples of 4 */
 {
    int i, j;
-   spx_word16_t *a;
    spx_word16_t *xx;
    
    xx= PUSH(stack, M+N-1, spx_word16_t);
@@ -339,14 +334,6 @@
    for (i = 0; i < M - 1; i += 2)
       xx[N+i] = mem[i+1];
 
-#ifdef FIXED_POINT
-   a = PUSH(stack, M, spx_word16_t);
-   for (i=0;i<M;i++)
-      a[i] = floor(.5+65536*aa[i]);
-#else
-   a = aa;
-#endif
-
    for (i = 0; i < N; i += 4) {
       spx_sig_t y0, y1, y2, y3;
       spx_word16_t x0;

<p><p>1.29      +2 -2      speex/libspeex/filters.h

Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- filters.h	8 Oct 2003 05:12:37 -0000	1.28
+++ filters.h	8 Oct 2003 22:31:41 -0000	1.29
@@ -47,8 +47,8 @@
 } CombFilterMem;
 
 
-void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack);
-void fir_mem_up(spx_sig_t *x, float *a, spx_sig_t *y, int N, int M, float *mem, char *stack);
+void qmf_decomp(short *xx, spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack);
+void fir_mem_up(spx_sig_t *x, spx_word16_t *a, spx_sig_t *y, int N, int M, spx_word32_t *mem, char *stack);
 
 
 void filter_mem2(spx_sig_t *x, spx_coef_t *num, spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem);

<p><p>1.32      +13 -4     speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- lsp.c	8 Oct 2003 05:06:01 -0000	1.31
+++ lsp.c	8 Oct 2003 22:31:41 -0000	1.32
@@ -56,6 +56,15 @@
 #define NULL 0
 #endif
 
+#ifdef FIXED_POINT
+#define ANGLE2X(a) (cos(a))
+#define X2ANGLE(x) (acos(x))
+#else
+#define ANGLE2X(a) (cos(a))
+#define X2ANGLE(x) (acos(x))
+#endif
+
+
 /*---------------------------------------------------------------------------*\
 
         FUNCTION....: cheb_poly_eva()
@@ -291,7 +300,7 @@
                 }
 
                /* once zero is found, reset initial interval to xr 	*/
-	       freq[j] = acos(xm);
+	       freq[j] = X2ANGLE(xm);
                xl = xm;
                flag = 0;       		/* reset flag for next search 	*/
             }
@@ -335,7 +344,7 @@
     
     freqn = PUSH(stack, lpcrdr, spx_word16_t);
     for (i=0;i<lpcrdr;i++)
-       freqn[i] = cos(freq[i])*32768.;
+       freqn[i] = ANGLE2X(freq[i])*32768.;
 
     Wp = PUSH(stack, 4*m+2, spx_word32_t);
     pw = Wp;
@@ -430,8 +439,8 @@
             n2 = n1 + 1;
             n3 = n2 + 1;
             n4 = n3 + 1;
-	    xout1 = xin1 - 2*(cos(freq[i2])) * *n1 + *n2;
-	    xout2 = xin2 - 2*(cos(freq[i2+1])) * *n3 + *n4;
+	    xout1 = xin1 - 2*(ANGLE2X(freq[i2])) * *n1 + *n2;
+	    xout2 = xin2 - 2*(ANGLE2X(freq[i2+1])) * *n3 + *n4;
             *n2 = *n1;
             *n4 = *n3;
             *n1 = xin1;

<p><p>1.10      +0 -1      speex/libspeex/lsp.h

Index: lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- lsp.h	8 Oct 2003 04:27:51 -0000	1.9
+++ lsp.h	8 Oct 2003 22:31:41 -0000	1.10
@@ -55,5 +55,4 @@
 /*Added by JMV*/
 void lsp_enforce_margin(float *lsp, int len, float margin);
 
-
 #endif	/* __AK2LSPD__ */

<p><p>1.138     +1 -1      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- nb_celp.c	8 Oct 2003 05:11:25 -0000	1.137
+++ nb_celp.c	8 Oct 2003 22:31:41 -0000	1.138
@@ -154,7 +154,7 @@
    st->first = 1;
    for (i=0;i<st->lpcSize;i++)
    {
-      st->lsp[i]=(M_PI*((float)(i+1)))/(st->lpcSize+1);
+      st->lsp[i]=8192*(M_PI*((float)(i+1)))/(st->lpcSize+1);
    }
 
    st->mem_sp = PUSH(st->stack, st->lpcSize, spx_mem_t);

<p><p>1.141     +16 -9     speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- sb_celp.c	8 Oct 2003 05:12:37 -0000	1.140
+++ sb_celp.c	8 Oct 2003 22:31:42 -0000	1.141
@@ -54,6 +54,14 @@
 #define SUBMODE(x) st->submodes[st->submodeID]->x
 
 #define QMF_ORDER 64
+
+#ifdef FIXED_POINT
+static spx_word16_t h0[64] = {2, -7, -7, 18, 15, -39, -25, 75, 35, -130, -41, 212, 38, -327, -17, 483, -32, -689, 124, 956, -283, -1307, 543, 1780, -973, -2467, 1733, 3633, -3339, -6409, 9059, 30153, 30153, 9059, -6409, -3339, 3633, 1733, -2467, -973, 1780, 543, -1307, -283, 956, 124, -689, -32, 483, -17, -327, 38, 212, -41, -130, 35, 75, -25, -39, 15, 18, -7, -7, 2};
+
+static spx_word16_t h1[64] = {2, 7, -7, -18, 15, 39, -25, -75, 35, 130, -41, -212, 38, 327, -17, -483, -32, 689, 124, -956, -283, 1307, 543, -1780, -973, 2467, 1733, -3633, -3339, 6409, 9059, -30153, 30153, -9059, -6409, 3339, 3633, -1733, -2467, 973, 1780, -543, -1307, 283, 956, -124, -689, 32, 483, 17, -327, -38, 212, 41, -130, -35, 75, 25, -39, -15, 18, 7, -7, -2};
+
+
+#else
 static float h0[64] = {
    3.596189e-05, -0.0001123515,
    -0.0001104587, 0.0002790277,
@@ -123,6 +131,7 @@
    0.0002790277, 0.0001104587,
    -0.0001123515, -3.596189e-05
 };
+#endif
 
 void *sb_encoder_init(SpeexMode *m)
 {
@@ -164,10 +173,10 @@
    st->y0=PUSH(st->stack, st->full_frame_size, spx_sig_t);
    st->y1=PUSH(st->stack, st->full_frame_size, spx_sig_t);
 
-   st->h0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->h1_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g1_mem=PUSH(st->stack, QMF_ORDER, float);
+   st->h0_mem=PUSH(st->stack, QMF_ORDER, spx_word16_t);
+   st->h1_mem=PUSH(st->stack, QMF_ORDER, spx_word16_t);
+   st->g0_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t);
+   st->g1_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t);
 
    st->buf=PUSH(st->stack, st->windowSize, spx_sig_t);
    st->excBuf=PUSH(st->stack, st->bufSize, spx_sig_t);
@@ -696,10 +705,8 @@
    st->y0=PUSH(st->stack, st->full_frame_size, spx_sig_t);
    st->y1=PUSH(st->stack, st->full_frame_size, spx_sig_t);
 
-   st->h0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->h1_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g0_mem=PUSH(st->stack, QMF_ORDER, float);
-   st->g1_mem=PUSH(st->stack, QMF_ORDER, float);
+   st->g0_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t);
+   st->g1_mem=PUSH(st->stack, QMF_ORDER, spx_word32_t);
 
    st->exc=PUSH(st->stack, st->frame_size, spx_sig_t);
 
@@ -1354,7 +1361,7 @@
          for (i=0;i<2*st->lpcSize;i++)
             st->mem_sp[i]=0;
          for (i=0;i<QMF_ORDER;i++)
-            st->h0_mem[i]=st->h1_mem[i]=st->g0_mem[i]=st->g1_mem[i]=0;
+            st->g0_mem[i]=st->g1_mem[i]=0;
       }
       break;
    case SPEEX_SET_SUBMODE_ENCODING:

<p><p>1.46      +3 -2      speex/libspeex/sb_celp.h

Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- sb_celp.h	8 Oct 2003 05:03:47 -0000	1.45
+++ sb_celp.h	8 Oct 2003 22:31:42 -0000	1.46
@@ -61,7 +61,8 @@
    spx_sig_t *x0d, *x1d; /**< QMF filter signals*/
    spx_sig_t *high;                /**< High-band signal (buffer) */
    spx_sig_t *y0, *y1;             /**< QMF synthesis signals */
-   float *h0_mem, *h1_mem, *g0_mem, *g1_mem; /**< QMF memories */
+   spx_word16_t *h0_mem, *h1_mem;
+   spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */
 
    spx_sig_t *excBuf;              /**< High-band excitation */
    spx_sig_t *exc;                 /**< High-band excitation (for QMF only)*/
@@ -125,7 +126,7 @@
    spx_sig_t *x0d, *x1d;
    spx_sig_t *high;
    spx_sig_t *y0, *y1;
-   float *h0_mem, *h1_mem, *g0_mem, *g1_mem;
+   spx_word32_t *g0_mem, *g1_mem;
 
    spx_sig_t *exc;
    float *qlsp;

<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