Change tx_size encoding for intra modes

Conveys depth from the largest transform size instead of the
actual transform size. Besides, the max depth is now limited
by the macro MAX_TX_DPETH set at 2.

Results: BDRATE lowres (30 frames): -0.005%

Change-Id: I1ccbac8ee18c77b816a6a8f500abfaa7892b21de
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 0cfbece..b8d8533 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -1201,12 +1201,17 @@
 
 void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y);
 
-static INLINE int tx_size_to_depth(TX_SIZE tx_size) {
-  return (int)(tx_size - TX_SIZE_LUMA_MIN);
+static INLINE int tx_size_cat_to_max_depth(int tx_size_cat) {
+  return AOMMIN(tx_size_cat + 1, MAX_TX_DEPTH);
 }
 
-static INLINE TX_SIZE depth_to_tx_size(int depth) {
-  return (TX_SIZE)(depth + TX_SIZE_LUMA_MIN);
+static INLINE int tx_size_to_depth(TX_SIZE tx_size, int tx_size_cat) {
+  return (int)(tx_size_cat + 1 - (int)tx_size);
+}
+
+static INLINE TX_SIZE depth_to_tx_size(int depth, int tx_size_cat) {
+  assert(tx_size_cat + 1 - depth >= 0 && tx_size_cat + 1 - depth < TX_SIZES);
+  return (TX_SIZE)(tx_size_cat + 1 - depth);
 }
 
 static INLINE TX_SIZE av1_get_uv_tx_size(const MB_MODE_INFO *mbmi,