summaryrefslogtreecommitdiff
path: root/libavfilter/graphparser.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-04-09 06:13:53 +0200
committerAnton Khirnov <anton@khirnov.net>2012-04-14 09:25:46 +0200
commit12e7e1d03e772b16ae95fa6c79ed870d9335564c (patch)
treecd908ebda0e42e651a1de7d1d78a7910f9bccca1 /libavfilter/graphparser.c
parent4e781c25b7b1955d1a9a0b0771c3ce1acb0957bd (diff)
graphparser: allow specifying sws flags in the graph description.
Diffstat (limited to 'libavfilter/graphparser.c')
-rw-r--r--libavfilter/graphparser.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index ebd9cc929c..d2d31653a9 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -349,6 +349,30 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
#else
#define log_ctx NULL
#endif
+
+static int parse_sws_flags(const char **buf, AVFilterGraph *graph)
+{
+ char *p = strchr(*buf, ';');
+
+ if (strncmp(*buf, "sws_flags=", 10))
+ return 0;
+
+ if (!p) {
+ av_log(log_ctx, AV_LOG_ERROR, "sws_flags not terminated with ';'.\n");
+ return AVERROR(EINVAL);
+ }
+
+ *buf += 4; // keep the 'flags=' part
+
+ av_freep(&graph->scale_sws_opts);
+ if (!(graph->scale_sws_opts = av_mallocz(p - *buf + 1)))
+ return AVERROR(ENOMEM);
+ av_strlcpy(graph->scale_sws_opts, *buf, p - *buf + 1);
+
+ *buf = p + 1;
+ return 0;
+}
+
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
AVFilterInOut **inputs,
AVFilterInOut **outputs)
@@ -358,6 +382,11 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
AVFilterInOut *curr_inputs = NULL, *open_inputs = NULL, *open_outputs = NULL;
+ filters += strspn(filters, WHITESPACES);
+
+ if ((ret = parse_sws_flags(&filters, graph)) < 0)
+ goto fail;
+
do {
AVFilterContext *filter;
filters += strspn(filters, WHITESPACES);