xiph / speexdsp

Speex audio processing library - THIS IS A MIRROR, DEVELOPMENT HAPPENS AT https://gitlab.xiph.org/xiph/speexdsp
https://speex.org
Other
469 stars 190 forks source link

FLOAT_OVERFLOW issue #46

Open martinzzrrxx opened 1 year ago

martinzzrrxx commented 1 year ago

Hi,

I'm using SpeexDSP in a VoIP project to support Noise suppression. It works well on the Windows C++ application but failed with a "FLOAT_OVERFLOW" exception when I tried to use it in a Windows Delphi application.

Snipaste_2023-06-19_15-53-54

After some debugging, I found the exception comes from the function qcurve: https://github.com/xiph/speexdsp/blob/738e17905e1ca2a1fa932ddd9c2a85d089f4e845/libspeexdsp/preprocess.c#L371 https://github.com/xiph/speexdsp/blob/738e17905e1ca2a1fa932ddd9c2a85d089f4e845/libspeexdsp/preprocess.c#L373

When the input argument x is 0.000000, it MAY crash with the FLOAT_OVERFLOW exception(Sometimes, even if the x is zero, no error is reported).

I was able to make it work as expected like this:

static inline spx_word16_t qcurve(spx_word16_t x)
{
   //return 1.f/(1.f+.15f/(SNR_SCALING_1*x));
   return (SNR_SCALING_1*x) / ((SNR_SCALING_1*x)+0.15f);
}

Let me know what you think, and if you need more information.

Thanks.