[Ffmpeg-cvslog] r7059 - trunk/libavformat/asf.c

gpoirier subversion
Tue Nov 14 15:37:59 CET 2006


Author: gpoirier
Date: Tue Nov 14 15:37:59 2006
New Revision: 7059

Modified:
   trunk/libavformat/asf.c

Log:
Use common macro PUT_UTF8 in asf.c
Patch by Zuxy Meng, % zuxy P meng A gmail P com %
date: Nov 5, 2006 9:56 AM
subject: [Ffmpeg-devel] PUT_UTF8 & asf format enhancement


Modified: trunk/libavformat/asf.c
==============================================================================
--- trunk/libavformat/asf.c	(original)
+++ trunk/libavformat/asf.c	Tue Nov 14 15:37:59 2006
@@ -22,6 +22,7 @@
 #include "riff.h"
 #include "mpegaudio.h"
 #include "asf.h"
+#include "common.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -107,15 +108,11 @@
 
 static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size)
 {
-    int c;
-    char *q;
-
-    q = buf;
-    while (len > 0) {
-        c = get_le16(pb);
-        if ((q - buf) < buf_size - 1)
-            *q++ = c;
-        len-=2;
+    char* q = buf;
+    len /= 2;
+    while (len--) {
+        uint8_t tmp;
+        PUT_UTF8(get_le16(pb), tmp, if (q - buf < buf_size - 1) *q++ = tmp;)
     }
     *q = '\0';
 }
@@ -361,14 +358,15 @@
                         char *name, *value;
 
                         name_len = get_le16(pb);
-                        name = (char *)av_mallocz(name_len);
-                        get_str16_nolen(pb, name_len, name, name_len);
+                        name = (char *)av_malloc(name_len * 2);
+                        get_str16_nolen(pb, name_len, name, name_len * 2);
                         value_type = get_le16(pb);
                         value_len = get_le16(pb);
                         if ((value_type == 0) || (value_type == 1)) // unicode or byte
                         {
-                                value = (char *)av_mallocz(value_len);
-                                get_str16_nolen(pb, value_len, value, value_len);
+                                value = (char *)av_malloc(value_len * 2);
+                                get_str16_nolen(pb, value_len, value,
+                                        value_len * 2);
                                 if (strcmp(name,"WM/AlbumTitle")==0) { pstrcpy(s->album, sizeof(s->album), value); }
                                 av_free(value);
                         }




More information about the ffmpeg-cvslog mailing list