avfiltergraph: make the AVFilterInOut alloc/free API public
authorStefano Sabatini <stefano.sabatini-lala@poste.it>
Sat, 11 Jun 2011 13:30:46 +0000 (15:30 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 14 Apr 2012 07:25:46 +0000 (09:25 +0200)
This is required for letting applications to create and destroy
AVFilterInOut structs in a convenient way.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
avconv.c
avplay.c
doc/APIchanges
libavfilter/avfiltergraph.h
libavfilter/graphparser.c
libavfilter/version.h

index 2cefe5d5497c3645e2e4ec999124a2cd05793df1..719df6ddc4cfd061418c409aac2687ba7adfd4ce 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -592,8 +592,8 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost)
     ost->graph->scale_sws_opts = av_strdup(args);
 
     if (ost->avfilter) {
     ost->graph->scale_sws_opts = av_strdup(args);
 
     if (ost->avfilter) {
-        AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
-        AVFilterInOut *inputs  = av_malloc(sizeof(AVFilterInOut));
+        AVFilterInOut *outputs = avfilter_inout_alloc();
+        AVFilterInOut *inputs  = avfilter_inout_alloc();
 
         outputs->name    = av_strdup("in");
         outputs->filter_ctx = last_filter;
 
         outputs->name    = av_strdup("in");
         outputs->filter_ctx = last_filter;
index 488d0fcd13cea0ac300093ba73a8a2bf4e69557c..4ebccb2acfe06674e9028a7495bfde000743b68f 100644 (file)
--- a/avplay.c
+++ b/avplay.c
@@ -1716,8 +1716,8 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
         return ret;
 
     if (vfilters) {
         return ret;
 
     if (vfilters) {
-        AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut));
-        AVFilterInOut *inputs  = av_malloc(sizeof(AVFilterInOut));
+        AVFilterInOut *outputs = avfilter_inout_alloc();
+        AVFilterInOut *inputs  = avfilter_inout_alloc();
 
         outputs->name    = av_strdup("in");
         outputs->filter_ctx = filt_src;
 
         outputs->name    = av_strdup("in");
         outputs->filter_ctx = filt_src;
index 889156e0bc05dd09d94301ddaca3c73e3ad58326..5114e14191b2e252a61d6baf71e3d90ce9786287 100644 (file)
@@ -12,6 +12,10 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
 
 API changes, most recent first:
 
+2012-xx-xx - xxxxxxx - lavfi 2.16.0 - avfiltergraph.h
+  Add avfilter_graph_parse2(), avfilter_inout_alloc() and
+  avfilter_inout_free() functions.
+
 2012-xx-xx - xxxxxxx - lavu 51.27.0 - samplefmt.h
   Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt()
 
 2012-xx-xx - xxxxxxx - lavu 51.27.0 - samplefmt.h
   Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt()
 
index 0d250df614f4aa9856f05ccba04ab688e7bad91d..0d600b91cec9eb6a214f73d644edc488494f92f9 100644 (file)
@@ -111,6 +111,19 @@ typedef struct AVFilterInOut {
     struct AVFilterInOut *next;
 } AVFilterInOut;
 
     struct AVFilterInOut *next;
 } AVFilterInOut;
 
+/**
+ * Allocate a single AVFilterInOut entry.
+ * Must be freed with avfilter_inout_free().
+ * @return allocated AVFilterInOut on success, NULL on failure.
+ */
+AVFilterInOut *avfilter_inout_alloc(void);
+
+/**
+ * Free the supplied list of AVFilterInOut and set *inout to NULL.
+ * If *inout is NULL, do nothing.
+ */
+void avfilter_inout_free(AVFilterInOut **inout);
+
 /**
  * Add a graph described by a string to a graph.
  *
 /**
  * Add a graph described by a string to a graph.
  *
index d2d31653a99427ec57e016c10dd7db261f8e29c5..454704710bbd8f7754d34fa9f00b2a39d136f0a9 100644 (file)
@@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr
     return ret;
 }
 
     return ret;
 }
 
-static void free_inout(AVFilterInOut *head)
+AVFilterInOut *avfilter_inout_alloc(void)
 {
 {
-    while (head) {
-        AVFilterInOut *next = head->next;
-        av_free(head->name);
-        av_free(head);
-        head = next;
+    return av_mallocz(sizeof(AVFilterInOut));
+}
+
+void avfilter_inout_free(AVFilterInOut **inout)
+{
+    while (*inout) {
+        AVFilterInOut *next = (*inout)->next;
+        av_freep(&(*inout)->name);
+        av_freep(inout);
+        *inout = next;
     }
 }
 
     }
 }
 
@@ -431,9 +436,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
     for (; graph->filter_count > 0; graph->filter_count--)
         avfilter_free(graph->filters[graph->filter_count - 1]);
     av_freep(&graph->filters);
     for (; graph->filter_count > 0; graph->filter_count--)
         avfilter_free(graph->filters[graph->filter_count - 1]);
     av_freep(&graph->filters);
-    free_inout(open_inputs);
-    free_inout(open_outputs);
-    free_inout(curr_inputs);
+    avfilter_inout_free(&open_inputs);
+    avfilter_inout_free(&open_outputs);
+    avfilter_inout_free(&curr_inputs);
 
     *inputs  = NULL;
     *outputs = NULL;
 
     *inputs  = NULL;
     *outputs = NULL;
@@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
             continue;
         ret = avfilter_link(match->filter_ctx, match->pad_idx,
                             cur->filter_ctx,   cur->pad_idx);
             continue;
         ret = avfilter_link(match->filter_ctx, match->pad_idx,
                             cur->filter_ctx,   cur->pad_idx);
-        free_inout(match);
+        avfilter_inout_free(&match);
         if (ret < 0)
             goto fail;
     }
         if (ret < 0)
             goto fail;
     }
@@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
             continue;
         ret = avfilter_link(cur->filter_ctx,   cur->pad_idx,
                             match->filter_ctx, match->pad_idx);
             continue;
         ret = avfilter_link(cur->filter_ctx,   cur->pad_idx,
                             match->filter_ctx, match->pad_idx);
-        free_inout(match);
+        avfilter_inout_free(&match);
         if (ret < 0)
             goto fail;
     }
         if (ret < 0)
             goto fail;
     }
@@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
             avfilter_free(graph->filters[graph->filter_count - 1]);
         av_freep(&graph->filters);
     }
             avfilter_free(graph->filters[graph->filter_count - 1]);
         av_freep(&graph->filters);
     }
-    free_inout(inputs);
-    free_inout(outputs);
-    free_inout(open_inputs);
-    free_inout(open_outputs);
+    avfilter_inout_free(&inputs);
+    avfilter_inout_free(&outputs);
+    avfilter_inout_free(&open_inputs);
+    avfilter_inout_free(&open_outputs);
     return ret;
 }
     return ret;
 }
index d84b67ff761ea4ffa05f8524a482e09f66fe4459..5d646e4f86764fa97f7974e082c17f9ed29475af 100644 (file)
@@ -29,7 +29,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  2
 #include "libavutil/avutil.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  2
-#define LIBAVFILTER_VERSION_MINOR  15
+#define LIBAVFILTER_VERSION_MINOR  16
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \