Revision 7634771e libavcodec/vp8.c

View differences:

libavcodec/vp8.c
125 125

  
126 126
    int chroma_pred_mode;    ///< 8x8c pred mode of the current macroblock
127 127
    int segment;             ///< segment of the current macroblock
128
    VP56mv mv_min;
129
    VP56mv mv_max;
128 130

  
129 131
    int mbskip_enabled;
130 132
    int sign_bias[4]; ///< one state [0, 1] per ref frame type
......
522 524
    return 0;
523 525
}
524 526

  
525
static av_always_inline
526
void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src, int mb_x, int mb_y)
527
static av_always_inline void clamp_mv(VP8Context *s, VP56mv *dst, const VP56mv *src)
527 528
{
528
#define MARGIN (16 << 2)
529
    dst->x = av_clip(src->x, -((mb_x << 6) + MARGIN),
530
                     ((s->mb_width  - 1 - mb_x) << 6) + MARGIN);
531
    dst->y = av_clip(src->y, -((mb_y << 6) + MARGIN),
532
                     ((s->mb_height - 1 - mb_y) << 6) + MARGIN);
529
    dst->x = av_clip(src->x, s->mv_min.x, s->mv_max.x);
530
    dst->y = av_clip(src->y, s->mv_min.y, s->mv_max.y);
533 531
}
534 532

  
535 533
/**
......
703 701
            if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
704 702

  
705 703
                /* Choose the best mv out of 0,0 and the nearest mv */
706
                clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])], mb_x, mb_y);
704
                clamp_mv(s, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
707 705
                cnt[CNT_SPLITMV] = ((mb_edge[EDGE_LEFT]->mode    == VP8_MVMODE_SPLIT) +
708 706
                                    (mb_edge[EDGE_TOP]->mode     == VP8_MVMODE_SPLIT)) * 2 +
709 707
                                    (mb_edge[EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
......
717 715
                    mb->bmv[0] = mb->mv;
718 716
                }
719 717
            } else {
720
                clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR], mb_x, mb_y);
718
                clamp_mv(s, &mb->mv, &near_mv[CNT_NEAR]);
721 719
                mb->bmv[0] = mb->mv;
722 720
            }
723 721
        } else {
724
            clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST], mb_x, mb_y);
722
            clamp_mv(s, &mb->mv, &near_mv[CNT_NEAREST]);
725 723
            mb->bmv[0] = mb->mv;
726 724
        }
727 725
    } else {
......
1707 1705
    if (s->keyframe)
1708 1706
        memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4);
1709 1707

  
1708
    #define MARGIN (16 << 2)
1709
    s->mv_min.y = -MARGIN;
1710
    s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
1711

  
1710 1712
    for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1711 1713
        VP56RangeCoder *c = &s->coeff_partition[mb_y & (s->num_coeff_partitions-1)];
1712 1714
        VP8Macroblock *mb = s->macroblocks + (s->mb_height - mb_y - 1)*2;
......
1730 1732
                s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
1731 1733
        }
1732 1734

  
1735
        s->mv_min.x = -MARGIN;
1736
        s->mv_max.x = ((s->mb_width  - 1) << 6) + MARGIN;
1737

  
1733 1738
        for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
1734 1739
            /* Prefetch the current frame, 4 MBs ahead */
1735 1740
            s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4);
......
1770 1775
            dst[0] += 16;
1771 1776
            dst[1] += 8;
1772 1777
            dst[2] += 8;
1778
            s->mv_min.x -= 64;
1779
            s->mv_max.x -= 64;
1773 1780
        }
1774 1781
        if (s->deblock_filter) {
1775 1782
            if (s->filter.simple)
......
1777 1784
            else
1778 1785
                filter_mb_row(s, mb_y);
1779 1786
        }
1787
        s->mv_min.y -= 64;
1788
        s->mv_max.y -= 64;
1780 1789
    }
1781 1790

  
1782 1791
skip_decode:

Also available in: Unified diff