From 408587c83673e8cff71ed77ecc87ea00a2f4bd5c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 4 Sep 2024 14:43:33 +0200 Subject: [PATCH] lavfi/af_extrastereo: convert to query_func2() Also, drop a redundant call that also happens implicitly in generic code. --- libavfilter/af_extrastereo.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/libavfilter/af_extrastereo.c b/libavfilter/af_extrastereo.c index 6563b39402..e511a2b968 100644 --- a/libavfilter/af_extrastereo.c +++ b/libavfilter/af_extrastereo.c @@ -42,19 +42,30 @@ static const AVOption extrastereo_options[] = { AVFILTER_DEFINE_CLASS(extrastereo); -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_FLT, + 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_FLT )) < 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 filter_frame(AVFilterLink *inlink, AVFrame *in) @@ -118,7 +129,7 @@ const AVFilter ff_af_extrastereo = { .priv_class = &extrastereo_class, FILTER_INPUTS(inputs), FILTER_OUTPUTS(ff_audio_default_filterpad), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, .process_command = ff_filter_process_command, };