This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit cf6abefe83e8faa06f8f7e033a67716f1c1f937d Author: Nicolas George <[email protected]> AuthorDate: Sat May 2 16:25:18 2026 +0200 Commit: Nicolas George <[email protected]> CommitDate: Mon Jul 27 10:51:09 2026 +0200 lavfi/vf_format: report error for invalid names --- libavfilter/vf_format.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c index 76d64bb4ae..6ab7d9cbcc 100644 --- a/libavfilter/vf_format.c +++ b/libavfilter/vf_format.c @@ -88,25 +88,34 @@ static av_cold int invert_formats(AVFilterFormats **fmts, return 0; } -static int parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx) -{ - char *tail; - int pix_fmt = av_get_pix_fmt(arg); - if (pix_fmt == AV_PIX_FMT_NONE) { - pix_fmt = strtol(arg, &tail, 0); - if (*tail || !av_pix_fmt_desc_get(pix_fmt)) { - av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg); - return AVERROR(EINVAL); - } - } - *ret = pix_fmt; - return 0; +#define DEFINE_PARSE(name, Type, get, descr, extra_test) \ +static int parse_##name(enum Type *ret, const char *arg, void *log_ctx) \ +{ \ + char *tail; \ + int val = get(arg); \ + if (val < 0) { \ + val = strtol(arg, &tail, 0); \ + if (*tail || extra_test) { \ + av_log(log_ctx, AV_LOG_ERROR, "Invalid " descr " '%s'\n", arg); \ + return AVERROR(EINVAL); \ + } \ + } \ + *ret = val; \ + return 0; \ } +DEFINE_PARSE(pixel_format, AVPixelFormat, av_get_pix_fmt, "pixel format", !av_pix_fmt_desc_get(val)) +DEFINE_PARSE(color_space, AVColorSpace, av_color_space_from_name, "color space", 0) +DEFINE_PARSE(color_range, AVColorRange, av_color_range_from_name, "color range", 0) +DEFINE_PARSE(alpha_mode, AVAlphaMode, av_alpha_mode_from_name, "alpha mode", 0) + static av_cold int init(AVFilterContext *ctx) { FormatContext *s = ctx->priv; enum AVPixelFormat pix_fmt; + enum AVColorSpace csp; + enum AVColorRange crg; + enum AVAlphaMode alm; int ret; for (char *sep, *cur = s->pix_fmts; cur; cur = sep) { @@ -122,8 +131,8 @@ static av_cold int init(AVFilterContext *ctx) sep = strchr(cur, '|'); if (sep && *sep) *sep++ = 0; - if ((ret = av_color_space_from_name(cur)) < 0 || - (ret = ff_add_format(&s->color_spaces, ret)) < 0) + if ((ret = parse_color_space(&csp, cur, ctx)) < 0 || + (ret = ff_add_format(&s->color_spaces, csp)) < 0) return ret; } @@ -131,8 +140,8 @@ static av_cold int init(AVFilterContext *ctx) sep = strchr(cur, '|'); if (sep && *sep) *sep++ = 0; - if ((ret = av_color_range_from_name(cur)) < 0 || - (ret = ff_add_format(&s->color_ranges, ret)) < 0) + if ((ret = parse_color_range(&crg, cur, ctx)) < 0 || + (ret = ff_add_format(&s->color_ranges, crg)) < 0) return ret; } @@ -140,8 +149,8 @@ static av_cold int init(AVFilterContext *ctx) sep = strchr(cur, '|'); if (sep && *sep) *sep++ = 0; - if ((ret = av_alpha_mode_from_name(cur)) < 0 || - (ret = ff_add_format(&s->alpha_modes, ret)) < 0) + if ((ret = parse_alpha_mode(&alm, cur, ctx)) < 0 || + (ret = ff_add_format(&s->alpha_modes, alm)) < 0) return ret; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
