Since we do not support "standalone" filters not attached to an AVFilterGraph, we should not have a public function to create such filters. In addition that function is horribly named, the action it does cannot be possibly described as "opening" a filter.
Showing the changes to libavfilter/avfiltergraph.c (1 of 7 files). Show all
Unified · Split
| @@ -81,12 +81,12 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, · 80 unmodified lines | ||
| 81 | 81 | { |
| 82 | 82 | int ret; |
| 83 | 83 | |
| 84 | − if ((ret = avfilter_open(filt_ctx, filt, name)) < 0) | |
| 85 | − goto fail; | |
| 84 | + *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name); | |
| 85 | + if (!*filt_ctx) | |
| 86 | + return AVERROR(ENOMEM); | |
| 86 | 87 | if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0) |
| 87 | 88 | goto fail; |
| 88 | − if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0) | |
| 89 | − goto fail; | |
| 89 | + | |
| 90 | 90 | return 0; |
| 91 | 91 | |
| 92 | 92 | fail: |
| @@ -96,6 +96,32 @@ fail: · 3 unmodified lines | ||
| 96 | 96 | return ret; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | +AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, | |
| 100 | + const AVFilter *filter, | |
| 101 | + const char *name) | |
| 102 | +{ | |
| 103 | + AVFilterContext **filters, *s; | |
| 104 | + | |
| 105 | + s = ff_filter_alloc(filter, name); | |
| 106 | + if (!s) | |
| 107 | + return NULL; | |
| 108 | + | |
| 109 | + filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1)); | |
| 110 | + if (!filters) { | |
| 111 | + avfilter_free(s); | |
| 112 | + return NULL; | |
| 113 | + } | |
| 114 | + | |
| 115 | + graph->filters = filters; | |
| 116 | + graph->filters[graph->nb_filters++] = s; | |
| 117 | + | |
| 118 | +#if FF_API_FOO_COUNT | |
| 119 | + graph->filter_count = graph->nb_filters; | |
| 120 | +#endif | |
| 121 | + | |
| 122 | + return s; | |
| 123 | +} | |
| 124 | + | |
| 99 | 125 | /** |
| 100 | 126 | * Check for the validity of graph. |
| 101 | 127 | * |