Cleanup some functions related to transform sizes

Some functions were thin wrappers around another function/tables, so
removed them, and tweaked one function:

- Removed get_max_rect_tx_size()
- Removed av1_get_uv_tx_size()
- Use get_plane_block_size() instead of 'ss_size_lookup' whenever possible
- Simplified signature of av1_get_max_uv_txsize()

Change-Id: I7580cbd9d5e90244628c12829329c359dc0e9894
diff --git a/av1/common/av1_loopfilter.c b/av1/common/av1_loopfilter.c
index fb4bd93..acfe8b0 100644
--- a/av1/common/av1_loopfilter.c
+++ b/av1/common/av1_loopfilter.c
@@ -591,7 +591,8 @@
                         (!curr_skip || !prev_skip || is_coding_block_border);
     if (is_edge) {
       const TX_SIZE prev_tx_size =
-          plane ? av1_get_uv_tx_size(mbmi_prev, subsampling_x, subsampling_y)
+          plane ? av1_get_max_uv_tx_size(mbmi_prev->sb_type, subsampling_x,
+                                         subsampling_y)
                 : mbmi_prev->tx_size;
       const TX_SIZE min_tx_size =
           (dir == VERT_EDGE)
@@ -636,14 +637,14 @@
   TX_SIZE plane_tx_size;
   const int is_inter = is_inter_block(mbmi);
   if (is_inter) {
-    plane_tx_size = plane
-                        ? av1_get_uv_tx_size(mbmi, subsampling_x, subsampling_y)
-                        : mbmi->inter_tx_size[av1_get_txb_size_index(
-                              plane_bsize, blk_row, blk_col)];
+    plane_tx_size = plane ? av1_get_max_uv_txsize(mbmi->sb_type, subsampling_x,
+                                                  subsampling_y)
+                          : mbmi->inter_tx_size[av1_get_txb_size_index(
+                                plane_bsize, blk_row, blk_col)];
   } else {
-    plane_tx_size = plane
-                        ? av1_get_uv_tx_size(mbmi, subsampling_x, subsampling_y)
-                        : mbmi->tx_size;
+    plane_tx_size = plane ? av1_get_max_uv_txsize(mbmi->sb_type, subsampling_x,
+                                                  subsampling_y)
+                          : mbmi->tx_size;
   }
 
   if (plane) assert(plane_tx_size == tx_size);
@@ -682,7 +683,7 @@
       scale_chroma_bsize(bsize, subsampling_x, subsampling_y);
   const BLOCK_SIZE plane_bsize =
       ss_size_lookup[bsizec][subsampling_x][subsampling_y];
-  TX_SIZE max_txsize = get_max_rect_tx_size(plane_bsize);
+  TX_SIZE max_txsize = max_txsize_rect_lookup[plane_bsize];
   // The decoder is designed so that it can process 64x64 luma pixels at a
   // time. If this is a chroma plane with subsampling and bsize corresponds to
   // a subsampled BLOCK_128X128 then the lookup above will give TX_64X64. That
@@ -902,8 +903,7 @@
 
   TX_SIZE tx_size = (plane == AOM_PLANE_Y)
                         ? mbmi->tx_size
-                        : av1_get_uv_tx_size(mbmi, plane_ptr->subsampling_x,
-                                             plane_ptr->subsampling_y);
+                        : av1_get_max_uv_txsize(mbmi->sb_type, plane_ptr);
   assert(tx_size < TX_SIZES_ALL);
   if ((plane == AOM_PLANE_Y) && is_inter_block(mbmi) && !mbmi->skip) {
     const BLOCK_SIZE sb_type = mbmi->sb_type;
@@ -999,7 +999,7 @@
 
           const int pv_skip = mi_prev->skip && is_inter_block(mi_prev);
           const BLOCK_SIZE bsize =
-              ss_size_lookup[mbmi->sb_type][scale_horz][scale_vert];
+              get_plane_block_size(mbmi->sb_type, plane_ptr);
           const int prediction_masks = edge_dir == VERT_EDGE
                                            ? block_size_wide[bsize] - 1
                                            : block_size_high[bsize] - 1;
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 1530805..a25eb42 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -696,13 +696,9 @@
 #define TXSIZEMAX(t1, t2) (tx_size_2d[(t1)] >= tx_size_2d[(t2)] ? (t1) : (t2))
 #define TXSIZEMIN(t1, t2) (tx_size_2d[(t1)] <= tx_size_2d[(t2)] ? (t1) : (t2))
 
-static INLINE TX_SIZE get_max_rect_tx_size(BLOCK_SIZE bsize) {
-  return max_txsize_rect_lookup[bsize];
-}
-
 static INLINE TX_SIZE tx_size_from_tx_mode(BLOCK_SIZE bsize, TX_MODE tx_mode) {
   const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
-  const TX_SIZE max_rect_tx_size = get_max_rect_tx_size(bsize);
+  const TX_SIZE max_rect_tx_size = max_txsize_rect_lookup[bsize];
   if (bsize == BLOCK_4X4)
     return AOMMIN(max_txsize_lookup[bsize], largest_tx_size);
   if (txsize_sqr_map[max_rect_tx_size] <= largest_tx_size)
@@ -848,7 +844,7 @@
                             const int num_planes);
 
 static INLINE int bsize_to_max_depth(BLOCK_SIZE bsize) {
-  TX_SIZE tx_size = get_max_rect_tx_size(bsize);
+  TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
   int depth = 0;
   while (depth < MAX_TX_DEPTH && tx_size != TX_4X4) {
     depth++;
@@ -858,7 +854,7 @@
 }
 
 static INLINE int bsize_to_tx_size_cat(BLOCK_SIZE bsize) {
-  TX_SIZE tx_size = get_max_rect_tx_size(bsize);
+  TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
   assert(tx_size != TX_4X4);
   int depth = 0;
   while (tx_size != TX_4X4) {
@@ -871,15 +867,15 @@
 }
 
 static INLINE TX_SIZE depth_to_tx_size(int depth, BLOCK_SIZE bsize) {
-  TX_SIZE max_tx_size = get_max_rect_tx_size(bsize);
+  TX_SIZE max_tx_size = max_txsize_rect_lookup[bsize];
   TX_SIZE tx_size = max_tx_size;
   for (int d = 0; d < depth; ++d) tx_size = sub_tx_size_map[tx_size];
   return tx_size;
 }
 
-static INLINE TX_SIZE av1_get_max_uv_txsize(BLOCK_SIZE bsize, int ss_x,
-                                            int ss_y) {
-  const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][ss_x][ss_y];
+static INLINE TX_SIZE
+av1_get_max_uv_txsize(BLOCK_SIZE bsize, const struct macroblockd_plane *pd) {
+  const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
   assert(plane_bsize < BLOCK_SIZES_ALL);
   TX_SIZE uv_tx = max_txsize_rect_lookup[plane_bsize];
   switch (uv_tx) {
@@ -893,17 +889,12 @@
   return uv_tx;
 }
 
-static INLINE TX_SIZE av1_get_uv_tx_size(const MB_MODE_INFO *mbmi, int ss_x,
-                                         int ss_y) {
-  return av1_get_max_uv_txsize(mbmi->sb_type, ss_x, ss_y);
-}
-
 static INLINE TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) {
   const MB_MODE_INFO *mbmi = xd->mi[0];
   if (xd->lossless[mbmi->segment_id]) return TX_4X4;
   if (plane == 0) return mbmi->tx_size;
   const MACROBLOCKD_PLANE *pd = &xd->plane[plane];
-  return av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y);
+  return av1_get_max_uv_txsize(mbmi->sb_type, pd);
 }
 
 void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col,
@@ -973,7 +964,7 @@
                                        int subsampled) {
   TX_SIZE max_txsize = xd->lossless[xd->mi[0]->segment_id]
                            ? TX_4X4
-                           : get_max_rect_tx_size(bsize);
+                           : max_txsize_rect_lookup[bsize];
 
   // The decoder is designed so that it can process 64x64 luma pixels at a
   // time. If this is a chroma plane with subsampling and bsize corresponds to
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index d834127..c9bbed3 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -1219,8 +1219,7 @@
                            int dir) {
   assert(is_motion_variation_allowed_bsize(bsize));
 
-  BLOCK_SIZE bsize_plane =
-      ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y];
+  const BLOCK_SIZE bsize_plane = get_plane_block_size(bsize, pd);
   switch (bsize_plane) {
 #if DISABLE_CHROMA_U8X8_OBMC
     case BLOCK_4X4:
@@ -1685,7 +1684,7 @@
   xd->mi[0]->use_intrabc = 0;
 
   av1_predict_intra_block(cm, xd, pd->width, pd->height,
-                          get_max_rect_tx_size(plane_bsize), mode, 0, 0,
+                          max_txsize_rect_lookup[plane_bsize], mode, 0, 0,
                           FILTER_INTRA_MODES, ctx->plane[plane],
                           ctx->stride[plane], dst, dst_stride, 0, 0, plane);
 }
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 003e504..f302f71 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -190,7 +190,7 @@
                                   TX_SIZE tx_size, int *eob_total) {
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const TX_SIZE plane_tx_size =
-      plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
+      plane ? av1_get_max_uv_txsize(mbmi->sb_type, pd)
             : mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row,
                                                          blk_col)];
   // Scale to match transform block unit.
@@ -610,7 +610,7 @@
     }
   } else {
     assert(IMPLIES(tx_mode == ONLY_4X4, bsize == BLOCK_4X4));
-    return get_max_rect_tx_size(bsize);
+    return max_txsize_rect_lookup[bsize];
   }
 }
 
@@ -632,7 +632,7 @@
   int inter_block_tx = is_inter_block(mbmi) || is_intrabc_block(mbmi);
   if (cm->tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
       !mbmi->skip && inter_block_tx && !xd->lossless[mbmi->segment_id]) {
-    const TX_SIZE max_tx_size = get_max_rect_tx_size(bsize);
+    const TX_SIZE max_tx_size = max_txsize_rect_lookup[bsize];
     const int bh = tx_size_high_unit[max_tx_size];
     const int bw = tx_size_wide_unit[max_tx_size];
     const int width = block_size_wide[bsize] >> tx_size_wide_log2[0];
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index eb48509..9216824 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -355,7 +355,7 @@
 
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const TX_SIZE plane_tx_size =
-      plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
+      plane ? av1_get_max_uv_txsize(mbmi->sb_type, pd)
             : mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row,
                                                          blk_col)];
 
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 294c1b2..4b5303a 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -380,7 +380,7 @@
 }
 
 static INLINE int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {
-  TX_SIZE ctx_size = get_max_rect_tx_size(bsize);
+  TX_SIZE ctx_size = max_txsize_rect_lookup[bsize];
   int depth = 0;
   while (tx_size != ctx_size) {
     depth++;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index eef447f..31dd950 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4844,7 +4844,8 @@
         tx_partition_count_update(cm, x, bsize, mi_row, mi_col, td->counts,
                                   tile_data->allow_update_cdf);
       } else {
-        if (mbmi->tx_size != get_max_rect_tx_size(bsize)) ++x->txb_split_count;
+        if (mbmi->tx_size != max_txsize_rect_lookup[bsize])
+          ++x->txb_split_count;
         if (block_signals_txsize(bsize)) {
           const int tx_size_ctx = get_tx_size_context(xd);
           const int32_t tx_size_cat = bsize_to_tx_size_cat(bsize);
@@ -4879,7 +4880,7 @@
           if (mi_col + i < cm->mi_cols && mi_row + j < cm->mi_rows)
             mi_4x4[mis * j + i]->tx_size = intra_tx_size;
 
-      if (intra_tx_size != get_max_rect_tx_size(bsize)) ++x->txb_split_count;
+      if (intra_tx_size != max_txsize_rect_lookup[bsize]) ++x->txb_split_count;
     }
   }
 
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index e08bfbb..ed4ade3 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -307,7 +307,7 @@
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
   const TX_SIZE plane_tx_size =
-      plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
+      plane ? av1_get_max_uv_txsize(mbmi->sb_type, pd)
             : mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row,
                                                          blk_col)];
   if (!plane) {
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index cc50e1b..5827c59 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2987,7 +2987,7 @@
   int start_tx;
   int depth;
   int64_t best_rd = INT64_MAX;
-  const TX_SIZE max_rect_tx_size = get_max_rect_tx_size(bs);
+  const TX_SIZE max_rect_tx_size = max_txsize_rect_lookup[bs];
   TX_SIZE best_tx_size = max_rect_tx_size;
   TX_TYPE best_txk_type[TXK_TYPE_BUF_LEN];
   uint8_t best_blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE];
@@ -4353,7 +4353,7 @@
     const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
     const int mi_width = mi_size_wide[plane_bsize];
     const int mi_height = mi_size_high[plane_bsize];
-    const TX_SIZE max_tx_size = get_max_rect_tx_size(plane_bsize);
+    const TX_SIZE max_tx_size = max_txsize_rect_lookup[plane_bsize];
     const int bh = tx_size_high_unit[max_tx_size];
     const int bw = tx_size_wide_unit[max_tx_size];
     int idx, idy;
@@ -4824,7 +4824,7 @@
 // The sse value is stored in dist.
 static int predict_skip_flag(MACROBLOCK *x, BLOCK_SIZE bsize, int64_t *dist,
                              int reduced_tx_set) {
-  int max_tx_size = get_max_rect_tx_size(bsize);
+  int max_tx_size = max_txsize_rect_lookup[bsize];
   if (tx_size_high[max_tx_size] > 16 || tx_size_wide[max_tx_size] > 16)
     max_tx_size = AOMMIN(max_txsize_lookup[bsize], TX_16X16);
   const int tx_h = tx_size_high[max_tx_size];
@@ -4882,7 +4882,7 @@
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mbmi = xd->mi[0];
   const int n4 = bsize_to_num_blk(bsize);
-  const TX_SIZE tx_size = get_max_rect_tx_size(bsize);
+  const TX_SIZE tx_size = max_txsize_rect_lookup[bsize];
   memset(mbmi->txk_type, DCT_DCT, sizeof(mbmi->txk_type[0]) * TXK_TYPE_BUF_LEN);
   memset(mbmi->inter_tx_size, tx_size, sizeof(mbmi->inter_tx_size));
   mbmi->tx_size = tx_size;
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 2018b4c..caaca1d 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -138,7 +138,7 @@
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
   const TX_SIZE plane_tx_size =
-      plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
+      plane ? av1_get_max_uv_txsize(mbmi->sb_type, pd)
             : mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row,
                                                          blk_col)];