[FFmpeg-devel] MPEG Audio elementary streams and layers

Marc Mason mpeg.blue
Mon Jan 5 12:30:07 CET 2009

[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...

Fabrice added it 5 years ago. But I don't understand what it means.

BTW, svn blame fails for large files in my cygwin env :-(

$ svn blame avcodec.h
svn: Can't open '/cygdrive/c/DOCUME~1/ADMINI~1/LOCALS~1/Temp/tmp.2.tmp': 
Permission denied

(Yet it works for small files like g729.h)

> but looking again, the codec_id likely should be handled like the sample
> rate

What do you mean ?

> 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 ?

     /* 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 ?

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 ?

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mp2.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090105/9834910a/attachment.asc>

More information about the ffmpeg-devel mailing list