[FFmpeg-devel] [PATCH] als in mp4
Robert Swain
robert.swain
Mon Apr 6 15:05:03 CEST 2009
On 6/4/09 13:12, Jai Menon wrote:
> On Fri, Apr 3, 2009 at 11:28 PM, Baptiste Coudurier
> <baptiste.coudurier at gmail.com> wrote:
[snip]
>> > I think the AOT_ALS case should be handled within mpeg4audio_get_config,
>> > to retrieve correct sample_rate/channels if these are not set in
>> > AudioSpecificCOnfig, I also beleve all AOT should be handled this way.
>
> another attempt.
[snip]
> diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
> index 9c7e02b..b391609 100644
> --- a/libavcodec/mpeg4audio.c
> +++ b/libavcodec/mpeg4audio.c
> @@ -55,6 +55,8 @@ int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_si
> c->object_type = get_object_type(&gb);
> c->sample_rate = get_sample_rate(&gb,&c->sampling_index);
> c->chan_config = get_bits(&gb, 4);
> + c->absolute_channels = 0;
> + c->bits_per_sample = 0;
> c->sbr = -1;
> if (c->object_type == 5) {
> c->ext_object_type = c->object_type;
We should swap these constants out for AOT_SBR and so on as appropriate
in my opinion. But this isn't your job. :)
> @@ -80,5 +82,11 @@ int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_si
> get_bits1(&gb); // skip 1 bit
> }
> }
> + if (c->object_type == AOT_ALS) {
> + c->absolute_channels = 1;
> + c->sample_rate = AV_RB32(buf + 10);
> + c->chan_config = AV_RB16(buf + 18) + 1;
> + c->bits_per_sample = (((buf[20]>> 2)& 0x07) + 1)<< 3;
> + }
> return specific_config_bitindex;
> }
I expect this to be a switch in future, but for the moment the if () is
fine in my opinion.
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 214e74e..0020358 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -425,13 +425,18 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
> MPEG4AudioConfig cfg;
> ff_mpeg4audio_get_config(&cfg, st->codec->extradata,
> st->codec->extradata_size);
> + if (!cfg.absolute_channels) {
> if (cfg.chan_config> 7)
> return -1;
> st->codec->channels = ff_mpeg4audio_channels[cfg.chan_config];
> + } else st->codec->channels = cfg.chan_config;
> +
Nit:
} else
st->codec->channels = cfg.chan_config;
Looks OK to me but wait for Baptiste to comment as he is the maintainer
of this code.
Regards,
Rob
More information about the ffmpeg-devel
mailing list