aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/graphparser.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-11 15:30:46 +0200
committerAnton Khirnov <anton@khirnov.net>2012-04-14 09:25:46 +0200
commit91d3cbe0fde05c45837649c213de879c8d85aa67 (patch)
treed3e0fc70a6c72a4b8ebd2d3f640a87c109d7467b /libavfilter/graphparser.c
parent12e7e1d03e772b16ae95fa6c79ed870d9335564c (diff)
downloadffmpeg-91d3cbe0fde05c45837649c213de879c8d85aa67.tar.gz
avfiltergraph: make the AVFilterInOut alloc/free API public
This is required for letting applications to create and destroy AVFilterInOut structs in a convenient way. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavfilter/graphparser.c')
-rw-r--r--libavfilter/graphparser.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index d2d31653a9..454704710b 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr
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);
- 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;
@@ -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);
- free_inout(match);
+ avfilter_inout_free(&match);
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);
- free_inout(match);
+ avfilter_inout_free(&match);
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);
}
- 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;
}