[Ffmpeg-devel] RealAudio 14.4

mkhodor7 at yahoo.com mkhodor7
Sun Dec 11 06:49:50 CET 2005


This patch should fix the problem with RealAudio 14.4 files.  The
problem is that not all the headers are guaranteed to be there.  In
particular the fourcc may not be present in old-style .ra files.
(I've never seen one of these files with anything but 14.4 in it.)
We need to pay attention to the total header length and not read more
bytes than are actually there.

This should successfully play the thankyou144.ra file that was posted
earlier.  Please test.

--- ffmpeg/libavformat/rm.c     9 Dec 2005 16:08:18 -0000       1.50
+++ ffmpeg/libavformat/rm.c     11 Dec 2005 04:50:34 -0000
@@ -488,7 +488,7 @@
 {
     RMContext *rm = s->priv_data;
     ByteIOContext *pb = &s->pb;
-    char buf[128];
+    char buf[65536];
     uint32_t version;
     int i;
 
@@ -496,14 +496,46 @@
     version = get_be32(pb); /* version */
     if (((version >> 16) & 0xff) == 3) {
         /* very old version */
-        for(i = 0; i < 14; i++)
-            get_byte(pb);
-        get_str8(pb, s->title, sizeof(s->title));
-        get_str8(pb, s->author, sizeof(s->author));
-        get_str8(pb, s->copyright, sizeof(s->copyright));
-        get_str8(pb, s->comment, sizeof(s->comment));
-        get_byte(pb);
-        get_str8(pb, buf, sizeof(buf));
+        unsigned char *ptr,*dst,*end;
+        int len;
+        ptr=buf;
+        for(i = 0; i < (version & 0xffff); i++)
+            *(ptr++)=get_byte(pb);
+        end=ptr;
+        ptr=buf+14;
+        // title
+        len = (ptr<end) ? *(ptr++) : 0;
+        dst = s->title;
+        for(i = 0; i < len && ptr < end; i++) {
+            if(i<sizeof(s->title)-1) *(dst++)=*ptr;
+            ptr++;
+        }
+        *dst=0;
+        // author
+        len = (ptr<end) ? *(ptr++) : 0;
+        dst = s->author;
+        for(i = 0; i < len && ptr < end; i++) {
+            if(i<sizeof(s->author)-1) *(dst++)=*ptr;
+            ptr++;
+        }
+        *dst=0;
+        // copyright
+        len = (ptr<end) ? *(ptr++) : 0;
+        dst = s->copyright;
+        for(i = 0; i < len && ptr < end; i++) {
+            if(i<sizeof(s->copyright)-1) *(dst++)=*ptr;
+            ptr++;
+        }
+        *dst=0;
+        // comment
+        len = (ptr<end) ? *(ptr++) : 0;
+        dst = s->comment;
+        for(i = 0; i < len && ptr < end; i++) {
+            if(i<sizeof(s->comment)-1) *(dst++)=*ptr;
+            ptr++;
+        }
+        *dst=0;
+        /* TODO: Check the 4CC here */
         st->codec->sample_rate = 8000;
         st->codec->channels = 1;
         st->codec->codec_type = CODEC_TYPE_AUDIO;





More information about the ffmpeg-devel mailing list