diff --git a/libavutil/opt.c b/libavutil/opt.c index 5f8aaad6a1..0957281076 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -267,16 +267,16 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) if (!val || !strcmp(val, "none")) ret = PIX_FMT_NONE; else { - ret = av_get_pix_fmt(val); - if (ret == PIX_FMT_NONE) { - char *tail; - ret = strtol(val, &tail, 0); - if (*tail || (unsigned)ret >= PIX_FMT_NB) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val); - return AVERROR(EINVAL); + ret = av_get_pix_fmt(val); + if (ret == PIX_FMT_NONE) { + char *tail; + ret = strtol(val, &tail, 0); + if (*tail || (unsigned)ret >= PIX_FMT_NB) { + av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val); + return AVERROR(EINVAL); + } } } - } *(enum PixelFormat *)dst = ret; return 0; }