diff options
author | Andriy Rysin <arysin@bcsii.net> | 2003-05-05 10:56:23 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-05 10:56:23 +0000 |
commit | eeb67f400c3a0b9d1b93d6062565cc6bfff893f7 (patch) | |
tree | 2f867e1aca4426e4196af808c2e1304da4d29281 | |
parent | eb14c7136081fc320c6dd6063318db6dd6b4e818 (diff) | |
download | ffmpeg-eeb67f400c3a0b9d1b93d6062565cc6bfff893f7.tar.gz |
mp3 codec autodetection patch by (Andriy Rysin <arysin at bcsii dot net>)
Originally committed as revision 1833 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/raw.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavformat/raw.c b/libavformat/raw.c index bc6e0ac56e..f6c0458fa8 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -109,6 +109,7 @@ static int mp3_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; + int pos; st = av_new_stream(s, 0); if (!st) @@ -116,6 +117,19 @@ static int mp3_read_header(AVFormatContext *s, st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec.codec_id = CODEC_ID_MP2; + + /* looking for 11111111 111MMLLC - MPEG synchronization tag + MM: 00 - MPEG-2.5, 10 - MPEG-2, 11 - MPEG-1 + LL: 11 - Layer I, 10 - Layer II, 01 - Layer III + XXX: this code does not read more bytes from file + so if ID3 (or other stuff) length > IO_BUFFER_SIZE it fails back to CODEC_ID_MP2 */ + for(pos=0; pos < s->pb.buffer_size-1; pos++) + if( s->pb.buffer[pos] == 0xFF && (s->pb.buffer[pos] & 0xE0) == 0xE0 ) + break; + + if( pos < s->pb.buffer_size-1 && (s->pb.buffer[pos+1] & 6) == 2 ) + st->codec.codec_id = CODEC_ID_MP3LAME; + /* the parameters will be extracted from the compressed bitstream */ return 0; } |