Refactor set_plane_n4()

Make the block size and mode_info size scalable to mode_info unit
size.

Change-Id: I38c49bad118e0565a104cb6edfc3e3266519f9ee
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 8d939c0..9c533b7 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -560,16 +560,14 @@
   return len + MAX_MIB_SIZE;
 }
 
-static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh, int bwl,
-                                int bhl) {
+static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh) {
   int i;
   for (i = 0; i < MAX_MB_PLANE; i++) {
     xd->plane[i].n4_w = (bw << 1) >> xd->plane[i].subsampling_x;
     xd->plane[i].n4_h = (bh << 1) >> xd->plane[i].subsampling_y;
-    xd->plane[i].n4_wl = bwl - xd->plane[i].subsampling_x;
-    xd->plane[i].n4_hl = bhl - xd->plane[i].subsampling_y;
-    xd->plane[i].width = xd->plane[i].n4_w * 4;
-    xd->plane[i].height = xd->plane[i].n4_h * 4;
+
+    xd->plane[i].width = (bw * MI_SIZE) >> xd->plane[i].subsampling_x;
+    xd->plane[i].height = (bh * MI_SIZE) >> xd->plane[i].subsampling_y;
   }
 }
 
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index c870c15..c545450 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -601,8 +601,7 @@
 
 static MB_MODE_INFO *set_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd,
                                  BLOCK_SIZE bsize, int mi_row, int mi_col,
-                                 int bw, int bh, int x_mis, int y_mis, int bwl,
-                                 int bhl) {
+                                 int bw, int bh, int x_mis, int y_mis) {
   const int offset = mi_row * cm->mi_stride + mi_col;
   int x, y;
   const TileInfo *const tile = &xd->tile;
@@ -619,7 +618,7 @@
   for (y = 0; y < y_mis; ++y)
     for (x = !y; x < x_mis; ++x) xd->mi[y * cm->mi_stride + x] = xd->mi[0];
 
-  set_plane_n4(xd, bw, bh, bwl, bhl);
+  set_plane_n4(xd, bw, bh);
   set_skip_context(xd, mi_row, mi_col);
 
 #if CONFIG_VAR_TX
@@ -647,8 +646,6 @@
   const int bw = num_8x8_blocks_wide_lookup[bsize_pred];
   const int bh = num_8x8_blocks_high_lookup[bsize_pred];
   const int offset = mi_row_ori * cm->mi_stride + mi_col_ori;
-  const int bwl = b_width_log2_lookup[bsize_pred];
-  const int bhl = b_height_log2_lookup[bsize_pred];
   xd->mi = cm->mi_grid_visible + offset;
   xd->mi[0] = cm->mi + offset;
   set_mi_row_col(xd, tile, mi_row_pred, bh, mi_col_pred, bw, cm->mi_rows,
@@ -657,7 +654,7 @@
   xd->up_available = (mi_row_ori > tile->mi_row_start);
   xd->left_available = (mi_col_ori > tile->mi_col_start);
 
-  set_plane_n4(xd, bw, bh, bwl, bhl);
+  set_plane_n4(xd, bw, bh);
 
   return &xd->mi[0]->mbmi;
 }
@@ -685,13 +682,11 @@
   const int bw = num_8x8_blocks_wide_lookup[bsize];
   const int bh = num_8x8_blocks_high_lookup[bsize];
   const int offset = mi_row * cm->mi_stride + mi_col;
-  const int bwl = b_width_log2_lookup[bsize];
-  const int bhl = b_height_log2_lookup[bsize];
 
   xd->mi = cm->mi_grid_visible + offset;
   xd->mi[0] = cm->mi + offset;
 
-  set_plane_n4(xd, bw, bh, bwl, bhl);
+  set_plane_n4(xd, bw, bh);
 
   set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
 
@@ -1360,7 +1355,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                          PARTITION_TYPE partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                         BLOCK_SIZE bsize, int bwl, int bhl) {
+                         BLOCK_SIZE bsize) {
   AV1_COMMON *const cm = &pbi->common;
   const int bw = mi_size_wide[bsize];
   const int bh = mi_size_high[bsize];
@@ -1375,16 +1370,14 @@
   if (supertx_enabled) {
     mbmi = set_mb_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
   } else {
-    mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis, bwl,
-                       bhl);
+    mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
   }
 #if CONFIG_EXT_PARTITION_TYPES
   xd->mi[0]->mbmi.partition = partition;
 #endif
   av1_read_mode_info(pbi, xd, supertx_enabled, mi_row, mi_col, r, x_mis, y_mis);
 #else
-  mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis, bwl,
-                     bhl);
+  mbmi = set_offsets(cm, xd, bsize, mi_row, mi_col, bw, bh, x_mis, y_mis);
 #if CONFIG_EXT_PARTITION_TYPES
   xd->mi[0]->mbmi.partition = partition;
 #endif
@@ -1814,7 +1807,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                  partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                 subsize, 1, 1);
+                 subsize);
   } else {
     switch (partition) {
       case PARTITION_NONE:
@@ -1826,7 +1819,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                      partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                     subsize, n4x4_l2, n4x4_l2);
+                     subsize);
         break;
       case PARTITION_HORZ:
         decode_block(pbi, xd,
@@ -1837,7 +1830,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                      partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                     subsize, n4x4_l2, n8x8_l2);
+                     subsize);
         if (has_rows)
           decode_block(pbi, xd,
 #if CONFIG_SUPERTX
@@ -1847,7 +1840,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                        partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                       subsize, n4x4_l2, n8x8_l2);
+                       subsize);
         break;
       case PARTITION_VERT:
         decode_block(pbi, xd,
@@ -1858,7 +1851,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                      partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                     subsize, n8x8_l2, n4x4_l2);
+                     subsize);
         if (has_cols)
           decode_block(pbi, xd,
 #if CONFIG_SUPERTX
@@ -1868,7 +1861,7 @@
 #if CONFIG_EXT_PARTITION_TYPES
                        partition,
 #endif  // CONFIG_EXT_PARTITION_TYPES
-                       subsize, n8x8_l2, n4x4_l2);
+                       subsize);
         break;
       case PARTITION_SPLIT:
         decode_partition(pbi, xd,
@@ -1898,76 +1891,68 @@
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col, r, partition, bsize2, n8x8_l2, n8x8_l2);
+                     mi_row, mi_col, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col + hbs, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row, mi_col + hbs, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row + hbs, mi_col, r, partition, subsize, n4x4_l2,
-                     n8x8_l2);
+                     mi_row + hbs, mi_col, r, partition, subsize);
         break;
       case PARTITION_HORZ_B:
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col, r, partition, subsize, n4x4_l2, n8x8_l2);
+                     mi_row, mi_col, r, partition, subsize);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row + hbs, mi_col, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row + hbs, mi_col, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row + hbs, mi_col + hbs, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row + hbs, mi_col + hbs, r, partition, bsize2);
         break;
       case PARTITION_VERT_A:
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col, r, partition, bsize2, n8x8_l2, n8x8_l2);
+                     mi_row, mi_col, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row + hbs, mi_col, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row + hbs, mi_col, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col + hbs, r, partition, subsize, n8x8_l2,
-                     n4x4_l2);
+                     mi_row, mi_col + hbs, r, partition, subsize);
         break;
       case PARTITION_VERT_B:
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col, r, partition, subsize, n8x8_l2, n4x4_l2);
+                     mi_row, mi_col, r, partition, subsize);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row, mi_col + hbs, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row, mi_col + hbs, r, partition, bsize2);
         decode_block(pbi, xd,
 #if CONFIG_SUPERTX
                      supertx_enabled,
 #endif
-                     mi_row + hbs, mi_col + hbs, r, partition, bsize2, n8x8_l2,
-                     n8x8_l2);
+                     mi_row + hbs, mi_col + hbs, r, partition, bsize2);
         break;
 #endif
       default: assert(0 && "Invalid partition type");
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index d8d8af7..e4873ab 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -266,8 +266,6 @@
   MACROBLOCKD *const xd = &x->e_mbd;
   const int mi_width = mi_size_wide[bsize];
   const int mi_height = mi_size_high[bsize];
-  const int bwl = b_width_log2_lookup[AOMMAX(bsize, BLOCK_8X8)];
-  const int bhl = b_height_log2_lookup[AOMMAX(bsize, BLOCK_8X8)];
 
   set_skip_context(xd, mi_row, mi_col);
 
@@ -290,7 +288,7 @@
   x->mv_row_max = (cm->mi_rows - mi_row) * MI_SIZE + AOM_INTERP_EXTEND;
   x->mv_col_max = (cm->mi_cols - mi_col) * MI_SIZE + AOM_INTERP_EXTEND;
 
-  set_plane_n4(xd, mi_width, mi_height, bwl, bhl);
+  set_plane_n4(xd, mi_width, mi_height);
 
   // Set up distance of MB to edge of frame in 1/8th pel units.
   assert(!(mi_col & (mi_width - 1)) && !(mi_row & (mi_height - 1)));
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 968677d..18860bb 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -619,9 +619,7 @@
       xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME;
       set_mi_row_col(xd, &tile, mb_row << 1, mi_size_high[bsize], mb_col << 1,
                      mi_size_wide[bsize], cm->mi_rows, cm->mi_cols);
-      set_plane_n4(xd, num_8x8_blocks_wide_lookup[bsize],
-                   num_8x8_blocks_high_lookup[bsize],
-                   mi_width_log2_lookup[bsize], mi_height_log2_lookup[bsize]);
+      set_plane_n4(xd, mi_size_wide[bsize], mi_size_high[bsize]);
 
       // Do intra 16x16 prediction.
       xd->mi[0]->mbmi.segment_id = 0;