diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index fe0968c974..adcfcb3c5a 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -90,35 +90,32 @@ static const AVOption aphasemeter_options[] = { AVFILTER_DEFINE_CLASS(aphasemeter); -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AudioPhaseMeterContext *s = ctx->priv; + const AudioPhaseMeterContext *s = ctx->priv; 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_FLT, AV_SAMPLE_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, 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_formats_ref (formats, &outlink->incfg.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 || - (ret = ff_channel_layouts_ref (layout , &outlink->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0 || + (ret = ff_formats_ref(formats, &cfg_out[0]->formats)) < 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_channel_layouts_from_list2(ctx, cfg_in, cfg_out, layouts); + if (ret < 0) return ret; if (s->do_video) { - AVFilterLink *outlink = ctx->outputs[1]; - 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[1]->formats)) < 0) return ret; } @@ -440,7 +437,7 @@ const AVFilter ff_avf_aphasemeter = { FILTER_INPUTS(inputs), .activate = activate, .outputs = NULL, - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .priv_class = &aphasemeter_class, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS, };