diff mbox series

[FFmpeg-devel,09/25] lavfi/af_haas: convert to query_func2()

Message ID 20240905100729.6030-9-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/25] lavfi/af_channelmap: remove an arbitrary limit on channel count | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

FFmpeg Technical Committee Sept. 5, 2024, 10:07 a.m. UTC
Also, drop a redundant call that also happens implicitly in generic code.
---
 libavfilter/af_haas.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/af_haas.c b/libavfilter/af_haas.c
index 6385b328e4..81643cfd9d 100644
--- a/libavfilter/af_haas.c
+++ b/libavfilter/af_haas.c
@@ -81,19 +81,29 @@  static const AVOption haas_options[] = {
 
 AVFILTER_DEFINE_CLASS(haas);
 
-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[] = {
+        (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;
 
-    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)
@@ -216,5 +226,5 @@  const AVFilter ff_af_haas = {
     .uninit         = uninit,
     FILTER_INPUTS(inputs),
     FILTER_OUTPUTS(ff_audio_default_filterpad),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
 };