Revision 45a09319 libavfilter/avfiltergraph.c

View differences:

libavfilter/avfiltergraph.c
488 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 493
    AVFilterGraphDescFilter *curfilt;
494 494
    AVFilterGraphDescLink   *curlink;
495
    AVFilterGraphDescExport *curpad;
496 495
    AVFilterContext *filt, *filtb;
497 496

  
498 497
    AVFilter *filterdef;
......
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 551
    /* export all input pads */
537 552
    for(curpad = desc->inputs; curpad; curpad = curpad->next) {
538 553
        snprintf(tmp, 20, "%d", curpad->filter);
......
560 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 621
static int init(AVFilterContext *ctx, const char *args, void *opaque)
564 622
{
565 623
    GraphContext *gctx = ctx->priv;

Also available in: Unified diff