In CVBR mode the rate selection was failing to add bytes which were about to fall off the end of the bitres and never be reusable, causing undershoot.

This commit is contained in:
Gregory Maxwell 2011-01-13 14:38:24 -05:00 committed by Jean-Marc Valin
parent 5677e34fde
commit d85018cb54

View file

@ -1163,10 +1163,8 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
min_allowed = (tell+total_boost+(1<<BITRES+3)-1>>(BITRES+3)) + 2 - nbFilledBytes; min_allowed = (tell+total_boost+(1<<BITRES+3)-1>>(BITRES+3)) + 2 - nbFilledBytes;
nbAvailableBytes = target+(1<<(BITRES+2))>>(BITRES+3); nbAvailableBytes = target+(1<<(BITRES+2))>>(BITRES+3);
nbAvailableBytes=IMAX(min_allowed,nbAvailableBytes); nbAvailableBytes = IMAX(min_allowed,nbAvailableBytes);
nbAvailableBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes) - nbFilledBytes;
nbCompressedBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes);
nbAvailableBytes = nbCompressedBytes - nbFilledBytes;
target=nbAvailableBytes<<(BITRES+3); target=nbAvailableBytes<<(BITRES+3);
@ -1194,6 +1192,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
st->vbr_reservoir = 0; st->vbr_reservoir = 0;
/*printf ("+%d\n", adjust);*/ /*printf ("+%d\n", adjust);*/
} }
nbCompressedBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes);
/* This moves the raw bits to take into account the new compressed size */ /* This moves the raw bits to take into account the new compressed size */
ec_byte_shrink(&buf, nbCompressedBytes); ec_byte_shrink(&buf, nbCompressedBytes);