]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blob - libavfilter/avfiltergraph.c
Use av_log(ctx, ...) instead of av_log(NULL, ...)
[frescor/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(AVFilterContext *graphctx,
496                                                 const char *filt, void *opaque)
497 {
498     AVFilterContext *ret;
499     char *filter = av_strdup(filt); /* copy - don't mangle the input string */
500     char *name, *args;
501
502     name = filter;
503     if((args = strchr(filter, '='))) {
504         /* ensure we at least have a name */
505         if(args == filter)
506             goto fail;
507
508         *args ++ = 0;
509     }
510
511     av_log(graphctx, AV_LOG_INFO, "creating filter \"%s\" with args \"%s\"\n",
512            name, args ? args : "(none)");
513
514     if((ret = avfilter_open(avfilter_get_by_name(name), NULL))) {
515         if(avfilter_init_filter(ret, args, opaque)) {
516             av_log(graphctx, AV_LOG_ERROR, "error initializing filter!\n");
517             avfilter_destroy(ret);
518             goto fail;
519         }
520     } else {
521         av_log(graphctx, AV_LOG_ERROR,
522                "error creating filter \"%s\" with args \"%s\"\n",
523                name, args ? args : "(none)");
524     }
525
526     av_free(filter);
527
528     return ret;
529
530 fail:
531     av_free(filter);
532     return NULL;
533 }
534
535 static int graph_load_chain(AVFilterContext *graphctx,
536                               unsigned count, char **filter_list, void **opaque,
537                               AVFilterContext **first, AVFilterContext **last)
538 {
539     unsigned i;
540     AVFilterContext *filters[2] = {NULL,NULL};
541
542     for(i = 0; i < count; i ++) {
543         void *op;
544
545         if(opaque) op = opaque[i];
546         else       op = NULL;
547
548         if(!(filters[1] = create_filter_with_args(graphctx, filter_list[i], op)))
549             goto fail;
550         if(i == 0) {
551             if(first) *first = filters[1];
552         } else {
553             if(avfilter_link(filters[0], 0, filters[1], 0)) {
554                 av_log(graphctx, AV_LOG_ERROR, "error linking filters!\n");
555                 goto fail;
556             }
557         }
558         avfilter_graph_add_filter(graphctx, filters[1]);
559         if(i == 0 && filters[1]->input_count > 0)
560             add_graph_input(graphctx, filters[1], 0, "default");
561         filters[0] = filters[1];
562     }
563
564     if(filters[1]->output_count > 0)
565         add_graph_output(graphctx, filters[1], 0, "default");
566
567     if(last) *last = filters[1];
568     return 0;
569
570 fail:
571     uninit(graphctx);
572     if(first) *first = NULL;
573     if(last)  *last  = NULL;
574     return -1;
575 }
576
577 static int graph_load_chain_from_string(AVFilterContext *ctx, const char *str,
578                                         AVFilterContext **first,
579                                         AVFilterContext **last)
580 {
581     int count, ret = 0;
582     char **strings;
583     char *filt;
584
585     strings    = av_malloc(sizeof(char *));
586     strings[0] = av_strdup(str);
587
588     filt = strchr(strings[0], ',');
589     for(count = 1; filt; count ++) {
590         if(filt == strings[count-1]) {
591             ret = -1;
592             goto done;
593         }
594
595         strings = av_realloc(strings, sizeof(char *) * (count+1));
596         strings[count] = filt + 1;
597         *filt = '\0';
598         filt = strchr(strings[count], ',');
599     }
600
601     ret = graph_load_chain(ctx, count, strings, NULL, first, last);
602
603 done:
604     av_free(strings[0]);
605     av_free(strings);
606
607     return ret;
608 }
609
610 static int init(AVFilterContext *ctx, const char *args, void *opaque)
611 {
612     GraphContext *gctx = ctx->priv;
613
614     if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
615         return -1;
616     if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
617         goto fail;
618
619     if(!args)
620         return 0;
621
622     return graph_load_chain_from_string(ctx, args, NULL, NULL);
623
624 fail:
625     avfilter_destroy(gctx->link_filter);
626     return -1;
627 }
628
629 AVFilter avfilter_vf_graph =
630 {
631     .name      = "graph",
632     .author    = "Bobby Bingham",
633
634     .priv_size = sizeof(GraphContext),
635
636     .init      = init,
637     .uninit    = uninit,
638
639     .query_formats = query_formats,
640
641     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
642     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
643 };
644
645 static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc)
646 {
647     AVFilterGraphDescFilter *curfilt;
648     AVFilterGraphDescLink   *curlink;
649     AVFilterGraphDescExport *curpad;
650     AVFilterContext *filt, *filtb;
651
652     AVFilter *filterdef;
653
654     /* create all filters */
655     for(curfilt = desc->filters; curfilt; curfilt = curfilt->next) {
656         if(!(filterdef = avfilter_get_by_name(curfilt->filter)) ||
657            !(filt = avfilter_open(filterdef, curfilt->name))) {
658             av_log(ctx, AV_LOG_ERROR, "error creating filter\n");
659             goto fail;
660         }
661         avfilter_graph_add_filter(ctx, filt);
662         if(avfilter_init_filter(filt, curfilt->args, NULL)) {
663             av_log(ctx, AV_LOG_ERROR, "error initializing filter\n");
664             goto fail;
665         }
666     }
667
668     /* create all links */
669     for(curlink = desc->links; curlink; curlink = curlink->next) {
670         if(!(filt = avfilter_graph_get_filter(ctx, curlink->src))) {
671             av_log(ctx, AV_LOG_ERROR, "link source does not exist in graph\n");
672             goto fail;
673         }
674         if(!(filtb = avfilter_graph_get_filter(ctx, curlink->dst))) {
675             av_log(ctx, AV_LOG_ERROR, "link destination does not exist in graph\n");
676             goto fail;
677         }
678         if(avfilter_link(filt, curlink->srcpad, filtb, curlink->dstpad)) {
679             av_log(ctx, AV_LOG_ERROR, "cannot create link between source and destination filters\n");
680             goto fail;
681         }
682     }
683
684     /* export all input pads */
685     for(curpad = desc->inputs; curpad; curpad = curpad->next) {
686         if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
687             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
688             goto fail;
689         }
690         add_graph_input(ctx, filt, curpad->pad, curpad->name);
691     }
692
693     /* export all output pads */
694     for(curpad = desc->outputs; curpad; curpad = curpad->next) {
695         if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) {
696             av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n");
697             goto fail;
698         }
699         add_graph_output(ctx, filt, curpad->pad, curpad->name);
700     }
701
702     return 0;
703
704 fail:
705     uninit(ctx);
706     return -1;
707 }
708
709 static int init_desc(AVFilterContext *ctx, const char *args, void *opaque)
710 {
711     GraphContext *gctx = ctx->priv;
712
713     if(!opaque)
714         return -1;
715
716     if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
717         return -1;
718     if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
719         goto fail;
720
721     return graph_load_from_desc(ctx, opaque);
722
723 fail:
724     avfilter_destroy(gctx->link_filter);
725     return -1;
726 }
727
728 AVFilter avfilter_vf_graphdesc =
729 {
730     .name      = "graph_desc",
731     .author    = "Bobby Bingham",
732
733     .priv_size = sizeof(GraphContext),
734
735     .init      = init_desc,
736     .uninit    = uninit,
737
738     .query_formats = query_formats,
739
740     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
741     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
742 };
743
744 static int init_file(AVFilterContext *ctx, const char *args, void *opaque)
745 {
746     AVFilterGraphDesc *desc;
747     int ret;
748
749     if(!args)
750         return -1;
751     if(!(desc = avfilter_graph_load_desc(args)))
752         return -1;
753
754     ret = init_desc(ctx, NULL, desc);
755     avfilter_graph_free_desc(desc);
756     return ret;
757 }
758
759 AVFilter avfilter_vf_graphfile =
760 {
761     .name      = "graph_file",
762     .author    = "Bobby Bingham",
763
764     .priv_size = sizeof(GraphContext),
765
766     .init      = init_file,
767     .uninit    = uninit,
768
769     .query_formats = query_formats,
770
771     .inputs    = (AVFilterPad[]) {{ .name = NULL, }},
772     .outputs   = (AVFilterPad[]) {{ .name = NULL, }},
773 };
774