Make chroma loopfiltering tx_sizes consistent

Removes existing inconsistencies between chroma tx_sizes
used for chroma loopfiltering.
Includes various refactoring to remove the uv_txsize_lookup
array eventually.

BUG=aomedia:1090

Change-Id: Ib74299b41280ca3ebeaf9a9293242d531d68ad28
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index dda3372..e58c338 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -495,19 +495,18 @@
   const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  TX_SIZE plane_tx_size;
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     TOKEN_STATS tmp_token_stats;
@@ -557,19 +556,18 @@
   const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  TX_SIZE plane_tx_size;
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     TOKEN_STATS tmp_token_stats;
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c
index 7edc15a..c1b3624 100644
--- a/av1/encoder/encodemb.c
+++ b/av1/encoder/encodemb.c
@@ -658,19 +658,18 @@
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  TX_SIZE plane_tx_size;
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 42235ba..b32329e 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4314,7 +4314,6 @@
   BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  TX_SIZE plane_tx_size;
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
@@ -4322,8 +4321,8 @@
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row,
@@ -4332,7 +4331,7 @@
   av1_init_rd_stats(rd_stats);
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     ENTROPY_CONTEXT *ta = above_ctx + blk_col;
@@ -5020,7 +5019,6 @@
   BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
   const int tx_row = blk_row >> (1 - pd->subsampling_y);
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
-  TX_SIZE plane_tx_size;
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
 
@@ -5028,13 +5026,13 @@
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     ENTROPY_CONTEXT *ta = above_ctx + blk_col;
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 86c1cce..3809e58 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -508,17 +508,16 @@
   const int tx_col = blk_col >> (1 - pd->subsampling_x);
   const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
   const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
-  TX_SIZE plane_tx_size;
 
   if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
 
-  plane_tx_size =
-      plane ? uv_txsize_lookup[bsize][mbmi->inter_tx_size[tx_row][tx_col]][0][0]
+  const TX_SIZE plane_tx_size =
+      plane ? av1_get_uv_tx_size_vartx(mbmi, pd, bsize, tx_row, tx_col)
             : mbmi->inter_tx_size[tx_row][tx_col];
 
   if (tx_size == plane_tx_size
 #if DISABLE_VARTX_FOR_CHROMA
-      || pd->subsampling_x || pd->subsampling_y
+      || plane
 #endif  // DISABLE_VARTX_FOR_CHROMA
       ) {
     plane_bsize = get_plane_block_size(mbmi->sb_type, pd);