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

jm at svn.xiph.org jm at svn.xiph.org
Sat Jan 20 03:06:57 PST 2007


Author: jm
Date: 2007-01-20 03:06:55 -0800 (Sat, 20 Jan 2007)
New Revision: 12361

Modified:
   trunk/speex/libspeex/resample.c
Log:
interpolate after accumulation


Modified: trunk/speex/libspeex/resample.c
===================================================================
--- trunk/speex/libspeex/resample.c	2007-01-20 09:51:14 UTC (rev 12360)
+++ trunk/speex/libspeex/resample.c	2007-01-20 11:06:55 UTC (rev 12361)
@@ -36,7 +36,7 @@
             
 //#define float double
 #define FILTER_SIZE 64
-#define OVERSAMPLE 128
+#define OVERSAMPLE 64
 
 typedef enum {SPEEX_RESAMPLER_DIRECT=0, SPEEX_RESAMPLER_INTERPOLATE=1} SpeexSincType;
 
@@ -140,25 +140,22 @@
             sum += in[st->last_sample-N+1+j]*st->sinc_table[st->samp_frac_num*st->filt_len+j];
          }
       } else {
+         float accum[2] = {0.f,0.f};
          float alpha = ((float)st->samp_frac_num)/st->den_rate;
          int offset = st->samp_frac_num*OVERSAMPLE/st->den_rate;
          float frac = alpha*OVERSAMPLE - offset;
          for (j=0;st->last_sample-N+1+j < 0;j++)
          {
-            float interp = frac*st->sinc_table[4+(j+1)*OVERSAMPLE-offset-1] + (1-frac)*st->sinc_table[4+(j+1)*OVERSAMPLE-offset];
-            //sum += st->mem[st->last_sample+j]*sinc((j-N/2+1)-((float)st->samp_frac_num)/st->den_rate, N);
-            sum += st->mem[st->last_sample+j]*interp;
+            accum[0] += st->mem[st->last_sample+j]*st->sinc_table[4+(j+1)*OVERSAMPLE-offset-1];
+            accum[1] += st->mem[st->last_sample+j]*st->sinc_table[4+(j+1)*OVERSAMPLE-offset];
          }
          /* Do the new part */
          for (;j<N;j++)
          {
-            float interp = frac*st->sinc_table[4+(j+1)*OVERSAMPLE-offset-1] + (1-frac)*st->sinc_table[4+(j+1)*OVERSAMPLE-offset];
-            //if (st->last_sample > N+2)
-            //   fprintf (stderr, "%f %f %f %f\n", sinc((j-N/2+1)-alpha, N), st->sinc_table[4+(j+1)*OVERSAMPLE-offset], st->sinc_table[4+(j+1)*OVERSAMPLE-offset-1], interp);
-            //sum += in[st->last_sample-N+1+j]*sinc((j-N/2+1)-alpha, N);
-            sum += in[st->last_sample-N+1+j]*interp;
-            
+            accum[0] += in[st->last_sample-N+1+j]*st->sinc_table[4+(j+1)*OVERSAMPLE-offset-1];
+            accum[1] += in[st->last_sample-N+1+j]*st->sinc_table[4+(j+1)*OVERSAMPLE-offset];
          }
+         sum = frac*accum[0] + (1-frac)*accum[1];
       }
       //if (st->last_sample > N+2)
       //   exit(0);



More information about the commits mailing list