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

Jean-Marc Valin jm at xiph.org
Sun Nov 30 14:23:00 PST 2003



jm          03/11/30 17:23:00

  Modified:    libspeex filters.c
  Log:
  fixed-point: comb filter, part III

Revision  Changes    Path
1.72      +27 -13    speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- filters.c	30 Nov 2003 20:23:30 -0000	1.71
+++ filters.c	30 Nov 2003 22:22:59 -0000	1.72
@@ -447,6 +447,12 @@
    mem->smooth_gain=1;
 }
 
+#ifdef FIXED_POINT
+#define COMB_STEP 32767
+#else
+#define COMB_STEP 1.0
+#endif
+
 void comb_filter(
 spx_sig_t *exc,          /*decoded excitation*/
 spx_sig_t *new_exc,      /*enhanced excitation*/
@@ -462,8 +468,9 @@
    int i;
    spx_word16_t exc_energy=0, new_exc_energy=0;
    float gain;
-   float step;
-   float fact;
+   spx_word16_t step;
+   spx_word16_t fact;
+   spx_word16_t cgain;
 
    /*Compute excitation amplitude prior to enhancement*/
    exc_energy = compute_rms(exc, nsf);
@@ -479,23 +486,30 @@
       if (g<.5)
          comb_gain*=2*g;
    }
-   step = 1.0/nsf;
+   step = DIV32(COMB_STEP, nsf);
    fact=0;
+
+#ifdef FIXED_POINT
+   cgain = comb_gain*32768;
+#else
+   cgain = comb_gain;
+#endif
+
    /*Apply pitch comb-filter (filter out noise between pitch harmonics)*/
    for (i=0;i<nsf;i++)
    {
+      spx_word32_t exc1, exc2;
+
       fact += step;
+      
+      exc1 = SHL(MULT16_32_Q15(SHL(pitch_gain[0],7),exc[i-pitch+1]) +
+                 MULT16_32_Q15(SHL(pitch_gain[1],7),exc[i-pitch]) +
+                 MULT16_32_Q15(SHL(pitch_gain[2],7),exc[i-pitch-1]) , 2);
+      exc2 = SHL(MULT16_32_Q15(SHL(mem->last_pitch_gain[0],7),exc[i-mem->last_pitch+1]) +
+                 MULT16_32_Q15(SHL(mem->last_pitch_gain[1],7),exc[i-mem->last_pitch]) +
+                 MULT16_32_Q15(SHL(mem->last_pitch_gain[2],7),exc[i-mem->last_pitch-1]),2);
 
-      new_exc[i] = exc[i] + comb_gain * fact * SHL(
-                                         MULT16_32_Q15(SHL(pitch_gain[0],7),exc[i-pitch+1]) +
-                                         MULT16_32_Q15(SHL(pitch_gain[1],7),exc[i-pitch]) +
-                                         MULT16_32_Q15(SHL(pitch_gain[2],7),exc[i-pitch-1])
-                                         ,2)
-      + comb_gain * (1-fact) * SHL(
-                                         MULT16_32_Q15(SHL(mem->last_pitch_gain[0],7),exc[i-mem->last_pitch+1]) +
-                                         MULT16_32_Q15(SHL(mem->last_pitch_gain[1],7),exc[i-mem->last_pitch]) +
-                                         MULT16_32_Q15(SHL(mem->last_pitch_gain[2],7),exc[i-mem->last_pitch-1])
-                                         ,2);
+      new_exc[i] = exc[i] + MULT16_32_Q15(cgain,MULT16_32_Q15(fact,exc1)  + MULT16_32_Q15(SUB16(COMB_STEP,fact), exc2));
    }
 
    mem->last_pitch_gain[0] = pitch_gain[0];

<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