diff mbox series

[FFmpeg-devel,15/16] lavfi/vaf_spectrumsynth: switch to query_func2()

Message ID 20241001105421.28967-15-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/16] lavfi/buffersink: move the option sanity check to init | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Oct. 1, 2024, 10:54 a.m. UTC
---
 libavfilter/vaf_spectrumsynth.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vaf_spectrumsynth.c b/libavfilter/vaf_spectrumsynth.c
index a62151aa4f..c8d3525b7b 100644
--- a/libavfilter/vaf_spectrumsynth.c
+++ b/libavfilter/vaf_spectrumsynth.c
@@ -93,14 +93,18 @@  static const AVOption spectrumsynth_options[] = {
 
 AVFILTER_DEFINE_CLASS(spectrumsynth);
 
-static int query_formats(AVFilterContext *ctx)
+enum {
+    MAGNITUDE = 0,
+    PHASE     = 1,
+};
+
+static int query_formats(const AVFilterContext *ctx,
+                         AVFilterFormatsConfig **cfg_in,
+                         AVFilterFormatsConfig **cfg_out)
 {
-    SpectrumSynthContext *s = ctx->priv;
+    const SpectrumSynthContext *s = ctx->priv;
     AVFilterFormats *formats = NULL;
     AVFilterChannelLayouts *layout = NULL;
-    AVFilterLink *magnitude = ctx->inputs[0];
-    AVFilterLink *phase = ctx->inputs[1];
-    AVFilterLink *outlink = ctx->outputs[0];
     static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
     static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
                                                    AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
@@ -108,28 +112,28 @@  static int query_formats(AVFilterContext *ctx)
     int ret, sample_rates[] = { 48000, -1 };
 
     formats = ff_make_format_list(sample_fmts);
-    if ((ret = ff_formats_ref         (formats, &outlink->incfg.formats        )) < 0 ||
+    if ((ret = ff_formats_ref         (formats, &cfg_out[0]->formats         )) < 0 ||
         (ret = ff_add_channel_layout  (&layout, &FF_COUNT2LAYOUT(s->channels))) < 0 ||
-        (ret = ff_channel_layouts_ref (layout , &outlink->incfg.channel_layouts)) < 0)
+        (ret = ff_channel_layouts_ref (layout , &cfg_out[0]->channel_layouts)) < 0)
         return ret;
 
     sample_rates[0] = s->sample_rate;
     formats = ff_make_format_list(sample_rates);
     if (!formats)
         return AVERROR(ENOMEM);
-    if ((ret = ff_formats_ref(formats, &outlink->incfg.samplerates)) < 0)
+    if ((ret = ff_formats_ref(formats, &cfg_out[0]->samplerates)) < 0)
         return ret;
 
     formats = ff_make_format_list(pix_fmts);
     if (!formats)
         return AVERROR(ENOMEM);
-    if ((ret = ff_formats_ref(formats, &magnitude->outcfg.formats)) < 0)
+    if ((ret = ff_formats_ref(formats, &cfg_in[MAGNITUDE]->formats)) < 0)
         return ret;
 
     formats = ff_make_format_list(pix_fmts);
     if (!formats)
         return AVERROR(ENOMEM);
-    if ((ret = ff_formats_ref(formats, &phase->outcfg.formats)) < 0)
+    if ((ret = ff_formats_ref(formats, &cfg_in[PHASE]->formats)) < 0)
         return ret;
 
     return 0;
@@ -543,6 +547,6 @@  const AVFilter ff_vaf_spectrumsynth = {
     .priv_size     = sizeof(SpectrumSynthContext),
     FILTER_INPUTS(spectrumsynth_inputs),
     FILTER_OUTPUTS(spectrumsynth_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_QUERY_FUNC2(query_formats),
     .priv_class    = &spectrumsynth_class,
 };