Merge "Replace num_4x4_blocks_txsize_loopup table" into nextgenv2
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 16923c9..ab535ae 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1730,20 +1730,21 @@
       assert(mbmi->segment_id_supertx != MAX_SEGMENTS);
       for (i = 0; i < MAX_MB_PLANE; ++i) {
         const struct macroblockd_plane *const pd = &xd->plane[i];
-        const int num_4x4_w = pd->n4_w;
-        const int num_4x4_h = pd->n4_h;
         int row, col;
         const TX_SIZE tx_size = i ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
-        const int stepr = num_4x4_blocks_high_txsize_lookup[tx_size];
-        const int stepc = num_4x4_blocks_wide_txsize_lookup[tx_size];
-        const int max_blocks_wide =
-            num_4x4_w + (xd->mb_to_right_edge >= 0
+        const int stepr = tx_size_high_unit[tx_size];
+        const int stepc = tx_size_wide_unit[tx_size];
+        int max_blocks_wide =
+            pd->width + (xd->mb_to_right_edge >= 0
                              ? 0
-                             : xd->mb_to_right_edge >> (5 + pd->subsampling_x));
-        const int max_blocks_high =
-            num_4x4_h +
+                             : xd->mb_to_right_edge >> (3 + pd->subsampling_x));
+        int max_blocks_high =
+            pd->height +
             (xd->mb_to_bottom_edge >= 0 ? 0 : xd->mb_to_bottom_edge >>
-                                                  (5 + pd->subsampling_y));
+                                                  (3 + pd->subsampling_y));
+
+        max_blocks_wide >>= tx_size_wide_log2[0];
+        max_blocks_high >>= tx_size_wide_log2[0];
 
         for (row = 0; row < max_blocks_high; row += stepr)
           for (col = 0; col < max_blocks_wide; col += stepc)
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 21725d7..bf50bc4 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1305,8 +1305,8 @@
 #if CONFIG_VAR_TX
   {
     const TX_SIZE mtx = mbmi->tx_size;
-    const int num_4x4_blocks_wide = num_4x4_blocks_wide_txsize_lookup[mtx] >> 1;
-    const int num_4x4_blocks_high = num_4x4_blocks_high_txsize_lookup[mtx] >> 1;
+    const int num_4x4_blocks_wide = tx_size_wide_unit[mtx] >> 1;
+    const int num_4x4_blocks_high = tx_size_high_unit[mtx] >> 1;
     int idy, idx;
     mbmi->inter_tx_size[0][0] = mtx;
     for (idy = 0; idy < num_4x4_blocks_high; ++idy)