lavfi/af_anequalizer: convert to query_func2()

Also, simplify code and drop redundant calls that also happen implicitly
in generic code.
This commit is contained in:
Anton Khirnov 2024-08-30 21:56:02 +02:00
parent 6e4affc407
commit e0ab1fcc8c
1 changed files with 9 additions and 23 deletions

View File

@ -217,13 +217,11 @@ static av_cold int init(AVFilterContext *ctx)
return 0; 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]; const AudioNEqualizerContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
AudioNEqualizerContext *s = ctx->priv;
AVFilterFormats *formats;
AVFilterChannelLayouts *layouts;
static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE };
static const enum AVSampleFormat sample_fmts[] = { static const enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_DBLP,
@ -232,25 +230,13 @@ static int query_formats(AVFilterContext *ctx)
int ret; int ret;
if (s->draw_curves) { if (s->draw_curves) {
AVFilterLink *videolink = ctx->outputs[1]; ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts);
formats = ff_make_format_list(pix_fmts); if (ret < 0)
if ((ret = ff_formats_ref(formats, &videolink->incfg.formats)) < 0)
return ret; return ret;
} }
formats = ff_make_format_list(sample_fmts); ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0 || if (ret < 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)
return ret; return ret;
return 0; return 0;
@ -775,7 +761,7 @@ const AVFilter ff_af_anequalizer = {
.uninit = uninit, .uninit = uninit,
FILTER_INPUTS(inputs), FILTER_INPUTS(inputs),
.outputs = NULL, .outputs = NULL,
FILTER_QUERY_FUNC(query_formats), FILTER_QUERY_FUNC2(query_formats),
.process_command = process_command, .process_command = process_command,
.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |