Lines Matching defs:graph
64 void ff_graph_thread_free(AVFilterGraph *graph)
68 int ff_graph_thread_init(AVFilterGraph *graph)
70 graph->thread_type = 0;
71 graph->nb_threads = 1;
94 void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
97 for (i = 0; i < graph->nb_filters; i++) {
98 if (graph->filters[i] == filter) {
99 FFSWAP(AVFilterContext*, graph->filters[i],
100 graph->filters[graph->nb_filters - 1]);
101 graph->nb_filters--;
107 void avfilter_graph_free(AVFilterGraph **graph)
109 if (!*graph)
112 while ((*graph)->nb_filters)
113 avfilter_free((*graph)->filters[0]);
115 ff_graph_thread_free(*graph);
117 av_freep(&(*graph)->sink_links);
119 av_freep(&(*graph)->scale_sws_opts);
120 av_freep(&(*graph)->aresample_swr_opts);
121 av_freep(&(*graph)->resample_lavr_opts);
122 av_freep(&(*graph)->filters);
123 av_freep(&(*graph)->internal);
124 av_freep(graph);
128 int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
130 AVFilterContext **filters = av_realloc(graph->filters,
131 sizeof(*filters) * (graph->nb_filters + 1));
135 graph->filters = filters;
136 graph->filters[graph->nb_filters++] = filter;
140 graph->filter_count_unused = graph->nb_filters;
144 filter->graph = graph;
173 void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
175 graph->disable_auto_convert = flags;
178 AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
184 if (graph->thread_type && !graph->internal->thread_execute) {
185 if (graph->execute) {
186 graph->internal->thread_execute = graph->execute;
188 int ret = ff_graph_thread_init(graph);
190 av_log(graph, AV_LOG_ERROR, "Error initializing threading.\n");
200 filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1));
206 graph->filters = filters;
207 graph->filters[graph->nb_filters++] = s;
211 graph->filter_count_unused = graph->nb_filters;
215 s->graph = graph;
221 * Check for the validity of graph.
223 * A graph is considered valid if all its input and output pads are
228 static int graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
233 for (i = 0; i < graph->nb_filters; i++) {
235 filt = graph->filters[i];
266 static int graph_config_links(AVFilterGraph *graph, AVClass *log_ctx)
271 for (i = 0; i < graph->nb_filters; i++) {
272 filt = graph->filters[i];
283 AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name)
287 for (i = 0; i < graph->nb_filters; i++)
288 if (graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
289 return graph->filters[i];
428 * filter graph.
436 static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
445 for (i = 0; i < graph->nb_filters; i++) {
446 AVFilterContext *f = graph->filters[i];
460 for (i = 0; i < graph->nb_filters; i++) {
461 AVFilterContext *filter = graph->filters[i];
533 inst_name, graph->scale_sws_opts, NULL,
534 graph)) < 0)
547 if (graph->aresample_swr_opts)
549 graph->aresample_swr_opts);
551 inst_name, graph->aresample_swr_opts,
552 NULL, graph)) < 0)
591 av_log(graph, AV_LOG_DEBUG, "query_formats: "
605 for (i = 0; i < graph->nb_filters; i++)
606 if (!formats_declared(graph->filters[i]))
608 graph->filters[i]->name);
609 av_log(graph, AV_LOG_ERROR,
765 static void reduce_formats(AVFilterGraph *graph)
772 for (i = 0; i < graph->nb_filters; i++)
773 reduced |= reduce_formats_on_filter(graph->filters[i]);
816 static void swap_samplerates(AVFilterGraph *graph)
820 for (i = 0; i < graph->nb_filters; i++)
821 swap_samplerates_on_filter(graph->filters[i]);
947 static void swap_channel_layouts(AVFilterGraph *graph)
951 for (i = 0; i < graph->nb_filters; i++)
952 swap_channel_layouts_on_filter(graph->filters[i]);
1015 static void swap_sample_fmts(AVFilterGraph *graph)
1019 for (i = 0; i < graph->nb_filters; i++)
1020 swap_sample_fmts_on_filter(graph->filters[i]);
1024 static int pick_formats(AVFilterGraph *graph)
1031 for (i = 0; i < graph->nb_filters; i++) {
1032 AVFilterContext *filter = graph->filters[i];
1063 for (i = 0; i < graph->nb_filters; i++) {
1064 AVFilterContext *filter = graph->filters[i];
1077 * Configure the formats of all the links in the graph.
1079 static int graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx)
1084 while ((ret = query_formats(graph, log_ctx)) == AVERROR(EAGAIN))
1085 av_log(graph, AV_LOG_DEBUG, "query_formats not finished\n");
1092 reduce_formats(graph);
1096 swap_sample_fmts(graph);
1097 swap_samplerates(graph);
1098 swap_channel_layouts(graph);
1100 if ((ret = pick_formats(graph)) < 0)
1106 static int ff_avfilter_graph_config_pointers(AVFilterGraph *graph,
1114 for (i = 0; i < graph->nb_filters; i++) {
1115 f = graph->filters[i];
1117 f->inputs[j]->graph = graph;
1121 f->outputs[j]->graph = graph;
1133 for (i = 0; i < graph->nb_filters; i++) {
1134 f = graph->filters[i];
1143 graph->sink_links = sinks;
1144 graph->sink_links_count = sink_links_count;
1148 static int graph_insert_fifos(AVFilterGraph *graph, AVClass *log_ctx)
1154 for (i = 0; i < graph->nb_filters; i++) {
1155 f = graph->filters[i];
1173 NULL, graph);
1204 int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
1208 if (!graph)
1212 r = avfilter_graph_send_command(graph, target, cmd, arg, res, res_len, flags | AVFILTER_CMD_FLAG_FAST);
1220 for (i = 0; i < graph->nb_filters; i++) {
1221 AVFilterContext *filter = graph->filters[i];
1234 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *command, const char *arg, int flags, double ts)
1238 if(!graph)
1241 for (i = 0; i < graph->nb_filters; i++) {
1242 AVFilterContext *filter = graph->filters[i];
1262 static void heap_bubble_up(AVFilterGraph *graph,
1265 AVFilterLink **links = graph->sink_links;
1279 static void heap_bubble_down(AVFilterGraph *graph,
1282 AVFilterLink **links = graph->sink_links;
1286 if (child >= graph->sink_links_count)
1288 if (child + 1 < graph->sink_links_count &&
1301 void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link)
1303 heap_bubble_up (graph, link, link->age_index);
1304 heap_bubble_down(graph, link, link->age_index);
1308 int avfilter_graph_request_oldest(AVFilterGraph *graph)
1310 while (graph->sink_links_count) {
1311 AVFilterLink *oldest = graph->sink_links[0];
1319 if (oldest->age_index < --graph->sink_links_count)
1320 heap_bubble_down(graph, graph->sink_links[graph->sink_links_count],