Revision a9f3cb93

View differences:

ffmpeg.c
398 398

  
399 399
static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
400 400
{
401
    AVFilterContext *curr_filter;
401
    AVFilterContext *last_filter, *filter;
402 402
    /** filter graph containing all filters including input & output */
403 403
    AVCodecContext *codec = ost->st->codec;
404 404
    AVCodecContext *icodec = ist->st->codec;
......
422 422
    avfilter_graph_add_filter(graph, ist->input_video_filter);
423 423
    avfilter_graph_add_filter(graph, ist->out_video_filter);
424 424

  
425
    curr_filter = ist->input_video_filter;
425
    last_filter = ist->input_video_filter;
426 426

  
427 427
    if (ost->video_crop) {
428
        AVFilterContext *filt_crop;
429 428
        snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand,
430 429
                 codec->width,
431 430
                 codec->height);
432
        filt_crop = avfilter_open(avfilter_get_by_name("crop"), NULL);
433
        if (!filt_crop)
431
        filter = avfilter_open(avfilter_get_by_name("crop"), NULL);
432
        if (!filter)
434 433
            return -1;
435
        if (avfilter_init_filter(filt_crop, args, NULL))
434
        if (avfilter_init_filter(filter, args, NULL))
436 435
            return -1;
437
        if (avfilter_link(curr_filter, 0, filt_crop, 0))
436
        if (avfilter_link(last_filter, 0, filter, 0))
438 437
            return -1;
439
        curr_filter = filt_crop;
440
        avfilter_graph_add_filter(graph, curr_filter);
438
        last_filter = filter;
439
        avfilter_graph_add_filter(graph, last_filter);
441 440
    }
442 441

  
443 442
    if((codec->width !=
444 443
        icodec->width - (frame_leftBand + frame_rightBand)) ||
445 444
       (codec->height != icodec->height - (frame_topBand  + frame_bottomBand))) {
446
        AVFilterContext *filt_scale;
447 445
        snprintf(args, 255, "%d:%d:flags=0x%X",
448 446
                 codec->width,
449 447
                 codec->height,
450 448
                 (int)av_get_int(sws_opts, "sws_flags", NULL));
451
        filt_scale = avfilter_open(avfilter_get_by_name("scale"), NULL);
452
        if (!filt_scale)
449
        filter = avfilter_open(avfilter_get_by_name("scale"), NULL);
450
        if (!filter)
453 451
            return -1;
454
        if (avfilter_init_filter(filt_scale, args, NULL))
452
        if (avfilter_init_filter(filter, args, NULL))
455 453
            return -1;
456
        if (avfilter_link(curr_filter, 0, filt_scale, 0))
454
        if (avfilter_link(last_filter, 0, filter, 0))
457 455
            return -1;
458
        curr_filter = filt_scale;
459
        avfilter_graph_add_filter(graph, curr_filter);
456
        last_filter = filter;
457
        avfilter_graph_add_filter(graph, last_filter);
460 458
    }
461 459

  
462 460
    if (vfilters) {
......
464 462
        AVFilterInOut *inputs  = av_malloc(sizeof(AVFilterInOut));
465 463

  
466 464
        outputs->name    = av_strdup("in");
467
        outputs->filter  = curr_filter;
465
        outputs->filter  = last_filter;
468 466
        outputs->pad_idx = 0;
469 467
        outputs->next    = NULL;
470 468

  
......
477 475
            return -1;
478 476
        av_freep(&vfilters);
479 477
    } else {
480
        if (avfilter_link(curr_filter, 0, ist->out_video_filter, 0) < 0)
478
        if (avfilter_link(last_filter, 0, ist->out_video_filter, 0) < 0)
481 479
            return -1;
482 480
    }
483 481

  

Also available in: Unified diff