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

Anton Khirnov git at videolan.org
Fri Oct 4 11:04:11 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue Oct  1 12:02:29 2024 +0200| [60192367a8f363f7a8deb13495c37d6c74af8ac4] | committer: Anton Khirnov

lavfi/f_ebur128: switch to query_func2()

Also, drop redundant calls that also happen implicitly in generic code.

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

 libavfilter/f_ebur128.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c
index f71c230b45..8760c74f78 100644
--- a/libavfilter/f_ebur128.c
+++ b/libavfilter/f_ebur128.c
@@ -1005,13 +1005,13 @@ static int activate(AVFilterContext *ctx)
     return ret;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    EBUR128Context *ebur128 = ctx->priv;
+    const EBUR128Context *ebur128 = ctx->priv;
     AVFilterFormats *formats;
-    AVFilterChannelLayouts *layouts;
-    AVFilterLink *inlink = ctx->inputs[0];
-    AVFilterLink *outlink = ctx->outputs[0];
+    int out_idx = 0;
     int ret;
 
     static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE };
@@ -1020,27 +1020,17 @@ static int query_formats(AVFilterContext *ctx)
     /* set optional output video format */
     if (ebur128->do_video) {
         formats = ff_make_format_list(pix_fmts);
-        if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
+        if ((ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 0)
             return ret;
-        outlink = ctx->outputs[1];
+        out_idx = 1;
     }
 
     /* set input and output audio formats
      * Note: ff_set_common_* functions are not used because they affect all the
      * links, and thus break the video format negotiation */
     formats = ff_make_format_list(sample_fmts);
-    if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0 ||
-        (ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
-        return ret;
-
-    layouts = ff_all_channel_layouts();
-    if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 ||
-        (ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0)
-        return ret;
-
-    formats = ff_all_samplerates();
-    if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0 ||
-        (ret = ff_formats_ref(formats, &outlink->incfg.samplerates)) < 0)
+    if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0 ||
+        (ret = ff_formats_ref(formats, &cfg_out[out_idx]->formats)) < 0)
         return ret;
 
     return 0;
@@ -1128,7 +1118,7 @@ const AVFilter ff_af_ebur128 = {
     .activate      = activate,
     FILTER_INPUTS(ebur128_inputs),
     .outputs       = NULL,
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .priv_class    = &ebur128_class,
     .flags         = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
 };



More information about the ffmpeg-cvslog mailing list