98e14661f326cb76b5be803ad0f799eb50f422c4
[ffmpeg.git] / libavfilter / avfiltergraph.c
1 /*
2  * Filter graphs
3  * copyright (c) 2007 Bobby Bingham
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #include <string.h>
23 #include <stddef.h>
24
25 #include "avstring.h"
26 #include "avfilter.h"
27 #include "avfiltergraph.h"
28
29 #include "allfilters.h"
30
31 typedef struct AVFilterGraph {
32     unsigned filter_count;
33     AVFilterContext **filters;
34
35     /** fake filter to handle links to internal filters */
36     AVFilterContext *link_filter;
37 } GraphContext;
38
39 typedef struct {
40     AVFilterContext *graph;
41 } GraphLinkContext;
42
43 static int link_init(AVFilterContext *ctx, const char *args, void *opaque)
44 {
45     GraphLinkContext *linkctx = ctx->priv;
46     linkctx->graph = opaque;
47     return !opaque;
48 }
49
50 /**
51  * Given the link between the dummy filter and an internal filter whose input
52  * is being exported outside the graph, this returns the externally visible
53  * link
54  */
55 static inline AVFilterLink *get_extern_input_link(AVFilterLink *link)
56 {
57     GraphLinkContext *lctx = link->src->priv;
58     return lctx->graph->inputs[link->srcpad];
59 }
60
61 /** request a frame from a filter providing input to the graph */
62 static int link_in_request_frame(AVFilterLink *link)
63 {
64     AVFilterLink *link2 = get_extern_input_link(link);
65
66     if(!link2)
67         return -1;
68     return avfilter_request_frame(link2);
69 }
70
71 static int link_in_config_props(AVFilterLink *link)
72 {
73     AVFilterLink *link2 = get_extern_input_link(link);
74     int (*config_props)(AVFilterLink *);
75     int ret;
76
77     if(!link2)
78         return -1;
79     if(!(config_props = link2->src->output_pads[link2->srcpad].config_props))
80         config_props = avfilter_default_config_output_link;
81     ret = config_props(link2);
82
83     link->w = link2->w;
84     link->h = link2->h;
85
86     return ret;
87 }
88
89 /**
90  * Given the link between the dummy filter and an internal filter whose input
91  * is being exported outside the graph, this returns the externally visible
92  * link
93  */
94 static inline AVFilterLink *get_extern_output_link(AVFilterLink *link)
95 {
96     GraphLinkContext *lctx = link->dst->priv;
97     return lctx->graph->outputs[link->dstpad];
98 }
99
100 static int link_out_config_props(AVFilterLink *link)
101 {
102     AVFilterLink *link2 = get_extern_output_link(link);
103     int (*config_props)(AVFilterLink *);
104
105     if(!link2)
106         return 0;
107
108     link2->w = link->w;
109     link2->h = link->h;
110
111     if(!(config_props = link2->dst->input_pads[link2->dstpad].config_props))
112         config_props = avfilter_default_config_input_link;
113     return config_props(link2);
114 }
115
116 static void link_out_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
117 {
118     AVFilterLink *link2 = get_extern_output_link(link);
119
120     if(!link2)
121         avfilter_unref_pic(picref);
122     else
123         avfilter_start_frame(link2, picref);
124 }
125
126 static void link_out_end_frame(AVFilterLink *link)
127 {
128     AVFilterLink *link2 = get_extern_output_link(link);
129
130     if(link2)
131         avfilter_end_frame(link2);
132 }
133
134 static AVFilterPicRef *link_out_get_video_buffer(AVFilterLink *link, int perms)
135 {
136     AVFilterLink *link2 = get_extern_output_link(link);
137
138     if(!link2)
139         return NULL;
140     else
141         return avfilter_get_video_buffer(link2, perms);
142 }
143
144 static void link_out_draw_slice(AVFilterLink *link, int y, int height)
145 {
146     AVFilterLink *link2 = get_extern_output_link(link);
147
148     if(link2)
149         avfilter_draw_slice(link2, y, height);
150 }
151
152 /** dummy filter used to help export filters pads outside the graph */
153 static AVFilter vf_graph_dummy =
154 {
155     .name      = "graph_dummy",
156     .author    = "Bobby Bingham",
157
158     .priv_size = sizeof(GraphLinkContext),
159
160     .init      = link_init,
161
162     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
163     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
164 };
165
166 static AVFilterLink *get_intern_input_link(AVFilterLink *link)
167 {
168     GraphContext *graph = link->dst->priv;
169     return graph->link_filter->outputs[link->dstpad];
170 }
171
172 static void graph_in_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
173 {
174     AVFilterLink *link2 = get_intern_input_link(link);
175     if(link2)
176         avfilter_start_frame(link2, picref);
177 }
178
179 static void graph_in_end_frame(AVFilterLink *link)
180 {
181     AVFilterLink *link2 = get_intern_input_link(link);
182     if(link2)
183         avfilter_end_frame(link2);
184 }
185
186 static AVFilterPicRef *graph_in_get_video_buffer(AVFilterLink *link, int perms)
187 {
188     AVFilterLink *link2 = get_intern_input_link(link);
189     if(link2)
190         return avfilter_get_video_buffer(link2, perms);
191     return NULL;
192 }
193
194 static void graph_in_draw_slice(AVFilterLink *link, int y, int height)
195 {
196     AVFilterLink *link2 = get_intern_input_link(link);
197     if(link2)
198         avfilter_draw_slice(link2, y, height);
199 }
200
201 static int graph_in_config_props(AVFilterLink *link)
202 {
203     AVFilterLink *link2 = get_intern_input_link(link);
204     int (*config_props)(AVFilterLink *);
205
206     if(!link2)
207         return -1;
208
209     /* copy link properties over to the dummy internal link */
210     link2->w = link->w;
211     link2->h = link->h;
212     link2->format = link->format;
213
214     if(!(config_props = link2->dst->input_pads[link2->dstpad].config_props))
215         return 0;   /* FIXME? */
216         //config_props = avfilter_default_config_input_link;
217     return config_props(link2);
218 }
219
220 static AVFilterLink *get_intern_output_link(AVFilterLink *link)
221 {
222     GraphContext *graph = link->src->priv;
223     return graph->link_filter->inputs[link->srcpad];
224 }
225
226 static int graph_out_request_frame(AVFilterLink *link)
227 {
228     AVFilterLink *link2 = get_intern_output_link(link);
229
230     if(link2)
231         return avfilter_request_frame(link2);
232     return -1;
233 }
234
235 static int graph_out_config_props(AVFilterLink *link)
236 {
237     AVFilterLink *link2 = get_intern_output_link(link);
238     int (*config_props)(AVFilterLink *);
239     int ret;
240
241     if(!link2)
242         return 0;
243
244     link2->w = link->w;
245     link2->h = link->h;
246     link2->format = link->format;
247
248     if(!(config_props = link2->src->output_pads[link2->srcpad].config_props))
249         config_props = avfilter_default_config_output_link;
250     ret = config_props(link2);
251
252     link->w = link2->w;
253     link->h = link2->h;
254     link->format = link2->format;
255
256     return ret;
257 }
258
259 static int add_graph_input(AVFilterContext *gctx, AVFilterContext *filt, unsigned idx,
260                            char *name)
261 {
262     GraphContext *graph = gctx->priv;
263
264     AVFilterPad graph_inpad =
265     {
266         .name             = name,
267         .type             = AV_PAD_VIDEO,
268         .start_frame      = graph_in_start_frame,
269         .end_frame        = graph_in_end_frame,
270         .get_video_buffer = graph_in_get_video_buffer,
271         .draw_slice       = graph_in_draw_slice,
272         .config_props     = graph_in_config_props,
273         /* XXX */
274     };
275     AVFilterPad dummy_outpad =
276     {
277         .name          = NULL,          /* FIXME? */
278         .type          = AV_PAD_VIDEO,
279         .request_frame = link_in_request_frame,
280         .config_props  = link_in_config_props,
281     };
282
283     avfilter_insert_inpad (gctx, gctx->input_count, &graph_inpad);
284     avfilter_insert_outpad(graph->link_filter, graph->link_filter->output_count,
285                            &dummy_outpad);
286     return avfilter_link(graph->link_filter,
287                          graph->link_filter->output_count-1, filt, idx);
288 }
289
290 static int add_graph_output(AVFilterContext *gctx, AVFilterContext *filt, unsigned idx,
291                             char *name)
292 {
293     GraphContext *graph = gctx->priv;
294
295     AVFilterPad graph_outpad =
296     {
297         .name             = name,
298         .type             = AV_PAD_VIDEO,
299         .request_frame    = graph_out_request_frame,
300         .config_props     = graph_out_config_props,
301     };
302     AVFilterPad dummy_inpad =
303     {
304         .name             = NULL,          /* FIXME? */
305         .type             = AV_PAD_VIDEO,
306         .start_frame      = link_out_start_frame,
307         .end_frame        = link_out_end_frame,
308         .draw_slice       = link_out_draw_slice,
309         .get_video_buffer = link_out_get_video_buffer,
310         .config_props     = link_out_config_props,
311     };
312
313     avfilter_insert_outpad(gctx, gctx->output_count, &graph_outpad);
314     avfilter_insert_inpad (graph->link_filter, graph->link_filter->input_count,
315                            &dummy_inpad);
316     return avfilter_link(filt, idx, graph->link_filter,
317                          graph->link_filter->input_count-1);
318 }
319
320 static void uninit(AVFilterContext *ctx)
321 {
322     GraphContext *graph = ctx->priv;
323
324     if(graph->link_filter) {
325         avfilter_destroy(graph->link_filter);
326         graph->link_filter = NULL;
327     }
328     for(; graph->filter_count > 0; graph->filter_count --)
329         avfilter_destroy(graph->filters[graph->filter_count - 1]);
330     av_freep(&graph->filters);
331 }
332
333 /* TODO: insert in sorted order */
334 void avfilter_graph_add_filter(AVFilterContext *graphctx, AVFilterContext *filter)
335 {
336     GraphContext *graph = graphctx->priv;
337
338     graph->filters = av_realloc(graph->filters,
339                                 sizeof(AVFilterContext*) * ++graph->filter_count);
340     graph->filters[graph->filter_count - 1] = filter;
341 }
342
343 /* search intelligently, once we insert in order */
344 AVFilterContext *avfilter_graph_get_filter(AVFilterContext *ctx, char *name)
345 {
346     GraphContext *graph = ctx->priv;
347     int i;
348
349     if(!name)
350         return NULL;
351
352     for(i = 0; i < graph->filter_count; i ++)
353         if(graph->filters[i]->name && !strcmp(name, graph->filters[i]->name))
354             return graph->filters[i];
355
356     return NULL;
357 }
358
359 static int query_formats(AVFilterContext *graphctx)
360 {
361     GraphContext *graph = graphctx->priv;
362     AVFilterContext *linkfilt = graph->link_filter;
363     int i, j;
364
365     /* ask all the sub-filters for their supported colorspaces */
366     for(i = 0; i < graph->filter_count; i ++) {
367         if(graph->filters[i]->filter->query_formats)
368             graph->filters[i]->filter->query_formats(graph->filters[i]);
369         else
370             avfilter_default_query_formats(graph->filters[i]);
371     }
372
373     /* use these formats on our exported links */
374     for(i = 0; i < linkfilt->input_count; i ++) {
375         avfilter_formats_ref( linkfilt->inputs[i]->in_formats,
376                              &linkfilt->inputs[i]->out_formats);
377
378         if(graphctx->outputs[i])
379             avfilter_formats_ref( linkfilt-> inputs[i]->in_formats,
380                                  &graphctx->outputs[i]->in_formats);
381     }
382     for(i = 0; i < linkfilt->output_count; i ++) {
383         avfilter_formats_ref( linkfilt->outputs[i]->out_formats,
384                              &linkfilt->outputs[i]->in_formats);
385
386         if(graphctx->inputs[i])
387             avfilter_formats_ref( linkfilt->outputs[i]->out_formats,
388                                  &graphctx-> inputs[i]->out_formats);
389     }
390
391     /* go through and merge as many format lists as possible */
392     for(i = 0; i < graph->filter_count; i ++) {
393         AVFilterContext *filter = graph->filters[i];
394
395         for(j = 0; j < filter->input_count; j ++) {
396             AVFilterLink *link;
397             if(!(link = filter->inputs[j]))
398                 continue;
399             if(link->in_formats != link->out_formats) {
400                 if(!avfilter_merge_formats(link->in_formats,
401                                            link->out_formats)) {
402                     /* couldn't merge format lists. auto-insert scale filter */
403                     AVFilterContext *scale;
404
405                     if(!(scale = avfilter_open(&avfilter_vf_scale, NULL)))
406                         return -1;
407                     if(scale->filter->init(scale, NULL, NULL) ||
408                        avfilter_insert_filter(link, scale, 0, 0)) {
409                         avfilter_destroy(scale);
410                         return -1;
411                     }
412
413                     avfilter_graph_add_filter(graphctx, scale);
414                     scale->filter->query_formats(scale);
415                     if(!avfilter_merge_formats(scale-> inputs[0]->in_formats,
416                                               scale-> inputs[0]->out_formats) ||
417                        !avfilter_merge_formats(scale->outputs[0]->in_formats,
418                                               scale->outputs[0]->out_formats))
419                         return -1;
420                 }
421             }
422         }
423     }
424
425     return 0;
426 }
427
428 static void pick_format(AVFilterLink *link)
429 {
430     if(!link || !link->in_formats)
431         return;
432
433     link->in_formats->format_count = 1;
434     link->format = link->in_formats->formats[0];
435
436     avfilter_formats_unref(&link->in_formats);
437     avfilter_formats_unref(&link->out_formats);
438 }
439
440 static void pick_formats(GraphContext *graph)
441 {
442     int i, j;
443
444     for(i = 0; i < graph->filter_count; i ++) {
445         AVFilterContext *filter = graph->filters[i];
446
447         if(filter->filter == &avfilter_vf_graph     ||
448            filter->filter == &avfilter_vf_graphfile ||
449            filter->filter == &avfilter_vf_graphdesc)
450             pick_formats(filter->priv);
451
452         for(j = 0; j < filter->input_count; j ++)
453             pick_format(filter->inputs[j]);
454         for(j = 0; j < filter->output_count; j ++)
455             pick_format(filter->outputs[j]);
456     }
457 }
458
459 int avfilter_graph_config_formats(AVFilterContext *graphctx)
460 {
461     GraphContext *graph = graphctx->priv;
462
463     /* Find supported formats from sub-filters, and merge along links */
464     if(query_formats(graphctx))
465         return -1;
466
467     /* Once everything is merged, it's possible that we'll still have
468      * multiple valid choices of colorspace. We pick the first one. */
469     pick_formats(graph);
470
471     return 0;
472 }
473
474 int avfilter_graph_config_links(AVFilterContext *graphctx)
475 {
476     GraphContext *graph = graphctx->priv;
477     int i, j;
478
479     for(i = 0; i < graph->filter_count; i ++) {
480         for(j = 0; j < graph->filters[i]->input_count; j ++) {
481             /* ensure that graphs contained within graphs are configured */
482             if((graph->filters[i]->filter == &avfilter_vf_graph     ||
483                 graph->filters[i]->filter == &avfilter_vf_graphfile ||
484                 graph->filters[i]->filter == &avfilter_vf_graphdesc) &&
485                 avfilter_graph_config_links(graph->filters[i]))
486                 return -1;
487             if(avfilter_config_link(graph->filters[i]->inputs[j]))
488                 return -1;
489         }
490     }
491
492     return 0;
493 }
494
495 static AVFilterContext *create_filter_with_args(const char *filt, void *opaque)
496 {
497     AVFilterContext *ret;
498     char *filter = av_strdup(filt); /* copy - don't mangle the input string */
499     char *name, *args;
500
501     name = filter;
502     if((args = strchr(filter, '='))) {
503         /* ensure we at least have a name */
504         if(args == filter)
505             goto fail;
506
507         *args ++ = 0;
508     }
509
510     av_log(NULL, AV_LOG_INFO, "creating filter \"%s\" with args \"%s\"\n",
511            name, args ? args : "(none)");
512
513     if((ret = avfilter_open(avfilter_get_by_name(name), NULL))) {
514         if(avfilter_init_filter(ret, args, opaque)) {
515             av_log(NULL, AV_LOG_ERROR, "error initializing filter!\n");
516             avfilter_destroy(ret);
517             goto fail;
518         }
519     } else {
520         av_log(NULL, AV_LOG_ERROR,
521                "error creating filter \"%s\" with args \"%s\"\n",
522                name, args ? args : "(none)");
523     }
524
525     av_free(filter);
526
527     return ret;
528
529 fail:
530     av_free(filter);
531     return NULL;
532 }
533
534 static int graph_load_chain(AVFilterContext *graphctx,
535                               unsigned count, char **filter_list, void **opaque,
536                               AVFilterContext **first, AVFilterContext **last)
537 {
538     unsigned i;
539     AVFilterContext *filters[2] = {NULL,NULL};
540
541     for(i = 0; i < count; i ++) {
542         void *op;
543
544         if(opaque) op = opaque[i];
545         else       op = NULL;
546
547         if(!(filters[1] = create_filter_with_args(filter_list[i], op)))
548             goto fail;
549         if(i == 0) {
550             if(first) *first = filters[1];
551         } else {
552             if(avfilter_link(filters[0], 0, filters[1], 0)) {
553                 av_log(NULL, AV_LOG_ERROR, "error linking filters!\n");
554                 goto fail;
555             }
556         }
557         avfilter_graph_add_filter(graphctx, filters[1]);
558         if(i == 0 && filters[1]->input_count > 0)
559             add_graph_input(graphctx, filters[1], 0, "default");
560         filters[0] = filters[1];
561     }
562
563     if(filters[1]->output_count > 0)
564         add_graph_output(graphctx, filters[1], 0, "default");
565
566     if(last) *last = filters[1];
567     return 0;
568
569 fail:
570     uninit(graphctx);
571     if(first) *first = NULL;
572     if(last)  *last  = NULL;
573     return -1;
574 }
575
576 static int graph_load_chain_from_string(AVFilterContext *ctx, const char *str,
577                                         AVFilterContext **first,
578                                         AVFilterContext **last)
579 {
580     int count, ret = 0;
581     char **strings;
582     char *filt;
583
584     strings    = av_malloc(sizeof(char *));
585     strings[0] = av_strdup(str);
586
587     filt = strchr(strings[0], ',');
588     for(count = 1; filt; count ++) {
589         if(filt == strings[count-1]) {
590             ret = -1;
591             goto done;
592         }
593
594         strings = av_realloc(strings, sizeof(char *) * (count+1));
595         strings[count] = filt + 1;
596         *filt = '\0';
597         filt = strchr(strings[count], ',');
598     }
599
600     ret = graph_load_chain(ctx, count, strings, NULL, first, last);
601
602 done:
603     av_free(strings[0]);
604     av_free(strings);
605
606     return ret;
607 }
608
609 static int init(AVFilterContext *ctx, const char *args, void *opaque)
610 {
611     GraphContext *gctx = ctx->priv;
612
613     if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
614         return -1;
615     if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
616         goto fail;
617
618     if(!args)
619         return 0;
620
621     return graph_load_chain_from_string(ctx, args, NULL, NULL);
622
623 fail:
624     avfilter_destroy(gctx->link_filter);
625     return -1;
626 }
627
628 AVFilter avfilter_vf_graph =
629 {
630     .name      = "graph",
631     .author    = "Bobby Bingham",
632
633     .priv_size = sizeof(GraphContext),
634
635     .init      = init,
636     .uninit    = uninit,
637
638     .query_formats = query_formats,
639
640     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
641     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
642 };
643
644 static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc)
645 {
646     AVFilterGraphDescFilter *curfilt;
647     AVFilterGraphDescLink   *curlink;
648     AVFilterGraphDescExport *curpad;
649     AVFilterContext *filt, *filtb;
650
651     AVFilter *filterdef;
652
653     /* create all filters */
654     for(curfilt = desc->filters; curfilt; curfilt = curfilt->next) {
655         if(!(filterdef = avfilter_get_by_name(curfilt->filter)) ||
656            !(filt = avfilter_open(filterdef, curfilt->name))) {
657             av_log(ctx, AV_LOG_ERROR, "error creating filter\n");
658             goto fail;
659         }
660         avfilter_graph_add_filter(ctx, filt);
661         if(avfilter_init_filter(filt, curfilt->args, NULL)) {
662             av_log(ctx, AV_LOG_ERROR, "error initializing filter\n");
663             goto fail;
664         }
665     }
666
667     /* create all links */
668     for(curlink = desc->links; curlink; curlink = curlink->next) {
669         if(!(filt = avfilter_graph_get_filter(ctx, curlink->src))) {
670             av_log(ctx, AV_LOG_ERROR, "link source does not exist in graph\n");
671             goto fail;
672         }
673         if(!(filtb = avfilter_graph_get_filter(ctx, curlink->dst))) {
674             av_log(ctx, AV_LOG_ERROR, "link destination does not exist in graph\n");
675             goto fail;
676         }
677         if(avfilter_link(filt, curlink->srcpad, filtb, curlink->dstpad)) {
678             av_log(ctx, AV_LOG_ERROR, "cannot create link between source and destination filters\n");
679             goto fail;
680         }
681     }
682
683     /* export all input pads */
684     for(curpad = desc->inputs; curpad; curpad = curpad->next) {
685         if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
686             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
687             goto fail;
688         }
689         add_graph_input(ctx, filt, curpad->pad, curpad->name);
690     }
691
692     /* export all output pads */
693     for(curpad = desc->outputs; curpad; curpad = curpad->next) {
694         if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
695             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
696             goto fail;
697         }
698         add_graph_output(ctx, filt, curpad->pad, curpad->name);
699     }
700
701     return 0;
702
703 fail:
704     uninit(ctx);
705     return -1;
706 }
707
708 static int init_desc(AVFilterContext *ctx, const char *args, void *opaque)
709 {
710     GraphContext *gctx = ctx->priv;
711
712     if(!opaque)
713         return -1;
714
715     if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
716         return -1;
717     if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
718         goto fail;
719
720     return graph_load_from_desc(ctx, opaque);
721
722 fail:
723     avfilter_destroy(gctx->link_filter);
724     return -1;
725 }
726
727 AVFilter avfilter_vf_graphdesc =
728 {
729     .name      = "graph_desc",
730     .author    = "Bobby Bingham",
731
732     .priv_size = sizeof(GraphContext),
733
734     .init      = init_desc,
735     .uninit    = uninit,
736
737     .query_formats = query_formats,
738
739     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
740     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
741 };
742
743 static int init_file(AVFilterContext *ctx, const char *args, void *opaque)
744 {
745     AVFilterGraphDesc *desc;
746     int ret;
747
748     if(!args)
749         return -1;
750     if(!(desc = avfilter_graph_load_desc(args)))
751         return -1;
752
753     ret = init_desc(ctx, NULL, desc);
754     avfilter_graph_free_desc(desc);
755     return ret;
756 }
757
758 AVFilter avfilter_vf_graphfile =
759 {
760     .name      = "graph_file",
761     .author    = "Bobby Bingham",
762
763     .priv_size = sizeof(GraphContext),
764
765     .init      = init_file,
766     .uninit    = uninit,
767
768     .query_formats = query_formats,
769
770     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
771     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
772 };
773