History

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.

Andreas Rheinhardt committed 2 years ago

Commit 03567ed1 parent a1aec774 files · +43 −35Browse files

Showing the changes to libavfilter/avfiltergraph.c (1 of 4 files). Show all

Unified · Split

libavfilter/avfiltergraph.c+15−17
@@ -67,33 +67,30 @@ static const AVClass filtergraph_class = { · 66 unmodified lines
6767 };
6868
6969 #if !HAVE_THREADS
70−void ff_graph_thread_free(AVFilterGraph *graph)
70+void ff_graph_thread_free(FFFilterGraph *graph)
7171 {
7272 }
7373
74−int ff_graph_thread_init(AVFilterGraph *graph)
74+int ff_graph_thread_init(FFFilterGraph *graph)
7575 {
76− graph->thread_type = 0;
77− graph->nb_threads = 1;
76+ graph->p.thread_type = 0;
77+ graph->p.nb_threads = 1;
7878 return 0;
7979 }
8080 #endif
8181
8282 AVFilterGraph *avfilter_graph_alloc(void)
8383 {
84− AVFilterGraph *ret = av_mallocz(sizeof(*ret));
85− if (!ret)
86− return NULL;
84+ FFFilterGraph *graph = av_mallocz(sizeof(*graph));
85+ AVFilterGraph *ret;
8786
88− ret->internal = av_mallocz(sizeof(*ret->internal));
89− if (!ret->internal) {
90− av_freep(&ret);
87+ if (!graph)
9188 return NULL;
92− }
9389
90+ ret = &graph->p;
9491 ret->av_class = &filtergraph_class;
9592 av_opt_set_defaults(ret);
96− ff_framequeue_global_init(&ret->internal->frame_queues);
93+ ff_framequeue_global_init(&graph->frame_queues);
9794
9895 return ret;
9996 }
@@ -119,6 +116,7 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter · 19 unmodified lines
119116 void avfilter_graph_free(AVFilterGraph **graphp)
120117 {
121118 AVFilterGraph *graph = *graphp;
119+ FFFilterGraph *graphi = fffiltergraph(graph);
122120
123121 if (!graph)
124122 return;
@@ -126,14 +124,13 @@ void avfilter_graph_free(AVFilterGraph **graphp) · 1 unmodified line
126124 while (graph->nb_filters)
127125 avfilter_free(graph->filters[0]);
128126
129− ff_graph_thread_free(graph);
127+ ff_graph_thread_free(graphi);
130128
131129 av_freep(&graph->sink_links);
132130
133131 av_opt_free(graph);
134132
135133 av_freep(&graph->filters);
136− av_freep(&graph->internal);
137134 av_freep(graphp);
138135 }
139136
@@ -169,12 +166,13 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 29 unmodified lines
169166 const char *name)
170167 {
171168 AVFilterContext **filters, *s;
169+ FFFilterGraph *graphi = fffiltergraph(graph);
172170
173− if (graph->thread_type && !graph->internal->thread_execute) {
171+ if (graph->thread_type && !graphi->thread_execute) {
174172 if (graph->execute) {
175− graph->internal->thread_execute = graph->execute;
173+ graphi->thread_execute = graph->execute;
176174 } else {
177− int ret = ff_graph_thread_init(graph);
175+ int ret = ff_graph_thread_init(graphi);
178176 if (ret < 0) {
179177 av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret));
180178 return NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t