diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-05-16 09:19:46 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-06-22 21:06:01 +0200 |
commit | 58b049f2fa4f192b00baadb5f1f32ca366f936ea (patch) | |
tree | 8b44e5cdd0178461047042a10fc0d101f4bcba8e /libavfilter/avfiltergraph.c | |
parent | fa0662393096a1ece73ccc321cd5b8948e96e431 (diff) | |
download | ffmpeg-58b049f2fa4f192b00baadb5f1f32ca366f936ea.tar.gz |
lavfi: support automatically inserting the fifo filter when needed.
This breaks libavfilter ABI.
Diffstat (limited to 'libavfilter/avfiltergraph.c')
-rw-r--r-- | libavfilter/avfiltergraph.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 3d463a84d5..95e0a219af 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -591,12 +591,52 @@ static int graph_config_formats(AVFilterGraph *graph, AVClass *log_ctx) return 0; } +static int graph_insert_fifos(AVFilterGraph *graph, AVClass *log_ctx) +{ + AVFilterContext *f; + int i, j, ret; + int fifo_count = 0; + + for (i = 0; i < graph->filter_count; i++) { + f = graph->filters[i]; + + for (j = 0; j < f->nb_inputs; j++) { + AVFilterLink *link = f->inputs[j]; + AVFilterContext *fifo_ctx; + AVFilter *fifo; + char name[32]; + + if (!link->dstpad->needs_fifo) + continue; + + fifo = f->inputs[j]->type == AVMEDIA_TYPE_VIDEO ? + avfilter_get_by_name("fifo") : + avfilter_get_by_name("afifo"); + + snprintf(name, sizeof(name), "auto-inserted fifo %d", fifo_count++); + + ret = avfilter_graph_create_filter(&fifo_ctx, fifo, name, NULL, + NULL, graph); + if (ret < 0) + return ret; + + ret = avfilter_insert_filter(link, fifo_ctx, 0, 0); + if (ret < 0) + return ret; + } + } + + return 0; +} + int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx) { int ret; if ((ret = graph_check_validity(graphctx, log_ctx))) return ret; + if ((ret = graph_insert_fifos(graphctx, log_ctx)) < 0) + return ret; if ((ret = graph_config_formats(graphctx, log_ctx))) return ret; if ((ret = graph_config_links(graphctx, log_ctx))) |