* commit 'd79bd6040599ef017dc45d5997fcc959ab1f71f6': lavfi: factorize freeing a link Conflicts: libavfilter/avfilter.c
Unified · Split
| @@ -622,10 +622,28 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in · 621 unmodified lines | ||
| 622 | 622 | } |
| 623 | 623 | #endif |
| 624 | 624 | |
| 625 | +static void free_link(AVFilterLink *link) | |
| 626 | +{ | |
| 627 | + if (!link) | |
| 628 | + return; | |
| 629 | + | |
| 630 | + if (link->src) | |
| 631 | + link->src->outputs[link->srcpad - link->src->output_pads] = NULL; | |
| 632 | + if (link->dst) | |
| 633 | + link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; | |
| 634 | + | |
| 635 | + ff_formats_unref(&link->in_formats); | |
| 636 | + ff_formats_unref(&link->out_formats); | |
| 637 | + ff_formats_unref(&link->in_samplerates); | |
| 638 | + ff_formats_unref(&link->out_samplerates); | |
| 639 | + ff_channel_layouts_unref(&link->in_channel_layouts); | |
| 640 | + ff_channel_layouts_unref(&link->out_channel_layouts); | |
| 641 | + avfilter_link_free(&link); | |
| 642 | +} | |
| 643 | + | |
| 625 | 644 | void avfilter_free(AVFilterContext *filter) |
| 626 | 645 | { |
| 627 | 646 | int i; |
| 628 | − AVFilterLink *link; | |
| 629 | 647 | |
| 630 | 648 | if (!filter) |
| 631 | 649 | return; |
| @@ -637,30 +655,10 @@ void avfilter_free(AVFilterContext *filter) · 5 unmodified lines | ||
| 637 | 655 | filter->filter->uninit(filter); |
| 638 | 656 | |
| 639 | 657 | for (i = 0; i < filter->nb_inputs; i++) { |
| 640 | − if ((link = filter->inputs[i])) { | |
| 641 | − if (link->src) | |
| 642 | − link->src->outputs[link->srcpad - link->src->output_pads] = NULL; | |
| 643 | − ff_formats_unref(&link->in_formats); | |
| 644 | − ff_formats_unref(&link->out_formats); | |
| 645 | − ff_formats_unref(&link->in_samplerates); | |
| 646 | − ff_formats_unref(&link->out_samplerates); | |
| 647 | − ff_channel_layouts_unref(&link->in_channel_layouts); | |
| 648 | − ff_channel_layouts_unref(&link->out_channel_layouts); | |
| 649 | − } | |
| 650 | − avfilter_link_free(&link); | |
| 658 | + free_link(filter->inputs[i]); | |
| 651 | 659 | } |
| 652 | 660 | for (i = 0; i < filter->nb_outputs; i++) { |
| 653 | − if ((link = filter->outputs[i])) { | |
| 654 | − if (link->dst) | |
| 655 | − link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL; | |
| 656 | − ff_formats_unref(&link->in_formats); | |
| 657 | − ff_formats_unref(&link->out_formats); | |
| 658 | − ff_formats_unref(&link->in_samplerates); | |
| 659 | − ff_formats_unref(&link->out_samplerates); | |
| 660 | − ff_channel_layouts_unref(&link->in_channel_layouts); | |
| 661 | − ff_channel_layouts_unref(&link->out_channel_layouts); | |
| 662 | − } | |
| 663 | − avfilter_link_free(&link); | |
| 661 | + free_link(filter->outputs[i]); | |
| 664 | 662 | } |
| 665 | 663 | |
| 666 | 664 | if (filter->filter->priv_class) |