Take into accound the 32-bit limit in the VQ

This reduces waste at high bit-rate
This commit is contained in:
Jean-Marc Valin 2010-12-06 21:31:15 -05:00
parent 79b34eb83e
commit 52dc66b887

View file

@ -166,6 +166,9 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
for (j=start;j<end;j++)
{
int tmp = bits1[j] + (mid*bits2[j]>>ALLOC_STEPS);
/* Don't allocate more than we can actually use */
if (tmp > 64*C<<BITRES<<LM)
tmp = 64*C<<BITRES<<LM;
if (tmp >= thresh[j])
psum += tmp;
else if (tmp >= 1<<BITRES)
@ -189,6 +192,9 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
bits[j] = 1<<BITRES;
else
bits[j] = 0;
/* Don't allocate more than we can actually use */
if (bits[j] > 64*C<<BITRES<<LM)
bits[j] = 64*C<<BITRES<<LM;
psum += bits[j];
}
codedBands++;