lavfi/af_pan: convert to query_func2()

Also, drop redundant calls that also happen implicitly in generic code.
This commit is contained in:
Anton Khirnov 2024-09-05 12:03:23 +02:00
parent b38f4e7f86
commit 691e0a1082
1 changed files with 6 additions and 13 deletions

View File

@ -243,31 +243,24 @@ fail:
return ret;
}
static int query_formats(AVFilterContext *ctx)
static int query_formats(const AVFilterContext *ctx,
AVFilterFormatsConfig **cfg_in,
AVFilterFormatsConfig **cfg_out)
{
const PanContext *pan = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
AVFilterLink *outlink = ctx->outputs[0];
AVFilterChannelLayouts *layouts;
int ret;
/* libswr supports any sample and packing formats */
if ((ret = ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_AUDIO))) < 0)
return ret;
if ((ret = ff_set_common_all_samplerates(ctx)) < 0)
return ret;
// inlink supports any channel layout
layouts = ff_all_channel_counts();
if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0)
if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts)) < 0)
return ret;
// outlink supports only requested output channel layout
layouts = NULL;
if ((ret = ff_add_channel_layout(&layouts, &pan->out_channel_layout)) < 0)
return ret;
return ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts);
return ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
}
static int config_props(AVFilterLink *link)
@ -432,5 +425,5 @@ const AVFilter ff_af_pan = {
.uninit = uninit,
FILTER_INPUTS(pan_inputs),
FILTER_OUTPUTS(ff_audio_default_filterpad),
FILTER_QUERY_FUNC(query_formats),
FILTER_QUERY_FUNC2(query_formats),
};