[FFmpeg-devel] [PATCH] ac3dec: fix center_mix_level handling.
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Fri Jan 20 07:42:21 CET 2012
On 19 Jan 2012, at 00:39, Michael Niedermayer <michaelni at gmx.at> wrote:
> 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.
>
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavcodec/ac3_parser.c | 12 +++++++++---
> libavcodec/ac3dec.c | 10 ++--------
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
> index 17f205b..d2ec6a0 100644
> --- a/libavcodec/ac3_parser.c
> +++ b/libavcodec/ac3_parser.c
> @@ -53,7 +53,7 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
> hdr->num_blocks = 6;
>
> /* set default mix levels */
> - hdr->center_mix_level = 1; // -4.5dB
> + hdr->center_mix_level = 5; // -4.5dB
> hdr->surround_mix_level = 1; // -6.0dB
>
> if(hdr->bitstream_id <= 10) {
> @@ -75,8 +75,14 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
> if(hdr->channel_mode == AC3_CHMODE_STEREO) {
> skip_bits(gbc, 2); // skip dsurmod
> } else {
> - if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO)
> - hdr->center_mix_level = get_bits(gbc, 2);
> + if ((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) {
> + hdr->center_mix_level = get_bits(gbc, 2) + 4;
> + if (hdr->center_mix_level == 3 + 4) {
> + hdr->center_mix_level = 5;
> + av_log(NULL, AV_LOG_DEBUG,
> + "Reserved center_mix_level, using -4.5dB as mandated by spec\n");
> + }
Maybe you should do the + 4 just here at the very end once, with a comment like "convert to EAC-3 level range"?
More information about the ffmpeg-devel
mailing list