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

Jean-Marc Valin jm at xiph.org
Tue Oct 22 23:24:58 PDT 2002



jm          02/10/23 02:24:58

  Modified:    libspeex cb_search.c filters.c filters.h nb_celp.c
  Log:
  Continuing cleanup, removed unused functions, ...

Revision  Changes    Path
1.72      +1 -3      speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- cb_search.c	23 Oct 2002 06:03:16 -0000	1.71
+++ cb_search.c	23 Oct 2002 06:24:57 -0000	1.72
@@ -387,9 +387,7 @@
 {
    int i;
    float *tmp=PUSH(stack, nsf);
-   syn_filt_zero(target, awk1, tmp, nsf, p);
-   residue_zero(tmp, ak, tmp, nsf, p);
-   residue_zero(tmp, awk2, tmp, nsf, p);
+   residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack);
 
    for (i=0;i<nsf;i++)
       exc[i]+=tmp[i];

<p><p>1.24      +0 -82     speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- filters.c	23 Oct 2002 06:10:35 -0000	1.23
+++ filters.c	23 Oct 2002 06:24:57 -0000	1.24
@@ -59,88 +59,6 @@
    }
 }
 
-void enh_lpc(float *ak, int order, float *num, float *den, float k1, float k2, float *stack)
-{
-   int i;
-   float *n2, *d2;
-   float k3, r;
-   n2=PUSH(stack,order+1);
-   d2=PUSH(stack,order+1);
-   for (i=0;i<=order;i++)
-   {
-      /*FIXME: Big kludge here!!!*/
-      den[i]=0*ak[i];
-      num[i]=0;
-   }
-   den[0]=1;
-   for (i=order+1;i<=(order<<1);i++)
-      den[i]=num[i]=0;
-   r=.9;
-   k3=(1-(1-r*k1)/(1-r*k2))/r;
-   bw_lpc(k1, ak, d2, order);
-   num[0]=1;
-   bw_lpc(k2, ak, num, order);
-   bw_lpc(k3, ak, n2, order);
-   residue_zero(num,n2,num,1+(order<<1),order);
-   residue_zero(den,d2,den,1+(order<<1),order);
-}
-
-
-void syn_filt_zero(float *x, float *a, float *y, int N, int ord)
-{
-#if 0
-   int i;
-   float mem[10];
-   for (i=0;i<10;i++)
-      mem[i]=0;
-   iir_mem2(x,a,y,N,ord,mem);
-#else
-   int i,j;
-   for (i=0;i<N;i++)
-   {
-      y[i]=x[i];
-      for (j=1;j<=min(ord,i);j++)
-         y[i] -= a[j]*y[i-j];
-   }
-#endif
-}
-
-
-void residue_zero(float *x, float *a, float *y, int N, int ord)
-{
-#if 0
-   int i;
-   float mem[10];
-   for (i=0;i<10;i++)
-      mem[i]=0;
-   fir_mem2(x,a,y,N,ord,mem);
-#else
-   int i,j;
-   for (i=N-1;i>=0;i--)
-   {
-      y[i]=x[i];
-      for (j=1;j<=min(ord,i);j++)
-         y[i] += a[j]*x[i-j];
-         }
-#endif
-}
-
-
-void _filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem)
-{
-   int i,j;
-   float xi;
-   for (i=0;i<N;i++)
-   {
-      xi=x[i];
-      y[i] = num[0]*xi + mem[0];
-      for (j=0;j<ord-1;j++)
-      {
-         mem[j] = mem[j+1] + num[j+1]*xi - den[j+1]*y[i];
-      }
-      mem[ord-1] = num[ord]*xi - den[ord]*y[i];
-   }
-}
 
 void filter_mem2(float *x, float *num, float *den, float *y, int N, int ord, float *mem)
 {

<p><p>1.18      +0 -16     speex/libspeex/filters.h

Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- filters.h	23 Oct 2002 02:56:46 -0000	1.17
+++ filters.h	23 Oct 2002 06:24:57 -0000	1.18
@@ -44,22 +44,6 @@
 /* Apply bandwidth expansion on LPC coef */
 void bw_lpc(float gamma, float *lpc_in, float *lpc_out, int order);
 
-void poly(float *re, float *im, float *p, int ord);
-
-void enh_lpc(float *ak, int order, float *num, float *den, float k1, float k2, float *stack);
-
-/*LPC polynomial "flatifier"*/
-void lpc_flat(float g1, float g2, float *lpc_in, float *lpc_out1, float *lpc_out2, int order);
-
-
-
-/* Synthesis filter using zero memory */
-void syn_filt_zero(float *x, float *a, float *y, int N, int ord);
-
-/* Analysis (FIR) filter using zero memory */
-void residue_zero(float *x, float *a, float *y, int N, int ord);
-
-
 
 
 /* FIR filter */

<p><p>1.65      +23 -21    speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- nb_celp.c	22 Oct 2002 19:29:29 -0000	1.64
+++ nb_celp.c	23 Oct 2002 06:24:57 -0000	1.65
@@ -576,9 +576,6 @@
       }
 
       /* Update target for adaptive codebook contribution */
-      /*residue_zero(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
-      syn_filt_zero(res, st->interp_qlpc, res, st->subframeSize, st->lpcSize);
-      syn_filt_zero(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize);*/
       syn_percep_zero(exc, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, res, st->subframeSize, st->lpcSize, stack);
       for (i=0;i<st->subframeSize;i++)
         target[i]-=res[i];
@@ -603,9 +600,6 @@
          for (i=0;i<st->subframeSize;i++)
             innov[i]=0;
          
-         /*syn_filt_zero(target, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
-         residue_zero(res, st->interp_qlpc, st->buf2, st->subframeSize, st->lpcSize);
-         residue_zero(st->buf2, st->bw_lpc2, st->buf2, st->subframeSize, st->lpcSize);*/
          residue_percep_zero(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, st->buf2, st->subframeSize, st->lpcSize, stack);
          for (i=0;i<st->subframeSize;i++)
             ener+=st->buf2[i]*st->buf2[i];
@@ -808,14 +802,15 @@
 static void nb_decode_lost(DecState *st, float *out, float *stack)
 {
    int i, sub;
-   float *num, *den;
+   float *awk1, *awk2, *awk3;
    /*float exc_ener=0,g;*/
    /* Shift all buffers by one frame */
    speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
    speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
 
-   num=PUSH(stack, ((st->lpcSize<<1)+1));
-   den=PUSH(stack, ((st->lpcSize<<1)+1));
+   awk1=PUSH(stack, (st->lpcSize+1));
+   awk2=PUSH(stack, (st->lpcSize+1));
+   awk3=PUSH(stack, (st->lpcSize+1));
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
@@ -829,13 +824,22 @@
       exc=st->exc+offset;
       /* Excitation after post-filter*/
 
-      if (st->lpc_enh_enabled)
       {
-         enh_lpc(st->interp_qlpc, st->lpcSize, num, den, 
-                 SUBMODE(lpc_enh_k1), SUBMODE(lpc_enh_k2), stack);
-      } else {
-         enh_lpc(st->interp_qlpc, st->lpcSize, num, den, 
-                 SUBMODE(lpc_enh_k2), SUBMODE(lpc_enh_k2), stack);
+         float r=.9;
+         
+         float k1,k2,k3;
+         k1=SUBMODE(lpc_enh_k1);
+         k2=SUBMODE(lpc_enh_k2);
+         k3=(1-(1-r*k1)/(1-r*k2))/r;
+         if (!st->lpc_enh_enabled)
+         {
+            k1=k2;
+            k3=0;
+         }
+         bw_lpc(k1, st->interp_qlpc, awk1, st->lpcSize);
+         bw_lpc(k2, st->interp_qlpc, awk2, st->lpcSize);
+         bw_lpc(k3, st->interp_qlpc, awk3, st->lpcSize);
+         
       }
         
       for (i=0;i<st->subframeSize;i++)
@@ -847,11 +851,9 @@
       for (i=0;i<st->subframeSize;i++)
          sp[i]=exc[i];
       
-      /*pole_zero_mem(sp, num, den, sp, st->subframeSize, (st->lpcSize<<1), 
-                    st->mem_sp+st->lpcSize, stack);*/
-      filter_mem2(sp, num, den, sp, st->subframeSize, (st->lpcSize<<1), 
+      filter_mem2(sp, awk3, awk1, sp, st->subframeSize, st->lpcSize, 
         st->mem_sp+st->lpcSize);
-      iir_mem2(sp, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
+      filter_mem2(sp, awk2, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
         st->mem_sp);
   
    }
@@ -1150,9 +1152,9 @@
          comb_filter(exc, sp, st->interp_qlpc, st->lpcSize, st->subframeSize,
                               pitch, pitch_gain, .5);
       filter_mem2(sp, awk3, awk1, sp, st->subframeSize, st->lpcSize, 
-        st->mem_sp);
-      filter_mem2(sp, awk2, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
         st->mem_sp+st->lpcSize);
+      filter_mem2(sp, awk2, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, 
+        st->mem_sp);
    }
    
    /*Copy output signal*/

<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