aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avfiltergraph.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-03-31 13:02:55 +0200
committerAnton Khirnov <anton@khirnov.net>2013-04-11 20:38:48 +0200
commit1565cbc65cbb9f95c11367314a080068895e0cf0 (patch)
treeb97be56bae403beb5e75d2328833dca9af148792 /libavfilter/avfiltergraph.c
parent111367263af41c88a44bd763ceefc11d53a7f655 (diff)
downloadffmpeg-1565cbc65cbb9f95c11367314a080068895e0cf0.tar.gz
lavfi: make avfilter_free() remove the filter from its graph.
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r--libavfilter/avfiltergraph.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 969d958541..5679ad98bc 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -46,12 +46,27 @@ AVFilterGraph *avfilter_graph_alloc(void)
return ret;
}
+void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
+{
+ int i;
+ for (i = 0; i < graph->nb_filters; i++) {
+ if (graph->filters[i] == filter) {
+ FFSWAP(AVFilterContext*, graph->filters[i],
+ graph->filters[graph->nb_filters - 1]);
+ graph->nb_filters--;
+ return;
+ }
+ }
+}
+
void avfilter_graph_free(AVFilterGraph **graph)
{
if (!*graph)
return;
- for (; (*graph)->nb_filters > 0; (*graph)->nb_filters--)
- avfilter_free((*graph)->filters[(*graph)->nb_filters - 1]);
+
+ while ((*graph)->nb_filters)
+ avfilter_free((*graph)->filters[0]);
+
av_freep(&(*graph)->scale_sws_opts);
av_freep(&(*graph)->resample_lavr_opts);
av_freep(&(*graph)->filters);