[FFmpeg-cvslog] r20516 - trunk/libavcodec/mpeg4audio.c

Justin Ruggles justin.ruggles
Wed Nov 11 23:51:17 CET 2009


Ronald wrote:

> On Wed, Nov 11, 2009 at 5:29 PM, Justin Ruggles
> <justin.ruggles at gmail.com> wrote:
>> > I think this could use get_bits_left() in a couple places.
> 
> Don't forget all input buffers are + FF_INPUT_BUFFER_PADDING_SIZE, so
> as long as the #bits read is less than that, you never have to call
> get_bits_left(). (I would expect that to be the case for a
> audio-config.)


I mean using it for checks that are already there.

> 
> Modified: trunk/libavcodec/mpeg4audio.c
> ==============================================================================
> --- trunk/libavcodec/mpeg4audio.c	Wed Nov 11 22:57:50 2009	(r20515)
> +++ trunk/libavcodec/mpeg4audio.c	Wed Nov 11 23:16:54 2009	(r20516)
> @@ -24,6 +24,34 @@
>  #include "put_bits.h"
>  #include "mpeg4audio.h"
>  
> +/**
> + * Parse MPEG-4 audio configuration for ALS object type.
> + * @param[in] gb       bit reader context
> + * @param[in] c        MPEG4AudioConfig structure to fill
> + * @return on success 0 is returned, otherwise a value < 0
> + */
> +static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c)
> +{
> +    if (gb->size_in_bits - get_bits_count(gb) < 112)
> +        return -1;


here

> +
> +    if (get_bits_long(gb, 32) != MKBETAG('A','L','S','\0'))
> +        return -1;
> +
> +    // override AudioSpecificConfig channel configuration and sample rate
> +    // which are buggy in old ALS conformance files
> +    c->sample_rate = get_bits_long(gb, 32);
> +
> +    // skip number of samples
> +    skip_bits_long(gb, 32);
> +
> +    // read number of channels
> +    c->chan_config = 0;
> +    c->channels    = get_bits(gb, 16) + 1;
> +
> +    return 0;
> +}
> +
>  const int ff_mpeg4audio_sample_rates[16] = {
>      96000, 88200, 64000, 48000, 44100, 32000,
>      24000, 22050, 16000, 12000, 11025, 8000, 7350
> @@ -73,8 +101,19 @@ int ff_mpeg4audio_get_config(MPEG4AudioC
>      }
>      specific_config_bitindex = get_bits_count(&gb);
>  
> +    if (c->object_type == AOT_ALS) {
> +        skip_bits(&gb, 5);
> +        if (show_bits_long(&gb, 24) != MKBETAG('\0','A','L','S'))
> +            skip_bits_long(&gb, 24);
> +
> +        specific_config_bitindex = get_bits_count(&gb);
> +
> +        if (parse_config_ALS(&gb, c))
> +            return -1;
> +    }
> +
>      if (c->ext_object_type != AOT_SBR) {
> -        int bits_left = buf_size*8 - specific_config_bitindex;
> +        int bits_left = buf_size*8 - get_bits_count(&gb);


and maybe here.


-Justin



More information about the ffmpeg-cvslog mailing list