diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-17 18:02:12 +0300 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-17 18:02:12 +0300 |
commit | 98e34e71c06251531aaab668a870ec44c648de6e (patch) | |
tree | 190b36d536b11fb09565cdf13f2456ae8d99c85c /libavcodec/ac3enc.c | |
parent | 1653027ac40b598cec8416da31ab4742b6ef9c4e (diff) |
Simplify bit allocation search by using a loop for the SNR offset increment.
Originally committed as revision 26044 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3495db0ad5..da9293b867 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1055,7 +1055,7 @@ static int cbr_bit_allocation(AC3EncodeContext *s) { int ch; int bits_left; - int snr_offset; + int snr_offset, snr_incr; bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits); @@ -1069,25 +1069,12 @@ static int cbr_bit_allocation(AC3EncodeContext *s) return AVERROR(EINVAL); FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); + for (snr_incr = 64; snr_incr > 0; snr_incr >>= 2) { while (snr_offset + 64 <= 1023 && - bit_alloc(s, snr_offset + 64) <= bits_left) { - snr_offset += 64; + bit_alloc(s, snr_offset + snr_incr) <= bits_left) { + snr_offset += snr_incr; FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); } - while (snr_offset + 16 <= 1023 && - bit_alloc(s, snr_offset + 16) <= bits_left) { - snr_offset += 16; - FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); - } - while (snr_offset + 4 <= 1023 && - bit_alloc(s, snr_offset + 4) <= bits_left) { - snr_offset += 4; - FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); - } - while (snr_offset + 1 <= 1023 && - bit_alloc(s, snr_offset + 1) <= bits_left) { - snr_offset++; - FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); } FFSWAP(uint8_t *, s->bap_buffer, s->bap1_buffer); reset_block_bap(s); |