Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all
Unified · Split
| @@ -81,6 +81,41 @@ static char *parse_link_name(const char **buf, void *log_ctx) · 80 unmodified lines | ||
| 81 | 81 | return name; |
| 82 | 82 | } |
| 83 | 83 | |
| 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 | + | |
| 84 | 119 | /** |
| 85 | 120 | * Create an instance of a filter, initialize and insert it in the |
| 86 | 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 | 134 | AVFilter *filt; |
| 100 | 135 | char inst_name[30]; |
| 101 | − char tmp_args[256]; | |
| 136 | + char tmp_args[TMP_ARGS_SIZE]; | |
| 102 | 137 | int ret; |
| 103 | 138 | |
| 104 | 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 | 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 | 157 | 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); | |
| 126 | 159 | } |
| 127 | 160 | |
| 128 | 161 | ret = avfilter_init_str(*filt_ctx, args); |