[FFmpeg-devel] [PATCH] Add a channels field to m4ac
Baptiste Coudurier
baptiste.coudurier
Wed Nov 11 19:51:59 CET 2009
On 11/11/2009 10:48 AM, Alex Converse wrote:
> On Tue, Nov 10, 2009 at 7:15 PM, Baptiste Coudurier
> <baptiste.coudurier at gmail.com> wrote:
>> On 11/10/2009 03:51 PM, Alex Converse wrote:
>>>
>>> As requested for the ALS decoder.
>>>
>>>
>>> m4ac.channels.diff
>>>
>>>
>>> diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
>>> index 6c0bc7d..8c96572 100644
>>> --- a/libavcodec/mpeg4audio.c
>>> +++ b/libavcodec/mpeg4audio.c
>>> @@ -57,6 +57,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);
>>> + if (c->chan_config< FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
>>> + c->channels = ff_mpeg4audio_channels[c->chan_config];
>>> c->sbr = -1;
>>> if (c->object_type == AOT_SBR) {
>>> c->ext_object_type = c->object_type;
>>> diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
>>> index 98cddad..a51a1a4 100644
>>> --- a/libavcodec/mpeg4audio.h
>>> +++ b/libavcodec/mpeg4audio.h
>>> @@ -36,6 +36,7 @@ typedef struct {
>>> int ext_sampling_index;
>>> int ext_sample_rate;
>>> int ext_chan_config;
>>> + int channels;
>>> } MPEG4AudioConfig;
>>>
>>> extern const int ff_mpeg4audio_sample_rates[16];
>>> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
>>> index b3b3cc1..5b47f19 100644
>>> --- a/libavformat/flvdec.c
>>> +++ b/libavformat/flvdec.c
>>> @@ -412,7 +412,7 @@ static int flv_read_packet(AVFormatContext *s,
>>> AVPacket *pkt)
>>> st->codec->extradata_size);
>>> if (cfg.chan_config> 7)
>>> return -1;
>>> - st->codec->channels =
>>> ff_mpeg4audio_channels[cfg.chan_config];
>>> + st->codec->channels = cfg.channels;
>>> st->codec->sample_rate = cfg.sample_rate;
>>> dprintf(s, "mp4a config channels %d sample rate %d\n",
>>> st->codec->channels, st->codec->sample_rate);
>>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>>> index 3d67630..65d1aad 100644
>>> --- a/libavformat/mov.c
>>> +++ b/libavformat/mov.c
>>> @@ -436,7 +436,7 @@ int ff_mov_read_esds(AVFormatContext *fc,
>>> ByteIOContext *pb, MOVAtom atom)
>>> st->codec->extradata_size);
>>> if (cfg.chan_config> 7)
>>> return -1;
>>> - st->codec->channels =
>>> ff_mpeg4audio_channels[cfg.chan_config];
>>> + st->codec->channels = cfg.channels;
>>> if (cfg.object_type == 29&& cfg.sampling_index< 3) //
>>> old mp3on4
>>> st->codec->sample_rate =
>>> ff_mpa_freq_tab[cfg.sampling_index];
>>> else
>>>
>>
>> Ok with me.
>>
>> Btw I think the> 7 check can be dropped in demuxers.
>> It should be able to demux it even if wronly set, and since it is not used
>> anymore to address the array, it should be safe.
>
> Ok.
>
> Do I need to increment any version fields? This is going to keep new
> libavformat from playing nice with old libavcodec.
I'd say minor libavcodec.
I thought we decided that symbols used by libavformat should be part of
the public API ?
--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list