Browse Source

Split bit allocation search into a separate function.

Originally committed as revision 26017 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/n0.8
Justin Ruggles 15 years ago
parent
commit
cb6247cb30
1 changed files with 21 additions and 14 deletions
  1. +21
    -14
      libavcodec/ac3enc.c

+ 21
- 14
libavcodec/ac3enc.c View File

@@ -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;
@@ -990,6 +979,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.
*/


Loading…
Cancel
Save