Mercurial > libavformat.hg
changeset 1503:a4ab86a48604 libavformat
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
author | gpoirier |
---|---|
date | Tue, 14 Nov 2006 14:37:59 +0000 |
parents | eae8cc31215e |
children | 03ff0a61a23c |
files | asf.c |
diffstat | 1 files changed, 11 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/asf.c Tue Nov 14 13:33:05 2006 +0000 +++ b/asf.c Tue Nov 14 14:37:59 2006 +0000 @@ -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); }