diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-03-31 08:28:11 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2013-04-11 20:34:14 +0200 |
commit | bc1a985ba030e9861d24965d42792850b43a43ea (patch) | |
tree | 5bfe8c12dcb58b6560a0028a03da63bfc36cde80 /libavfilter/avfiltergraph.c | |
parent | 38f0c0781a6e099f11c0acec07f9b8be742190c4 (diff) | |
download | ffmpeg-bc1a985ba030e9861d24965d42792850b43a43ea.tar.gz |
lavfi: replace avfilter_open() with avfilter_graph_alloc_filter().
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.
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r-- | libavfilter/avfiltergraph.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 44736cc71d..c35d0ea18d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -81,12 +81,12 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, { int ret; - if ((ret = avfilter_open(filt_ctx, filt, name)) < 0) - goto fail; + *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name); + if (!*filt_ctx) + return AVERROR(ENOMEM); if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0) goto fail; - if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0) - goto fail; + return 0; fail: @@ -96,6 +96,32 @@ fail: return ret; } +AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, + const AVFilter *filter, + const char *name) +{ + AVFilterContext **filters, *s; + + s = ff_filter_alloc(filter, name); + if (!s) + return NULL; + + filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1)); + if (!filters) { + avfilter_free(s); + return NULL; + } + + graph->filters = filters; + graph->filters[graph->nb_filters++] = s; + +#if FF_API_FOO_COUNT + graph->filter_count = graph->nb_filters; +#endif + + return s; +} + /** * Check for the validity of graph. * |