[FFmpeg-devel] [PATCH 17/25] lavfi/af_surround: convert to query_func2()
Anton Khirnov
anton at khirnov.net
Thu Sep 5 13:07:21 EEST 2024
Also, drop redundant calls that also happen implicitly in generic code.
---
libavfilter/af_surround.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
index 111af03335..95efe4685a 100644
--- a/libavfilter/af_surround.c
+++ b/libavfilter/af_surround.c
@@ -146,17 +146,20 @@ typedef struct AudioSurroundContext {
int n);
} AudioSurroundContext;
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
{
- AudioSurroundContext *s = ctx->priv;
- AVFilterFormats *formats = NULL;
+ static const enum AVSampleFormat formats[] = {
+ AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_NONE,
+ };
+
+ const AudioSurroundContext *s = ctx->priv;
AVFilterChannelLayouts *layouts = NULL;
int ret;
- ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
- if (ret)
- return ret;
- ret = ff_set_common_formats(ctx, formats);
+ ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, formats);
if (ret)
return ret;
@@ -165,7 +168,7 @@ static int query_formats(AVFilterContext *ctx)
if (ret)
return ret;
- ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts);
+ ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
if (ret)
return ret;
@@ -174,11 +177,11 @@ static int query_formats(AVFilterContext *ctx)
if (ret)
return ret;
- ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts);
+ ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts);
if (ret)
return ret;
- return ff_set_common_all_samplerates(ctx);
+ return 0;
}
static void set_input_levels(AVFilterContext *ctx)
@@ -1517,7 +1520,7 @@ const AVFilter ff_af_surround = {
.activate = activate,
FILTER_INPUTS(inputs),
FILTER_OUTPUTS(outputs),
- FILTER_QUERY_FUNC(query_formats),
+ FILTER_QUERY_FUNC2(query_formats),
.flags = AVFILTER_FLAG_SLICE_THREADS,
.process_command = process_command,
};
--
2.43.0
More information about the ffmpeg-devel
mailing list