[FFmpeg-devel] MPEG Audio elementary streams and layers

Michael Niedermayer michaelni
Mon Jan 5 16:55:38 CET 2009


On Mon, Jan 05, 2009 at 12:30:07PM +0100, Marc Mason wrote:
> [Sorry for the delay.]
>
> Michael Niedermayer wrote:
>
>> On 2008-12-16, Marc Mason wrote:
>>
>>> Michael Niedermayer wrote:
>>>
>>>> Marc Mason wrote:
>>>>
>>>>> CODEC_ID_MP2 and CODEC_ID_MP3 are defined in avcodec.h
>>>>>
>>>>> As far as I understand,
>>>>> CODEC_ID_MP2 = MPEG Audio Layer II
>>>>> CODEC_ID_MP3 = MPEG Audio Layer III
>>>>>
>>>>> CODEC_ID_MP3 appeared in rev 2231 with the following comment.
>>>>> /* preferred ID for MPEG Audio layer 1, 2 or 3 decoding */
>>>>> http://svn.ffmpeg.org/ffmpeg/trunk/libavcodec/avcodec.h?r1=2217&r2=2231
>>>>>
>>>>> What does the comment mean ?
>>>
>>> Does anybody remember what the comment means ?
>> svn blame will tell you who and when that comment was added...
[...]
>> but looking again, the codec_id likely should be handled like the sample
>> rate
>
> What do you mean ?

I meant, it should be exported like the samplerate and only set after a few
valid headers (like samplerate)


>
>> this should be more robust in presence of errors that might look like
>> valid headers.
>>
>>> In that case, setting sub_id becomes redundant, doesn't it ?
>> if you remove its only use from utils.c ...
>
> I noticed that decode_frame() also calls ff_mpegaudio_decode_header() and I 
> suppose decode_frame() is called for every frame.
>
> decode_frame changes the sub_id; sub_id represents the layer i.e. the 
> algorithm used to encode the frame AFAIU. 

> Is it legal to change layers 
> mid-stream in an MPEG Audio stream ?

i dont know


>
>     /* update codec info */
>     avctx->channels = s->nb_channels;
>     avctx->bit_rate = s->bit_rate;
>     avctx->sub_id = s->layer;
>
> I suppose it is legal for nb_channels and bit_rate to change ?

bitrate certainly, channels i dont know


>
> I've attached a small, trivial patch to spark more discussion.
>

> Creating a new CODEC_ID will change the value of all subsequent CODEC_ID. 
> Is this an issue ?

yes it is, you have to add it at the end of a "block"


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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- 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/20090105/c8465259/attachment.pgp>



More information about the ffmpeg-devel mailing list