Originally committed as revision 13360 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/graphparser.c (1 of 2 files). Show all
Unified · Split
| @@ -212,7 +212,7 @@ static void insert_inout(AVFilterInOut **inouts, AVFilterInOut *element) · 211 unmodified lines | |||
| 212 | 212 | ||
| 213 | static int link_filter_inouts(AVFilterContext *filter, | 213 | static int link_filter_inouts(AVFilterContext *filter, |
| 214 | AVFilterInOut **currInputs, | 214 | AVFilterInOut **currInputs, |
| 215 | AVFilterInOut **openLinks, AVClass *log_ctx) | 215 | AVFilterInOut **openInputs, AVClass *log_ctx) |
| 216 | { | 216 | { |
| 217 | int pad = filter->input_count; | 217 | int pad = filter->input_count; |
| 218 | 218 | ||
| @@ -249,7 +249,6 @@ static int link_filter_inouts(AVFilterContext *filter, · 30 unmodified lines | |||
| 249 | pad = filter->output_count; | 249 | pad = filter->output_count; |
| 250 | while(pad--) { | 250 | while(pad--) { |
| 251 | AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); | 251 | AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); |
| 252 | currlinkn->type = LinkTypeOut; | ||
| 253 | currlinkn->filter = filter; | 252 | currlinkn->filter = filter; |
| 254 | currlinkn->pad_idx = pad; | 253 | currlinkn->pad_idx = pad; |
| 255 | insert_inout(currInputs, currlinkn); | 254 | insert_inout(currInputs, currlinkn); |
| @@ -259,7 +258,7 @@ static int link_filter_inouts(AVFilterContext *filter, · 3 unmodified lines | |||
| 259 | } | 258 | } |
| 260 | 259 | ||
| 261 | static int parse_inputs(const char **buf, AVFilterInOut **currInputs, | 260 | static int parse_inputs(const char **buf, AVFilterInOut **currInputs, |
| 262 | AVFilterInOut **openLinks, AVClass *log_ctx) | 261 | AVFilterInOut **openOutputs, AVClass *log_ctx) |
| 263 | { | 262 | { |
| 264 | int pad = 0; | 263 | int pad = 0; |
| 265 | 264 | ||
| @@ -270,23 +269,15 @@ static int parse_inputs(const char **buf, AVFilterInOut **currInputs, · 4 unmodified lines | |||
| 270 | if(!name) | 269 | if(!name) |
| 271 | return -1; | 270 | return -1; |
| 272 | 271 | ||
| 273 | /* First check if the label is not in the openLinks list */ | 272 | /* First check if the label is not in the openOutputs list */ |
| 274 | match = extract_inout(name, openLinks); | 273 | match = extract_inout(name, openOutputs); |
| 275 | 274 | ||
| 276 | if(match) { | 275 | if(match) { |
| 277 | /* A label of a open link. Make it one of the inputs of the next | ||
| 278 | filter */ | ||
| 279 | if(match->type != LinkTypeOut) { | ||
| 280 | av_log(log_ctx, AV_LOG_ERROR, | ||
| 281 | "Label \"%s\" appears twice as input!\n", match->name); | ||
| 282 | return -1; | ||
| 283 | } | ||
| 284 | av_free(name); | 276 | av_free(name); |
| 285 | } else { | 277 | } else { |
| 286 | /* Not in the list, so add it as an input */ | 278 | /* Not in the list, so add it as an input */ |
| 287 | match = av_mallocz(sizeof(AVFilterInOut)); | 279 | match = av_mallocz(sizeof(AVFilterInOut)); |
| 288 | match->name = name; | 280 | match->name = name; |
| 289 | match->type = LinkTypeIn; | ||
| 290 | match->pad_idx = pad; | 281 | match->pad_idx = pad; |
| 291 | } | 282 | } |
| 292 | 283 | ||
| @@ -300,7 +291,8 @@ static int parse_inputs(const char **buf, AVFilterInOut **currInputs, · 7 unmodified lines | |||
| 300 | } | 291 | } |
| 301 | 292 | ||
| 302 | static int parse_outputs(const char **buf, AVFilterInOut **currInputs, | 293 | static int parse_outputs(const char **buf, AVFilterInOut **currInputs, |
| 303 | AVFilterInOut **openLinks, AVClass *log_ctx) | 294 | AVFilterInOut **openInputs, |
| 295 | AVFilterInOut **openOutputs, AVClass *log_ctx) | ||
| 304 | { | 296 | { |
| 305 | int pad = 0; | 297 | int pad = 0; |
| 306 | 298 | ||
| @@ -314,17 +306,10 @@ static int parse_outputs(const char **buf, AVFilterInOut **currInputs, · 7 unmodified lines | |||
| 314 | if(!name) | 306 | if(!name) |
| 315 | return -1; | 307 | return -1; |
| 316 | 308 | ||
| 317 | /* First check if the label is not in the openLinks list */ | 309 | /* First check if the label is not in the openInputs list */ |
| 318 | match = extract_inout(name, openLinks); | 310 | match = extract_inout(name, openInputs); |
| 319 | 311 | ||
| 320 | if(match) { | 312 | if(match) { |
| 321 | /* A label of a open link. Link it. */ | ||
| 322 | if(match->type != LinkTypeIn) { | ||
| 323 | av_log(log_ctx, AV_LOG_ERROR, | ||
| 324 | "Label \"%s\" appears twice as output!\n", match->name); | ||
| 325 | return -1; | ||
| 326 | } | ||
| 327 | |||
| 328 | if(link_filter(input->filter, input->pad_idx, | 313 | if(link_filter(input->filter, input->pad_idx, |
| 329 | match->filter, match->pad_idx, log_ctx) < 0) | 314 | match->filter, match->pad_idx, log_ctx) < 0) |
| 330 | return -1; | 315 | return -1; |
| @@ -333,9 +318,7 @@ static int parse_outputs(const char **buf, AVFilterInOut **currInputs, · 2 unmodified lines | |||
| 333 | av_free(match); | 318 | av_free(match); |
| 334 | av_free(input); | 319 | av_free(input); |
| 335 | } else { | 320 | } else { |
| 336 | /* Not in the list, so add the first input as a openLink */ | 321 | /* Not in the list, so add the first input as a openOutput */ |
| 337 | input->next = *openLinks; | ||
| 338 | input->type = LinkTypeOut; | ||
| 339 | input->name = name; | 322 | input->name = name; |
| 340 | insert_inout(openOutputs, input); | 323 | insert_inout(openOutputs, input); |
| 341 | } | 324 | } |
| @@ -347,7 +330,8 @@ static int parse_outputs(const char **buf, AVFilterInOut **currInputs, · 5 unmodified lines | |||
| 347 | } | 330 | } |
| 348 | 331 | ||
| 349 | int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, | 332 | int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, |
| 350 | AVFilterInOut *openLinks, AVClass *log_ctx) | 333 | AVFilterInOut *openInputs, |
| 334 | AVFilterInOut *openOutputs, AVClass *log_ctx) | ||
| 351 | { | 335 | { |
| 352 | int index = 0; | 336 | int index = 0; |
| 353 | char chr = 0; | 337 | char chr = 0; |
| @@ -358,7 +342,7 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | |||
| 358 | AVFilterContext *filter; | 342 | AVFilterContext *filter; |
| 359 | filters += consume_whitespace(filters); | 343 | filters += consume_whitespace(filters); |
| 360 | 344 | ||
| 361 | if(parse_inputs(&filters, &currInputs, &openLinks, log_ctx) < 0) | 345 | if(parse_inputs(&filters, &currInputs, &openOutputs, log_ctx) < 0) |
| 362 | goto fail; | 346 | goto fail; |
| 363 | 347 | ||
| 364 | filter = parse_filter(&filters, graph, index, log_ctx); | 348 | filter = parse_filter(&filters, graph, index, log_ctx); |
| @@ -369,14 +353,15 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | |||
| 369 | if(filter->input_count == 1 && !currInputs && !index) { | 353 | if(filter->input_count == 1 && !currInputs && !index) { |
| 370 | /* First input can be ommitted if it is "[in]" */ | 354 | /* First input can be ommitted if it is "[in]" */ |
| 371 | const char *tmp = "[in]"; | 355 | const char *tmp = "[in]"; |
| 372 | if(parse_inputs(&tmp, &currInputs, &openLinks, log_ctx)) | 356 | if(parse_inputs(&tmp, &currInputs, &openOutputs, log_ctx) < 0) |
| 373 | goto fail; | 357 | goto fail; |
| 374 | } | 358 | } |
| 375 | 359 | ||
| 376 | if(link_filter_inouts(filter, &currInputs, &openLinks, log_ctx) < 0) | 360 | if(link_filter_inouts(filter, &currInputs, &openInputs, log_ctx) < 0) |
| 377 | goto fail; | 361 | goto fail; |
| 378 | 362 | ||
| 379 | if(parse_outputs(&filters, &currInputs, &openLinks, log_ctx)) | 363 | if(parse_outputs(&filters, &currInputs, &openInputs, &openOutputs, |
| 364 | log_ctx) < 0) | ||
| 380 | goto fail; | 365 | goto fail; |
| 381 | 366 | ||
| 382 | filters += consume_whitespace(filters); | 367 | filters += consume_whitespace(filters); |
| @@ -391,10 +376,11 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 8 unmodified lines | |||
| 391 | index++; | 376 | index++; |
| 392 | } while(chr == ',' || chr == ';'); | 377 | } while(chr == ',' || chr == ';'); |
| 393 | 378 | ||
| 394 | if(openLinks && !strcmp(openLinks->name, "out") && currInputs) { | 379 | if(openInputs && !strcmp(openInputs->name, "out") && currInputs) { |
| 395 | /* Last output can be ommitted if it is "[out]" */ | 380 | /* Last output can be ommitted if it is "[out]" */ |
| 396 | const char *tmp = "[out]"; | 381 | const char *tmp = "[out]"; |
| 397 | if(parse_outputs(&tmp, &currInputs, &openLinks, log_ctx) < 0) | 382 | if(parse_outputs(&tmp, &currInputs, &openInputs, |
| 383 | &openOutputs, log_ctx) < 0) | ||
| 398 | goto fail; | 384 | goto fail; |
| 399 | } | 385 | } |
| 400 | 386 | ||
| @@ -402,7 +388,8 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 1 unmodified line | |||
| 402 | 388 | ||
| 403 | fail: | 389 | fail: |
| 404 | avfilter_destroy_graph(graph); | 390 | avfilter_destroy_graph(graph); |
| 405 | free_inout(openLinks); | 391 | free_inout(openInputs); |
| 392 | free_inout(openOutputs); | ||
| 406 | free_inout(currInputs); | 393 | free_inout(currInputs); |
| 407 | return -1; | 394 | return -1; |
| 408 | } | 395 | } |