This fixes a potential assertion failure with some very weak signals
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Tue, 30 Jun 2009 14:31:00 +0000 (10:31 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Tue, 30 Jun 2009 14:31:00 +0000 (10:31 -0400)
libcelt/vq.c

index fb9e2cb..e5be457 100644 (file)
@@ -147,9 +147,17 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, celt_norm_t *P, ec_
       j=0; do {
          sum += X[j];
       }  while (++j<N);
-      if (sum == 0)
+
+#ifdef FIXED_POINT
+      if (sum <= K)
+#else
+      if (sum <= EPSILON)
+#endif
       {
          X[0] = 16384;
+         j=1; do
+            X[j]=0;
+         while (++j<N);
          sum = 16384;
       }
       /* Do we have sufficient accuracy here? */