History

avfilter: Support both syntaxes for the scale filter

Luca Barbato committed 11 years ago

Commit 285fe5b1 parent c7247eb1 file · +38 −5Browse files

Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all

Unified · Split

libavfilter/graphparser.c+38−5
@@ -81,6 +81,41 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 80 unmodified lines
8181 return name;
8282 }
8383
84+#define TMP_ARGS_SIZE 256
85+
86+static void append_sws_flags(const char **args, const char *sws_opts, char *tmp)
87+{
88+ int nb_opts = 0;
89+ const char *separator = ":";
90+ const char *opt = *args;
91+
92+ if (strstr(*args, "flags"))
93+ return;
94+
95+ if (strstr(*args, "="))
96+ separator = ":flags=";
97+
98+ while ((opt = strstr(opt, ":")) && *opt) {
99+ av_log(NULL, AV_LOG_INFO, "opts '%s' \n", opt);
100+ if (nb_opts > 2) {
101+ return;
102+ }
103+ nb_opts++;
104+ opt++;
105+ }
106+
107+ opt = strstr(sws_opts, "flags=");
108+ if (opt && strlen(opt) > 6)
109+ opt += 6;
110+ else
111+ opt = sws_opts;
112+
113+ snprintf(tmp, TMP_ARGS_SIZE, "%s%s%s",
114+ *args, separator, opt);
115+
116+ *args = tmp;
117+}
118+
84119 /**
85120 * Create an instance of a filter, initialize and insert it in the
86121 * filtergraph in *ctx.
@@ -98,7 +133,7 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind · 11 unmodified lines
98133 {
99134 AVFilter *filt;
100135 char inst_name[30];
101− char tmp_args[256];
136+ char tmp_args[TMP_ARGS_SIZE];
102137 int ret;
103138
104139 snprintf(inst_name, sizeof(inst_name), "Parsed filter %d %s", index, filt_name);
@@ -118,11 +153,9 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind · 13 unmodified lines
118153 return AVERROR(ENOMEM);
119154 }
120155
121− if (!strcmp(filt_name, "scale") && args && !strstr(args, "flags") &&
156+ if (!strcmp(filt_name, "scale") && args &&
122157 ctx->scale_sws_opts) {
123− snprintf(tmp_args, sizeof(tmp_args), "%s:%s",
124− args, ctx->scale_sws_opts);
125− args = tmp_args;
158+ append_sws_flags(&args, ctx->scale_sws_opts, tmp_args);
126159 }
127160
128161 ret = avfilter_init_str(*filt_ctx, args);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t