changeset 125:7500e14259a6 libavformat

mp3 codec autodetection patch by (Andriy Rysin <arysin at bcsii dot net>)
author michaelni
date Mon, 05 May 2003 10:56:23 +0000
parents a1ad0f8b75bf
children 23f62139c013
files raw.c
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/raw.c	Mon May 05 02:54:15 2003 +0000
+++ b/raw.c	Mon May 05 10:56:23 2003 +0000
@@ -109,6 +109,7 @@
                            AVFormatParameters *ap)
 {
     AVStream *st;
+    int pos;
 
     st = av_new_stream(s, 0);
     if (!st)
@@ -116,6 +117,19 @@
 
     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;
 }