[SCM] libav/experimental: Merge get_str() and get_str8() functions. patch by Ronald S. Bultje, rsbultje gmail com

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:04:22 UTC 2013


The following commit has been merged in the experimental branch:
commit 36cf20f5a6dc5fd183c0aa2f071f91175f23b4e1
Author: Ronald S. Bultje <rsbultje at gmail.com>
Date:   Sat Jul 28 18:05:11 2007 +0000

    Merge get_str() and get_str8() functions.
    patch by Ronald S. Bultje, rsbultje gmail com
    
    Originally committed as revision 9818 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index d2e8ea2..40e3462 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -22,12 +22,11 @@
 #include "rm.h"
 #include "avstring.h"
 
-static void get_str(ByteIOContext *pb, char *buf, int buf_size)
+static inline void get_strl(ByteIOContext *pb, char *buf, int buf_size, int len)
 {
-    int len, i;
+    int i;
     char *q, r;
 
-    len = get_be16(pb);
     q = buf;
     for(i=0;i<len;i++) {
         r = get_byte(pb);
@@ -37,19 +36,14 @@ static void get_str(ByteIOContext *pb, char *buf, int buf_size)
     if (buf_size > 0) *q = '\0';
 }
 
-static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
+static void get_str16(ByteIOContext *pb, char *buf, int buf_size)
 {
-    int len, i;
-    char *q, r;
+    get_strl(pb, buf, buf_size, get_be16(pb));
+}
 
-    len = get_byte(pb);
-    q = buf;
-    for(i=0;i<len;i++) {
-        r = get_byte(pb);
-        if (i < buf_size - 1)
-            *q++ = r;
-    }
-    if (buf_size > 0) *q = '\0';
+static void get_str8(ByteIOContext *pb, char *buf, int buf_size)
+{
+    get_strl(pb, buf, buf_size, get_byte(pb));
 }
 
 static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
@@ -263,10 +257,10 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
             flags = get_be16(pb); /* flags */
             break;
         case MKTAG('C', 'O', 'N', 'T'):
-            get_str(pb, s->title, sizeof(s->title));
-            get_str(pb, s->author, sizeof(s->author));
-            get_str(pb, s->copyright, sizeof(s->copyright));
-            get_str(pb, s->comment, sizeof(s->comment));
+            get_str16(pb, s->title, sizeof(s->title));
+            get_str16(pb, s->author, sizeof(s->author));
+            get_str16(pb, s->copyright, sizeof(s->copyright));
+            get_str16(pb, s->comment, sizeof(s->comment));
             break;
         case MKTAG('M', 'D', 'P', 'R'):
             st = av_new_stream(s, 0);

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list