It is necessary for filters with child objects, to set the class and default options values.
Showing the changes to libavfilter/avfilter.c (1 of 2 files). Show all
Unified · Split
| @@ -692,6 +692,7 @@ static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, voi · 691 unmodified lines | ||
| 692 | 692 | AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) |
| 693 | 693 | { |
| 694 | 694 | AVFilterContext *ret; |
| 695 | + int preinited = 0; | |
| 695 | 696 | |
| 696 | 697 | if (!filter) |
| 697 | 698 | return NULL; |
| @@ -708,6 +709,11 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) · 10 unmodified lines | ||
| 708 | 709 | if (!ret->priv) |
| 709 | 710 | goto err; |
| 710 | 711 | } |
| 712 | + if (filter->preinit) { | |
| 713 | + if (filter->preinit(ret) < 0) | |
| 714 | + goto err; | |
| 715 | + preinited = 1; | |
| 716 | + } | |
| 711 | 717 | |
| 712 | 718 | av_opt_set_defaults(ret); |
| 713 | 719 | if (filter->priv_class) { |
| @@ -745,6 +751,8 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) · 31 unmodified lines | ||
| 745 | 751 | return ret; |
| 746 | 752 | |
| 747 | 753 | err: |
| 754 | + if (preinited) | |
| 755 | + filter->uninit(ret); | |
| 748 | 756 | av_freep(&ret->inputs); |
| 749 | 757 | av_freep(&ret->input_pads); |
| 750 | 758 | ret->nb_inputs = 0; |