aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-04-15 22:49:05 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-05-01 13:32:04 -0400
commit177fed4e9baa43bdcfb6771195eb85f19412c23e (patch)
tree8d832fd1d0ec1df44a7fb341545fc139685c7abf
parenta1d0f511fc3a758146d9384ccaab31743d8bd600 (diff)
downloadffmpeg-177fed4e9baa43bdcfb6771195eb85f19412c23e.tar.gz
ac3enc: do not store a bandwidth code for each channel.
Although AC-3 allows it, it's not very useful. The encoder uses the same code for all full-bandwidth channels.
-rw-r--r--libavcodec/ac3enc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 6d899f5a24..bf106eb22a 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -162,7 +162,7 @@ typedef struct AC3EncodeContext {
int loro_surround_mix_level; ///< Lo/Ro surround mix level code
int cutoff; ///< user-specified cutoff frequency, in Hz
- int bandwidth_code[AC3_MAX_CHANNELS]; ///< bandwidth code (0 to 60) (chbwcod)
+ int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod)
int nb_coefs[AC3_MAX_CHANNELS];
int rematrixing_enabled; ///< stereo rematrixing enabled
@@ -1407,7 +1407,7 @@ static void output_audio_block(AC3EncodeContext *s, int blk)
/* bandwidth */
for (ch = 0; ch < s->fbw_channels; ch++) {
if (s->exp_strategy[ch][blk] != EXP_REUSE)
- put_bits(&s->pb, 6, s->bandwidth_code[ch]);
+ put_bits(&s->pb, 6, s->bandwidth_code);
}
/* exponents */
@@ -2047,22 +2047,21 @@ static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
*/
static av_cold void set_bandwidth(AC3EncodeContext *s)
{
- int ch, bw_code;
+ int ch;
if (s->cutoff) {
/* calculate bandwidth based on user-specified cutoff frequency */
int fbw_coeffs;
fbw_coeffs = s->cutoff * 2 * AC3_MAX_COEFS / s->sample_rate;
- bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
+ s->bandwidth_code = av_clip((fbw_coeffs - 73) / 3, 0, 60);
} else {
/* use default bandwidth setting */
- bw_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];
+ s->bandwidth_code = ac3_bandwidth_tab[s->fbw_channels-1][s->bit_alloc.sr_code][s->frame_size_code/2];
}
/* set number of coefficients for each channel */
for (ch = 0; ch < s->fbw_channels; ch++) {
- s->bandwidth_code[ch] = bw_code;
- s->nb_coefs[ch] = bw_code * 3 + 73;
+ s->nb_coefs[ch] = s->bandwidth_code * 3 + 73;
}
if (s->lfe_on)
s->nb_coefs[s->lfe_channel] = 7; /* LFE channel always has 7 coefs */