[FFmpeg-devel] [PATCH] asf - read/write metadata as UTF-16
Michael Niedermayer
michaelni
Mon Feb 22 23:51:37 CET 2010
On Mon, Feb 22, 2010 at 11:12:14PM +0100, Anton Khirnov wrote:
> On Mon, Feb 22, 2010 at 08:18:53PM +0100, Michael Niedermayer wrote:
> > ^^^^^
> > unused
> >
> oops, fixed
> >
> > > + {\
> > > + uint32_t in = val;\
> > > + if (in < 0x10000) {\
> > > + tmp = in;\
> > > + PUT_16BIT\
> > > + } else if ( in <= 0x10FFFFU ) {\
> >
> > else
> >
> fixed
> >
> > > @@ -461,9 +455,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
> > > put_le16(pb, -1);
> > >
> > > if(enc->codec_id == CODEC_ID_WMAV2)
> > > - put_str16(pb, "Windows Media Audio V8");
> > > + desc = "Windows Media Audio V8";
> > > else
> > > - put_str16(pb, p ? p->name : enc->codec_name);
> > > + desc = p ? p->name : enc->codec_name;
> > > + put_le16(pb, strlen(desc) + 1); // "number of characters" = length in bytes / 2
> >
> > the comment and the code dont match
> >
> at that point the output is utf-8 interleaved with 0s, so length of
> output is exactly 2*strlen(input+1). it gets changed in a later patch
> anyway so i don't think writing a more detailed comment is necessary.
> >
> > > diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
> > > index b24baaf..5f584a2 100644
> > > --- a/libavformat/asfenc.c
> > > +++ b/libavformat/asfenc.c
> > > @@ -345,10 +345,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
> > > hpos = put_header(pb, &ff_asf_extended_content_header);
> > > put_le16(pb, metadata_count);
> > > while ((tag = av_metadata_get(s->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX))) {
> > > - put_le16(pb, 2*(strlen(tag->key) + 4));
> > > - put_le16(pb, 'W');
> > > - put_le16(pb, 'M');
> > > - put_le16(pb, '/');
> > > + put_le16(pb, 2*(strlen(tag->key) + 1));
> >
> > thats storing a different length than it did before
> > no doubt the one before was wrong but this doesnt belong in this patch
> > and the new looks at least suspicous as thats strlen of utf8
> >
> huh? i just removed the 'WM/' prefix => length decreased by 2*3.
ill skip the math
first is even second is odd no change to strlen can do this
> >
> > i wouldnt normally be asking but as this is M$ design
> > did you check they use bytes/2 for all fields in wmp? :)
> > i wouldnt be much surpised if they used that just for some ...
> >
> actually they use "number of unicode characters" ( == length/2 ) _only_
> for codec name/description in codec list. for everything else they use
> length in bytes like almost sane people. tested with wmp, it refuses to
> play invalid files.
>
> Anton Khirnov
> asfdec.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
> 0707bffdb7148943d0ecfdebf9288288d15d7b6c 0006-asfdec-read-metadata-as-proper-UTF-16.patch
> From 3a05d17ad1544174a473d6438583f46b16515354 Mon Sep 17 00:00:00 2001
> From: Anton Khirnov <wyskas at gmail.com>
> Date: Sun, 21 Feb 2010 18:45:38 +0100
> Subject: [PATCH 6/6] asfdec: read metadata as proper UTF-16.
ok
[...]
> common.h | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
> bc1d40a760a8a74c0ec323c92f2cfd6dd5907fb3 0001-Add-PUT_UTF16-macro.patch
> From b6cc069ec137fe83f8dbb0d912b6013f58421aac Mon Sep 17 00:00:00 2001
> From: Anton Khirnov <wyskas at gmail.com>
> Date: Sun, 21 Feb 2010 15:20:23 +0100
> Subject: [PATCH 1/6] Add PUT_UTF16 macro.
ok
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100222/66e46a3a/attachment.pgp>
More information about the ffmpeg-devel
mailing list