[FFmpeg-cvslog] lavfi/af_anequalizer: convert to query_func2()

Anton Khirnov git at videolan.org
Thu Sep 5 11:09:02 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Aug 30 21:56:02 2024 +0200| [e0ab1fcc8ca718ee79ecdd258ceaf5e39a01bbf7] | committer: Anton Khirnov

lavfi/af_anequalizer: convert to query_func2()

Also, simplify code and drop redundant calls that also happen implicitly
in generic code.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0ab1fcc8ca718ee79ecdd258ceaf5e39a01bbf7
---

 libavfilter/af_anequalizer.c | 32 +++++++++-----------------------
 1 file changed, 9 insertions(+), 23 deletions(-)

diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c
index fdc9404857..26e9c3cdd7 100644
--- a/libavfilter/af_anequalizer.c
+++ b/libavfilter/af_anequalizer.c
@@ -217,13 +217,11 @@ static av_cold int init(AVFilterContext *ctx)
     return 0;
 }
 
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    AVFilterLink *inlink = ctx->inputs[0];
-    AVFilterLink *outlink = ctx->outputs[0];
-    AudioNEqualizerContext *s = ctx->priv;
-    AVFilterFormats *formats;
-    AVFilterChannelLayouts *layouts;
+    const AudioNEqualizerContext *s = ctx->priv;
     static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
     static const enum AVSampleFormat sample_fmts[] = {
         AV_SAMPLE_FMT_DBLP,
@@ -232,25 +230,13 @@ static int query_formats(AVFilterContext *ctx)
     int ret;
 
     if (s->draw_curves) {
-        AVFilterLink *videolink = ctx->outputs[1];
-        formats = ff_make_format_list(pix_fmts);
-        if ((ret = ff_formats_ref(formats, &videolink->incfg.formats)) < 0)
+        ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
+        if (ret < 0)
             return ret;
     }
 
-    formats = ff_make_format_list(sample_fmts);
-    if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0 ||
-        (ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0)
-        return ret;
-
-    layouts = ff_all_channel_counts();
-    if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 ||
-        (ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0)
-        return ret;
-
-    formats = ff_all_samplerates();
-    if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0 ||
-        (ret = ff_formats_ref(formats, &outlink->incfg.samplerates)) < 0)
+    ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
+    if (ret < 0)
         return ret;
 
     return 0;
@@ -775,7 +761,7 @@ const AVFilter ff_af_anequalizer = {
     .uninit        = uninit,
     FILTER_INPUTS(inputs),
     .outputs       = NULL,
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .process_command = process_command,
     .flags         = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
                      AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |



More information about the ffmpeg-cvslog mailing list