[Speex-dev] Fixed-point scaling of mdf impulse response

Thorvald Natvig speex at natvig.com
Wed Feb 13 13:58:44 PST 2008


Hi,

I made a small error in the impulse reponse function; when doing the 
inverse fft in fixed point, it will overflow unless it's properly scaled. 
This patch uses the same scaling as that used when updating the filters, 
and the outputs now have the same shape and the same scale in fixed 
and floating point.

Best regards,
Thorvald
-------------- next part --------------
diff -ubBwr clean/libspeex/mdf.c impulse_scale/libspeex/mdf.c
--- clean/libspeex/mdf.c	2008-02-13 11:12:13.000000000 +0100
+++ impulse_scale/libspeex/mdf.c	2008-02-13 22:47:44.000000000 +0100
@@ -1180,13 +1180,13 @@
          {
 #ifdef FIXED_POINT
             for (i=0;i<N;i++)
-               st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],16));
+               st->wtmp2[i] = EXTRACT16(PSHR32(st->W[j*N+i],16+NORMALIZE_SCALEDOWN));
             spx_ifft(st->fft_table, st->wtmp2, st->wtmp);
 #else
             spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);
 #endif
             for(i=0;i<n;i++)
-               filt[j*n+i] = PSHR32(MULT16_16(32767,st->wtmp[i]), WEIGHT_SHIFT);
+               filt[j*n+i] = PSHR32(MULT16_16(32767,st->wtmp[i]), WEIGHT_SHIFT-NORMALIZE_SCALEDOWN);
          }
       }
          break;


More information about the Speex-dev mailing list