[FFmpeg-devel] [PATCH] support for UTF-16 encoding in id3v2 tags

Anton Khirnov wyskas
Sat Sep 12 18:12:37 CEST 2009


On Sat, Sep 12, 2009 at 02:46:54PM +0200, Reimar D?ffinger wrote:
> 
> This should probably be done in a separate patch, but IMO the if(...) in
> PUT_UTF8 should go and instead the while condition should check we have
> at least space for 7+1 bytes in dst.
> Also since dstlen == sizeof(dst) - 1 both this and the existing code are
> off by 1 I think.
> 
> > +        *q = '\0';
> 
> Again more an issue with the existing code, but I am allergic to that
> '\0' clutter instead of a simple 0.
> 

i don't think it's necessary to check for 7 bytes - PUT_UTF8 will make
max 2-byte sequences from single bytes and max 4 byte sequences from
20-bit characters that GET_UTF16 produces.

i've added 2 patches that remove the if() in PUT_UTF8 and change '\0'->0
in existing code+fixed in my patch

> 
> Should probably have a comment on endianness (e.g. "gets two
> bytes of UTF-16 encoded data converted to native endianness").
> 

added

> 
> GET_UTF8 does not have {} around ERROR, IMO having this consistent is a
> must.
> And since we're at consistency, changing
> > +    {\
> > +        unsigned int hi;\
> > +        val = GET_16BIT;\
> > +        hi = val - 0xD800;\
> 
> to
> 
> > +    val = GET_16BIT;\
> > +    {\
> > +        unsigned int hi = val - 0xD800;\
> 
> is both one line shorter and more similar to GET_UTF8.

done

Anton Khirnov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-id3v2-check-for-enough-space-to-write-full-UTF-8-cha.patch
Type: text/x-diff
Size: 940 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090912/91db84e3/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-id3v2-use-0-instead-of-0.patch
Type: text/x-diff
Size: 699 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090912/91db84e3/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-id3v2-add-support-for-UTF-16-encoding.patch
Type: text/x-diff
Size: 3314 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090912/91db84e3/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090912/91db84e3/attachment.pgp>



More information about the ffmpeg-devel mailing list