[FFmpeg-devel] [PATCH] lavu: add av_get_color_string() and use it in -colors option

Michael Niedermayer michaelni at gmx.at
Tue Oct 15 11:58:44 CEST 2013


On Sat, Mar 12, 2011 at 01:36:05PM +0100, Stefano Sabatini wrote:
> ---
>  cmdutils.c                   |   13 +++++++++++++
>  cmdutils.h                   |    6 ++++++
>  cmdutils_common_opts.h       |    1 +
>  doc/fftools-common-opts.texi |    3 +++
>  libavutil/parseutils.c       |   18 ++++++++++++++++++
>  libavutil/parseutils.h       |   14 ++++++++++++++
>  6 files changed, 55 insertions(+), 0 deletions(-)
> 
> diff --git a/cmdutils.c b/cmdutils.c
> index 514ebad..549c673 100644
> --- a/cmdutils.c
> +++ b/cmdutils.c
> @@ -713,6 +713,19 @@ void show_pix_fmts(void)
>      }
>  }
>  
> +void show_colors(void)
> +{
> +    char buf[256];
> +    int i;
> +

> +    /* print header */
> +    fprintf(stderr, av_get_color_string(buf, sizeof(buf), -1));
> +
> +    for (i = 0; av_get_color_string(buf, sizeof(buf), i); i++) {
> +        printf("%s", buf);
> +    }

is it intentional to mix stderr & stdout ?


> +}
> +
>  int read_yesno(void)
>  {
>      int c = getchar();
> diff --git a/cmdutils.h b/cmdutils.h
> index c3d8a42..191ee36 100644
> --- a/cmdutils.h
> +++ b/cmdutils.h
> @@ -195,6 +195,12 @@ void show_formats(void);
>  void show_codecs(void);
>  
>  /**
> + * Print a listing containing all the color names supported by the
> + * program.
> + */
> +void show_colors(void);
> +
> +/**
>   * Print a listing containing all the filters supported by the
>   * program.
>   */
> diff --git a/cmdutils_common_opts.h b/cmdutils_common_opts.h
> index da30997..1e3799a 100644
> --- a/cmdutils_common_opts.h
> +++ b/cmdutils_common_opts.h
> @@ -6,6 +6,7 @@
>      { "version", OPT_EXIT, {(void*)show_version}, "show version" },
>      { "formats"  , OPT_EXIT, {(void*)show_formats  }, "show available formats" },
>      { "codecs"   , OPT_EXIT, {(void*)show_codecs   }, "show available codecs" },
> +    { "colors"   , OPT_EXIT, {(void*)show_colors   }, "show recognized color names" },
>      { "bsfs"     , OPT_EXIT, {(void*)show_bsfs     }, "show available bit stream filters" },
>      { "protocols", OPT_EXIT, {(void*)show_protocols}, "show available protocols" },
>      { "filters",   OPT_EXIT, {(void*)show_filters  }, "show available filters" },
> diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
> index d72ca5c..5b25971 100644
> --- a/doc/fftools-common-opts.texi
> +++ b/doc/fftools-common-opts.texi
> @@ -59,6 +59,9 @@ Codec can handle input truncated at random locations instead of only at frame bo
>  @item -bsfs
>  Show available bitstream filters.
>  
> + at item -colors
> +Show recognized color names.
> +
>  @item -protocols
>  Show available protocols.
>  
> diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
> index d67d31b..e701620 100644
> --- a/libavutil/parseutils.c
> +++ b/libavutil/parseutils.c
> @@ -373,6 +373,24 @@ int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
>      return 0;
>  }
>  

> +char *av_get_color_string(char *buf, int buf_size, int color_idx)
> +{
> +    /* print header */
> +    if (color_idx < 0) {
> +        snprintf(buf, buf_size, "%-32s #RRGGBB\n", "name");

this would benefit from a buf_size check and maybe failure
if the buffer is too short instead of returning truncated items
same for the other rows

except that LGTM

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20131015/37de6448/attachment.asc>


More information about the ffmpeg-devel mailing list