shithub: libvpx

Download patch

ref: 9239e96536d521c2aee128edd33bd7e1fe783a26
parent: 3be9fd912086d396edb8ea0b9055f151e6ee4354
author: Dmitry Kovalev <[email protected]>
date: Wed Jul 31 07:58:00 EDT 2013

Removing get_mi_{row, col} functions.

Passing mi_row and mi_col parameters to functions explicitly. Removing
unused xd argument from scale_mv function.

Change-Id: Icb4c495ec72d26fb066c14470d3ae0b741fbf18a

--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -41,7 +41,8 @@
 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
                                    int_mv *dst_nearest,
                                    int_mv *dst_near,
-                                   int block_idx, int ref_idx) {
+                                   int block_idx, int ref_idx,
+                                   int mi_row, int mi_col) {
   int_mv dst_list[MAX_MV_REF_CANDIDATES];
   int_mv mv_list[MAX_MV_REF_CANDIDATES];
   MODE_INFO *mi = xd->mode_info_context;
@@ -53,7 +54,8 @@
   vp9_find_mv_refs_idx(cm, xd, xd->mode_info_context,
                        xd->prev_mode_info_context,
                        mbmi->ref_frame[ref_idx],
-                       mv_list, cm->ref_frame_sign_bias, block_idx);
+                       mv_list, cm->ref_frame_sign_bias, block_idx,
+                       mi_row, mi_col);
 
   dst_list[1].as_int = 0;
   if (block_idx == 0) {
--- a/vp9/common/vp9_findnearmv.h
+++ b/vp9/common/vp9_findnearmv.h
@@ -53,7 +53,8 @@
                                    MACROBLOCKD *xd,
                                    int_mv *dst_nearest,
                                    int_mv *dst_near,
-                                   int block_idx, int ref_idx);
+                                   int block_idx, int ref_idx,
+                                   int mi_row, int mi_col);
 
 static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
   // FIXME(rbultje, jingning): temporary hack because jenkins doesn't
--- a/vp9/common/vp9_mvref_common.c
+++ b/vp9/common/vp9_mvref_common.c
@@ -105,7 +105,7 @@
 
 
 // Performs mv sign inversion if indicated by the reference frame combination.
-static void scale_mv(MACROBLOCKD *xd, MV_REFERENCE_FRAME this_ref_frame,
+static void scale_mv(MV_REFERENCE_FRAME this_ref_frame,
                      MV_REFERENCE_FRAME candidate_ref_frame,
                      int_mv *candidate_mv, int *ref_sign_bias) {
 
@@ -139,10 +139,10 @@
 void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
                           MODE_INFO *lf_here, MV_REFERENCE_FRAME ref_frame,
                           int_mv *mv_ref_list, int *ref_sign_bias,
-                          int block_idx) {
+                          int block_idx, int mi_row, int mi_col) {
   int i;
   MODE_INFO *candidate_mi;
-  MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
+  MB_MODE_INFO *mbmi = &here->mbmi;
   int_mv c_refmv;
   int_mv c2_refmv;
   MV_REFERENCE_FRAME c_ref_frame;
@@ -150,8 +150,7 @@
   int candidate_scores[MAX_MV_REF_CANDIDATES] = { 0 };
   int refmv_count = 0;
   const int (*mv_ref_search)[2] = mv_ref_blocks[mbmi->sb_type];
-  const int mi_col = get_mi_col(xd);
-  const int mi_row = get_mi_row(xd);
+  const int mi_stride = cm->mode_info_stride;
   int intra_count = 0;
   int zero_count = 0;
   int newmv_count = 0;
@@ -176,7 +175,7 @@
       int b;
 
       candidate_mi = here + mv_ref_search[i][0] +
-                     (mv_ref_search[i][1] * xd->mode_info_stride);
+                     mi_stride * mv_ref_search[i][1];
 
       if (block_idx >= 0) {
         if (mv_ref_search[i][0])
@@ -186,13 +185,12 @@
       } else {
         b = -1;
       }
-      if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, b)) {
-        add_candidate_mv(mv_ref_list, candidate_scores,
-                         &refmv_count, c_refmv, 16);
-      }
+      if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, b))
+        add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv,
+                         16);
 
       // Count number of neihgbours coded intra and zeromv
-      intra_count += (candidate_mi->mbmi.mode < NEARESTMV);
+      intra_count += is_intra_mode(candidate_mi->mbmi.mode);
       zero_count += (candidate_mi->mbmi.mode == ZEROMV);
       newmv_count += (candidate_mi->mbmi.mode >= NEWMV);
     }
@@ -203,16 +201,16 @@
               (refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
     const int mi_search_col = mi_col + mv_ref_search[i][0];
     const int mi_search_row = mi_row + mv_ref_search[i][1];
-    if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
-        (mi_search_col < cm->cur_tile_mi_col_end) &&
-        (mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) {
+    if (mi_search_col >= cm->cur_tile_mi_col_start &&
+        mi_search_col < cm->cur_tile_mi_col_end &&
+        mi_search_row >= 0 &&
+        mi_search_row < cm->mi_rows) {
       candidate_mi = here + mv_ref_search[i][0] +
-                     (mv_ref_search[i][1] * xd->mode_info_stride);
+                     mi_stride * mv_ref_search[i][1];
 
-      if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) {
-        add_candidate_mv(mv_ref_list, candidate_scores,
-                         &refmv_count, c_refmv, 16);
-      }
+      if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1))
+        add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv,
+                         16);
     }
   }
 
@@ -219,10 +217,9 @@
   // Look in the last frame if it exists
   if (lf_here && (refmv_count < MAX_MV_REF_CANDIDATES)) {
     candidate_mi = lf_here;
-    if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) {
-      add_candidate_mv(mv_ref_list, candidate_scores,
-                       &refmv_count, c_refmv, 16);
-    }
+    if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1))
+      add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv,
+                       16);
   }
 
   // If we have not found enough candidates consider ones where the
@@ -233,11 +230,12 @@
               (refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
     const int mi_search_col = mi_col + mv_ref_search[i][0];
     const int mi_search_row = mi_row + mv_ref_search[i][1];
-    if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
-        (mi_search_col < cm->cur_tile_mi_col_end) &&
-        (mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) {
+    if (mi_search_col >= cm->cur_tile_mi_col_start &&
+        mi_search_col < cm->cur_tile_mi_col_end &&
+        mi_search_row >= 0 &&
+        mi_search_row < cm->mi_rows) {
       candidate_mi = here + mv_ref_search[i][0] +
-                     (mv_ref_search[i][1] * xd->mode_info_stride);
+                     mi_stride * mv_ref_search[i][1];
 
       get_non_matching_candidates(candidate_mi, ref_frame,
                                   &c_ref_frame, &c_refmv,
@@ -244,13 +242,13 @@
                                   &c2_ref_frame, &c2_refmv);
 
       if (c_ref_frame != INTRA_FRAME) {
-        scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
+        scale_mv(ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
         add_candidate_mv(mv_ref_list, candidate_scores,
                          &refmv_count, c_refmv, 1);
       }
 
       if (c2_ref_frame != INTRA_FRAME) {
-        scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
+        scale_mv(ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
         add_candidate_mv(mv_ref_list, candidate_scores,
                          &refmv_count, c2_refmv, 1);
       }
@@ -265,13 +263,13 @@
                                 &c2_ref_frame, &c2_refmv);
 
     if (c_ref_frame != INTRA_FRAME) {
-      scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
+      scale_mv(ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
       add_candidate_mv(mv_ref_list, candidate_scores,
                        &refmv_count, c_refmv, 1);
     }
 
     if (c2_ref_frame != INTRA_FRAME) {
-      scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
+      scale_mv(ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
       add_candidate_mv(mv_ref_list, candidate_scores,
                        &refmv_count, c2_refmv, 1);
     }
@@ -295,7 +293,6 @@
   }
 
   // Clamp vectors
-  for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
+  for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i)
     clamp_mv_ref(xd, &mv_ref_list[i]);
-  }
 }
--- a/vp9/common/vp9_mvref_common.h
+++ b/vp9/common/vp9_mvref_common.h
@@ -21,7 +21,8 @@
                           MV_REFERENCE_FRAME ref_frame,
                           int_mv *mv_ref_list,
                           int *ref_sign_bias,
-                          int block_idx);
+                          int block_idx,
+                          int mi_row, int mi_col);
 
 static INLINE void vp9_find_mv_refs(VP9_COMMON *cm,
                                     MACROBLOCKD *xd,
@@ -29,9 +30,10 @@
                                     MODE_INFO *lf_here,
                                     MV_REFERENCE_FRAME ref_frame,
                                     int_mv *mv_ref_list,
-                                    int *ref_sign_bias) {
+                                    int *ref_sign_bias,
+                                    int mi_row, int mi_col) {
   vp9_find_mv_refs_idx(cm, xd, here, lf_here, ref_frame,
-                       mv_ref_list, ref_sign_bias, -1);
+                       mv_ref_list, ref_sign_bias, -1, mi_row, mi_col);
 }
 
 #endif  // VP9_COMMON_VP9_MVREF_COMMON_H_
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -278,14 +278,6 @@
   xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end);
 }
 
-static int get_mi_row(const MACROBLOCKD *xd) {
-  return ((-xd->mb_to_top_edge) >> (3 + LOG2_MI_SIZE));
-}
-
-static int get_mi_col(const MACROBLOCKD *xd) {
-  return ((-xd->mb_to_left_edge) >> (3 + LOG2_MI_SIZE));
-}
-
 static int get_token_alloc(int mb_rows, int mb_cols) {
   return mb_rows * mb_cols * (48 * 16 + 4);
 }
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -439,7 +439,7 @@
 }
 
 static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
-                                  vp9_reader *r) {
+                                       int mi_row, int mi_col, vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
   nmv_context *const nmvc = &cm->fc.nmvc;
@@ -459,7 +459,8 @@
   ref1 = mbmi->ref_frame[1];
 
   vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context,
-                   ref0, mbmi->ref_mvs[ref0], cm->ref_frame_sign_bias);
+                   ref0, mbmi->ref_mvs[ref0], cm->ref_frame_sign_bias,
+                   mi_row, mi_col);
 
   inter_mode_ctx = mbmi->mb_mode_context[ref0];
 
@@ -482,7 +483,8 @@
 
   if (ref1 > INTRA_FRAME) {
     vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context,
-                     ref1, mbmi->ref_mvs[ref1], cm->ref_frame_sign_bias);
+                     ref1, mbmi->ref_mvs[ref1], cm->ref_frame_sign_bias,
+                     mi_row, mi_col);
 
     if (bsize < BLOCK_SIZE_SB8X8 || mbmi->mode != ZEROMV) {
       vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref1],
@@ -502,10 +504,13 @@
         const int b_mode = read_inter_mode(cm, r, inter_mode_ctx);
 
         if (b_mode == NEARESTMV || b_mode == NEARMV) {
-          vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest, &nearby, j, 0);
+          vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest, &nearby, j, 0,
+                                        mi_row, mi_col);
+
           if (ref1 > 0)
             vp9_append_sub8x8_mvs_for_idx(cm, xd,  &nearest_second,
-                                         &nearby_second, j, 1);
+                                         &nearby_second, j, 1,
+                                         mi_row, mi_col);
         }
 
         switch (b_mode) {
@@ -615,7 +620,7 @@
                                  !mbmi->mb_skip_coeff || !inter_block, r);
 
   if (inter_block)
-    read_inter_block_mode_info(pbi, mi, r);
+    read_inter_block_mode_info(pbi, mi, mi_row, mi_col, r);
   else
     read_intra_block_mode_info(pbi, mi, r);
 }
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1860,12 +1860,12 @@
       vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd,
                                     &frame_mv[NEARESTMV][mbmi->ref_frame[0]],
                                     &frame_mv[NEARMV][mbmi->ref_frame[0]],
-                                    i, 0);
+                                    i, 0, mi_row, mi_col);
       if (mbmi->ref_frame[1] > 0)
         vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd,
                                    &frame_mv[NEARESTMV][mbmi->ref_frame[1]],
                                    &frame_mv[NEARMV][mbmi->ref_frame[1]],
-                                   i, 1);
+                                   i, 1, mi_row, mi_col);
 
       // search for the best motion vector on this segment
       for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
@@ -2433,7 +2433,7 @@
                    xd->prev_mode_info_context,
                    frame_type,
                    mbmi->ref_mvs[frame_type],
-                   cpi->common.ref_frame_sign_bias);
+                   cpi->common.ref_frame_sign_bias, mi_row, mi_col);
 
   // Candidate refinement carried out at encoder and decoder
   vp9_find_best_ref_mvs(xd,