diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-01 02:22:08 +0300 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-01 02:22:08 +0300 |
commit | 9c84a72a250d048138c5e66a8d2655fd753eb32a (patch) | |
tree | b6394130d5ddf3379af3355146f132c4f6964632 /libavcodec/ac3enc.c | |
parent | 5128842ea2057c86550b833c9141c271df1bdc94 (diff) |
Skip the bit allocation search if previous and current SNR offsets are the
maximum value of 1023.
This speeds up overall encoding depending on the content and bitrate.
The most improvement is with high bitrates and/or low complexity content.
Originally committed as revision 26181 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 9b23f31b69..49fd853609 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1116,6 +1116,13 @@ static int cbr_bit_allocation(AC3EncodeContext *s) snr_offset = s->coarse_snr_offset << 4; + /* if previous frame SNR offset was 1023, check if current frame can also + use SNR offset of 1023. if so, skip the search. */ + if ((snr_offset | s->fine_snr_offset[0]) == 1023) { + if (bit_alloc(s, 1023) <= bits_left) + return 0; + } + while (snr_offset >= 0 && bit_alloc(s, snr_offset) > bits_left) { snr_offset -= 64; |