Simplify the implementation by using the fact that ff_set_common_*() will ignore those links on which the formats have already been set. --- libavfilter/vf_alphamerge.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c index 2abb7e5583..c732f29367 100644 --- a/libavfilter/vf_alphamerge.c +++ b/libavfilter/vf_alphamerge.c @@ -96,7 +96,9 @@ static av_cold int init(AVFilterContext *ctx) return 0; } -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { static const enum AVPixelFormat main_fmts[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P, @@ -105,15 +107,18 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_NONE }; static const enum AVPixelFormat alpha_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE }; - AVFilterFormats *main_formats = ff_make_format_list(main_fmts); int ret; - if ((ret = ff_formats_ref(main_formats, &ctx->inputs[0]->outcfg.formats)) < 0 || - (ret = ff_formats_ref(main_formats, &ctx->outputs[0]->incfg.formats)) < 0) - return ret; + ret = ff_formats_ref(ff_make_format_list(alpha_fmts), + &cfg_in[1]->formats); + if (ret < 0) + return ret; - return ff_formats_ref(ff_make_format_list(alpha_fmts), - &ctx->inputs[1]->outcfg.formats); + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, main_fmts); + if (ret < 0) + return ret; + + return 0; } static int config_input_main(AVFilterLink *inlink) @@ -203,7 +208,7 @@ const AVFilter ff_vf_alphamerge = { .init = init, FILTER_INPUTS(alphamerge_inputs), FILTER_OUTPUTS(alphamerge_outputs), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .uninit = uninit, .activate = activate, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL, -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".