[FFmpeg-devel] [PATCH 09/13] lavfi/af_asetrate: convert to query_func2()

Anton Khirnov anton at khirnov.net
Mon Sep 2 16:50:09 EEST 2024


Also, drop redundant calls that also happen implicitly in generic code.
---
 libavfilter/af_asetrate.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libavfilter/af_asetrate.c b/libavfilter/af_asetrate.c
index 80f76fbb70..061edebdf0 100644
--- a/libavfilter/af_asetrate.c
+++ b/libavfilter/af_asetrate.c
@@ -47,23 +47,19 @@ static const AVOption asetrate_options[] = {
 
 AVFILTER_DEFINE_CLASS(asetrate);
 
-static av_cold int query_formats(AVFilterContext *ctx)
+static av_cold int query_formats(const AVFilterContext *ctx,
+                                 AVFilterFormatsConfig **cfg_in,
+                                 AVFilterFormatsConfig **cfg_out)
 {
-    ASetRateContext *sr = ctx->priv;
+    const ASetRateContext *sr = ctx->priv;
     int ret, sample_rates[] = { sr->sample_rate, -1 };
 
-    if ((ret = ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO))) < 0)
-        return ret;
-
-    if ((ret = ff_set_common_all_channel_counts(ctx)) < 0)
-        return ret;
-
     if ((ret = ff_formats_ref(ff_all_samplerates(),
-                              &ctx->inputs[0]->outcfg.samplerates)) < 0)
+                              &cfg_in[0]->samplerates)) < 0)
         return ret;
 
     return ff_formats_ref(ff_make_format_list(sample_rates),
-                          &ctx->outputs[0]->incfg.samplerates);
+                          &cfg_out[0]->samplerates);
 }
 
 static av_cold int config_props(AVFilterLink *outlink)
@@ -122,7 +118,7 @@ const AVFilter ff_af_asetrate = {
     .priv_size     = sizeof(ASetRateContext),
     FILTER_INPUTS(asetrate_inputs),
     FILTER_OUTPUTS(asetrate_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .priv_class    = &asetrate_class,
     .flags         = AVFILTER_FLAG_METADATA_ONLY,
 };
-- 
2.43.0



More information about the ffmpeg-devel mailing list