[FFmpeg-devel] [PATCH] ac3dec: fix center_mix_level handling.

Michael Niedermayer michaelni at gmx.at
Sat Jan 21 05:40:06 CET 2012


On Fri, Jan 20, 2012 at 07:42:21AM +0100, Reimar Döffinger wrote:
> 
> 
> 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"?

i would but this patch is droped as justin suggested a different way
to do it

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There seems to be only one solution to NIH syndrom, ... a shooting squad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120121/0f88e1ec/attachment.asc>


More information about the ffmpeg-devel mailing list