| ... | ... |
@@ -76,6 +76,12 @@ In a complete filterchain all the unlabelled filter input and output |
| 76 | 76 |
pads must be connected. A filtergraph is considered valid if all the |
| 77 | 77 |
filter input and output pads of all the filterchains are connected. |
| 78 | 78 |
|
| 79 |
+Libavfilter will automatically insert scale filters where format |
|
| 80 |
+conversion is required. It is possible to specify swscale flags |
|
| 81 |
+for those automatically inserted scalers by prepending |
|
| 82 |
+@code{sws_flags=@var{flags};}
|
|
| 83 |
+to the filtergraph description. |
|
| 84 |
+ |
|
| 79 | 85 |
Follows a BNF description for the filtergraph syntax: |
| 80 | 86 |
@example |
| 81 | 87 |
@var{NAME} ::= sequence of alphanumeric characters and '_'
|
| ... | ... |
@@ -84,7 +90,7 @@ Follows a BNF description for the filtergraph syntax: |
| 84 | 84 |
@var{FILTER_ARGUMENTS} ::= sequence of chars (eventually quoted)
|
| 85 | 85 |
@var{FILTER} ::= [@var{LINKNAMES}] @var{NAME} ["=" @var{ARGUMENTS}] [@var{LINKNAMES}]
|
| 86 | 86 |
@var{FILTERCHAIN} ::= @var{FILTER} [,@var{FILTERCHAIN}]
|
| 87 |
-@var{FILTERGRAPH} ::= @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
|
|
| 87 |
+@var{FILTERGRAPH} ::= [sws_flags=@var{flags};] @var{FILTERCHAIN} [;@var{FILTERGRAPH}]
|
|
| 88 | 88 |
@end example |
| 89 | 89 |
|
| 90 | 90 |
@c man end FILTERGRAPH DESCRIPTION |
| ... | ... |
@@ -349,6 +349,30 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, |
| 349 | 349 |
#else |
| 350 | 350 |
#define log_ctx NULL |
| 351 | 351 |
#endif |
| 352 |
+ |
|
| 353 |
+static int parse_sws_flags(const char **buf, AVFilterGraph *graph) |
|
| 354 |
+{
|
|
| 355 |
+ char *p = strchr(*buf, ';'); |
|
| 356 |
+ |
|
| 357 |
+ if (strncmp(*buf, "sws_flags=", 10)) |
|
| 358 |
+ return 0; |
|
| 359 |
+ |
|
| 360 |
+ if (!p) {
|
|
| 361 |
+ av_log(log_ctx, AV_LOG_ERROR, "sws_flags not terminated with ';'.\n"); |
|
| 362 |
+ return AVERROR(EINVAL); |
|
| 363 |
+ } |
|
| 364 |
+ |
|
| 365 |
+ *buf += 4; // keep the 'flags=' part |
|
| 366 |
+ |
|
| 367 |
+ av_freep(&graph->scale_sws_opts); |
|
| 368 |
+ if (!(graph->scale_sws_opts = av_mallocz(p - *buf + 1))) |
|
| 369 |
+ return AVERROR(ENOMEM); |
|
| 370 |
+ av_strlcpy(graph->scale_sws_opts, *buf, p - *buf + 1); |
|
| 371 |
+ |
|
| 372 |
+ *buf = p + 1; |
|
| 373 |
+ return 0; |
|
| 374 |
+} |
|
| 375 |
+ |
|
| 352 | 376 |
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, |
| 353 | 377 |
AVFilterInOut **inputs, |
| 354 | 378 |
AVFilterInOut **outputs) |
| ... | ... |
@@ -358,6 +382,11 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, |
| 358 | 358 |
|
| 359 | 359 |
AVFilterInOut *curr_inputs = NULL, *open_inputs = NULL, *open_outputs = NULL; |
| 360 | 360 |
|
| 361 |
+ filters += strspn(filters, WHITESPACES); |
|
| 362 |
+ |
|
| 363 |
+ if ((ret = parse_sws_flags(&filters, graph)) < 0) |
|
| 364 |
+ goto fail; |
|
| 365 |
+ |
|
| 361 | 366 |
do {
|
| 362 | 367 |
AVFilterContext *filter; |
| 363 | 368 |
filters += strspn(filters, WHITESPACES); |