lavfi/avf_showcqt: switch to query_func2()

Also, drop redundant calls that also happen implicitly in generic code.
This commit is contained in:
Anton Khirnov 2024-09-25 10:31:52 +02:00
parent d36c368bf3
commit 70a16a18ca

View File

@ -1314,12 +1314,11 @@ static av_cold void uninit(AVFilterContext *ctx)
common_uninit(ctx->priv); common_uninit(ctx->priv);
} }
static int query_formats(AVFilterContext *ctx) static int query_formats(const AVFilterContext *ctx,
AVFilterFormatsConfig **cfg_in,
AVFilterFormatsConfig **cfg_out)
{ {
AVFilterFormats *formats = NULL; AVFilterFormats *formats = NULL;
AVFilterChannelLayouts *layouts = 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 AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE };
static const enum AVPixelFormat pix_fmts[] = { static const enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
@ -1331,20 +1330,16 @@ static int query_formats(AVFilterContext *ctx)
/* set input audio formats */ /* set input audio formats */
formats = ff_make_format_list(sample_fmts); formats = ff_make_format_list(sample_fmts);
if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0) if ((ret = ff_formats_ref(formats, &cfg_in[0]->formats)) < 0)
return ret; return ret;
layouts = ff_make_channel_layout_list(channel_layouts); ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, channel_layouts);
if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) if (ret < 0)
return ret;
formats = ff_all_samplerates();
if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0)
return ret; return ret;
/* set output video format */ /* set output video format */
formats = ff_make_format_list(pix_fmts); 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 ret;
return 0; return 0;
@ -1612,6 +1607,6 @@ const AVFilter ff_avf_showcqt = {
.priv_size = sizeof(ShowCQTContext), .priv_size = sizeof(ShowCQTContext),
FILTER_INPUTS(ff_audio_default_filterpad), FILTER_INPUTS(ff_audio_default_filterpad),
FILTER_OUTPUTS(showcqt_outputs), FILTER_OUTPUTS(showcqt_outputs),
FILTER_QUERY_FUNC(query_formats), FILTER_QUERY_FUNC2(query_formats),
.priv_class = &showcqt_class, .priv_class = &showcqt_class,
}; };