1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

lavfi/af_ladspa: convert to query_func2()

This commit is contained in:
Anton Khirnov 2024-09-04 14:43:33 +02:00
parent 48d9a4d7ca
commit bfb139bb8d

View File

@ -694,31 +694,29 @@ static av_cold int init(AVFilterContext *ctx)
return 0;
}
static int query_formats(AVFilterContext *ctx)
static int query_formats(const AVFilterContext *ctx,
AVFilterFormatsConfig **cfg_in,
AVFilterFormatsConfig **cfg_out)
{
LADSPAContext *s = ctx->priv;
const LADSPAContext *s = ctx->priv;
AVFilterChannelLayouts *layouts;
static const enum AVSampleFormat sample_fmts[] = {
AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
int ret = ff_set_common_formats_from_list(ctx, sample_fmts);
int ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
if (ret < 0)
return ret;
if (s->nb_inputs) {
ret = ff_set_common_all_samplerates(ctx);
if (ret < 0)
return ret;
} else {
if (!s->nb_inputs) {
int sample_rates[] = { s->sample_rate, -1 };
ret = ff_set_common_samplerates_from_list(ctx, sample_rates);
ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
if (ret < 0)
return ret;
}
if (s->nb_inputs == 1 && s->nb_outputs == 1) {
// We will instantiate multiple LADSPA_Handle, one over each channel
ret = ff_set_common_all_channel_counts(ctx);
ret = ff_set_common_all_channel_counts2(ctx, cfg_in, cfg_out);
if (ret < 0)
return ret;
} else if (s->nb_inputs == 2 && s->nb_outputs == 2) {
@ -726,26 +724,23 @@ static int query_formats(AVFilterContext *ctx)
ret = ff_add_channel_layout(&layouts, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
if (ret < 0)
return ret;
ret = ff_set_common_channel_layouts(ctx, layouts);
ret = ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, layouts);
if (ret < 0)
return ret;
} else {
AVFilterLink *outlink = ctx->outputs[0];
if (s->nb_inputs >= 1) {
AVFilterLink *inlink = ctx->inputs[0];
AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
layouts = NULL;
ret = ff_add_channel_layout(&layouts, &inlayout);
if (ret < 0)
return ret;
ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts);
ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts);
if (ret < 0)
return ret;
if (!s->nb_outputs) {
ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts);
ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
if (ret < 0)
return ret;
}
@ -758,7 +753,7 @@ static int query_formats(AVFilterContext *ctx)
ret = ff_add_channel_layout(&layouts, &outlayout);
if (ret < 0)
return ret;
ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts);
ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
if (ret < 0)
return ret;
}
@ -825,6 +820,6 @@ const AVFilter ff_af_ladspa = {
.process_command = process_command,
.inputs = 0,
FILTER_OUTPUTS(ladspa_outputs),
FILTER_QUERY_FUNC(query_formats),
FILTER_QUERY_FUNC2(query_formats),
.flags = AVFILTER_FLAG_DYNAMIC_INPUTS,
};