diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-02-10 18:26:54 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-02-18 16:38:09 +0100 |
commit | 03567ed80cf1cfdbf59f902cbf1dd2c35cc3de6a (patch) | |
tree | ae4b0d6c8dfba87a1597de1451b05d7f4d2d7151 /libavfilter/avfiltergraph.c | |
parent | a1aec776f13bd865a9b80446d33a796acb607db3 (diff) | |
download | ffmpeg-03567ed80cf1cfdbf59f902cbf1dd2c35cc3de6a.tar.gz |
avfilter/avfiltergraph: Avoid allocation for AVFilterGraphInternal
To do this, allocate AVFilterGraphInternal jointly with AVFilterGraph
and rename it to FFFilterGraph in the process (similarly to
AVStream/FFStream).
The AVFilterGraphInternal* will be removed on the next major version
bump.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r-- | libavfilter/avfiltergraph.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 212d29f5f8..02f4dee588 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -67,33 +67,30 @@ static const AVClass filtergraph_class = { }; #if !HAVE_THREADS -void ff_graph_thread_free(AVFilterGraph *graph) +void ff_graph_thread_free(FFFilterGraph *graph) { } -int ff_graph_thread_init(AVFilterGraph *graph) +int ff_graph_thread_init(FFFilterGraph *graph) { - graph->thread_type = 0; - graph->nb_threads = 1; + graph->p.thread_type = 0; + graph->p.nb_threads = 1; return 0; } #endif AVFilterGraph *avfilter_graph_alloc(void) { - AVFilterGraph *ret = av_mallocz(sizeof(*ret)); - if (!ret) - return NULL; + FFFilterGraph *graph = av_mallocz(sizeof(*graph)); + AVFilterGraph *ret; - ret->internal = av_mallocz(sizeof(*ret->internal)); - if (!ret->internal) { - av_freep(&ret); + if (!graph) return NULL; - } + ret = &graph->p; ret->av_class = &filtergraph_class; av_opt_set_defaults(ret); - ff_framequeue_global_init(&ret->internal->frame_queues); + ff_framequeue_global_init(&graph->frame_queues); return ret; } @@ -119,6 +116,7 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter void avfilter_graph_free(AVFilterGraph **graphp) { AVFilterGraph *graph = *graphp; + FFFilterGraph *graphi = fffiltergraph(graph); if (!graph) return; @@ -126,14 +124,13 @@ void avfilter_graph_free(AVFilterGraph **graphp) while (graph->nb_filters) avfilter_free(graph->filters[0]); - ff_graph_thread_free(graph); + ff_graph_thread_free(graphi); av_freep(&graph->sink_links); av_opt_free(graph); av_freep(&graph->filters); - av_freep(&graph->internal); av_freep(graphp); } @@ -169,12 +166,13 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, const char *name) { AVFilterContext **filters, *s; + FFFilterGraph *graphi = fffiltergraph(graph); - if (graph->thread_type && !graph->internal->thread_execute) { + if (graph->thread_type && !graphi->thread_execute) { if (graph->execute) { - graph->internal->thread_execute = graph->execute; + graphi->thread_execute = graph->execute; } else { - int ret = ff_graph_thread_init(graph); + int ret = ff_graph_thread_init(graphi); if (ret < 0) { av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret)); return NULL; |