diff mbox series

[FFmpeg-devel,13/13] lavfi/af_channelmap: convert to query_func2()

Message ID 20240902135013.13803-13-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/13] lavfi/af_agate: convert to query_func2() | 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

Anton Khirnov Sept. 2, 2024, 1:50 p.m. UTC
Also, drop redundant calls that also happen implicitly in generic code.
---
 libavfilter/af_channelmap.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 8d65fb3cd2..3f02a7fd8f 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -321,21 +321,28 @@  static av_cold int channelmap_init(AVFilterContext *ctx)
     return 0;
 }
 
-static int channelmap_query_formats(AVFilterContext *ctx)
+static int channelmap_query_formats(const AVFilterContext *ctx,
+                                    AVFilterFormatsConfig **cfg_in,
+                                    AVFilterFormatsConfig **cfg_out)
 {
-    ChannelMapContext *s = ctx->priv;
+    const ChannelMapContext *s = ctx->priv;
     AVFilterChannelLayouts *channel_layouts = NULL;
+
     int ret;
 
-    if ((ret = ff_set_common_formats    (ctx,  ff_planar_sample_fmts()))  < 0 ||
-        (ret = ff_set_common_all_samplerates(ctx                              )) < 0 ||
-        (ret = ff_add_channel_layout(&channel_layouts, &s->output_layout)) < 0 ||
-        (ret = ff_channel_layouts_ref(channel_layouts,
-                                      &ctx->outputs[0]->incfg.channel_layouts)) < 0)
+    ret = ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_planar_sample_fmts());
+    if (ret < 0)
         return ret;
 
-    return ff_channel_layouts_ref(ff_all_channel_counts(),
-                                  &ctx->inputs[0]->outcfg.channel_layouts);
+    ret = ff_add_channel_layout(&channel_layouts, &s->output_layout);
+    if (ret < 0)
+        return ret;
+
+    ret = ff_channel_layouts_ref(channel_layouts, &cfg_out[0]->channel_layouts);
+    if (ret < 0)
+        return ret;
+
+    return 0;
 }
 
 static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
@@ -425,5 +432,5 @@  const AVFilter ff_af_channelmap = {
     .priv_class    = &channelmap_class,
     FILTER_INPUTS(avfilter_af_channelmap_inputs),
     FILTER_OUTPUTS(ff_audio_default_filterpad),
-    FILTER_QUERY_FUNC(channelmap_query_formats),
+    FILTER_QUERY_FUNC2(channelmap_query_formats),
 };