Fixed a long-standing rare mismatch

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.
This commit is contained in:
Jean-Marc Valin 2010-05-26 15:04:41 -04:00
parent 40e993c029
commit c4ac57023c

View 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));