diff --git a/libavfilter/avf_showspatial.c b/libavfilter/avf_showspatial.c index f7380f885a..285f2f1a81 100644 --- a/libavfilter/avf_showspatial.c +++ b/libavfilter/avf_showspatial.c @@ -80,28 +80,26 @@ static av_cold void uninit(AVFilterContext *ctx) av_audio_fifo_free(s->fifo); } -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; - AVFilterLink *inlink = ctx->inputs[0]; - 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_GBRP, AV_PIX_FMT_NONE }; + static const AVChannelLayout layouts[] = { AV_CHANNEL_LAYOUT_STEREO, { .nb_channels = 0 } }; int ret; formats = ff_make_format_list(sample_fmts); - if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 || - (ret = ff_add_channel_layout (&layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) < 0 || - (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0) return ret; - formats = ff_all_samplerates(); - if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0) + ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, layouts); + if (ret < 0) return ret; formats = ff_make_format_list(pix_fmts); - if ((ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0) + if ((ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 0) return ret; return 0; @@ -330,7 +328,7 @@ const AVFilter ff_avf_showspatial = { .priv_size = sizeof(ShowSpatialContext), FILTER_INPUTS(ff_audio_default_filterpad), FILTER_OUTPUTS(showspatial_outputs), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .activate = spatial_activate, .priv_class = &showspatial_class, .flags = AVFILTER_FLAG_SLICE_THREADS,