From 1565cbc65cbb9f95c11367314a080068895e0cf0 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 31 Mar 2013 13:02:55 +0200 Subject: lavfi: make avfilter_free() remove the filter from its graph. --- libavfilter/avfiltergraph.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'libavfilter/avfiltergraph.c') 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); -- cgit v1.2.3