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
67};67};
68 68
69#if !HAVE_THREADS69#if !HAVE_THREADS
70void ff_graph_thread_free(AVFilterGraph *graph)70void ff_graph_thread_free(FFFilterGraph *graph)
71{71{
72}72}
73 73
74int ff_graph_thread_init(AVFilterGraph *graph)74int ff_graph_thread_init(FFFilterGraph *graph)
75{75{
76 graph->thread_type = 0;76 graph->p.thread_type = 0;
77 graph->nb_threads = 1;77 graph->p.nb_threads = 1;
78 return 0;78 return 0;
79}79}
80#endif80#endif
81 81
82AVFilterGraph *avfilter_graph_alloc(void)82AVFilterGraph *avfilter_graph_alloc(void)
83{83{
84 AVFilterGraph *ret = av_mallocz(sizeof(*ret));84 FFFilterGraph *graph = av_mallocz(sizeof(*graph));
85 if (!ret)85 AVFilterGraph *ret;
86 return NULL;
87 86
88 ret->internal = av_mallocz(sizeof(*ret->internal));87 if (!graph)
89 if (!ret->internal) {
90 av_freep(&ret);
91 return NULL;88 return NULL;
92 }
93 89
90 ret = &graph->p;
94 ret->av_class = &filtergraph_class;91 ret->av_class = &filtergraph_class;
95 av_opt_set_defaults(ret);92 av_opt_set_defaults(ret);
96 ff_framequeue_global_init(&ret->internal->frame_queues);93 ff_framequeue_global_init(&graph->frame_queues);
97 94
98 return ret;95 return ret;
99}96}
@@ -119,6 +116,7 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter · 19 unmodified lines
119void avfilter_graph_free(AVFilterGraph **graphp)116void avfilter_graph_free(AVFilterGraph **graphp)
120{117{
121 AVFilterGraph *graph = *graphp;118 AVFilterGraph *graph = *graphp;
119 FFFilterGraph *graphi = fffiltergraph(graph);
122 120
123 if (!graph)121 if (!graph)
124 return;122 return;
@@ -126,14 +124,13 @@ void avfilter_graph_free(AVFilterGraph **graphp) · 1 unmodified line
126 while (graph->nb_filters)124 while (graph->nb_filters)
127 avfilter_free(graph->filters[0]);125 avfilter_free(graph->filters[0]);
128 126
129 ff_graph_thread_free(graph);127 ff_graph_thread_free(graphi);
130 128
131 av_freep(&graph->sink_links);129 av_freep(&graph->sink_links);
132 130
133 av_opt_free(graph);131 av_opt_free(graph);
134 132
135 av_freep(&graph->filters);133 av_freep(&graph->filters);
136 av_freep(&graph->internal);
137 av_freep(graphp);134 av_freep(graphp);
138}135}
139 136
@@ -169,12 +166,13 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 29 unmodified lines
169 const char *name)166 const char *name)
170{167{
171 AVFilterContext **filters, *s;168 AVFilterContext **filters, *s;
169 FFFilterGraph *graphi = fffiltergraph(graph);
172 170
173 if (graph->thread_type && !graph->internal->thread_execute) {171 if (graph->thread_type && !graphi->thread_execute) {
174 if (graph->execute) {172 if (graph->execute) {
175 graph->internal->thread_execute = graph->execute;173 graphi->thread_execute = graph->execute;
176 } else {174 } else {
177 int ret = ff_graph_thread_init(graph);175 int ret = ff_graph_thread_init(graphi);
178 if (ret < 0) {176 if (ret < 0) {
179 av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret));177 av_log(graph, AV_LOG_ERROR, "Error initializing threading: %s.\n", av_err2str(ret));
180 return NULL;178 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