Originally committed as revision 12731 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/avfiltergraph.c (1 of 2 files). Show all
Unified · Split
| @@ -488,11 +488,10 @@ int avfilter_graph_config_formats(AVFilterContext *graphctx) · 487 unmodified lines | |||
| 488 | return 0; | 488 | return 0; |
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) | 491 | static int graph_load_from_desc2(AVFilterContext *ctx, AVFilterGraphDesc *desc) |
| 492 | { | 492 | { |
| 493 | AVFilterGraphDescFilter *curfilt; | 493 | AVFilterGraphDescFilter *curfilt; |
| 494 | AVFilterGraphDescLink *curlink; | 494 | AVFilterGraphDescLink *curlink; |
| 495 | AVFilterGraphDescExport *curpad; | ||
| 496 | AVFilterContext *filt, *filtb; | 495 | AVFilterContext *filt, *filtb; |
| 497 | 496 | ||
| 498 | AVFilter *filterdef; | 497 | AVFilter *filterdef; |
| @@ -533,6 +532,22 @@ static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) · 34 unmodified lines | |||
| 533 | } | 532 | } |
| 534 | } | 533 | } |
| 535 | 534 | ||
| 535 | return 0; | ||
| 536 | |||
| 537 | fail: | ||
| 538 | uninit(ctx); | ||
| 539 | return -1; | ||
| 540 | } | ||
| 541 | |||
| 542 | static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) | ||
| 543 | { | ||
| 544 | AVFilterGraphDescExport *curpad; | ||
| 545 | char tmp[20]; | ||
| 546 | AVFilterContext *filt; | ||
| 547 | |||
| 548 | if (graph_load_from_desc2(ctx, desc) < 0) | ||
| 549 | goto fail; | ||
| 550 | |||
| 536 | /* export all input pads */ | 551 | /* export all input pads */ |
| 537 | for(curpad = desc->inputs; curpad; curpad = curpad->next) { | 552 | for(curpad = desc->inputs; curpad; curpad = curpad->next) { |
| 538 | snprintf(tmp, 20, "%d", curpad->filter); | 553 | snprintf(tmp, 20, "%d", curpad->filter); |
| @@ -560,6 +575,49 @@ fail: · 21 unmodified lines | |||
| 560 | return -1; | 575 | return -1; |
| 561 | } | 576 | } |
| 562 | 577 | ||
| 578 | int graph_load_from_desc3(AVFilterContext *ctx, AVFilterGraphDesc *desc, AVFilterContext *in, int inpad, AVFilterContext *out, int outpad) | ||
| 579 | { | ||
| 580 | AVFilterGraphDescExport *curpad; | ||
| 581 | char tmp[20]; | ||
| 582 | AVFilterContext *filt; | ||
| 583 | |||
| 584 | if (graph_load_from_desc2(ctx, desc) < 0) | ||
| 585 | goto fail; | ||
| 586 | |||
| 587 | /* export all input pads */ | ||
| 588 | for(curpad = desc->inputs; curpad; curpad = curpad->next) { | ||
| 589 | snprintf(tmp, 20, "%d", curpad->filter); | ||
| 590 | if(!(filt = avfilter_graph_get_filter(ctx, tmp))) { | ||
| 591 | av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n"); | ||
| 592 | goto fail; | ||
| 593 | } | ||
| 594 | if(avfilter_link(in, inpad, filt, curpad->pad)) { | ||
| 595 | av_log(ctx, AV_LOG_ERROR, "cannot create link between source and destination filters\n"); | ||
| 596 | goto fail; | ||
| 597 | } | ||
| 598 | } | ||
| 599 | |||
| 600 | /* export all output pads */ | ||
| 601 | for(curpad = desc->outputs; curpad; curpad = curpad->next) { | ||
| 602 | snprintf(tmp, 20, "%d", curpad->filter); | ||
| 603 | if(!(filt = avfilter_graph_get_filter(ctx, tmp))) { | ||
| 604 | av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n"); | ||
| 605 | goto fail; | ||
| 606 | } | ||
| 607 | |||
| 608 | if(avfilter_link(filt, curpad->pad, out, outpad)) { | ||
| 609 | av_log(ctx, AV_LOG_ERROR, "cannot create link between source and destination filters\n"); | ||
| 610 | goto fail; | ||
| 611 | } | ||
| 612 | } | ||
| 613 | |||
| 614 | return 0; | ||
| 615 | |||
| 616 | fail: | ||
| 617 | uninit(ctx); | ||
| 618 | return -1; | ||
| 619 | } | ||
| 620 | |||
| 563 | static int init(AVFilterContext *ctx, const char *args, void *opaque) | 621 | static int init(AVFilterContext *ctx, const char *args, void *opaque) |
| 564 | { | 622 | { |
| 565 | GraphContext *gctx = ctx->priv; | 623 | GraphContext *gctx = ctx->priv; |