lavfi: replace avfilter_open() with avfilter_graph_alloc_filter().
[ffmpeg.git] / libavfilter / avfilter.c
index 7c5a971..7032f2d 100644 (file)
@@ -352,17 +352,16 @@ static const AVClass avfilter_class = {
     .child_class_next = filter_child_class_next,
 };
 
-int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
+AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
 {
     AVFilterContext *ret;
-    *filter_ctx = NULL;
 
     if (!filter)
-        return AVERROR(EINVAL);
+        return NULL;
 
     ret = av_mallocz(sizeof(AVFilterContext));
     if (!ret)
-        return AVERROR(ENOMEM);
+        return NULL;
 
     ret->av_class = &avfilter_class;
     ret->filter   = filter;
@@ -404,8 +403,7 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in
     ret->input_count  = ret->nb_inputs;
 #endif
 
-    *filter_ctx = ret;
-    return 0;
+    return ret;
 
 err:
     av_freep(&ret->inputs);
@@ -416,9 +414,17 @@ err:
     ret->nb_outputs = 0;
     av_freep(&ret->priv);
     av_free(ret);
-    return AVERROR(ENOMEM);
+    return NULL;
 }
 
+#if FF_API_AVFILTER_OPEN
+int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
+{
+    *filter_ctx = ff_filter_alloc(filter, inst_name);
+    return *filter_ctx ? 0 : AVERROR(ENOMEM);
+}
+#endif
+
 void avfilter_free(AVFilterContext *filter)
 {
     int i;