[FFmpeg-devel] [PATCH 04/22] lavfi/asrc_anullsrc: convert to query_func2()

Anton Khirnov anton at khirnov.net
Wed Sep 25 12:39:01 EEST 2024


Also, drop a redundant call that also happens implicitly in generic
code.
---
 libavfilter/asrc_anullsrc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c
index 3249cc33ad..d8fd5e7c06 100644
--- a/libavfilter/asrc_anullsrc.c
+++ b/libavfilter/asrc_anullsrc.c
@@ -61,18 +61,20 @@ static const AVOption anullsrc_options[]= {
 
 AVFILTER_DEFINE_CLASS(anullsrc);
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    ANullContext *null = ctx->priv;
+    const ANullContext *null = ctx->priv;
     const AVChannelLayout chlayouts[] = { null->ch_layout, { 0 } };
     int sample_rates[] = { null->sample_rate, -1 };
     int ret;
 
-    if ((ret = ff_set_common_formats         (ctx, ff_all_formats              (AVMEDIA_TYPE_AUDIO))) < 0 ||
-        (ret = ff_set_common_samplerates_from_list(ctx, sample_rates)) < 0)
+    ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
+    if (ret < 0)
         return ret;
 
-    return ff_set_common_channel_layouts_from_list(ctx, chlayouts);
+    return ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, chlayouts);
 }
 
 static av_cold int config_props(AVFilterLink *outlink)
@@ -124,7 +126,7 @@ const AVFilter ff_asrc_anullsrc = {
     .priv_size     = sizeof(ANullContext),
     .inputs        = NULL,
     FILTER_OUTPUTS(avfilter_asrc_anullsrc_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .activate      = activate,
     .priv_class    = &anullsrc_class,
 };
-- 
2.43.0



More information about the ffmpeg-devel mailing list