[FFmpeg-devel] [PATCH] pixdesc: Add API to map color property name to enum value

wm4 nfxjfg at googlemail.com
Wed Sep 20 21:30:02 EEST 2017


On Wed, 20 Sep 2017 14:23:32 +0200
Vittorio Giovara <vittorio.giovara at gmail.com> wrote:

> Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> ---
> Updated following review.
> Vittorio
> 
>  libavutil/pixdesc.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/pixdesc.h | 25 +++++++++++++++++++++
>  2 files changed, 90 insertions(+)
> 
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index 33aa2d705f..26e208a947 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -2749,26 +2749,91 @@ const char *av_color_range_name(enum AVColorRange range)
>          color_range_names[range] : NULL;
>  }
>  
> +int av_color_range_from_name(const char *name)
> +{
> +    int i;
> +
> +    for (i = 0; i < FF_ARRAY_ELEMS(color_range_names); i++) {
> +        size_t len = strlen(color_range_names[i]);
> +        if (!strncmp(color_range_names[i], name, len))
> +            return i;
> +    }
> +
> +    return AVERROR(ENOSYS);
> +}

To be honest, ENOSYS is even more confusing than -1. Think about what
happens if someone converts the error to a string and displays that to
a user.


More information about the ffmpeg-devel mailing list