[FFmpeg-devel] [PATCH] mp3enc: write ISO8859-1 instead of UTF-16 when possible

Anton Khirnov anton
Sat Feb 5 22:06:05 CET 2011


On Sat, Feb 05, 2011 at 09:37:21PM +0100, Reimar D?ffinger wrote:
> On Sat, Feb 05, 2011 at 09:28:22PM +0100, Anton Khirnov wrote:
> > +static int string_is_ascii(const uint8_t *str)
> > +{
> > +    int ret = 1;
> > +    do {
> > +        if (*str > 127)
> > +            ret = 0;
> 
> It's quite silly and inefficient to continue parsing after that.
> 
> > +    } while (*str++);
> > +    return ret;
> 
> In general it would be short/simpler/faster as
> 
> while (*str && *str < 128) str++;
> return !*str;
> 
> > @@ -92,6 +102,12 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
> >      if (url_open_dyn_buf(&dyn_buf) < 0)
> >          return AVERROR(ENOMEM);
> >  
> > +    /* check if the strings are ASCII-only and use UTF16 only if
> > +     * they're not */
> > +    if (enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1))
> > +        if ((str2 && string_is_ascii(str2)) || !str2)
> 
> enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1) &&
> (!str2 || string_is_ascii(str2))
I bow before your wisdom ;)

-- 
Anton Khirnov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mp3enc-write-ISO8859-1-instead-of-UTF-16-when-possib.patch
Type: text/x-diff
Size: 1400 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110205/f6d10324/attachment.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/20110205/f6d10324/attachment.pgp>



More information about the ffmpeg-devel mailing list