[FFmpeg-devel] [PATCH] mp3enc: write ISO8859-1 instead of UTF-16 when possible
Reimar Döffinger
Reimar.Doeffinger
Sat Feb 5 22:13:38 CET 2011
On Sat, Feb 05, 2011 at 10:06:05PM +0100, Anton Khirnov wrote:
> 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 ;)
New code looks fine to me, but I can't comment on whether what
the patch does overall makes sense.
More information about the ffmpeg-devel
mailing list