Thorvald Natvig
2008-Feb-13 13:58 UTC
[Speex-dev] Fixed-point scaling of mdf impulse response
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;
Jean-Marc Valin
2008-Feb-13 14:08 UTC
[Speex-dev] Fixed-point scaling of mdf impulse response
Thanks. All patches applied now. Cheers, Jean-Marc Thorvald Natvig a ?crit :> 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 > > > ------------------------------------------------------------------------ > > _______________________________________________ > Speex-dev mailing list > Speex-dev@xiph.org > http://lists.xiph.org/mailman/listinfo/speex-dev