summaryrefslogtreecommitdiff
path: root/libavfilter/avfiltergraph.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-11 23:56:39 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-12 00:31:44 +0200
commit86070b8e5a0e0ba087a9ce2a050c00094e29f35b (patch)
tree6e82eb3de383fa6f8756c5053d26e52fbf29f07b /libavfilter/avfiltergraph.c
parent9da369604ecf31d9dce2dee21ed214b8c43264c6 (diff)
parentbc1a985ba030e9861d24965d42792850b43a43ea (diff)
Merge commit 'bc1a985ba030e9861d24965d42792850b43a43ea'
* commit 'bc1a985ba030e9861d24965d42792850b43a43ea': lavfi: replace avfilter_open() with avfilter_graph_alloc_filter(). Conflicts: libavfilter/avfiltergraph.c libavfilter/internal.h libavfilter/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r--libavfilter/avfiltergraph.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 28fc743b59..771c7dfda6 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -96,12 +96,14 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
{
int ret;
- if ((ret = avfilter_open(filt_ctx, filt, name)) < 0)
- goto fail;
- if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0)
- goto fail;
- if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0)
+ *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) {
+ graph_ctx->filters[graph_ctx->nb_filters-1] = NULL;
goto fail;
+ }
+
return 0;
fail:
@@ -116,6 +118,32 @@ void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
graph->disable_auto_convert = flags;
}
+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_unused = graph->nb_filters;
+#endif
+
+ return s;
+}
+
/**
* Check for the validity of graph.
*