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 | 213 | static int link_filter_inouts(AVFilterContext *filter, |
| 214 | 214 | AVFilterInOut **currInputs, |
| 215 | − AVFilterInOut **openLinks, AVClass *log_ctx) | |
| 215 | + AVFilterInOut **openInputs, AVClass *log_ctx) | |
| 216 | 216 | { |
| 217 | 217 | int pad = filter->input_count; |
| 218 | 218 | |
| @@ -249,7 +249,6 @@ static int link_filter_inouts(AVFilterContext *filter, · 30 unmodified lines | ||
| 249 | 249 | pad = filter->output_count; |
| 250 | 250 | while(pad--) { |
| 251 | 251 | AVFilterInOut *currlinkn = av_mallocz(sizeof(AVFilterInOut)); |
| 252 | − currlinkn->type = LinkTypeOut; | |
| 253 | 252 | currlinkn->filter = filter; |
| 254 | 253 | currlinkn->pad_idx = pad; |
| 255 | 254 | insert_inout(currInputs, currlinkn); |
| @@ -259,7 +258,7 @@ static int link_filter_inouts(AVFilterContext *filter, · 3 unmodified lines | ||
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 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 | 263 | int pad = 0; |
| 265 | 264 | |
| @@ -270,23 +269,15 @@ static int parse_inputs(const char **buf, AVFilterInOut **currInputs, · 4 unmodified lines | ||
| 270 | 269 | if(!name) |
| 271 | 270 | return -1; |
| 272 | 271 | |
| 273 | − /* First check if the label is not in the openLinks list */ | |
| 274 | − match = extract_inout(name, openLinks); | |
| 272 | + /* First check if the label is not in the openOutputs list */ | |
| 273 | + match = extract_inout(name, openOutputs); | |
| 275 | 274 | |
| 276 | 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 | 276 | av_free(name); |
| 285 | 277 | } else { |
| 286 | 278 | /* Not in the list, so add it as an input */ |
| 287 | 279 | match = av_mallocz(sizeof(AVFilterInOut)); |
| 288 | 280 | match->name = name; |
| 289 | − match->type = LinkTypeIn; | |
| 290 | 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 | 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 | 297 | int pad = 0; |
| 306 | 298 | |
| @@ -314,17 +306,10 @@ static int parse_outputs(const char **buf, AVFilterInOut **currInputs, · 7 unmodified lines | ||
| 314 | 306 | if(!name) |
| 315 | 307 | return -1; |
| 316 | 308 | |
| 317 | − /* First check if the label is not in the openLinks list */ | |
| 318 | − match = extract_inout(name, openLinks); | |
| 309 | + /* First check if the label is not in the openInputs list */ | |
| 310 | + match = extract_inout(name, openInputs); | |
| 319 | 311 | |
| 320 | 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 | 313 | if(link_filter(input->filter, input->pad_idx, |
| 329 | 314 | match->filter, match->pad_idx, log_ctx) < 0) |
| 330 | 315 | return -1; |
| @@ -333,9 +318,7 @@ static int parse_outputs(const char **buf, AVFilterInOut **currInputs, · 2 unmodified lines | ||
| 333 | 318 | av_free(match); |
| 334 | 319 | av_free(input); |
| 335 | 320 | } else { |
| 336 | − /* Not in the list, so add the first input as a openLink */ | |
| 337 | − input->next = *openLinks; | |
| 338 | − input->type = LinkTypeOut; | |
| 321 | + /* Not in the list, so add the first input as a openOutput */ | |
| 339 | 322 | input->name = name; |
| 340 | 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 | 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 | 336 | int index = 0; |
| 353 | 337 | char chr = 0; |
| @@ -358,7 +342,7 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | ||
| 358 | 342 | AVFilterContext *filter; |
| 359 | 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 | 346 | goto fail; |
| 363 | 347 | |
| 364 | 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 | 353 | if(filter->input_count == 1 && !currInputs && !index) { |
| 370 | 354 | /* First input can be ommitted if it is "[in]" */ |
| 371 | 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 | 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 | 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 | 365 | goto fail; |
| 381 | 366 | |
| 382 | 367 | filters += consume_whitespace(filters); |
| @@ -391,10 +376,11 @@ int avfilter_parse_graph(AVFilterGraph *graph, const char *filters, · 8 unmodified lines | ||
| 391 | 376 | index++; |
| 392 | 377 | } while(chr == ',' || chr == ';'); |
| 393 | 378 | |
| 394 | − if(openLinks && !strcmp(openLinks->name, "out") && currInputs) { | |
| 379 | + if(openInputs && !strcmp(openInputs->name, "out") && currInputs) { | |
| 395 | 380 | /* Last output can be ommitted if it is "[out]" */ |
| 396 | 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 | 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 | 389 | fail: |
| 404 | 390 | avfilter_destroy_graph(graph); |
| 405 | − free_inout(openLinks); | |
| 391 | + free_inout(openInputs); | |
| 392 | + free_inout(openOutputs); | |
| 406 | 393 | free_inout(currInputs); |
| 407 | 394 | return -1; |
| 408 | 395 | } |