[FFmpeg-devel] [PATCH] Make av_parse_color() support a "Random" color

Måns Rullgård mans
Tue May 12 01:09:17 CEST 2009


Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:

> On date Monday 2009-05-11 23:08:22 +0100, M?ns Rullg?rd encoded:
>> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
>> 
>> > Also are you saying that there is no safe way to lowercase a string in
>> > C99?
>> 
>> Define lowercase.  As an example, in Turkish the lowercase version of
>> 'I' is not 'i'.
>
> Thanks, that means we should avoid functions fiddling with the
> locale. New attempt attached.
>
> Regards.
> -- 
> FFmpeg = Fiendish Freak Multipurpose Programmable Elastic God
>
> Index: ffmpeg/libavfilter/parseutils.c
> ===================================================================
> --- ffmpeg.orig/libavfilter/parseutils.c	2009-05-12 00:58:39.000000000 +0200
> +++ ffmpeg/libavfilter/parseutils.c	2009-05-12 00:58:59.000000000 +0200
> @@ -210,14 +210,33 @@
>      { "YellowGreen",          { 0x9A, 0xCD, 0x32 } },
>  };
>  
> +/**
> + * Compares two ASCII strings case-insensitively.
> + */
> +static int strcasecmp_ascii(const char *s1, const char *s2)
> +{
> +#define ASCII_LC(c) c >= 'A' && c <= 'Z' ? c + 32 : c
> +    char c1, c2;
> +    do {
> +        c1 = *s1++;
> +        c2 = *s2++;
> +        c1 = ASCII_LC(c1);
> +        c2 = ASCII_LC(c2);
> +    }
> +    while((c1 == c2) && c1);
> +
> +    return (int) c1-c2;

This assumes the character encoding is ASCII, which may not at all be
the case.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list