From 037be76e1588fc8135dd307ba0be4c792b3e93e6 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 2 Dec 2010 20:12:27 +0000 Subject: Add avfilter_graph_create_filter(). Originally committed as revision 25862 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'ffmpeg.c') diff --git a/ffmpeg.c b/ffmpeg.c index e58e7b5..96be297 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -356,22 +356,16 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) graph = avfilter_graph_alloc(); - if ((ret = avfilter_open(&ist->input_video_filter, avfilter_get_by_name("buffer"), "src")) < 0) - return ret; - if ((ret = avfilter_open(&ist->output_video_filter, &ffsink, "out")) < 0) - return ret; - snprintf(args, 255, "%d:%d:%d:%d:%d", ist->st->codec->width, ist->st->codec->height, ist->st->codec->pix_fmt, 1, AV_TIME_BASE); - if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0) + ret = avfilter_graph_create_filter(&ist->input_video_filter, avfilter_get_by_name("buffer"), + "src", args, NULL, graph); + if (ret < 0) return ret; - if ((ret = avfilter_init_filter(ist->output_video_filter, NULL, &ffsink_ctx)) < 0) + ret = avfilter_graph_create_filter(&ist->output_video_filter, &ffsink, + "out", NULL, &ffsink_ctx, graph); + if (ret < 0) return ret; - - /* add input and output filters to the overall graph */ - avfilter_graph_add_filter(graph, ist->input_video_filter); - avfilter_graph_add_filter(graph, ist->output_video_filter); - last_filter = ist->input_video_filter; if (codec->width != icodec->width || codec->height != icodec->height) { @@ -379,14 +373,12 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost) codec->width, codec->height, (int)av_get_int(sws_opts, "sws_flags", NULL)); - if ((ret = avfilter_open(&filter, avfilter_get_by_name("scale"), NULL)) < 0) - return ret; - if ((ret = avfilter_init_filter(filter, args, NULL)) < 0) + if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), + NULL, args, NULL, graph)) < 0) return ret; if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0) return ret; last_filter = filter; - avfilter_graph_add_filter(graph, last_filter); } snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL)); -- cgit v1.1