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

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


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,
-------------- 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 @@
             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);
             spx_ifft(st->fft_table, &st->W[j*N], st->wtmp);
-               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);

More information about the Speex-dev mailing list