Refactor to use block_size_wide/high[] consistently

Replace the computation of block size in pixels with lookup table
directly.

Change-Id: I39589b2bc1d20372969ff5ad0f60639e64a19b41
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index 1e6b619..c51df89 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -45,9 +45,11 @@
 static const uint8_t block_size_wide[BLOCK_SIZES] = {
   4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, IF_EXT_PARTITION(64, 128, 128)
 };
+
 static const uint8_t block_size_high[BLOCK_SIZES] = {
   4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 64, 32, 64, IF_EXT_PARTITION(128, 64, 128)
 };
+
 static const uint8_t num_4x4_blocks_wide_lookup[BLOCK_SIZES] = {
   1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, IF_EXT_PARTITION(16, 32, 32)
 };
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index d47ce10..36e916f 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -914,8 +914,8 @@
       mi_step = AOMMIN(xd->n8_w, num_8x8_blocks_wide_lookup[mbmi->sb_type]);
 
       if (mbmi->ref_frame[0] == ref_frame && mbmi->ref_frame[1] == NONE) {
-        int bw = num_4x4_blocks_wide_lookup[mbmi->sb_type] * 4;
-        int bh = num_4x4_blocks_high_lookup[mbmi->sb_type] * 4;
+        int bw = block_size_wide[mbmi->sb_type];
+        int bh = block_size_high[mbmi->sb_type];
         int mv_row = mbmi->mv[0].as_mv.row;
         int mv_col = mbmi->mv[0].as_mv.col;
         int cr_offset = -AOMMAX(bh, 8) / 2 - 1;
@@ -969,8 +969,8 @@
       mi_step = AOMMIN(xd->n8_h, num_8x8_blocks_high_lookup[mbmi->sb_type]);
 
       if (mbmi->ref_frame[0] == ref_frame && mbmi->ref_frame[1] == NONE) {
-        int bw = num_4x4_blocks_wide_lookup[mbmi->sb_type] * 4;
-        int bh = num_4x4_blocks_high_lookup[mbmi->sb_type] * 4;
+        int bw = block_size_wide[mbmi->sb_type];
+        int bh = block_size_high[mbmi->sb_type];
         int mv_row = mbmi->mv[0].as_mv.row;
         int mv_col = mbmi->mv[0].as_mv.col;
         int cr_offset = i * 8 + AOMMAX(bh, 8) / 2 - 1;
@@ -1020,8 +1020,8 @@
     MB_MODE_INFO *mbmi = &mi->mbmi;
 
     if (mbmi->ref_frame[0] == ref_frame && mbmi->ref_frame[1] == NONE) {
-      int bw = num_4x4_blocks_wide_lookup[mbmi->sb_type] * 4;
-      int bh = num_4x4_blocks_high_lookup[mbmi->sb_type] * 4;
+      int bw = block_size_wide[mbmi->sb_type];
+      int bh = block_size_high[mbmi->sb_type];
       int mv_row = mbmi->mv[0].as_mv.row;
       int mv_col = mbmi->mv[0].as_mv.col;
       int cr_offset = -AOMMAX(bh, 8) / 2 - 1;
@@ -1070,8 +1070,8 @@
   } else {
     MODE_INFO *mi = xd->mi[0];
     MB_MODE_INFO *mbmi = &mi->mbmi;
-    int bw = num_4x4_blocks_wide_lookup[mbmi->sb_type] * 4;
-    int bh = num_4x4_blocks_high_lookup[mbmi->sb_type] * 4;
+    int bw = block_size_wide[mbmi->sb_type];
+    int bh = block_size_high[mbmi->sb_type];
     int mv_row = mbmi->mv[0].as_mv.row;
     int mv_col = mbmi->mv[0].as_mv.col;
     int cr_offset = AOMMAX(bh, 8) / 2 - 1;
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 21921a8..04fbe9b 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -293,8 +293,8 @@
   BLOCK_SIZE sb_type;
   memset(wedge_signflip_lookup, 0, sizeof(wedge_signflip_lookup));
   for (sb_type = BLOCK_4X4; sb_type < BLOCK_SIZES; ++sb_type) {
-    const int bw = 4 * num_4x4_blocks_wide_lookup[sb_type];
-    const int bh = 4 * num_4x4_blocks_high_lookup[sb_type];
+    const int bw = block_size_wide[sb_type];
+    const int bh = block_size_high[sb_type];
     const wedge_params_type wedge_params = wedge_params_lookup[sb_type];
     const int wbits = wedge_params.bits;
     const int wtypes = 1 << wbits;
@@ -317,8 +317,8 @@
   memset(wedge_masks, 0, sizeof(wedge_masks));
   for (bsize = BLOCK_4X4; bsize < BLOCK_SIZES; ++bsize) {
     const uint8_t *mask;
-    const int bw = 4 * num_4x4_blocks_wide_lookup[bsize];
-    const int bh = 4 * num_4x4_blocks_high_lookup[bsize];
+    const int bw = block_size_wide[bsize];
+    const int bh = block_size_high[bsize];
     const wedge_params_type *wedge_params = &wedge_params_lookup[bsize];
     const int wbits = wedge_params->bits;
     const int wtypes = 1 << wbits;
@@ -390,8 +390,7 @@
   const uint8_t *mask =
       av1_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type);
   aom_blend_a64_mask(dst, dst_stride, src0, src0_stride, src1, src1_stride,
-                     mask, 4 * num_4x4_blocks_wide_lookup[sb_type], h, w, subh,
-                     subw);
+                     mask, block_size_wide[sb_type], h, w, subh, subw);
 }
 
 #if CONFIG_AOM_HIGHBITDEPTH
@@ -405,9 +404,9 @@
   const int subw = (2 << b_width_log2_lookup[sb_type]) == w;
   const uint8_t *mask =
       av1_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type);
-  aom_highbd_blend_a64_mask(
-      dst_8, dst_stride, src0_8, src0_stride, src1_8, src1_stride, mask,
-      4 * num_4x4_blocks_wide_lookup[sb_type], h, w, subh, subw, bd);
+  aom_highbd_blend_a64_mask(dst_8, dst_stride, src0_8, src0_stride, src1_8,
+                            src1_stride, mask, block_size_wide[sb_type], h, w,
+                            subh, subw, bd);
 }
 #endif  // CONFIG_AOM_HIGHBITDEPTH
 
@@ -732,9 +731,8 @@
   struct macroblockd_plane *const pd = &xd->plane[plane];
   MODE_INFO *const mi = xd->mi[0];
   const BLOCK_SIZE plane_bsize = get_plane_block_size(mi->mbmi.sb_type, pd);
-  const int width = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
-  const int height = 4 * num_4x4_blocks_high_lookup[plane_bsize];
-
+  const int width = block_size_wide[plane_bsize];
+  const int height = block_size_high[plane_bsize];
   uint8_t *const dst = &pd->dst.buf[(ir * pd->dst.stride + ic) << 2];
   int ref;
   const int is_compound = has_second_ref(&mi->mbmi);
@@ -774,8 +772,8 @@
   const int mi_y = mi_row * MI_SIZE;
   for (plane = plane_from; plane <= plane_to; ++plane) {
     const struct macroblockd_plane *pd = &xd->plane[plane];
-    const int bw = 4 * num_4x4_blocks_wide_lookup[bsize] >> pd->subsampling_x;
-    const int bh = 4 * num_4x4_blocks_high_lookup[bsize] >> pd->subsampling_y;
+    const int bw = block_size_wide[bsize] >> pd->subsampling_x;
+    const int bh = block_size_high[bsize] >> pd->subsampling_y;
 
     if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) {
       const PARTITION_TYPE bp = bsize - xd->mi[0]->mbmi.sb_type;
@@ -1102,8 +1100,8 @@
         get_plane_block_size(bsize, &xd->plane[plane]);
     const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
     const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
-    const int bw = 4 * num_4x4_w;
-    const int bh = 4 * num_4x4_h;
+    const int bw = block_size_wide[plane_bsize];
+    const int bh = block_size_high[plane_bsize];
 
     if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) {
       int x, y;
@@ -1610,8 +1608,8 @@
                                uint8_t *comppred, int compstride,
                                const uint8_t *interpred, int interstride,
                                const uint8_t *intrapred, int intrastride) {
-  const int bw = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
-  const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
+  const int bw = block_size_wide[plane_bsize];
+  const int bh = block_size_high[plane_bsize];
   const int size_scale = ii_size_scales[plane_bsize];
   int i, j;
 
@@ -1621,9 +1619,9 @@
           av1_get_contiguous_soft_mask(wedge_index, wedge_sign, bsize);
       const int subw = 2 * num_4x4_blocks_wide_lookup[bsize] == bw;
       const int subh = 2 * num_4x4_blocks_high_lookup[bsize] == bh;
-      aom_blend_a64_mask(
-          comppred, compstride, intrapred, intrastride, interpred, interstride,
-          mask, 4 * num_4x4_blocks_wide_lookup[bsize], bh, bw, subh, subw);
+      aom_blend_a64_mask(comppred, compstride, intrapred, intrastride,
+                         interpred, interstride, mask, block_size_wide[bsize],
+                         bh, bw, subh, subw);
     }
     return;
   }
@@ -1722,8 +1720,8 @@
     int wedge_sign, BLOCK_SIZE bsize, BLOCK_SIZE plane_bsize,
     uint8_t *comppred8, int compstride, const uint8_t *interpred8,
     int interstride, const uint8_t *intrapred8, int intrastride, int bd) {
-  const int bw = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
-  const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
+  const int bw = block_size_wide[plane_bsize];
+  const int bh = block_size_high[plane_bsize];
   const int size_scale = ii_size_scales[plane_bsize];
   int i, j;
 
@@ -2055,8 +2053,8 @@
         get_plane_block_size(bsize, &xd->plane[plane]);
     const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize];
     const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize];
-    const int bw = 4 * num_4x4_w;
-    const int bh = 4 * num_4x4_h;
+    const int bw = block_size_wide;
+    const int bh = block_size_high;
 
     if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) {
       int x, y;
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c
index c42b95e..2df8cd2 100644
--- a/av1/decoder/detokenize.c
+++ b/av1/decoder/detokenize.c
@@ -311,10 +311,10 @@
   const MODE_INFO *const mi = xd->mi[0];
   const MB_MODE_INFO *const mbmi = &mi->mbmi;
   const BLOCK_SIZE bsize = mbmi->sb_type;
-  const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
-                   (xd->plane[plane != 0].subsampling_y);
-  const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >>
-                   (xd->plane[plane != 0].subsampling_x);
+  const int rows =
+      (block_size_high[bsize]) >> (xd->plane[plane != 0].subsampling_y);
+  const int cols =
+      (block_size_wide[bsize]) >> (xd->plane[plane != 0].subsampling_x);
   uint8_t color_order[PALETTE_MAX_SIZE];
   const int n = mbmi->palette_mode_info.palette_size[plane != 0];
   int i, j;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index e4d8db0..4915f78 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1871,10 +1871,10 @@
 #if CONFIG_PALETTE
   for (plane = 0; plane <= 1; ++plane) {
     if (m->mbmi.palette_mode_info.palette_size[plane] > 0) {
-      const int rows = (4 * num_4x4_blocks_high_lookup[m->mbmi.sb_type]) >>
-                       (xd->plane[plane].subsampling_y);
-      const int cols = (4 * num_4x4_blocks_wide_lookup[m->mbmi.sb_type]) >>
-                       (xd->plane[plane].subsampling_x);
+      const int rows =
+          block_size_high[m->mbmi.sb_type] >> (xd->plane[plane].subsampling_y);
+      const int cols =
+          block_size_wide[m->mbmi.sb_type] >> (xd->plane[plane].subsampling_x);
       assert(*tok < tok_end);
       pack_palette_tokens(w, tok, m->mbmi.palette_mode_info.palette_size[plane],
                           rows * cols - 1);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 8540cc4..a768c1c 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -676,7 +676,7 @@
 
   if (bsize > leaf_size) {
     const BLOCK_SIZE subsize = get_subsize(bsize, PARTITION_SPLIT);
-    const int px = num_4x4_blocks_wide_lookup[subsize] * 4;
+    const int px = block_size_wide[subsize];
 
     init_variance_tree(vt->split[0],
 #if CONFIG_AOM_HIGHBITDEPTH
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index a0452e5..0319db6 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -38,8 +38,8 @@
   struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &x->e_mbd.plane[plane];
   const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
-  const int bw = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
-  const int bh = 4 * num_4x4_blocks_high_lookup[plane_bsize];
+  const int bw = block_size_wide[plane_bsize];
+  const int bh = block_size_high[plane_bsize];
 
 #if CONFIG_AOM_HIGHBITDEPTH
   if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -482,7 +482,7 @@
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   uint16_t *const eob = &p->eobs[block];
-  const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
+  const int diff_stride = block_size_wide[plane_bsize];
 #if CONFIG_AOM_QM
   int seg_id = xd->mi[0]->mbmi.segment_id;
   const qm_val_t *qmatrix = pd->seg_qmatrix[seg_id][!is_inter][tx_size];
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 4b54a2c..2956447 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -2562,8 +2562,8 @@
   int idx, best_idx = -1;
   unsigned int cost_array[5];
   int kr, kc;
-  const int w = 4 * num_4x4_blocks_wide_lookup[mbmi->sb_type];
-  const int h = 4 * num_4x4_blocks_high_lookup[mbmi->sb_type];
+  const int w = block_size_wide[mbmi->sb_type];
+  const int h = block_size_high[mbmi->sb_type];
   int offset;
   int y_stride;
   const uint8_t *y;
@@ -3064,8 +3064,8 @@
   int idx, best_idx = -1;
   unsigned int cost_array[5];
   int kr, kc;
-  const int w = 4 * num_4x4_blocks_wide_lookup[mbmi->sb_type];
-  const int h = 4 * num_4x4_blocks_high_lookup[mbmi->sb_type];
+  const int w = block_size_wide[mbmi->sb_type];
+  const int h = block_size_high[mbmi->sb_type];
   int offset;
   int y_stride;
   const uint8_t *y;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index e1bfdf4..190e07e 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -717,7 +717,7 @@
 
 int16_t *av1_raster_block_offset_int16(BLOCK_SIZE plane_bsize, int raster_block,
                                        int16_t *base) {
-  const int stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize];
+  const int stride = block_size_wide[plane_bsize];
   return base + av1_raster_block_offset(plane_bsize, raster_block, stride);
 }
 
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 6fd0926..0f5db59 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1853,8 +1853,8 @@
   int rate_overhead = 0;
   MACROBLOCKD *const xd = &x->e_mbd;
   MODE_INFO *const mic = xd->mi[0];
-  const int rows = 4 * num_4x4_blocks_high_lookup[bsize];
-  const int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int rows = block_size_high[bsize];
+  const int cols = block_size_wide[bsize];
   int this_rate, colors, n;
   RD_STATS tokenonly_rd_stats;
   int64_t this_rd;
@@ -2816,8 +2816,8 @@
   int64_t this_distortion, this_rd;
   TX_SIZE best_tx = TX_4X4;
 #if CONFIG_EXT_INTRA || CONFIG_PALETTE
-  const int rows = 4 * num_4x4_blocks_high_lookup[bsize];
-  const int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int rows = block_size_high[bsize];
+  const int cols = block_size_wide[bsize];
 #endif  // CONFIG_EXT_INTRA || CONFIG_PALETTE
 #if CONFIG_EXT_INTRA
   const int intra_filter_ctx = av1_get_pred_context_intra_interp(xd);
@@ -3737,10 +3737,8 @@
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const BLOCK_SIZE bsize = mbmi->sb_type;
-  const int rows =
-      (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y);
-  const int cols =
-      (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x);
+  const int rows = block_size_high[bsize] >> (xd->plane[1].subsampling_y);
+  const int cols = block_size_wide[bsize] >> (xd->plane[1].subsampling_x);
   int this_rate;
   int64_t this_rd;
   int colors_u, colors_v, colors;
@@ -4057,10 +4055,8 @@
   od_encode_checkpoint(&x->daala_enc, &buf);
 #endif
 #if CONFIG_PALETTE
-  const int rows =
-      (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y);
-  const int cols =
-      (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x);
+  const int rows = block_size_high[bsize] >> (xd->plane[1].subsampling_y);
+  const int cols = block_size_wide[bsize] >> (xd->plane[1].subsampling_x);
   PALETTE_MODE_INFO palette_mode_info;
   PALETTE_MODE_INFO *const pmi = &xd->mi[0]->mbmi.palette_mode_info;
   uint8_t *best_palette_color_map = NULL;
@@ -4847,8 +4843,8 @@
                                 int_mv single_newmv[TOTAL_REFS_PER_FRAME],
                                 int *rate_mv, const int block) {
   const AV1_COMMON *const cm = &cpi->common;
-  const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
-  const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
+  const int pw = block_size_wide[bsize];
+  const int ph = block_size_high[bsize];
   MACROBLOCKD *xd = &x->e_mbd;
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   const int refs[2] = { mbmi->ref_frame[0],
@@ -5445,8 +5441,8 @@
               const int try_second =
                   x->second_best_mv.as_int != INVALID_MV &&
                   x->second_best_mv.as_int != x->best_mv.as_int;
-              const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
-              const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
+              const int pw = block_size_wide[bsize];
+              const int ph = block_size_high[bsize];
               // Use up-sampled reference frames.
               struct buf_2d backup_pred = pd->pre[0];
               const YV12_BUFFER_CONFIG *upsampled_ref =
@@ -6244,8 +6240,8 @@
           int best_mv_var;
           const int try_second = x->second_best_mv.as_int != INVALID_MV &&
                                  x->second_best_mv.as_int != x->best_mv.as_int;
-          const int pw = 4 * num_4x4_blocks_wide_lookup[bsize];
-          const int ph = 4 * num_4x4_blocks_high_lookup[bsize];
+          const int pw = block_size_wide[bsize];
+          const int ph = block_size_high[bsize];
           // Use up-sampled reference frames.
           struct macroblockd_plane *const pd = &xd->plane[0];
           struct buf_2d backup_pred = pd->pre[ref_idx];
@@ -6481,7 +6477,7 @@
   MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
   BLOCK_SIZE sb_type = mbmi->sb_type;
   const uint8_t *mask;
-  const int mask_stride = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int mask_stride = block_size_wide[bsize];
   mask = av1_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type);
 
   if (which == 0 || which == 2)
@@ -6684,8 +6680,8 @@
                           int *const best_wedge_index) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   const struct buf_2d *const src = &x->plane[0].src;
-  const int bw = 4 * num_4x4_blocks_wide_lookup[bsize];
-  const int bh = 4 * num_4x4_blocks_high_lookup[bsize];
+  const int bw = block_size_wide[bsize];
+  const int bh = block_size_high[bsize];
   const int N = bw * bh;
   int rate;
   int64_t dist;
@@ -6759,8 +6755,8 @@
     const int wedge_sign, int *const best_wedge_index) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   const struct buf_2d *const src = &x->plane[0].src;
-  const int bw = 4 * num_4x4_blocks_wide_lookup[bsize];
-  const int bh = 4 * num_4x4_blocks_high_lookup[bsize];
+  const int bw = block_size_wide[bsize];
+  const int bh = block_size_high[bsize];
   const int N = bw * bh;
   int rate;
   int64_t dist;
@@ -6816,7 +6812,7 @@
                                      const uint8_t *const p1) {
   const MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-  const int bw = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int bw = block_size_wide[bsize];
 
   int64_t rd;
   int wedge_index = -1;
@@ -6890,7 +6886,7 @@
   int rate_mv = 0;
 #if CONFIG_EXT_INTER
   int pred_exists = 1;
-  const int bw = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int bw = block_size_wide[bsize];
   int mv_idx = (this_mode == NEWFROMNEARMV) ? 1 : 0;
   int_mv single_newmv[TOTAL_REFS_PER_FRAME];
   const unsigned int *const interintra_mode_cost =
@@ -8156,10 +8152,8 @@
   MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
   const BLOCK_SIZE bsize = mbmi->sb_type;
-  const int rows =
-      (4 * num_4x4_blocks_high_lookup[bsize]) >> (xd->plane[1].subsampling_y);
-  const int cols =
-      (4 * num_4x4_blocks_wide_lookup[bsize]) >> (xd->plane[1].subsampling_x);
+  const int rows = block_size_high[bsize] >> (xd->plane[1].subsampling_y);
+  const int cols = block_size_wide[bsize] >> (xd->plane[1].subsampling_x);
   int src_stride = x->plane[1].src.stride;
   const uint8_t *const src_u = x->plane[1].src.buf;
   const uint8_t *const src_v = x->plane[2].src.buf;
@@ -8494,8 +8488,8 @@
 #endif
 
 #if CONFIG_PALETTE || CONFIG_EXT_INTRA
-  const int rows = 4 * num_4x4_blocks_high_lookup[bsize];
-  const int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
+  const int rows = block_size_high[bsize];
+  const int cols = block_size_wide[bsize];
 #endif  // CONFIG_PALETTE || CONFIG_EXT_INTRA
 #if CONFIG_PALETTE
   int palette_ctx = 0;
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 0e6b815..136cdf2 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -394,10 +394,10 @@
   int i, j;
   int this_rate = 0;
   uint8_t color_order[PALETTE_MAX_SIZE];
-  const int rows = (4 * num_4x4_blocks_high_lookup[bsize]) >>
-                   (xd->plane[plane != 0].subsampling_y);
-  const int cols = (4 * num_4x4_blocks_wide_lookup[bsize]) >>
-                   (xd->plane[plane != 0].subsampling_x);
+  const int rows =
+      block_size_high[bsize] >> (xd->plane[plane != 0].subsampling_y);
+  const int cols =
+      block_size_wide[bsize] >> (xd->plane[plane != 0].subsampling_x);
   const aom_prob(*const probs)[PALETTE_COLOR_CONTEXTS][PALETTE_COLORS - 1] =
       plane == 0 ? av1_default_palette_y_color_prob
                  : av1_default_palette_uv_color_prob;
diff --git a/test/subtract_test.cc b/test/subtract_test.cc
index 6bd1b2b..34c57b1 100644
--- a/test/subtract_test.cc
+++ b/test/subtract_test.cc
@@ -45,8 +45,8 @@
   // FIXME(rbultje) split in its own file
   for (BLOCK_SIZE bsize = BLOCK_4X4; bsize < BLOCK_SIZES;
        bsize = static_cast<BLOCK_SIZE>(static_cast<int>(bsize) + 1)) {
-    const int block_width = 4 * num_4x4_blocks_wide_lookup[bsize];
-    const int block_height = 4 * num_4x4_blocks_high_lookup[bsize];
+    const int block_width = block_size_wide[bsize];
+    const int block_height = block_size_high[bsize];
     int16_t *diff = reinterpret_cast<int16_t *>(
         aom_memalign(16, sizeof(*diff) * block_width * block_height * 2));
     uint8_t *pred = reinterpret_cast<uint8_t *>(