The encoder would crash in the PVQ search if fed NaNs via the float interface. This...
authorGregory Maxwell <greg@xiph.org>
Mon, 9 May 2011 17:16:30 +0000 (13:16 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Mon, 9 May 2011 19:54:08 +0000 (15:54 -0400)
Thanks to David Richards for reporting this failure mode.

libcelt/celt.c
libcelt/vq.c

index 671ac58..63fa3d8 100644 (file)
@@ -1086,6 +1086,8 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
 
             x = SCALEIN(*pcmp);
 #ifndef FIXED_POINT
+            if (!(x==x))
+               x = 0;
             if (st->clip)
                x = MAX32(-65536.f, MIN32(65536.f,x));
 #endif
index 22aa03b..5c74351 100644 (file)
@@ -223,7 +223,9 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B,
 #ifdef FIXED_POINT
       if (sum <= K)
 #else
-      if (sum <= EPSILON)
+      /* Prevents infinities and NaNs from causing too many pulses
+         to be allocated. 64 is an approximation of infinity here. */
+      if (!(sum > EPSILON && sum < 64))
 #endif
       {
          X[0] = QCONST16(1.f,14);