[xiph-commits] r12373 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Mon Jan 22 05:53:55 PST 2007


Author: jm
Date: 2007-01-22 05:53:52 -0800 (Mon, 22 Jan 2007)
New Revision: 12373

Modified:
   trunk/speex/libspeex/resample.c
Log:
removing the div from the outer loop.


Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c	2007-01-22 04:58:07 UTC (rev 12372)
+++ trunk/speex/libspeex/resample.c	2007-01-22 13:53:52 UTC (rev 12373)
@@ -70,6 +70,8 @@
    int    last_sample;
    int    samp_frac_num;
    int    filt_len;
+   int    int_advance;
+   int    frac_advance;
    
    float *mem;
    float *sinc_table;
@@ -186,16 +188,18 @@
             but I know it's MMSE-optimal on a sinc */
          interp[0] =  -0.16667f*frac + 0.16667f*frac*frac*frac;
          interp[1] = frac + 0.5f*frac*frac - 0.5f*frac*frac*frac;
-         interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;
+         /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/
          interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac;
+         /* Just to make sure we don't have rounding problems */
+         interp[2] = 1.f-interp[0]-interp[1]-interp[3];
          /*sum = frac*accum[1] + (1-frac)*accum[2];*/
          sum = interp[0]*accum[0] + interp[1]*accum[1] + interp[2]*accum[2] + interp[3]*accum[3];
       }
       *out = sum;
       out += st->out_stride;
       out_sample++;
-      st->last_sample += st->num_rate/st->den_rate;
-      st->samp_frac_num += st->num_rate%st->den_rate;
+      st->last_sample += st->int_advance;
+      st->samp_frac_num += st->frac_advance;
       if (st->samp_frac_num >= st->den_rate)
       {
          st->samp_frac_num -= st->den_rate;
@@ -293,6 +297,8 @@
       st->type = SPEEX_RESAMPLER_INTERPOLATE;
       /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff);*/
    }
+   st->int_advance = st->num_rate/st->den_rate;
+   st->frac_advance = st->num_rate%st->den_rate;
 
 }
 



More information about the commits mailing list