mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
Make avfilter_graph_free() free the graph.
Make avfilter_graph_free() free not only the internal structures, but also the allocated graph, and set the graph pointer to NULL for increased safety. Simplify usage. Signed-off-by: Mans Rullgard <mans@mansr.com> (cherry picked from commit 4359288c565705d1734f63d277f8918ee5af5e54)
This commit is contained in:
parent
c68be8e135
commit
ab543afe47
5
ffmpeg.c
5
ffmpeg.c
@ -2708,10 +2708,7 @@ static int transcode(AVFormatContext **output_files,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
if (graph) {
|
avfilter_graph_free(&graph);
|
||||||
avfilter_graph_free(graph);
|
|
||||||
av_freep(&graph);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* finished ! */
|
/* finished ! */
|
||||||
|
3
ffplay.c
3
ffplay.c
@ -1899,8 +1899,7 @@ static int video_thread(void *arg)
|
|||||||
}
|
}
|
||||||
the_end:
|
the_end:
|
||||||
#if CONFIG_AVFILTER
|
#if CONFIG_AVFILTER
|
||||||
avfilter_graph_free(graph);
|
avfilter_graph_free(&graph);
|
||||||
av_freep(&graph);
|
|
||||||
#endif
|
#endif
|
||||||
av_free(frame);
|
av_free(frame);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -32,14 +32,15 @@ AVFilterGraph *avfilter_graph_alloc(void)
|
|||||||
return av_mallocz(sizeof(AVFilterGraph));
|
return av_mallocz(sizeof(AVFilterGraph));
|
||||||
}
|
}
|
||||||
|
|
||||||
void avfilter_graph_free(AVFilterGraph *graph)
|
void avfilter_graph_free(AVFilterGraph **graph)
|
||||||
{
|
{
|
||||||
if (!graph)
|
if (!*graph)
|
||||||
return;
|
return;
|
||||||
for (; graph->filter_count > 0; graph->filter_count --)
|
for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
|
||||||
avfilter_free(graph->filters[graph->filter_count - 1]);
|
avfilter_free((*graph)->filters[(*graph)->filter_count - 1]);
|
||||||
av_freep(&graph->scale_sws_opts);
|
av_freep(&(*graph)->scale_sws_opts);
|
||||||
av_freep(&graph->filters);
|
av_freep(&(*graph)->filters);
|
||||||
|
av_freep(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
|
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
|
||||||
|
@ -79,9 +79,10 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
|
|||||||
int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
|
int avfilter_graph_config(AVFilterGraph *graphctx, AVClass *log_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free a graph and destroy its links, graph may be NULL.
|
* Free a graph, destroy its links, and set *graph to NULL.
|
||||||
|
* If *graph is NULL, do nothing.
|
||||||
*/
|
*/
|
||||||
void avfilter_graph_free(AVFilterGraph *graph);
|
void avfilter_graph_free(AVFilterGraph **graph);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A linked-list of the inputs/outputs of the filter chain.
|
* A linked-list of the inputs/outputs of the filter chain.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user