summaryrefslogtreecommitdiff
path: root/libavformat/raw.c
diff options
context:
space:
mode:
authorAndriy Rysin <arysin@bcsii.net>2003-05-05 10:56:23 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-05-05 10:56:23 +0000
commiteeb67f400c3a0b9d1b93d6062565cc6bfff893f7 (patch)
tree2f867e1aca4426e4196af808c2e1304da4d29281 /libavformat/raw.c
parenteb14c7136081fc320c6dd6063318db6dd6b4e818 (diff)
mp3 codec autodetection patch by (Andriy Rysin <arysin at bcsii dot net>)
Originally committed as revision 1833 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/raw.c')
-rw-r--r--libavformat/raw.c14
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;
}