shithub: opus

Download patch

ref: bca70b87efc40595e2bb469d63c77618872bd97b
parent: 6be769c3f3f05a9fa090ac8b8371cc4fa7cd1e1b
author: Jean-Marc Valin <[email protected]>
date: Fri Jul 15 06:57:21 EDT 2016

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

--- a/src/opus.c
+++ b/src/opus.c
@@ -104,6 +104,10 @@
 
          /* 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 */