From: Michael Niedermayer Date: Thu, 11 Apr 2013 22:54:05 +0000 (+0200) Subject: Merge commit '1565cbc65cbb9f95c11367314a080068895e0cf0' X-Git-Tag: n2.0~1916 X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=eb0f774d4bfdb1e5cb131f63580417cfb6b47514 Merge commit '1565cbc65cbb9f95c11367314a080068895e0cf0' * commit '1565cbc65cbb9f95c11367314a080068895e0cf0': lavfi: make avfilter_free() remove the filter from its graph. Conflicts: libavfilter/avfilter.c libavfilter/avfiltergraph.c libavfilter/graphparser.c Merged-by: Michael Niedermayer --- eb0f774d4bfdb1e5cb131f63580417cfb6b47514 diff --cc libavfilter/avfilter.c index 406537a5a6,c32ae1745a..54d90dcd02 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@@ -568,9 -430,9 +568,12 @@@ void avfilter_free(AVFilterContext *fil int i; AVFilterLink *link; + if (!filter) + return; + + if (filter->graph) + ff_filter_graph_remove_filter(filter->graph, filter); + if (filter->filter->uninit) filter->filter->uninit(filter); diff --cc libavfilter/avfiltergraph.c index 8dd543362f,5679ad98bc..8e8edd5134 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@@ -63,11 -63,11 +76,13 @@@ void avfilter_graph_free(AVFilterGraph { 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)->sink_links); av_freep(&(*graph)->scale_sws_opts); + av_freep(&(*graph)->aresample_swr_opts); av_freep(&(*graph)->resample_lavr_opts); av_freep(&(*graph)->filters); av_freep(graph); diff --cc libavfilter/graphparser.c index 3af9b56021,5738a12e06..447b9ebc5d --- a/libavfilter/graphparser.c +++ b/libavfilter/graphparser.c @@@ -429,9 -429,9 +429,9 @@@ int avfilter_graph_parse2(AVFilterGrap *outputs = open_outputs; return 0; - fail: + fail:end: - 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->filters); avfilter_inout_free(&open_inputs); avfilter_inout_free(&open_outputs);