Fixes an overflow in the fixed-point celt_sqrt() for large values.
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Thu, 29 Nov 2012 21:51:06 +0000 (16:51 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Thu, 29 Nov 2012 21:51:50 +0000 (16:51 -0500)
Was causing problems with the PLC

celt/mathops.c

index ce472c9..21fd942 100644 (file)
@@ -123,6 +123,8 @@ opus_val32 celt_sqrt(opus_val32 x)
    static const opus_val16 C[5] = {23175, 11561, -3011, 1699, -664};
    if (x==0)
       return 0;
+   else if (x>=1073741824)
+      return 32767;
    k = (celt_ilog2(x)>>1)-7;
    x = VSHR32(x, 2*k);
    n = x-32768;