]> granicus.if.org Git - libvpx/commitdiff
added clamp for 2nd motion vector
authorYaowu Xu <yaowu@google.com>
Tue, 13 Mar 2012 17:26:53 +0000 (10:26 -0700)
committerYaowu Xu <yaowu@google.com>
Thu, 15 Mar 2012 14:49:52 +0000 (07:49 -0700)
The commit added a clamp to the 2nd motion vector used in compound
prediction to insure mv within UMV borders. The clamp is similar to
that of the first motion vector except that No SPLITMV is ever used
for the 2nd motion vector.

Change-Id: I26dd63c304bd66b2e03a083749cc98c641667116

vp8/common/blockd.h
vp8/common/reconinter.c
vp8/decoder/decodemv.c

index 89fe03516c3ade51aa746cd58b9aa0dcb4ce5d28..88773e9026f05524af37ada4986ade6c8d96b136 100644 (file)
@@ -188,6 +188,7 @@ typedef struct
     unsigned char partitioning;
     unsigned char mb_skip_coeff;                                /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
     unsigned char need_to_clamp_mvs;
+    unsigned char need_to_clamp_secondmv;
     unsigned char segment_id;                  /* Which set of segmentation parameters should be used for this MB */
 
     // Flags used for prediction status of various bistream signals
index bd08e7f2c2f6855f463b2f69e5774b597fdce383..ebcc665d512366812c3a856fc59608fbf779523c 100644 (file)
@@ -541,13 +541,25 @@ void vp8_build_2nd_inter16x16_predictors_mb(MACROBLOCKD *x,
     unsigned char *ptr;
     unsigned char *uptr, *vptr;
 
-    int mv_row = x->mode_info_context->mbmi.second_mv.as_mv.row;
-    int mv_col = x->mode_info_context->mbmi.second_mv.as_mv.col;
+    int_mv _16x16mv;
+    int mv_row;
+    int mv_col;
+
     int omv_row, omv_col;
 
     unsigned char *ptr_base = x->second_pre.y_buffer;
     int pre_stride = x->block[0].pre_stride;
 
+    _16x16mv.as_int = x->mode_info_context->mbmi.second_mv.as_int;
+
+    if (x->mode_info_context->mbmi.need_to_clamp_secondmv)
+    {
+        clamp_mv_to_umv_border(&_16x16mv.as_mv, x);
+    }
+
+    mv_row = _16x16mv.as_mv.row;
+    mv_col = _16x16mv.as_mv.col;
+
     ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
 
     if ((mv_row | mv_col) & 7)
index 8539ff25c8ecf3361c5006e60ac32f2c4cb18f71..07e4c90397fbf4dcbf917aa9a03b4e03ca33d6c8 100644 (file)
@@ -656,6 +656,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
     mb_to_top_edge -= LEFT_TOP_MARGIN;
     mb_to_bottom_edge += RIGHT_BOTTOM_MARGIN;
     mbmi->need_to_clamp_mvs = 0;
+    mbmi->need_to_clamp_secondmv = 0;
     mbmi->second_ref_frame = 0;
     /* Distance of Mb to the various image edges.
      * These specified to 8th pel as they are always compared to MV values that are in 1/8th pel units
@@ -894,7 +895,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
                     read_mv(bc, &mbmi->second_mv.as_mv, (const MV_CONTEXT *) mvc);
                     mbmi->second_mv.as_mv.row += best_mv.as_mv.row;
                     mbmi->second_mv.as_mv.col += best_mv.as_mv.col;
-                    mbmi->need_to_clamp_mvs |= vp8_check_mv_bounds(&mbmi->second_mv,
+                    mbmi->need_to_clamp_secondmv = vp8_check_mv_bounds(&mbmi->second_mv,
                                                                    mb_to_left_edge,
                                                                    mb_to_right_edge,
                                                                    mb_to_top_edge,