History

avfilter: Support both syntaxes for the scale filter

Luca Barbato committed 11 years ago

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

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
81 return name;81 return name;
82}82}
83 83
84#define TMP_ARGS_SIZE 256
85
86static 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
84/**119/**
85 * Create an instance of a filter, initialize and insert it in the120 * Create an instance of a filter, initialize and insert it in the
86 * filtergraph in *ctx.121 * filtergraph in *ctx.
@@ -98,7 +133,7 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind · 11 unmodified lines
98{133{
99 AVFilter *filt;134 AVFilter *filt;
100 char inst_name[30];135 char inst_name[30];
101 char tmp_args[256];136 char tmp_args[TMP_ARGS_SIZE];
102 int ret;137 int ret;
103 138
104 snprintf(inst_name, sizeof(inst_name), "Parsed filter %d %s", index, filt_name);139 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
118 return AVERROR(ENOMEM);153 return AVERROR(ENOMEM);
119 }154 }
120 155
121 if (!strcmp(filt_name, "scale") && args && !strstr(args, "flags") &&156 if (!strcmp(filt_name, "scale") && args &&
122 ctx->scale_sws_opts) {157 ctx->scale_sws_opts) {
123 snprintf(tmp_args, sizeof(tmp_args), "%s:%s",158 append_sws_flags(&args, ctx->scale_sws_opts, tmp_args);
124 args, ctx->scale_sws_opts);
125 args = tmp_args;
126 }159 }
127 160
128 ret = avfilter_init_str(*filt_ctx, args);161 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