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

Jean-Marc Valin jm at xiph.org
Tue Oct 7 22:12:37 PDT 2003



jm          03/10/08 01:12:37

  Modified:    libspeex filters.c filters.h sb_celp.c smallft.c
  Log:
  fixed-point: converted QMF functions

Revision  Changes    Path
1.48      +46 -29    speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- filters.c	8 Oct 2003 05:09:04 -0000	1.47
+++ filters.c	8 Oct 2003 05:12:37 -0000	1.48
@@ -282,83 +282,99 @@
    fir_mem2(y, awk2, y, N, ord, mem);
 }
 
-
-void qmf_decomp(float *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack)
+void qmf_decomp(short *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack)
 {
    int i,j,k,M2;
-   float *a;
-   float *x;
-   float *x2;
+   spx_word16_t *a;
+   spx_word16_t *x;
+   spx_word16_t *x2;
    
-   a = PUSH(stack, M, float);
-   x = PUSH(stack, N+M-1, float);
+   a = PUSH(stack, M, spx_word16_t);
+   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];
+      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++)
-      x[i+M-1]=xx[i];
+      x[i+M-1]=PSHR(xx[i],1);
    for (i=0,k=0;i<N;i+=2,k++)
    {
       y1[k]=0;
       y2[k]=0;
       for (j=0;j<M2;j++)
       {
-         y1[k]+=a[j]*(x[i+j]+x2[i-j]);
-         y2[k]-=a[j]*(x[i+j]-x2[i-j]);
+         y1[k]+=SHR(MULT16_16(a[j],(x[i+j]+x2[i-j])),1);
+         y2[k]-=SHR(MULT16_16(a[j],(x[i+j]-x2[i-j])),1);
          j++;
-         y1[k]+=a[j]*(x[i+j]+x2[i-j]);
-         y2[k]+=a[j]*(x[i+j]-x2[i-j]);
+         y1[k]+=SHR(MULT16_16(a[j],(x[i+j]+x2[i-j])),1);
+         y2[k]+=SHR(MULT16_16(a[j],(x[i+j]-x2[i-j])),1);
       }
    }
    for (i=0;i<M-1;i++)
-     mem[i]=xx[N-i-1];
+     mem[i]=PSHR(xx[N-i-1],1);
 }
 
+
 /* By segher */
-void fir_mem_up(spx_sig_t *x, float *a, spx_sig_t *y, int N, int M, float *mem, char *stack)
+void fir_mem_up(spx_sig_t *x, float *aa, spx_sig_t *y, int N, int M, float *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;
-   float *xx=PUSH(stack, M+N-1, float);
+   spx_word16_t *a;
+   spx_word16_t *xx;
+   
+   xx= PUSH(stack, M+N-1, spx_word16_t);
 
    for (i = 0; i < N/2; i++)
-      xx[2*i] = x[N/2-1-i];
+      xx[2*i] = SHR(x[N/2-1-i],SIG_SHIFT+1);
    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) {
-      float y0, y1, y2, y3;
-      float x0;
+      spx_sig_t y0, y1, y2, y3;
+      spx_word16_t x0;
 
       y0 = y1 = y2 = y3 = 0.f;
       x0 = xx[N-4-i];
 
       for (j = 0; j < M; j += 4) {
-         float x1;
-         float a0, a1;
+         spx_word16_t x1;
+         spx_word16_t a0, a1;
 
          a0 = a[j];
          a1 = a[j+1];
          x1 = xx[N-2+j-i];
 
-         y0 += a0 * x1;
-         y1 += a1 * x1;
-         y2 += a0 * x0;
-         y3 += a1 * x0;
+         y0 += SHR(MULT16_16(a0, x1),1);
+         y1 += SHR(MULT16_16(a1, x1),1);
+         y2 += SHR(MULT16_16(a0, x0),1);
+         y3 += SHR(MULT16_16(a1, x0),1);
 
          a0 = a[j+2];
          a1 = a[j+3];
          x0 = xx[N+j-i];
 
-         y0 += a0 * x0;
-         y1 += a1 * x0;
-         y2 += a0 * x1;
-         y3 += a1 * x1;
+         y0 += SHR(MULT16_16(a0, x0),1);
+         y1 += SHR(MULT16_16(a1, x0),1);
+         y2 += SHR(MULT16_16(a0, x1),1);
+         y3 += SHR(MULT16_16(a1, x1),1);
       }
       y[i] = y0;
       y[i+1] = y1;
@@ -371,6 +387,7 @@
 }
 
 
+
 void comp_filter_mem_init (CombFilterMem *mem)
 {
    mem->last_pitch=0;

<p><p>1.28      +1 -1      speex/libspeex/filters.h

Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- filters.h	8 Oct 2003 05:09:04 -0000	1.27
+++ filters.h	8 Oct 2003 05:12:37 -0000	1.28
@@ -47,7 +47,7 @@
 } CombFilterMem;
 
 
-void qmf_decomp(float *xx, float *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, float *mem, char *stack);
+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);
 
 

<p><p>1.140     +3 -13     speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- sb_celp.c	8 Oct 2003 05:11:25 -0000	1.139
+++ sb_celp.c	8 Oct 2003 05:12:37 -0000	1.140
@@ -250,31 +250,21 @@
    mode = (SpeexSBMode*)(st->mode->mode);
 
    {
-      float *sig_in;
       short *low = PUSH(stack, st->frame_size, short);
 
-      sig_in = PUSH(stack, st->full_frame_size, float);
-      for (i=0;i<st->full_frame_size;i++)
-         sig_in[i] = in[i];
-
       /* Compute the two sub-bands by filtering with h0 and h1*/
-      qmf_decomp(sig_in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
+      qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
       
       for (i=0;i<st->frame_size;i++)
-         low[i] = st->x0d[i];
+         low[i] = PSHR(st->x0d[i],SIG_SHIFT);
       
       /* Encode the narrowband part*/
       speex_encode(st->st_low, low, bits);
 
       for (i=0;i<st->frame_size;i++)
-         st->x0d[i] = low[i];
+         st->x0d[i] = SHL(low[i],SIG_SHIFT);
    }
 
-   for (i=0;i<st->frame_size;i++)
-      st->x0d[i] *= SIG_SCALING;
-   for (i=0;i<st->frame_size;i++)
-      st->x1d[i] *= SIG_SCALING;
-
    /* High-band buffering / sync with low band */
    for (i=0;i<st->windowSize-st->frame_size;i++)
       st->high[i] = st->high[st->frame_size+i];

<p><p>1.19      +0 -0      speex/libspeex/smallft.c

Index: smallft.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/smallft.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- smallft.c	8 Oct 2003 05:11:25 -0000	1.18
+++ smallft.c	8 Oct 2003 05:12:37 -0000	1.19
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: *unnormalized* fft transform
- last mod: $Id: smallft.c,v 1.18 2003/10/08 05:11:25 jm Exp $
+ last mod: $Id: smallft.c,v 1.19 2003/10/08 05:12:37 jm Exp $
 
  ********************************************************************/
 

<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