[FFmpeg-devel] [PATCH] code to parse mpeg4audio extradata

Michael Niedermayer michaelni
Thu Mar 27 15:55:14 CET 2008


On Wed, Mar 19, 2008 at 04:54:03PM +0100, Baptiste Coudurier wrote:
> Hi,
> 
> Here is a patch that adds parsing of mpeg4audio extradata, and retrieve
> needed infos for decoders (only mp3on4 atm, but will be needed for aac),
> and will be used by mov demuxer ideally to correctly compute sample rate
> and channels.
> Also extract common mpeg4audio code from aac_parser.c.

[...]

> Index: libavcodec/mpegaudiodec.c
> ===================================================================
> --- libavcodec/mpegaudiodec.c	(revision 12503)
> +++ libavcodec/mpegaudiodec.c	(working copy)
> @@ -2486,9 +2486,11 @@
>  #endif /* CONFIG_MP3ADU_DECODER */
>  
>  #ifdef CONFIG_MP3ON4_DECODER
> +
> +#include "mpeg4audio.h"
> +
>  /* Next 3 arrays are indexed by channel config number (passed via codecdata) */
> -static int mp3Frames[16] = {0,1,1,2,3,3,4,5,2};   /* number of mp3 decoder instances */
> -static int mp3Channels[16] = {0,1,2,3,4,5,6,8,4}; /* total output channels */
> +static const uint8_t mp3_frames[8] = {0,1,1,2,3,3,4,5}; /* number of mp3 decoder instances */

seperate commit and why does the 2 at the end disapear?


[...]

> +int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)
> +{
> +    GetBitContext gb;
> +
> +    init_get_bits(&gb, buf, buf_size*8);
> +    if ((c->object_type = get_bits(&gb, 5)) == 31)
> +        c->object_type = 32 + get_bits(&gb, 6);
> +    if ((c->sampling_index = get_bits(&gb, 4)) == 0x0f)
> +        c->sample_rate = get_bits(&gb, 24);
> +    else
> +        c->sample_rate = ff_mpeg4audio_sample_rates[c->sampling_index];
> +    c->chan_config = get_bits(&gb, 4);
> +    c->sbr = -1;
> +    if (c->object_type == 5) {
> +        c->ext_object_type = c->object_type;
> +        c->sbr = 1;
> +        if ((c->ext_sampling_index = get_bits(&gb, 4)) == 0x0f)
> +            c->ext_sample_rate = get_bits(&gb, 24);
> +        else
> +            c->ext_sample_rate = ff_mpeg4audio_sample_rates[c->sampling_index];
> +        if ((c->object_type = get_bits(&gb, 5)) == 31)
> +            c->object_type = 32 + get_bits(&gb, 6);
> +    }
> +    if (c->ext_object_type != 5 &&
> +        buf_size*8 - get_bits_count(&gb) >= 16) {
> +        if (get_bits(&gb, 11) == 0x2b7) { // sync extension
> +            if ((c->ext_object_type = get_bits(&gb, 5)) == 31)
> +                c->ext_object_type = 32 + get_bits(&gb, 6);
> +            if (c->object_type == 5)
> +                if ((c->sbr = get_bits1(&gb)) == 1)
> +                    if ((c->ext_sampling_index = get_bits(&gb, 4)) == 0x0f)
> +                        c->ext_sample_rate = get_bits(&gb, 24);
> +        }
> +    }
> +    return 0;
> +}

This either needs a function ptr as a argument for parsing codec specific stuff
or return some ptr / bitindex to where that is stored. Later is more flexible
for example with a binary decoder which expects a pointer to this stuff.


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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080327/1f826123/attachment.pgp>



More information about the ffmpeg-devel mailing list