[FFmpeg-devel] [PATCH 13/13] lavfi/af_channelmap: convert to query_func2()
Anton Khirnov
anton at khirnov.net
Mon Sep 2 16:50:13 EEST 2024
Also, drop redundant calls that also happen implicitly in generic code.
---
libavfilter/af_channelmap.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
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),
};
--
2.43.0
More information about the ffmpeg-devel
mailing list