[FFmpeg-devel] [PATCH 2/2] Extend color syntax, make it accept an alpha component specifier.

Stefano Sabatini stefano.sabatini-lala
Sat Jun 12 00:54:05 CEST 2010


On date Friday 2010-06-11 09:39:11 +0200, Benoit Fouet encoded:
> Hi,
> 
> On Fri, 11 Jun 2010 00:34:21 +0200 Stefano Sabatini wrote:
> > ---
> >  libavfilter/parseutils.h |    8 ++++++-
> > 
> > diff --git a/libavfilter/parseutils.h b/libavfilter/parseutils.h
> > index b5b494e..fc0c784 100644
> > --- a/libavfilter/parseutils.h
> > +++ b/libavfilter/parseutils.h
> > @@ -46,7 +46,13 @@ char *av_get_token(const char **buf, const char *term);
> >   * Puts the RGBA values that correspond to color_string in rgba_color.
> >   *
> >   * @param color_string a string specifying a color. It can be the name of
> > - * a color (case insensitive match) or a 0xRRGGBB[AA] sequence.
> > + * a color (case insensitive match) eventually followed by "@" and a
> > + * string representing the alpha component, or a 0xRRGGBB[AA]
> > + * sequence.
> 
> s/eventually/possibly/
> 
> > + * The alpha component may be a string composed by "0x" followed by an
> > + * hexadecimal number or a base-10 number between 0 and 255, or a
> > + * decimal number between 0.0 and 1.0, which represents the opacity
> > + * value. If the alpha component is not specified then 255 is assumed.
> 
> maybe add a hint for user to know that 255 (or 0xff, or 1.0) is opaque.

Updated, result of the test is now:

Testing av_parse_color()
bikeshed -> R(154) G(134) B(238) A(43)
RaNdOm -> R(51) G(54) B(196) A(23)
Cannot find color 'foo'
red -> R(255) G(0) B(0) A(255)
Cannot find color 'Red '
RED -> R(255) G(0) B(0) A(255)
Violet -> R(238) G(130) B(238) A(255)
Yellow -> R(255) G(255) B(0) A(255)
Red -> R(255) G(0) B(0) A(255)
0x000000 -> R(0) G(0) B(0) A(255)
Invalid 0xRRGGBB[AA] color string: '0x0000000'
0xff000000 -> R(255) G(0) B(0) A(0)
0x3e34ff -> R(62) G(52) B(255) A(255)
0x3e34ffaa -> R(62) G(52) B(255) A(170)
Invalid 0xRRGGBB[AA] color string: '0xffXXee'
Invalid 0xRRGGBB[AA] color string: '0xfoobar'
Invalid 0xRRGGBB[AA] color string: '0xffffeeeeeeee'
Invalid alpha value specifier 'foo' in 'red at foo'
random at 10 -> R(204) G(35) B(199) A(10)
0xff0000 at 1.0 -> R(255) G(0) B(0) A(255)
Invalid alpha value specifier '' in 'red@'
Invalid alpha value specifier '0xfff' in 'red at 0xfff'
red at 0xf -> R(255) G(0) B(0) A(15)
red at 2 -> R(255) G(0) B(0) A(2)
red at 0.1 -> R(255) G(0) B(0) A(25)
Invalid alpha value specifier '-1' in 'red at -1'
red at 0.5 -> R(255) G(0) B(0) A(127)
red at 1.0 -> R(255) G(0) B(0) A(255)
Invalid alpha value specifier '256' in 'red at 256'
Invalid alpha value specifier '10foo' in 'red at 10foo'
Invalid alpha value specifier '-1.0' in 'red at -1.0'
red at -0.0 -> R(255) G(0) B(0) A(0)

Regards.
-- 
FFmpeg = Foolish and Fundamental Magic Peaceful Ecstatic Gymnast



More information about the ffmpeg-devel mailing list