Enable ADST for UV channel

derflr +0.202%
hevclf +0.207%
hevcmr +0.095%
hevchr +0.077%

Tested locally on several derf sequences, speed (encoder + decoder)
is slower by less than 1%.

It is part of the EXT_TX experiment, which is to be continued to
explore different transform variants.

Change-Id: I05d44994a62106538a9a241ed8d89bd7c5d14761
diff --git a/configure b/configure
index ac196da..6bb90e3 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@
     spatial_svc
     fp_mb_stats
     emulate_hardware
+    ext_tx
 "
 CONFIG_LIST="
     dependency_tracking
diff --git a/vp10/common/blockd.h b/vp10/common/blockd.h
index 26703d1..09406a3 100644
--- a/vp10/common/blockd.h
+++ b/vp10/common/blockd.h
@@ -219,15 +219,21 @@
 };
 
 static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, const MACROBLOCKD *xd,
-                                  int block_idx) {
+                                  int block_idx, TX_SIZE tx_size) {
   const MODE_INFO *const mi = xd->mi[0];
   const MB_MODE_INFO *const mbmi = &mi->mbmi;
 
-  if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi) ||
-      mbmi->tx_size >= TX_32X32)
+#if CONFIG_EXT_TX
+  if (xd->lossless || is_inter_block(mbmi) || tx_size >= TX_32X32)
     return DCT_DCT;
-
+  return intra_mode_to_tx_type_lookup[plane_type == PLANE_TYPE_Y ?
+      get_y_mode(mi, block_idx) : mbmi->uv_mode];
+#else
+  if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi) ||
+      tx_size >= TX_32X32)
+    return DCT_DCT;
   return intra_mode_to_tx_type_lookup[get_y_mode(mi, block_idx)];
+#endif  // CONFIG_EXT_TX
 }
 
 void vp10_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y);
diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c
index 6cb2ff5..e113cdb 100644
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -188,7 +188,7 @@
                                           uint8_t *dst, int stride,
                                           int eob, int block) {
   struct macroblockd_plane *const pd = &xd->plane[plane];
-  TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block);
+  TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
   if (eob > 0) {
     tran_low_t *const dqcoeff = pd->dqcoeff;
 #if CONFIG_VP9_HIGHBITDEPTH
@@ -347,7 +347,7 @@
                           col, row, plane);
 
   if (!mbmi->skip) {
-    TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx);
+    TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
     const scan_order *sc = get_scan(tx_size, tx_type);
     const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size,
                                              r, mbmi->segment_id);
@@ -362,7 +362,7 @@
   struct macroblockd_plane *const pd = &xd->plane[plane];
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
   int block_idx = (row << 1) + col;
-  TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx);
+  TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx, tx_size);
   const scan_order *sc = get_scan(tx_size, tx_type);
   const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
                                           mbmi->segment_id);
diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c
index fbc9848..51b47c9 100644
--- a/vp10/encoder/encodemb.c
+++ b/vp10/encoder/encodemb.c
@@ -104,7 +104,7 @@
   const int mul = 1 + (tx_size == TX_32X32);
   const int16_t *dequant_ptr = pd->dequant;
   const uint8_t *const band_translate = get_band_translate(tx_size);
-  TX_TYPE tx_type = get_tx_type(type, xd, block);
+  TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
   const scan_order *const so = get_scan(tx_size, tx_type);
   const int16_t *const scan = so->scan;
   const int16_t *const nb = so->neighbors;
@@ -329,7 +329,7 @@
   const struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
-  TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+  TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const scan_order *const scan_order = get_scan(tx_size, tx_type);
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
@@ -642,7 +642,7 @@
   const struct macroblock_plane *const p = &x->plane[plane];
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
-  TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+  TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const scan_order *const scan_order = get_scan(tx_size, tx_type);
   tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
   tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
@@ -741,7 +741,7 @@
   int i, j;
   uint8_t *dst;
   ENTROPY_CONTEXT *a, *l;
-  TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block);
+  TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
   txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
   dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i];
   a = &ctx->ta[plane][i];
@@ -928,7 +928,7 @@
   tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
   PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
-  TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+  TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
   const scan_order *const scan_order = get_scan(tx_size, tx_type);
   PREDICTION_MODE mode;
   const int bwl = b_width_log2_lookup[plane_bsize];
diff --git a/vp10/encoder/pickmode.c b/vp10/encoder/pickmode.c
index ef1a060..3a542b9 100644
--- a/vp10/encoder/pickmode.c
+++ b/vp10/encoder/pickmode.c
@@ -601,7 +601,7 @@
     for (c = 0; c < num_4x4_w; c += block_step) {
       if (c < max_blocks_wide) {
         PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
-        TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+        TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
         const scan_order *const scan_order = get_scan(tx_size, tx_type);
         tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
         tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 14efe0e..ea4dce5 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -570,7 +570,7 @@
 
   vp10_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left);
 
-  tx_type = get_tx_type(pd->plane_type, xd, 0);
+  tx_type = get_tx_type(pd->plane_type, xd, 0, tx_size);
   args.so = get_scan(tx_size, tx_type);
 
   vp10_foreach_transformed_block_in_plane(xd, bsize, plane,
@@ -804,7 +804,7 @@
           vpx_highbd_subtract_block(4, 4, src_diff, 8, src, src_stride,
                                     dst, dst_stride, xd->bd);
           if (xd->lossless) {
-            TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+            TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
             const scan_order *so = get_scan(TX_4X4, tx_type);
             vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT,
                                      vp10_highbd_fwht4x4);
@@ -820,7 +820,7 @@
                                          vp10_highbd_iwht4x4_add);
           } else {
             int64_t unused;
-            TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+            TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
             const scan_order *so = get_scan(TX_4X4, tx_type);
             vp10_highbd_fwd_txfm_4x4(src_diff, coeff, 8, tx_type,
                                      vpx_highbd_fdct4x4);
@@ -909,7 +909,7 @@
         vpx_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride);
 
         if (xd->lossless) {
-          TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+          TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
           const scan_order *so = get_scan(TX_4X4, tx_type);
           vp10_fwd_txfm_4x4(src_diff, coeff, 8, DCT_DCT, vp10_fwht4x4);
           vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
@@ -923,7 +923,7 @@
                                 vp10_iwht4x4_add);
         } else {
           int64_t unused;
-          TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+          TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block, TX_4X4);
           const scan_order *so = get_scan(TX_4X4, tx_type);
           vp10_fwd_txfm_4x4(src_diff, coeff, 8, tx_type, vpx_fdct4x4);
           vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
@@ -1316,7 +1316,7 @@
                                                             pd->dst.stride)];
   int64_t thisdistortion = 0, thissse = 0;
   int thisrate = 0, ref;
-  TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, i);
+  TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, i, TX_4X4);
   const scan_order *so = get_scan(TX_4X4, tx_type);
   const int is_compound = has_second_ref(&mi->mbmi);
   const InterpKernel *kernel = vp10_filter_kernels[mi->mbmi.interp_filter];
diff --git a/vp10/encoder/tokenize.c b/vp10/encoder/tokenize.c
index af915fe..b2ee95e 100644
--- a/vp10/encoder/tokenize.c
+++ b/vp10/encoder/tokenize.c
@@ -507,7 +507,7 @@
   const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
   const int segment_id = mbmi->segment_id;
   const int16_t *scan, *nb;
-  const TX_TYPE tx_type = get_tx_type(type, xd, block);
+  const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
   const scan_order *const so = get_scan(tx_size, tx_type);
   const int ref = is_inter_block(mbmi);
   unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =