Commit bca70b87 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Fixes opus_pcm_soft_clip() returning values slightly larger than +/-1 with -ffast-math

parent 6be769c3
......@@ -104,6 +104,10 @@ OPUS_EXPORT void opus_pcm_soft_clip(float *_x, int N, int C, float *declip_mem)
/* Compute a such that maxval + a*maxval^2 = 1 */
a=(maxval-1)/(maxval*maxval);
/* Slightly boost "a" by 2^-24. This is just enough to ensure -ffast-math
does not cause output values larger than +/-1, but small enough not
to matter even for 24-bit output. */
a += a*6e-8;
if (x[i*C]>0)
a = -a;
/* Apply soft clipping */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment