History

lavfi/af_ladspa: convert to query_func2()

Anton Khirnov committed 2 years ago

Commit bfb139b1 parent 48d9a4d1 file · +13 −18Browse files

Unified · Split

libavfilter/af_ladspa.c+13−18
@@ -694,31 +694,29 @@ static av_cold int init(AVFilterContext *ctx) · 693 unmodified lines
694 return 0;694 return 0;
695}695}
696 696
697static int query_formats(AVFilterContext *ctx)697static int query_formats(const AVFilterContext *ctx,
698 AVFilterFormatsConfig **cfg_in,
699 AVFilterFormatsConfig **cfg_out)
698{700{
699 LADSPAContext *s = ctx->priv;701 const LADSPAContext *s = ctx->priv;
700 AVFilterChannelLayouts *layouts;702 AVFilterChannelLayouts *layouts;
701 static const enum AVSampleFormat sample_fmts[] = {703 static const enum AVSampleFormat sample_fmts[] = {
702 AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };704 AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE };
703 int ret = ff_set_common_formats_from_list(ctx, sample_fmts);705 int ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts);
704 if (ret < 0)706 if (ret < 0)
705 return ret;707 return ret;
706 708
707 if (s->nb_inputs) {709 if (!s->nb_inputs) {
708 ret = ff_set_common_all_samplerates(ctx);
709 if (ret < 0)
710 return ret;
711 } else {
712 int sample_rates[] = { s->sample_rate, -1 };710 int sample_rates[] = { s->sample_rate, -1 };
713 711
714 ret = ff_set_common_samplerates_from_list(ctx, sample_rates);712 ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
715 if (ret < 0)713 if (ret < 0)
716 return ret;714 return ret;
717 }715 }
718 716
719 if (s->nb_inputs == 1 && s->nb_outputs == 1) {717 if (s->nb_inputs == 1 && s->nb_outputs == 1) {
720 // We will instantiate multiple LADSPA_Handle, one over each channel718 // We will instantiate multiple LADSPA_Handle, one over each channel
721 ret = ff_set_common_all_channel_counts(ctx);719 ret = ff_set_common_all_channel_counts2(ctx, cfg_in, cfg_out);
722 if (ret < 0)720 if (ret < 0)
723 return ret;721 return ret;
724 } else if (s->nb_inputs == 2 && s->nb_outputs == 2) {722 } else if (s->nb_inputs == 2 && s->nb_outputs == 2) {
@@ -726,26 +724,23 @@ static int query_formats(AVFilterContext *ctx) · 1 unmodified line
726 ret = ff_add_channel_layout(&layouts, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);724 ret = ff_add_channel_layout(&layouts, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO);
727 if (ret < 0)725 if (ret < 0)
728 return ret;726 return ret;
729 ret = ff_set_common_channel_layouts(ctx, layouts);727 ret = ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, layouts);
730 if (ret < 0)728 if (ret < 0)
731 return ret;729 return ret;
732 } else {730 } else {
733 AVFilterLink *outlink = ctx->outputs[0];
734
735 if (s->nb_inputs >= 1) {731 if (s->nb_inputs >= 1) {
736 AVFilterLink *inlink = ctx->inputs[0];
737 AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);732 AVChannelLayout inlayout = FF_COUNT2LAYOUT(s->nb_inputs);
738 733
739 layouts = NULL;734 layouts = NULL;
740 ret = ff_add_channel_layout(&layouts, &inlayout);735 ret = ff_add_channel_layout(&layouts, &inlayout);
741 if (ret < 0)736 if (ret < 0)
742 return ret;737 return ret;
743 ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts);738 ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts);
744 if (ret < 0)739 if (ret < 0)
745 return ret;740 return ret;
746 741
747 if (!s->nb_outputs) {742 if (!s->nb_outputs) {
748 ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts);743 ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
749 if (ret < 0)744 if (ret < 0)
750 return ret;745 return ret;
751 }746 }
@@ -758,7 +753,7 @@ static int query_formats(AVFilterContext *ctx) · 6 unmodified lines
758 ret = ff_add_channel_layout(&layouts, &outlayout);753 ret = ff_add_channel_layout(&layouts, &outlayout);
759 if (ret < 0)754 if (ret < 0)
760 return ret;755 return ret;
761 ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts);756 ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts);
762 if (ret < 0)757 if (ret < 0)
763 return ret;758 return ret;
764 }759 }
@@ -825,6 +820,6 @@ const AVFilter ff_af_ladspa = { · 60 unmodified lines
825 .process_command = process_command,820 .process_command = process_command,
826 .inputs = 0,821 .inputs = 0,
827 FILTER_OUTPUTS(ladspa_outputs),822 FILTER_OUTPUTS(ladspa_outputs),
828 FILTER_QUERY_FUNC(query_formats),823 FILTER_QUERY_FUNC2(query_formats),
829 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS,824 .flags = AVFILTER_FLAG_DYNAMIC_INPUTS,
830};825};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t