diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-19 00:06:03 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-21 05:29:47 +0100 |
commit | 99a42f3fa95aa68f6c945e98e043d69e541d93cc (patch) | |
tree | 438cc910521b3d5484763a4a3dbfbc5ce83debc1 /libavcodec/ac3dec.c | |
parent | 9ec39937f9c7f28a2279a19f71f290d8161eb52f (diff) | |
download | ffmpeg-99a42f3fa95aa68f6c945e98e043d69e541d93cc.tar.gz |
ac3dec: Move center&surround mix level tables to parser.
That way all mix levels as exported by the parser
will have the same meaning.
Previously the 3bit center mix level for eac3 was
used to index in a 4 entry table leading to out of array reads.
this change removes the table and offsets the ac3 variable by 4
so it matches the meanings for eac3 except the reserved case.
The reserved case is then explicitly handled.
Idea-by: Justin Ruggles <justin.ruggles@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ac3dec.c')
-rw-r--r-- | libavcodec/ac3dec.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 325d23bb3d..598255830b 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -77,18 +77,6 @@ static const float gain_levels[9] = { }; /** - * Table for center mix levels - * reference: Section 5.4.2.4 cmixlev - */ -static const uint8_t center_levels[4] = { 4, 5, 6, 5 }; - -/** - * Table for surround mix levels - * reference: Section 5.4.2.5 surmixlev - */ -static const uint8_t surround_levels[4] = { 4, 6, 7, 6 }; - -/** * Table for default stereo downmixing coefficients * reference: Section 7.8.2 Downmixing Into Two Channels */ @@ -320,8 +308,8 @@ static int parse_frame_header(AC3DecodeContext *s) static void set_downmix_coeffs(AC3DecodeContext *s) { int i; - float cmix = gain_levels[center_levels[s->center_mix_level]]; - float smix = gain_levels[surround_levels[s->surround_mix_level]]; + float cmix = gain_levels[s-> center_mix_level]; + float smix = gain_levels[s->surround_mix_level]; float norm0, norm1; for (i = 0; i < s->fbw_channels; i++) { @@ -1400,8 +1388,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data, avctx->channels = s->out_channels; avctx->channel_layout = s->channel_layout; - s->loro_center_mix_level = gain_levels[ center_levels[s-> center_mix_level]]; - s->loro_surround_mix_level = gain_levels[surround_levels[s->surround_mix_level]]; + s->loro_center_mix_level = gain_levels[s-> center_mix_level]; + s->loro_surround_mix_level = gain_levels[s->surround_mix_level]; s->ltrt_center_mix_level = LEVEL_MINUS_3DB; s->ltrt_surround_mix_level = LEVEL_MINUS_3DB; /* set downmixing coefficients if needed */ |