[Ffmpeg-devel] RealAudio 14.4

mkhodor7 at yahoo.com mkhodor7
Sun Dec 11 20:52:15 CET 2005


Michael Niedermayer wrote:
>then add a if() before the code which loads the fourcc or fix get_str8()
>so it doesnt read too much, i dont see why the get_str8() code should
>be duplicated 5 times, this is not acceptable

Okay, this should be a little cleaner.  I made a new function since 
get_str8() is used elsewhere.

--- ffmpeg/libavformat/rm.c     9 Dec 2005 16:08:18 -0000       1.50
+++ ffmpeg/libavformat/rm.c     11 Dec 2005 18:59:25 -0000
@@ -483,12 +483,27 @@
     *q = '\0';
 }
 
+static void extract_str8(char **buf, char *buf_end, char *str, int size)
+{
+    int len, i;
+    char *q;
+
+    len = (*buf < buf_end) ? *((*(unsigned char **)buf)++) : 0;
+    q = str;
+    for(i = 0; i < len && *buf < buf_end; i++) {
+        if(i < size-1)
+            *q++ = **buf;
+        (*buf)++;
+    }
+    *q = '\0';
+}
+
 static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, 
                                       int read_all)
 {
     RMContext *rm = s->priv_data;
     ByteIOContext *pb = &s->pb;
-    char buf[128];
+    char buf[1044];
     uint32_t version;
     int i;
 
@@ -496,14 +511,20 @@
     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));
+        char *ptr,*end;
+        ptr=buf;
+        for(i = 0; i < (version & 0xffff); i++) {
+            if(ptr<buf+sizeof(buf)) *(ptr++)=get_byte(pb);
+            else get_byte(pb);
+        }
+        end=ptr;
+        ptr=buf+14;
+        extract_str8(&ptr, end, s->title, sizeof(s->title));
+        extract_str8(&ptr, end, s->author, sizeof(s->author));
+        extract_str8(&ptr, end, s->copyright, sizeof(s->copyright));
+        extract_str8(&ptr, end, s->comment, sizeof(s->comment));
+        /* TODO: Should we look for a 4cc? */
+        /* Is anything other than lpcJ possible in a version 3 file? */
         st->codec->sample_rate = 8000;
         st->codec->channels = 1;
         st->codec->codec_type = CODEC_TYPE_AUDIO;





More information about the ffmpeg-devel mailing list