Originally committed as revision 24418 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -34,7 +34,7 @@ static int link_filter(AVFilterContext *src, int srcpad, · 33 unmodified lines | |||
| 34 | AVFilterContext *dst, int dstpad, | 34 | AVFilterContext *dst, int dstpad, |
| 35 | AVClass *log_ctx) | 35 | AVClass *log_ctx) |
| 36 | { | 36 | { |
| 37 | if(avfilter_link(src, srcpad, dst, dstpad)) { | 37 | if (avfilter_link(src, srcpad, dst, dstpad)) { |
| 38 | av_log(log_ctx, AV_LOG_ERROR, | 38 | av_log(log_ctx, AV_LOG_ERROR, |
| 39 | "cannot create the link %s:%d -> %s:%d\n", | 39 | "cannot create the link %s:%d -> %s:%d\n", |
| 40 | src->filter->name, srcpad, dst->filter->name, dstpad); | 40 | src->filter->name, srcpad, dst->filter->name, dstpad); |
| @@ -57,13 +57,13 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) · 16 unmodified lines | |||
| 57 | 57 | ||
| 58 | name = av_get_token(buf, "]"); | 58 | name = av_get_token(buf, "]"); |
| 59 | 59 | ||
| 60 | if(!name[0]) { | 60 | if (!name[0]) { |
| 61 | av_log(log_ctx, AV_LOG_ERROR, | 61 | av_log(log_ctx, AV_LOG_ERROR, |
| 62 | "Bad (empty?) label found in the following: \"%s\".\n", start); | 62 | "Bad (empty?) label found in the following: \"%s\".\n", start); |
| 63 | goto fail; | 63 | goto fail; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | if(*(*buf)++ != ']') { | 66 | if (*(*buf)++ != ']') { |
| 67 | av_log(log_ctx, AV_LOG_ERROR, | 67 | av_log(log_ctx, AV_LOG_ERROR, |
| 68 | "Mismatched '[' found in the following: \"%s\".\n", start); | 68 | "Mismatched '[' found in the following: \"%s\".\n", start); |
| 69 | fail: | 69 | fail: |
| @@ -87,20 +87,20 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 17 unmodified lines | |||
| 87 | 87 | ||
| 88 | filt = avfilter_get_by_name(filt_name); | 88 | filt = avfilter_get_by_name(filt_name); |
| 89 | 89 | ||
| 90 | if(!filt) { | 90 | if (!filt) { |
| 91 | av_log(log_ctx, AV_LOG_ERROR, | 91 | av_log(log_ctx, AV_LOG_ERROR, |
| 92 | "no such filter: '%s'\n", filt_name); | 92 | "no such filter: '%s'\n", filt_name); |
| 93 | return NULL; | 93 | return NULL; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | filt_ctx = avfilter_open(filt, inst_name); | 96 | filt_ctx = avfilter_open(filt, inst_name); |
| 97 | if(!filt_ctx) { | 97 | if (!filt_ctx) { |
| 98 | av_log(log_ctx, AV_LOG_ERROR, | 98 | av_log(log_ctx, AV_LOG_ERROR, |
| 99 | "error creating filter '%s'\n", filt_name); | 99 | "error creating filter '%s'\n", filt_name); |
| 100 | return NULL; | 100 | return NULL; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | if(avfilter_graph_add_filter(ctx, filt_ctx) < 0) { | 103 | if (avfilter_graph_add_filter(ctx, filt_ctx) < 0) { |
| 104 | avfilter_destroy(filt_ctx); | 104 | avfilter_destroy(filt_ctx); |
| 105 | return NULL; | 105 | return NULL; |
| 106 | } | 106 | } |
| @@ -111,7 +111,7 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 4 unmodified lines | |||
| 111 | args = tmp_args; | 111 | args = tmp_args; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | if(avfilter_init_filter(filt_ctx, args, NULL)) { | 114 | if (avfilter_init_filter(filt_ctx, args, NULL)) { |
| 115 | av_log(log_ctx, AV_LOG_ERROR, | 115 | av_log(log_ctx, AV_LOG_ERROR, |
| 116 | "error initializing filter '%s' with args '%s'\n", filt_name, args); | 116 | "error initializing filter '%s' with args '%s'\n", filt_name, args); |
| 117 | return NULL; | 117 | return NULL; |
| @@ -130,7 +130,7 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 12 unmodified lines | |||
| 130 | char *name = av_get_token(buf, "=,;[\n"); | 130 | char *name = av_get_token(buf, "=,;[\n"); |
| 131 | AVFilterContext *ret; | 131 | AVFilterContext *ret; |
| 132 | 132 | ||
| 133 | if(**buf == '=') { | 133 | if (**buf == '=') { |
| 134 | (*buf)++; | 134 | (*buf)++; |
| 135 | opts = av_get_token(buf, "[],;\n"); | 135 | opts = av_get_token(buf, "[],;\n"); |
| 136 | } | 136 | } |
| @@ -143,7 +143,7 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 6 unmodified lines | |||
| 143 | 143 | ||
| 144 | static void free_inout(AVFilterInOut *head) | 144 | static void free_inout(AVFilterInOut *head) |
| 145 | { | 145 | { |
| 146 | while(head) { | 146 | while (head) { |
| 147 | AVFilterInOut *next = head->next; | 147 | AVFilterInOut *next = head->next; |
| 148 | av_free(head->name); | 148 | av_free(head->name); |
| 149 | av_free(head); | 149 | av_free(head); |
| @@ -155,12 +155,12 @@ static AVFilterInOut *extract_inout(const char *label, AVFilterInOut **links) · 5 unmodified lines | |||
| 155 | { | 155 | { |
| 156 | AVFilterInOut *ret; | 156 | AVFilterInOut *ret; |
| 157 | 157 | ||
| 158 | while(*links && strcmp((*links)->name, label)) | 158 | while (*links && strcmp((*links)->name, label)) |
| 159 | links = &((*links)->next); | 159 | links = &((*links)->next); |
| 160 | 160 | ||
| 161 | ret = *links; | 161 | ret = *links; |
| 162 | 162 | ||
| 163 | if(ret) | 163 | if (ret) |
| 164 | *links = ret->next; | 164 | *links = ret->next; |
| 165 | 165 | ||
| 166 | return ret; | 166 | return ret; |
| @@ -178,9 +178,9 @@ static int link_filter_inouts(AVFilterContext *filter, · 11 unmodified lines | |||
| 178 | { | 178 | { |
| 179 | int pad = filter->input_count; | 179 | int pad = filter->input_count; |
| 180 | 180 | ||
| 181 | while(pad--) { | 181 | while (pad--) { |
| 182 | AVFilterInOut *p = *curr_inputs; | 182 | AVFilterInOut *p = *curr_inputs; |
| 183 | if(!p) { | 183 | if (!p) { |
| 184 | av_log(log_ctx, AV_LOG_ERROR, | 184 | av_log(log_ctx, AV_LOG_ERROR, |
| 185 | "Not enough inputs specified for the \"%s\" filter.\n", | 185 | "Not enough inputs specified for the \"%s\" filter.\n", |
| 186 | filter->filter->name); | 186 | filter->filter->name); |
| @@ -189,8 +189,8 @@ static int link_filter_inouts(AVFilterContext *filter, · 2 unmodified lines | |||
| 189 | 189 | ||
| 190 | *curr_inputs = (*curr_inputs)->next; | 190 | *curr_inputs = (*curr_inputs)->next; |
| 191 | 191 | ||
| 192 | if(p->filter) { | 192 | if (p->filter) { |
| 193 | if(link_filter(p->filter, p->pad_idx, filter, pad, log_ctx)) | 193 | if (link_filter(p->filter, p->pad_idx, filter, pad, log_ctx)) |
| 194 | return -1; | 194 | return -1; |
| 195 | av_free(p->name); | 195 | av_free(p->name); |
| 196 | av_free(p); | 196 | av_free(p); |
| @@ -201,7 +201,7 @@ static int link_filter_inouts(AVFilterContext *filter, · 4 unmodified lines | |||
| 201 | } | 201 | } |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | if(*curr_inputs) { | 204 | if (*curr_inputs) { |
| 205 | av_log(log_ctx, AV_LOG_ERROR, | 205 | av_log(log_ctx, AV_LOG_ERROR, |
| 206 | "Too many inputs specified for the \"%s\" filter.\n", | 206 | "Too many inputs specified for the \"%s\" filter.\n", |
| 207 | filter->filter->name); | 207 | filter->filter->name); |
| @@ -209,7 +209,7 @@ static int link_filter_inouts(AVFilterContext *filter, · 1 unmodified line | |||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | pad = filter->output_count; | 211 | pad = filter->output_count; |
| 212 | while(pad--) { | 212 | while (pad--) { |
| 213 | AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); | 213 | AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); |
| 214 | currlinkn->filter = filter; | 214 | currlinkn->filter = filter; |
| 215 | currlinkn->pad_idx = pad; | 215 | currlinkn->pad_idx = pad; |
| @@ -224,17 +224,17 @@ static int parse_inputs(const char **buf, AVFilterInOut **curr_inputs, · 8 unmodified lines | |||
| 224 | { | 224 | { |
| 225 | int pad = 0; | 225 | int pad = 0; |
| 226 | 226 | ||
| 227 | while(**buf == '[') { | 227 | while (**buf == '[') { |
| 228 | char *name = parse_link_name(buf, log_ctx); | 228 | char *name = parse_link_name(buf, log_ctx); |
| 229 | AVFilterInOut *match; | 229 | AVFilterInOut *match; |
| 230 | 230 | ||
| 231 | if(!name) | 231 | if (!name) |
| 232 | return -1; | 232 | return -1; |
| 233 | 233 | ||
| 234 | /* First check if the label is not in the open_outputs list */ | 234 | /* First check if the label is not in the open_outputs list */ |
| 235 | match = extract_inout(name, open_outputs); | 235 | match = extract_inout(name, open_outputs); |
| 236 | 236 | ||
| 237 | if(match) { | 237 | if (match) { |
| 238 | av_free(name); | 238 | av_free(name); |
| 239 | } else { | 239 | } else { |
| 240 | /* Not in the list, so add it as an input */ | 240 | /* Not in the list, so add it as an input */ |
| @@ -258,22 +258,22 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs, · 17 unmodified lines | |||
| 258 | { | 258 | { |
| 259 | int pad = 0; | 259 | int pad = 0; |
| 260 | 260 | ||
| 261 | while(**buf == '[') { | 261 | while (**buf == '[') { |
| 262 | char *name = parse_link_name(buf, log_ctx); | 262 | char *name = parse_link_name(buf, log_ctx); |
| 263 | AVFilterInOut *match; | 263 | AVFilterInOut *match; |
| 264 | 264 | ||
| 265 | AVFilterInOut *input = *curr_inputs; | 265 | AVFilterInOut *input = *curr_inputs; |
| 266 | *curr_inputs = (*curr_inputs)->next; | 266 | *curr_inputs = (*curr_inputs)->next; |
| 267 | 267 | ||
| 268 | if(!name) | 268 | if (!name) |
| 269 | return -1; | 269 | return -1; |
| 270 | 270 | ||
| 271 | /* First check if the label is not in the open_inputs list */ | 271 | /* First check if the label is not in the open_inputs list */ |
| 272 | match = extract_inout(name, open_inputs); | 272 | match = extract_inout(name, open_inputs); |
| 273 | 273 | ||
| 274 | if(match) { | 274 | if (match) { |
| 275 | if(link_filter(input->filter, input->pad_idx, | 275 | if (link_filter(input->filter, input->pad_idx, |
| 276 | match->filter, match->pad_idx, log_ctx) < 0) | 276 | match->filter, match->pad_idx, log_ctx) < 0) |
| 277 | return -1; | 277 | return -1; |
| 278 | av_free(match->name); | 278 | av_free(match->name); |
| 279 | av_free(name); | 279 | av_free(name); |
| @@ -304,39 +304,39 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 24 unmodified lines | |||
| 304 | AVFilterContext *filter; | 304 | AVFilterContext *filter; |
| 305 | filters += strspn(filters, WHITESPACES); | 305 | filters += strspn(filters, WHITESPACES); |
| 306 | 306 | ||
| 307 | if(parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx) < 0) | 307 | if (parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx) < 0) |
| 308 | goto fail; | 308 | goto fail; |
| 309 | 309 | ||
| 310 | filter = parse_filter(&filters, graph, index, log_ctx); | 310 | filter = parse_filter(&filters, graph, index, log_ctx); |
| 311 | 311 | ||
| 312 | if(!filter) | 312 | if (!filter) |
| 313 | goto fail; | 313 | goto fail; |
| 314 | 314 | ||
| 315 | if(filter->input_count == 1 && !curr_inputs && !index) { | 315 | if (filter->input_count == 1 && !curr_inputs && !index) { |
| 316 | /* First input can be omitted if it is "[in]" */ | 316 | /* First input can be omitted if it is "[in]" */ |
| 317 | const char *tmp = "[in]"; | 317 | const char *tmp = "[in]"; |
| 318 | if(parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx) < 0) | 318 | if(parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx) < 0) |
| 319 | goto fail; | 319 | goto fail; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | if(link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx) < 0) | 322 | if (link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx) < 0) |
| 323 | goto fail; | 323 | goto fail; |
| 324 | 324 | ||
| 325 | if(parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs, | 325 | if (parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs, |
| 326 | log_ctx) < 0) | 326 | log_ctx) < 0) |
| 327 | goto fail; | 327 | goto fail; |
| 328 | 328 | ||
| 329 | filters += strspn(filters, WHITESPACES); | 329 | filters += strspn(filters, WHITESPACES); |
| 330 | chr = *filters++; | 330 | chr = *filters++; |
| 331 | 331 | ||
| 332 | if(chr == ';' && curr_inputs) { | 332 | if (chr == ';' && curr_inputs) { |
| 333 | av_log(log_ctx, AV_LOG_ERROR, | 333 | av_log(log_ctx, AV_LOG_ERROR, |
| 334 | "Could not find a output to link when parsing \"%s\"\n", | 334 | "Could not find a output to link when parsing \"%s\"\n", |
| 335 | filters - 1); | 335 | filters - 1); |
| 336 | goto fail; | 336 | goto fail; |
| 337 | } | 337 | } |
| 338 | index++; | 338 | index++; |
| 339 | } while(chr == ',' || chr == ';'); | 339 | } while (chr == ',' || chr == ';'); |
| 340 | 340 | ||
| 341 | if (chr) { | 341 | if (chr) { |
| 342 | av_log(log_ctx, AV_LOG_ERROR, | 342 | av_log(log_ctx, AV_LOG_ERROR, |
| @@ -345,10 +345,10 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 2 unmodified lines | |||
| 345 | goto fail; | 345 | goto fail; |
| 346 | } | 346 | } |
| 347 | 347 | ||
| 348 | if(open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { | 348 | if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) { |
| 349 | /* Last output can be omitted if it is "[out]" */ | 349 | /* Last output can be omitted if it is "[out]" */ |
| 350 | const char *tmp = "[out]"; | 350 | const char *tmp = "[out]"; |
| 351 | if(parse_outputs(&tmp, &curr_inputs, &open_inputs, | 351 | if (parse_outputs(&tmp, &curr_inputs, &open_inputs, |
| 352 | &open_outputs, log_ctx) < 0) | 352 | &open_outputs, log_ctx) < 0) |
| 353 | goto fail; | 353 | goto fail; |
| 354 | } | 354 | } |