Also, drop a redundant call that also happens implicitly in generic code.
Unified · Split
| @@ -594,19 +594,23 @@ static int activate(AVFilterContext *ctx) · 593 unmodified lines | |||
| 594 | return 0; | 594 | return 0; |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | static int query_formats(AVFilterContext *ctx) | 597 | static int query_formats(const AVFilterContext *ctx, |
| 598 | AVFilterFormatsConfig **cfg_in, | ||
| 599 | AVFilterFormatsConfig **cfg_out) | ||
| 598 | { | 600 | { |
| 599 | struct HeadphoneContext *s = ctx->priv; | 601 | static const enum AVSampleFormat formats[] = { |
| 600 | AVFilterFormats *formats = NULL; | 602 | AV_SAMPLE_FMT_FLT, |
| 603 | AV_SAMPLE_FMT_NONE, | ||
| 604 | }; | ||
| 605 | |||
| 606 | const HeadphoneContext *s = ctx->priv; | ||
| 607 | |||
| 601 | AVFilterChannelLayouts *layouts = NULL; | 608 | AVFilterChannelLayouts *layouts = NULL; |
| 602 | AVFilterChannelLayouts *stereo_layout = NULL; | 609 | AVFilterChannelLayouts *stereo_layout = NULL; |
| 603 | AVFilterChannelLayouts *hrir_layouts = NULL; | 610 | AVFilterChannelLayouts *hrir_layouts = NULL; |
| 604 | int ret, i; | 611 | int ret, i; |
| 605 | 612 | ||
| 606 | ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT); | 613 | ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, formats); |
| 607 | if (ret) | ||
| 608 | return ret; | ||
| 609 | ret = ff_set_common_formats(ctx, formats); | ||
| 610 | if (ret) | 614 | if (ret) |
| 611 | return ret; | 615 | return ret; |
| 612 | 616 | ||
| @@ -614,14 +618,14 @@ static int query_formats(AVFilterContext *ctx) · 1 unmodified line | |||
| 614 | if (!layouts) | 618 | if (!layouts) |
| 615 | return AVERROR(ENOMEM); | 619 | return AVERROR(ENOMEM); |
| 616 | 620 | ||
| 617 | ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); | 621 | ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts); |
| 618 | if (ret) | 622 | if (ret) |
| 619 | return ret; | 623 | return ret; |
| 620 | 624 | ||
| 621 | ret = ff_add_channel_layout(&stereo_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO); | 625 | ret = ff_add_channel_layout(&stereo_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO); |
| 622 | if (ret) | 626 | if (ret) |
| 623 | return ret; | 627 | return ret; |
| 624 | ret = ff_channel_layouts_ref(stereo_layout, &ctx->outputs[0]->incfg.channel_layouts); | 628 | ret = ff_channel_layouts_ref(stereo_layout, &cfg_out[0]->channel_layouts); |
| 625 | if (ret) | 629 | if (ret) |
| 626 | return ret; | 630 | return ret; |
| 627 | 631 | ||
| @@ -629,18 +633,18 @@ static int query_formats(AVFilterContext *ctx) · 1 unmodified line | |||
| 629 | hrir_layouts = ff_all_channel_counts(); | 633 | hrir_layouts = ff_all_channel_counts(); |
| 630 | if (!hrir_layouts) | 634 | if (!hrir_layouts) |
| 631 | return AVERROR(ENOMEM); | 635 | return AVERROR(ENOMEM); |
| 632 | ret = ff_channel_layouts_ref(hrir_layouts, &ctx->inputs[1]->outcfg.channel_layouts); | 636 | ret = ff_channel_layouts_ref(hrir_layouts, &cfg_in[1]->channel_layouts); |
| 633 | if (ret) | 637 | if (ret) |
| 634 | return ret; | 638 | return ret; |
| 635 | } else { | 639 | } else { |
| 636 | for (i = 1; i <= s->nb_hrir_inputs; i++) { | 640 | for (i = 1; i <= s->nb_hrir_inputs; i++) { |
| 637 | ret = ff_channel_layouts_ref(stereo_layout, &ctx->inputs[i]->outcfg.channel_layouts); | 641 | ret = ff_channel_layouts_ref(stereo_layout, &cfg_in[1]->channel_layouts); |
| 638 | if (ret) | 642 | if (ret) |
| 639 | return ret; | 643 | return ret; |
| 640 | } | 644 | } |
| 641 | } | 645 | } |
| 642 | 646 | ||
| 643 | return ff_set_common_all_samplerates(ctx); | 647 | return 0; |
| 644 | } | 648 | } |
| 645 | 649 | ||
| 646 | static int config_input(AVFilterLink *inlink) | 650 | static int config_input(AVFilterLink *inlink) |
| @@ -782,6 +786,6 @@ const AVFilter ff_af_headphone = { · 135 unmodified lines | |||
| 782 | .activate = activate, | 786 | .activate = activate, |
| 783 | .inputs = NULL, | 787 | .inputs = NULL, |
| 784 | FILTER_OUTPUTS(outputs), | 788 | FILTER_OUTPUTS(outputs), |
| 785 | FILTER_QUERY_FUNC(query_formats), | 789 | FILTER_QUERY_FUNC2(query_formats), |
| 786 | .flags = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_DYNAMIC_INPUTS, | 790 | .flags = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_DYNAMIC_INPUTS, |
| 787 | }; | 791 | }; |