diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-15 17:28:38 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2010-12-15 17:28:38 +0000 |
commit | cb6247cb30845bb70195dcc539d8fad72a30512f (patch) | |
tree | e292062f766818dfbc26822582a9a6ef1cd71a02 | |
parent | a4a3bade0acd1276ad43850fb2371823bce970c6 (diff) | |
download | ffmpeg-cb6247cb30845bb70195dcc539d8fad72a30512f.tar.gz |
Split bit allocation search into a separate function.
Originally committed as revision 26017 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/ac3enc.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index fe445ad2bb..d2f604257f 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -929,26 +929,15 @@ static int bit_alloc(AC3EncodeContext *s, /** - * Perform bit allocation search. - * Finds the SNR offset value that maximizes quality and fits in the specified - * frame size. Output is the SNR offset and a set of bit allocation pointers - * used to quantize the mantissas. + * Constant bitrate bit allocation search. + * Find the largest SNR offset that will allow data to fit in the frame. */ -static int compute_bit_allocation(AC3EncodeContext *s) +static int cbr_bit_allocation(AC3EncodeContext *s) { int ch; int bits_left; int snr_offset; - /* count frame bits other than exponents and mantissas */ - count_frame_bits(s); - - /* calculate psd and masking curve before doing bit allocation */ - bit_alloc_masking(s); - - /* now the big work begins : do the bit allocation. Modify the snr - offset until we can pack everything in the requested frame size */ - bits_left = 8 * s->frame_size - (s->frame_bits + s->exponent_bits); snr_offset = s->coarse_snr_offset << 4; @@ -991,6 +980,24 @@ static int compute_bit_allocation(AC3EncodeContext *s) /** + * Perform bit allocation search. + * Finds the SNR offset value that maximizes quality and fits in the specified + * frame size. Output is the SNR offset and a set of bit allocation pointers + * used to quantize the mantissas. + */ +static int compute_bit_allocation(AC3EncodeContext *s) +{ + /* count frame bits other than exponents and mantissas */ + count_frame_bits(s); + + /* calculate psd and masking curve before doing bit allocation */ + bit_alloc_masking(s); + + return cbr_bit_allocation(s); +} + + +/** * Symmetric quantization on 'levels' levels. */ static inline int sym_quant(int c, int e, int levels) |