[FFmpeg-cvslog] lavfi/vf_alphamerge: switch to query_func2()

Anton Khirnov git at videolan.org
Mon Oct 7 11:57:19 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Oct  4 10:09:29 2024 +0200| [7ab1ddbaf3f45d7dfe51b1caf78b5ca55fbb2bb6] | committer: Anton Khirnov

lavfi/vf_alphamerge: switch to query_func2()

Simplify the implementation by using the fact that ff_set_common_*()
will ignore those links on which the formats have already been set.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7ab1ddbaf3f45d7dfe51b1caf78b5ca55fbb2bb6
---

 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;
+
+    ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, main_fmts);
+    if (ret < 0)
+        return ret;
 
-    return ff_formats_ref(ff_make_format_list(alpha_fmts),
-                          &ctx->inputs[1]->outcfg.formats);
+    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,



More information about the ffmpeg-cvslog mailing list