]> granicus.if.org Git - libvpx/commitdiff
Respect MV limit in vp9_int_pro_motion_estimation()
authorHui Su <huisu@google.com>
Thu, 26 Apr 2018 20:31:43 +0000 (13:31 -0700)
committerHui Su <huisu@google.com>
Thu, 26 Apr 2018 20:59:42 +0000 (13:59 -0700)
Change-Id: I08cb072a32e06c6452eca068b2f7ef7287f221e6

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_mcomp.c
vp9/encoder/vp9_mcomp.h
vp9/encoder/vp9_pickmode.c

index a283d92a889f00dbde761494787da50a4fb8e9d9..fa93c16305234e81a8bdf4eca0d9df191de20198 100644 (file)
@@ -1387,7 +1387,9 @@ static int choose_partitioning(VP9_COMP *cpi, const TileInfo *const tile,
           x->plane[0].src.buf, x->plane[0].src.stride, xd->plane[0].pre[0].buf,
           xd->plane[0].pre[0].stride);
     } else {
-      y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col);
+      const MV dummy_mv = { 0, 0 };
+      y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col,
+                                            &dummy_mv);
       x->sb_use_mv_part = 1;
       x->sb_mvcol_part = mi->mv[0].as_mv.col;
       x->sb_mvrow_part = mi->mv[0].as_mv.row;
index 1cb978667b56ec0a7d373d296e1140322d8470ec..b42e4c4ea6e6a75ce9e3581a562af6c7f25c4ace 100644 (file)
@@ -1793,7 +1793,7 @@ static const MV search_pos[4] = {
 
 unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
                                            BLOCK_SIZE bsize, int mi_row,
-                                           int mi_col) {
+                                           int mi_col, const MV *ref_mv) {
   MACROBLOCKD *xd = &x->e_mbd;
   MODE_INFO *mi = xd->mi[0];
   struct buf_2d backup_yv12[MAX_MB_PLANE] = { { 0, 0 } };
@@ -1815,6 +1815,7 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
   const int norm_factor = 3 + (bw >> 5);
   const YV12_BUFFER_CONFIG *scaled_ref_frame =
       vp9_get_scaled_ref_frame(cpi, mi->ref_frame[0]);
+  MvLimits subpel_mv_limits;
 
   if (scaled_ref_frame) {
     int i;
@@ -1917,6 +1918,10 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
   tmp_mv->row *= 8;
   tmp_mv->col *= 8;
 
+  vp9_set_subpel_mv_search_range(&subpel_mv_limits, &x->mv_limits, ref_mv);
+  clamp_mv(tmp_mv, subpel_mv_limits.col_min, subpel_mv_limits.col_max,
+           subpel_mv_limits.row_min, subpel_mv_limits.row_max);
+
   if (scaled_ref_frame) {
     int i;
     for (i = 0; i < MAX_MB_PLANE; i++) xd->plane[i].pre[0] = backup_yv12[i];
index b8db2c353688fb78a18675ab382bfc86d9a6c90c..b4787fe1fc5ab2d51159e51f9baaf240a1bb36ab 100644 (file)
@@ -66,7 +66,8 @@ int vp9_refining_search_sad(const struct macroblock *x, struct mv *ref_mv,
 // Perform integral projection based motion estimation.
 unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi,
                                            MACROBLOCK *x, BLOCK_SIZE bsize,
-                                           int mi_row, int mi_col);
+                                           int mi_row, int mi_col,
+                                           const MV *ref_mv);
 
 typedef uint32_t(fractional_mv_step_fp)(
     const MACROBLOCK *x, MV *bestmv, const MV *ref_mv, int allow_hp,
index 3aee4663683a0ea236b27ad4155d6e8a682d81bc..ccff24ca061ec0cb78ade6ce44fa48485541f582 100644 (file)
@@ -1886,7 +1886,9 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data,
 
         if (bsize < BLOCK_16X16) continue;
 
-        tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col);
+        tmp_sad = vp9_int_pro_motion_estimation(
+            cpi, x, bsize, mi_row, mi_col,
+            &x->mbmi_ext->ref_mvs[ref_frame][0].as_mv);
 
         if (tmp_sad > x->pred_mv_sad[LAST_FRAME]) continue;
         if (tmp_sad + (num_pels_log2_lookup[bsize] << 4) > best_pred_sad)