Fixed a long-standing rare mismatch
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Wed, 26 May 2010 19:04:41 +0000 (15:04 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Wed, 26 May 2010 19:04:41 +0000 (15:04 -0400)
In cases where the coarse energy quantizer wasn't able to
go down fast enough, we could have a negative error that didn't
get clamped.

libcelt/quant_bands.c

index 391d58c..8ddedc2 100644 (file)
@@ -164,6 +164,8 @@ void quant_fine_energy(const CELTMode *m, int start, celt_ener *eBands, celt_wor
 #endif
          if (q2 > frac-1)
             q2 = frac-1;
+         if (q2<0)
+            q2 = 0;
          ec_enc_bits(enc, q2, fine_quant[i]);
 #ifdef FIXED_POINT
          offset = SUB16(SHR16(SHL16(q2,DB_SHIFT)+QCONST16(.5,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));