[FFmpeg-cvslog] lavfi/af_stereotools: convert to query_func2()

Anton Khirnov git at videolan.org
Mon Sep 9 18:27:23 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Sep  4 15:11:22 2024 +0200| [449f670a14b1c7700ecf28677132412d05aa1160] | committer: Anton Khirnov

lavfi/af_stereotools: convert 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=449f670a14b1c7700ecf28677132412d05aa1160
---

 libavfilter/af_stereotools.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c
index 934c5d33aa..bbbc88cd4f 100644
--- a/libavfilter/af_stereotools.c
+++ b/libavfilter/af_stereotools.c
@@ -101,19 +101,31 @@ static const AVOption stereotools_options[] = {
 
 AVFILTER_DEFINE_CLASS(stereotools);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    AVFilterFormats *formats = NULL;
-    AVFilterChannelLayouts *layout = NULL;
+    static const enum AVSampleFormat formats[] = {
+        AV_SAMPLE_FMT_DBL,
+        AV_SAMPLE_FMT_NONE,
+    };
+    static const AVChannelLayout layouts[] = {
+        AV_CHANNEL_LAYOUT_STEREO,
+        { .nb_channels = 0 },
+    };
+
     int ret;
 
-    if ((ret = ff_add_format                 (&formats, AV_SAMPLE_FMT_DBL  )) < 0 ||
-        (ret = ff_set_common_formats         (ctx     , formats            )) < 0 ||
-        (ret = ff_add_channel_layout         (&layout , &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) < 0 ||
-        (ret = ff_set_common_channel_layouts (ctx     , layout             )) < 0)
+
+    ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, formats);
+    if (ret < 0)
         return ret;
 
-    return ff_set_common_all_samplerates(ctx);
+    ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, layouts);
+    if (ret < 0)
+        return ret;
+
+    return 0;
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -375,7 +387,7 @@ const AVFilter ff_af_stereotools = {
     .uninit         = uninit,
     FILTER_INPUTS(inputs),
     FILTER_OUTPUTS(ff_audio_default_filterpad),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .process_command = process_command,
     .flags          = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
 };



More information about the ffmpeg-cvslog mailing list