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

Anton Khirnov git at videolan.org
Thu Sep 5 11:09:06 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Aug 30 21:56:02 2024 +0200| [c24e0df30b9fe2ea0fabc6a6382d2e40b4d3e47a] | committer: Anton Khirnov

lavfi/af_apulsator: convert to query_func2()

Also, simplify code, and drop a redundant call that also happens
implicitly in generic code.

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

 libavfilter/af_apulsator.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c
index 4487bec956..8e01cd6feb 100644
--- a/libavfilter/af_apulsator.c
+++ b/libavfilter/af_apulsator.c
@@ -185,19 +185,30 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     return ff_filter_frame(outlink, out);
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    AVFilterChannelLayouts *layout = NULL;
-    AVFilterFormats *formats = NULL;
+    static const enum AVSampleFormat formats[] = {
+        AV_SAMPLE_FMT_DBL,
+        AV_SAMPLE_FMT_NONE,
+    };
+    static const AVChannelLayout layouts[] = {
+        (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO,
+        (AVChannelLayout){ .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;
+
+    ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, layouts);
+    if (ret < 0)
         return ret;
 
-    return ff_set_common_all_samplerates(ctx);
+    return 0;
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -245,5 +256,5 @@ const AVFilter ff_af_apulsator = {
     .priv_class    = &apulsator_class,
     FILTER_INPUTS(inputs),
     FILTER_OUTPUTS(ff_audio_default_filterpad),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
 };



More information about the ffmpeg-cvslog mailing list