localize the use of CONFIG_DEPENDENT_HORZTILES

This commit changes is_inside() function to reduce the code polution
of CONFIG_DEPENDENT_HORZTILES.

Change-Id: Ic065cc337e0246379d87966a49ddeb48b975c5be
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 0ffe2a0..5946b5e 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -191,12 +191,7 @@
 
     mi_pos.row = row_offset;
     mi_pos.col = i;
-#if CONFIG_DEPENDENT_HORZTILES
-    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                  &mi_pos)) {
-#else
-    if (is_inside(tile, mi_col, mi_row, &mi_pos)) {
-#endif
+    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos)) {
       const MODE_INFO *const candidate_mi =
           xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
       const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -243,12 +238,7 @@
 
     mi_pos.row = i;
     mi_pos.col = col_offset;
-#if CONFIG_DEPENDENT_HORZTILES
-    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                  &mi_pos)) {
-#else
-    if (is_inside(tile, mi_col, mi_row, &mi_pos)) {
-#endif
+    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos)) {
       const MODE_INFO *const candidate_mi =
           xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
       const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -281,14 +271,8 @@
   mi_pos.row = row_offset;
   mi_pos.col = col_offset;
 
-#if CONFIG_DEPENDENT_HORZTILES
-  if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                &mi_pos) &&
+  if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos) &&
       *refmv_count < MAX_REF_MV_STACK_SIZE) {
-#else
-  if (is_inside(tile, mi_col, mi_row, &mi_pos) &&
-      *refmv_count < MAX_REF_MV_STACK_SIZE) {
-#endif
     const MODE_INFO *const candidate_mi =
         xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
     const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -369,14 +353,8 @@
   mi_pos.col = blk_col;
 #endif
 
-#if CONFIG_DEPENDENT_HORZTILES
-  if (!is_inside(&xd->tile, mi_col, mi_row, cm->mi_rows,
-                 cm->dependent_horz_tiles, &mi_pos))
+  if (!is_inside(&xd->tile, mi_col, mi_row, cm->mi_rows, cm, &mi_pos))
     return coll_blk_count;
-#else
-  if (!is_inside(&xd->tile, mi_col, mi_row, &mi_pos)) return coll_blk_count;
-#endif
-
   for (ref = 0; ref < 2; ++ref) {
     if (prev_frame_mvs->ref_frame[ref] == ref_frame) {
       int_mv this_refmv = prev_frame_mvs->mv[ref];
@@ -678,12 +656,7 @@
   // and we also need to keep a mode count.
   for (i = 0; i < 2; ++i) {
     const POSITION *const mv_ref = &mv_ref_search[i];
-#if CONFIG_DEPENDENT_HORZTILES
-    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                  mv_ref)) {
-#else
-    if (is_inside(tile, mi_col, mi_row, mv_ref)) {
-#endif
+    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, mv_ref)) {
       const MODE_INFO *const candidate_mi =
           xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
       const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -705,12 +678,7 @@
   // mode counts.
   for (; i < MVREF_NEIGHBOURS; ++i) {
     const POSITION *const mv_ref = &mv_ref_search[i];
-#if CONFIG_DEPENDENT_HORZTILES
-    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                  mv_ref)) {
-#else
-    if (is_inside(tile, mi_col, mi_row, mv_ref)) {
-#endif
+    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, mv_ref)) {
       const MB_MODE_INFO *const candidate =
           !xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]
               ? NULL
@@ -764,12 +732,7 @@
   if (different_ref_found) {
     for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
       const POSITION *mv_ref = &mv_ref_search[i];
-#if CONFIG_DEPENDENT_HORZTILES
-      if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                    mv_ref)) {
-#else
-      if (is_inside(tile, mi_col, mi_row, mv_ref)) {
-#endif
+      if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, mv_ref)) {
         const MB_MODE_INFO *const candidate =
             !xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride]
                 ? NULL
@@ -822,10 +785,10 @@
 
 #if CONFIG_EXT_INTER
 // This function keeps a mode count for a given MB/SB
-void av1_update_mv_context(const MACROBLOCKD *xd, MODE_INFO *mi,
-                           MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list,
-                           int block, int mi_row, int mi_col,
-                           int16_t *mode_context) {
+void av1_update_mv_context(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+                           MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
+                           int_mv *mv_ref_list, int block, int mi_row,
+                           int mi_col, int16_t *mode_context) {
   int i, refmv_count = 0;
 #if !CONFIG_REF_MV
   const POSITION *const mv_ref_search = mv_ref_blocks[mi->mbmi.sb_type];
@@ -879,12 +842,7 @@
   // If the size < 8x8, we get the mv from the bmi substructure;
   for (i = 0; i < 2; ++i) {
     const POSITION *const mv_ref = &mv_ref_search[i];
-#if CONFIG_DEPENDENT_HORZTILES
-    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm->dependent_horz_tiles,
-                  mv_ref)) {
-#else
-    if (is_inside(tile, mi_col, mi_row, mv_ref)) {
-#endif
+    if (is_inside(tile, mi_col, mi_row, cm->mi_rows, cm, mv_ref)) {
       const MODE_INFO *const candidate_mi =
           xd->mi[mv_ref->col + mv_ref->row * xd->mi_stride];
       const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
@@ -929,7 +887,7 @@
 #endif
 #endif
 #if CONFIG_EXT_INTER
-  av1_update_mv_context(xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col,
+  av1_update_mv_context(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col,
 #if CONFIG_REF_MV
                         compound_mode_context);
 #else
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index d91efb2..eea2b8e 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -345,10 +345,15 @@
 
 // Checks that the given mi_row, mi_col and search point
 // are inside the borders of the tile.
-#if CONFIG_DEPENDENT_HORZTILES
 static INLINE int is_inside(const TileInfo *const tile, int mi_col, int mi_row,
-                            int mi_rows, int dependent_horz_tile_flag,
+                            int mi_rows, const AV1_COMMON *cm,
                             const POSITION *mi_pos) {
+#if CONFIG_DEPENDENT_HORZTILES
+  const int dependent_horz_tile_flag = cm->dependent_horz_tiles;
+#else
+  const int dependent_horz_tile_flag = 0;
+  (void)cm;
+#endif
 #if CONFIG_TILE_GROUPS
   if (dependent_horz_tile_flag && !tile->tg_horz_boundary) {
 #else
@@ -365,15 +370,6 @@
              mi_col + mi_pos->col >= tile->mi_col_end);
   }
 }
-#else
-static INLINE int is_inside(const TileInfo *const tile, int mi_col, int mi_row,
-                            const POSITION *mi_pos) {
-  return !(mi_row + mi_pos->row < tile->mi_row_start ||
-           mi_col + mi_pos->col < tile->mi_col_start ||
-           mi_row + mi_pos->row >= tile->mi_row_end ||
-           mi_col + mi_pos->col >= tile->mi_col_end);
-}
-#endif
 
 static INLINE void lower_mv_precision(MV *mv, int allow_hp) {
   if (!allow_hp) {
@@ -513,10 +509,10 @@
 
 #if CONFIG_EXT_INTER
 // This function keeps a mode count for a given MB/SB
-void av1_update_mv_context(const MACROBLOCKD *xd, MODE_INFO *mi,
-                           MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list,
-                           int block, int mi_row, int mi_col,
-                           int16_t *mode_context);
+void av1_update_mv_context(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+                           MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame,
+                           int_mv *mv_ref_list, int block, int mi_row,
+                           int mi_col, int16_t *mode_context);
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_WARPED_MOTION
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index eba62c9..3550050 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1834,8 +1834,8 @@
 #if CONFIG_EXT_INTER
           {
             int_mv mv_ref_list[MAX_MV_REF_CANDIDATES];
-            av1_update_mv_context(xd, mi, mbmi->ref_frame[ref], mv_ref_list, j,
-                                  mi_row, mi_col, NULL);
+            av1_update_mv_context(cm, xd, mi, mbmi->ref_frame[ref], mv_ref_list,
+                                  j, mi_row, mi_col, NULL);
 #endif  // CONFIG_EXT_INTER
             av1_append_sub8x8_mvs_for_idx(cm, xd, j, ref, mi_row, mi_col,
 #if CONFIG_REF_MV
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 268426c..24da721 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -5835,8 +5835,8 @@
         const MV_REFERENCE_FRAME frame = mbmi->ref_frame[ref];
 #if CONFIG_EXT_INTER
         int_mv mv_ref_list[MAX_MV_REF_CANDIDATES];
-        av1_update_mv_context(xd, mi, frame, mv_ref_list, index, mi_row, mi_col,
-                              NULL);
+        av1_update_mv_context(cm, xd, mi, frame, mv_ref_list, index, mi_row,
+                              mi_col, NULL);
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_GLOBAL_MOTION
         frame_mv[ZEROMV][frame].as_int =