Revision ace38c36

View differences:

libavcodec/indeo5.c
57 57
    IVIPlaneDesc    planes[3];       ///< color planes
58 58
    const uint8_t   *frame_data;     ///< input frame data pointer
59 59
    int             buf_switch;      ///< used to switch between three buffers
60
    int             inter_scal;      ///< signals a sequence of scalable inter frames
60 61
    int             dst_buf;         ///< buffer index for the currently decoded frame
61 62
    int             ref_buf;         ///< inter frame reference buffer index
63
    int             ref2_buf;        ///< temporal storage for switching buffers
62 64
    uint32_t        frame_size;      ///< frame size in bytes
63 65
    int             frame_type;
64 66
    int             prev_frame_type; ///< frame type of the previous frame
......
648 650
 */
649 651
static void switch_buffers(IVI5DecContext *ctx, AVCodecContext *avctx)
650 652
{
651
    switch (ctx->frame_type) {
653
    switch (ctx->prev_frame_type) {
652 654
    case FRAMETYPE_INTRA:
653
        ctx->buf_switch = 0;
654
        ctx->dst_buf    = 0;
655
        ctx->ref_buf    = 0;
656
        break;
657 655
    case FRAMETYPE_INTER:
658
        ctx->buf_switch &= 1;
659
        /* swap buffers only if there were no droppable frames */
660
        if (ctx->prev_frame_type != FRAMETYPE_INTER_NOREF &&
661
            ctx->prev_frame_type != FRAMETYPE_INTER_SCAL)
662
            ctx->buf_switch ^= 1;
656
        ctx->buf_switch ^= 1;
663 657
        ctx->dst_buf = ctx->buf_switch;
664 658
        ctx->ref_buf = ctx->buf_switch ^ 1;
665 659
        break;
666 660
    case FRAMETYPE_INTER_SCAL:
667
        if (ctx->prev_frame_type == FRAMETYPE_INTER_NOREF)
668
            break;
669
        if (ctx->prev_frame_type != FRAMETYPE_INTER_SCAL) {
670
            ctx->buf_switch ^= 1;
671
            ctx->dst_buf     = ctx->buf_switch;
672
            ctx->ref_buf     = ctx->buf_switch ^ 1;
673
        } else {
674
            ctx->buf_switch ^= 2;
675
            ctx->dst_buf = 2;
676
            ctx->ref_buf = ctx->buf_switch & 1;
677
            if (!(ctx->buf_switch & 2))
678
                FFSWAP(int, ctx->dst_buf, ctx->ref_buf);
661
        if (!ctx->inter_scal) {
662
            ctx->ref2_buf   = 2;
663
            ctx->inter_scal = 1;
679 664
        }
665
        FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
666
        ctx->ref_buf = ctx->ref2_buf;
680 667
        break;
681 668
    case FRAMETYPE_INTER_NOREF:
682
        if (ctx->prev_frame_type == FRAMETYPE_INTER_SCAL) {
683
            ctx->buf_switch ^= 2;
684
            ctx->dst_buf = 2;
685
            ctx->ref_buf = ctx->buf_switch & 1;
686
            if (!(ctx->buf_switch & 2))
687
                FFSWAP(int, ctx->dst_buf, ctx->ref_buf);
688
        } else {
689
            ctx->buf_switch ^= 1;
690
            ctx->dst_buf     =  ctx->buf_switch & 1;
691
            ctx->ref_buf     = (ctx->buf_switch & 1) ^ 1;
692
        }
693 669
        break;
670
    }
671

  
672
    switch (ctx->frame_type) {
673
    case FRAMETYPE_INTRA:
674
        ctx->buf_switch = 0;
675
        /* FALLTHROUGH */
676
    case FRAMETYPE_INTER:
677
        ctx->inter_scal = 0;
678
        ctx->dst_buf = ctx->buf_switch;
679
        ctx->ref_buf = ctx->buf_switch ^ 1;
680
        break;
681
    case FRAMETYPE_INTER_SCAL:
682
    case FRAMETYPE_INTER_NOREF:
694 683
    case FRAMETYPE_NULL:
695
        return;
696
    default:
697
        av_log(avctx, AV_LOG_ERROR, "unsupported frame type: %d\n", ctx->frame_type);
684
        break;
698 685
    }
699 686
}
700 687

  
......
729 716
        return -1;
730 717
    }
731 718

  
719
    ctx->buf_switch = 0;
720
    ctx->inter_scal = 0;
721

  
732 722
    avctx->pix_fmt = PIX_FMT_YUV410P;
733 723

  
734 724
    return 0;
......
766 756

  
767 757
    //START_TIMER;
768 758

  
769
    if (ctx->frame_type == FRAMETYPE_NULL) {
770
        ctx->frame_type = ctx->prev_frame_type;
771
    } else {
759
    if (ctx->frame_type != FRAMETYPE_NULL) {
772 760
        for (p = 0; p < 3; p++) {
773 761
            for (b = 0; b < ctx->planes[p].num_bands; b++) {
774 762
                result = decode_band(ctx, p, &ctx->planes[p].bands[b], avctx);

Also available in: Unified diff