changeset 5239:4d1a325b53cc libavformat

Convert latin1 codec_name in mov to UTF-8, since all strings in FFmpeg must be valid UTF-8.
author reimar
date Wed, 30 Sep 2009 09:43:56 +0000
parents c872818a8e1f
children 432736854b4c
files mov.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mov.c	Tue Sep 29 10:23:47 2009 +0000
+++ b/mov.c	Wed Sep 30 09:43:56 2009 +0000
@@ -909,8 +909,13 @@
 
             get_buffer(pb, codec_name, 32); /* codec name, pascal string */
             if (codec_name[0] <= 31) {
-                memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
-                st->codec->codec_name[codec_name[0]] = 0;
+                int i;
+                int pos = 0;
+                for (i = 0; i < codec_name[0] && pos < sizeof(st->codec->codec_name) - 3; i++) {
+                    uint8_t tmp;
+                    PUT_UTF8(codec_name[i], tmp, st->codec->codec_name[pos++] = tmp;)
+                }
+                st->codec->codec_name[pos] = 0;
             }
 
             st->codec->bits_per_coded_sample = get_be16(pb); /* depth */