Functional as is, but still work-in-progress in the sense that some things need to be fixed before sending it as a patch to SVN. Commited in SoC by Vitor Sessak on 2008-03-20 21:48:30 Originally committed as revision 12729 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/avfiltergraph.c (1 of 2 files). Show all
Unified · Split
| @@ -463,9 +463,7 @@ static void pick_formats(GraphContext *graph) · 462 unmodified lines | ||
| 463 | 463 | for(i = 0; i < graph->filter_count; i ++) { |
| 464 | 464 | AVFilterContext *filter = graph->filters[i]; |
| 465 | 465 | |
| 466 | − if(filter->filter == &avfilter_vf_graph || | |
| 467 | − filter->filter == &avfilter_vf_graphfile || | |
| 468 | − filter->filter == &avfilter_vf_graphdesc) | |
| 466 | + if(filter->filter == &avfilter_vf_graph) | |
| 469 | 467 | pick_formats(filter->priv); |
| 470 | 468 | |
| 471 | 469 | for(j = 0; j < filter->input_count; j ++) |
| @@ -498,30 +496,34 @@ static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) · 26 unmodified lines | ||
| 498 | 496 | AVFilterContext *filt, *filtb; |
| 499 | 497 | |
| 500 | 498 | AVFilter *filterdef; |
| 499 | + char tmp[20]; | |
| 501 | 500 | |
| 502 | 501 | /* create all filters */ |
| 503 | 502 | for(curfilt = desc->filters; curfilt; curfilt = curfilt->next) { |
| 503 | + snprintf(tmp, 20, "%d", curfilt->index); | |
| 504 | 504 | if(!(filterdef = avfilter_get_by_name(curfilt->filter)) || |
| 505 | − !(filt = avfilter_open(filterdef, curfilt->name))) { | |
| 505 | + !(filt = avfilter_open(filterdef, tmp))) { | |
| 506 | 506 | av_log(ctx, AV_LOG_ERROR, |
| 507 | − "error creating filter '%s'\n", curfilt->name); | |
| 507 | + "error creating filter '%s'\n", curfilt->filter); | |
| 508 | 508 | goto fail; |
| 509 | 509 | } |
| 510 | 510 | avfilter_graph_add_filter(ctx, filt); |
| 511 | 511 | if(avfilter_init_filter(filt, curfilt->args, NULL)) { |
| 512 | 512 | av_log(ctx, AV_LOG_ERROR, |
| 513 | − "error initializing filter '%s'\n", curfilt->name); | |
| 513 | + "error initializing filter '%s'\n", curfilt->filter); | |
| 514 | 514 | goto fail; |
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /* create all links */ |
| 519 | 519 | for(curlink = desc->links; curlink; curlink = curlink->next) { |
| 520 | − if(!(filt = avfilter_graph_get_filter(ctx, curlink->src))) { | |
| 520 | + snprintf(tmp, 20, "%d", curlink->src); | |
| 521 | + if(!(filt = avfilter_graph_get_filter(ctx, tmp))) { | |
| 521 | 522 | av_log(ctx, AV_LOG_ERROR, "link source does not exist in graph\n"); |
| 522 | 523 | goto fail; |
| 523 | 524 | } |
| 524 | − if(!(filtb = avfilter_graph_get_filter(ctx, curlink->dst))) { | |
| 525 | + snprintf(tmp, 20, "%d", curlink->dst); | |
| 526 | + if(!(filtb = avfilter_graph_get_filter(ctx, tmp))) { | |
| 525 | 527 | av_log(ctx, AV_LOG_ERROR, "link destination does not exist in graph\n"); |
| 526 | 528 | goto fail; |
| 527 | 529 | } |
| @@ -533,7 +535,8 @@ static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) · 5 unmodified lines | ||
| 533 | 535 | |
| 534 | 536 | /* export all input pads */ |
| 535 | 537 | for(curpad = desc->inputs; curpad; curpad = curpad->next) { |
| 536 | − if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) { | |
| 538 | + snprintf(tmp, 20, "%d", curpad->filter); | |
| 539 | + if(!(filt = avfilter_graph_get_filter(ctx, tmp))) { | |
| 537 | 540 | av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n"); |
| 538 | 541 | goto fail; |
| 539 | 542 | } |
| @@ -542,7 +545,8 @@ static int graph_load_from_desc(AVFilterContext *ctx, AVFilterGraphDesc *desc) · 2 unmodified lines | ||
| 542 | 545 | |
| 543 | 546 | /* export all output pads */ |
| 544 | 547 | for(curpad = desc->outputs; curpad; curpad = curpad->next) { |
| 545 | − if(!(filt = avfilter_graph_get_filter(ctx, curpad->filter))) { | |
| 548 | + snprintf(tmp, 20, "%d", curpad->filter); | |
| 549 | + if(!(filt = avfilter_graph_get_filter(ctx, tmp))) { | |
| 546 | 550 | av_log(ctx, AV_LOG_ERROR, "filter owning exported pad does not exist\n"); |
| 547 | 551 | goto fail; |
| 548 | 552 | } |
| @@ -603,73 +607,3 @@ AVFilter avfilter_vf_graph = · 54 unmodified lines | ||
| 603 | 607 | .outputs = (AVFilterPad[]) {{ .name = NULL, }}, |
| 604 | 608 | }; |
| 605 | 609 | |
| 606 | −static int init_desc(AVFilterContext *ctx, const char *args, void *opaque) | |
| 607 | −{ | |
| 608 | − GraphContext *gctx = ctx->priv; | |
| 609 | − | |
| 610 | − if(!opaque) | |
| 611 | − return -1; | |
| 612 | − | |
| 613 | − if(!(gctx->link_filter_in = avfilter_open(&vf_graph_dummy, NULL))) | |
| 614 | − return -1; | |
| 615 | − if(avfilter_init_filter(gctx->link_filter_in, NULL, ctx)) | |
| 616 | − goto fail; | |
| 617 | − if(!(gctx->link_filter_out = avfilter_open(&vf_graph_dummy, NULL))) | |
| 618 | − goto fail; | |
| 619 | − if(avfilter_init_filter(gctx->link_filter_out, NULL, ctx)) | |
| 620 | − goto fail; | |
| 621 | − | |
| 622 | − return graph_load_from_desc(ctx, opaque); | |
| 623 | − | |
| 624 | −fail: | |
| 625 | − avfilter_destroy(gctx->link_filter_in); | |
| 626 | − if(gctx->link_filter_out) | |
| 627 | − avfilter_destroy(gctx->link_filter_out); | |
| 628 | − return -1; | |
| 629 | −} | |
| 630 | − | |
| 631 | −AVFilter avfilter_vf_graphdesc = | |
| 632 | −{ | |
| 633 | − .name = "graph_desc", | |
| 634 | − | |
| 635 | − .priv_size = sizeof(GraphContext), | |
| 636 | − | |
| 637 | − .init = init_desc, | |
| 638 | − .uninit = uninit, | |
| 639 | − | |
| 640 | − .query_formats = query_formats, | |
| 641 | − | |
| 642 | − .inputs = (AVFilterPad[]) {{ .name = NULL, }}, | |
| 643 | − .outputs = (AVFilterPad[]) {{ .name = NULL, }}, | |
| 644 | −}; | |
| 645 | − | |
| 646 | −static int init_file(AVFilterContext *ctx, const char *args, void *opaque) | |
| 647 | −{ | |
| 648 | − AVFilterGraphDesc *desc; | |
| 649 | − int ret; | |
| 650 | − | |
| 651 | − if(!args) | |
| 652 | − return -1; | |
| 653 | − if(!(desc = avfilter_graph_load_desc(args))) | |
| 654 | − return -1; | |
| 655 | − | |
| 656 | − ret = init_desc(ctx, NULL, desc); | |
| 657 | − avfilter_graph_free_desc(desc); | |
| 658 | − return ret; | |
| 659 | −} | |
| 660 | − | |
| 661 | −AVFilter avfilter_vf_graphfile = | |
| 662 | −{ | |
| 663 | − .name = "graph_file", | |
| 664 | − | |
| 665 | − .priv_size = sizeof(GraphContext), | |
| 666 | − | |
| 667 | − .init = init_file, | |
| 668 | − .uninit = uninit, | |
| 669 | − | |
| 670 | − .query_formats = query_formats, | |
| 671 | − | |
| 672 | − .inputs = (AVFilterPad[]) {{ .name = NULL, }}, | |
| 673 | − .outputs = (AVFilterPad[]) {{ .name = NULL, }}, | |
| 674 | −}; | |
| 675 | − | |