Merge "Enable computing of FastSSIM for HBD build" into nextgenv2
diff --git a/configure b/configure
index c93c22c..9769880 100755
--- a/configure
+++ b/configure
@@ -282,6 +282,7 @@
     ans
     loop_restoration
     ext_partition
+    obmc
 "
 CONFIG_LIST="
     dependency_tracking
diff --git a/vp10/common/entropymode.c b/vp10/common/entropymode.c
index 5c2d51b..4d9f773 100644
--- a/vp10/common/entropymode.c
+++ b/vp10/common/entropymode.c
@@ -184,6 +184,10 @@
     220, 220, 200, 200, 180, 128, 30, 220, 30,
 };
 
+static const vpx_prob default_drl_prob[DRL_MODE_CONTEXTS] = {
+    128, 128, 128,
+};
+
 #if CONFIG_EXT_INTER
 static const vpx_prob default_new2mv_prob = 180;
 #endif
@@ -1292,6 +1296,8 @@
   vp10_copy(fc->newmv_prob, default_newmv_prob);
   vp10_copy(fc->zeromv_prob, default_zeromv_prob);
   vp10_copy(fc->refmv_prob, default_refmv_prob);
+  vp10_copy(fc->drl_prob0, default_drl_prob);
+  vp10_copy(fc->drl_prob1, default_drl_prob);
 #if CONFIG_EXT_INTER
   fc->new2mv_prob = default_new2mv_prob;
 #endif  // CONFIG_EXT_INTER
@@ -1360,6 +1366,13 @@
     fc->refmv_prob[i] = mode_mv_merge_probs(pre_fc->refmv_prob[i],
                                             counts->refmv_mode[i]);
 
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    fc->drl_prob0[i] = mode_mv_merge_probs(pre_fc->drl_prob0[i],
+                                           counts->drl_mode0[i]);
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    fc->drl_prob1[i] = mode_mv_merge_probs(pre_fc->drl_prob1[i],
+                                           counts->drl_mode1[i]);
+
 #if CONFIG_EXT_INTER
   fc->new2mv_prob = mode_mv_merge_probs(pre_fc->new2mv_prob,
                                         counts->new2mv_mode);
diff --git a/vp10/common/entropymode.h b/vp10/common/entropymode.h
index fbadc4e..4b4bdf1 100644
--- a/vp10/common/entropymode.h
+++ b/vp10/common/entropymode.h
@@ -68,6 +68,9 @@
   vpx_prob newmv_prob[NEWMV_MODE_CONTEXTS];
   vpx_prob zeromv_prob[ZEROMV_MODE_CONTEXTS];
   vpx_prob refmv_prob[REFMV_MODE_CONTEXTS];
+  vpx_prob drl_prob0[DRL_MODE_CONTEXTS];
+  vpx_prob drl_prob1[DRL_MODE_CONTEXTS];
+
 #if CONFIG_EXT_INTER
   vpx_prob new2mv_prob;
 #endif  // CONFIG_EXT_INTER
@@ -121,6 +124,8 @@
   unsigned int newmv_mode[NEWMV_MODE_CONTEXTS][2];
   unsigned int zeromv_mode[ZEROMV_MODE_CONTEXTS][2];
   unsigned int refmv_mode[REFMV_MODE_CONTEXTS][2];
+  unsigned int drl_mode0[DRL_MODE_CONTEXTS][2];
+  unsigned int drl_mode1[DRL_MODE_CONTEXTS][2];
 #if CONFIG_EXT_INTER
   unsigned int new2mv_mode[2];
 #endif  // CONFIG_EXT_INTER
diff --git a/vp10/common/enums.h b/vp10/common/enums.h
index fdcde99..f41b8d9 100644
--- a/vp10/common/enums.h
+++ b/vp10/common/enums.h
@@ -231,6 +231,7 @@
 #define NEWMV_MODE_CONTEXTS  7
 #define ZEROMV_MODE_CONTEXTS 2
 #define REFMV_MODE_CONTEXTS  9
+#define DRL_MODE_CONTEXTS    3
 
 #define ZEROMV_OFFSET 3
 #define REFMV_OFFSET  4
@@ -251,6 +252,7 @@
 #define MAX_MV_REF_CANDIDATES 2
 #if CONFIG_REF_MV
 #define MAX_REF_MV_STACK_SIZE 16
+#define REF_CAT_LEVEL  160
 #endif
 
 #define INTRA_INTER_CONTEXTS 4
diff --git a/vp10/common/mvref_common.c b/vp10/common/mvref_common.c
index 53394e9..1b7fb7d 100644
--- a/vp10/common/mvref_common.c
+++ b/vp10/common/mvref_common.c
@@ -329,6 +329,9 @@
 
   nearest_refmv_count = *refmv_count;
 
+  for (idx = 0; idx < nearest_refmv_count; ++idx)
+    ref_mv_stack[idx].weight += REF_CAT_LEVEL;
+
   if (prev_frame_mvs_base && cm->show_frame && cm->last_show_frame
       && rf[1] == NONE) {
     int ref;
diff --git a/vp10/common/mvref_common.h b/vp10/common/mvref_common.h
index 3a77147..224c5ed 100644
--- a/vp10/common/mvref_common.h
+++ b/vp10/common/mvref_common.h
@@ -257,6 +257,24 @@
   else
     return mode_context[rf[0]];
 }
+
+static INLINE uint8_t vp10_drl_ctx(const CANDIDATE_MV *ref_mv_stack,
+                                   int ref_idx) {
+  if (ref_mv_stack[ref_idx + 1].weight > REF_CAT_LEVEL &&
+      ref_mv_stack[ref_idx + 2].weight > REF_CAT_LEVEL)
+    return 0;
+
+  if (ref_mv_stack[ref_idx + 1].weight > REF_CAT_LEVEL &&
+      ref_mv_stack[ref_idx + 2].weight < REF_CAT_LEVEL)
+    return 1;
+
+  if (ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL &&
+      ref_mv_stack[ref_idx + 2].weight < REF_CAT_LEVEL)
+    return 2;
+
+  assert(0);
+  return 0;
+}
 #endif
 
 typedef void (*find_mv_refs_sync)(void *const data, int mi_row);
diff --git a/vp10/common/thread_common.c b/vp10/common/thread_common.c
index bacc534..6e959ed 100644
--- a/vp10/common/thread_common.c
+++ b/vp10/common/thread_common.c
@@ -379,6 +379,15 @@
     for (j = 0; j < 2; ++j)
       cm->counts.refmv_mode[i][j] += counts->refmv_mode[i][j];
 
+
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    for (j = 0; j < 2; ++j)
+      cm->counts.drl_mode0[i][j] += counts->drl_mode0[i][j];
+
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    for (j = 0; j < 2; ++j)
+      cm->counts.drl_mode1[i][j] += counts->drl_mode1[i][j];
+
 #if CONFIG_EXT_INTER
   for (j = 0; j < 2; ++j)
     cm->counts.new2mv_mode[j] += counts->new2mv_mode[j];
diff --git a/vp10/common/vp10_fwd_txfm1d.c b/vp10/common/vp10_fwd_txfm1d.c
index 6e19e27..f3da5c9 100644
--- a/vp10/common/vp10_fwd_txfm1d.c
+++ b/vp10/common/vp10_fwd_txfm1d.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <stdlib.h>
 #include "vp10/common/vp10_fwd_txfm1d.h"
 #if CONFIG_COEFFICIENT_RANGE_CHECKING
 #define range_check(stage, input, buf, size, bit)                         \
@@ -24,7 +25,7 @@
           printf("%d,", input[j]);                                        \
         }                                                                 \
         printf("\n");                                                     \
-        assert(0, "vp10_fwd_txfm1d.c: range_check overflow");             \
+        assert(0);                                                        \
       }                                                                   \
     }                                                                     \
   }
diff --git a/vp10/common/vp10_fwd_txfm2d_cfg.h b/vp10/common/vp10_fwd_txfm2d_cfg.h
index 93fee6f..5c2b4ca 100644
--- a/vp10/common/vp10_fwd_txfm2d_cfg.h
+++ b/vp10/common/vp10_fwd_txfm2d_cfg.h
@@ -11,357 +11,354 @@
 #ifndef VP10_FWD_TXFM2D_CFG_H_
 #define VP10_FWD_TXFM2D_CFG_H_
 #include "vp10/common/vp10_fwd_txfm1d.h"
-
 //  ---------------- config fwd_dct_dct_4 ----------------
-static int8_t fwd_shift_dct_dct_4[3] = {4, 0, -2};
-static int8_t fwd_stage_range_col_dct_dct_4[4] = {15, 16, 17, 17};
-static int8_t fwd_stage_range_row_dct_dct_4[4] = {17, 18, 18, 18};
-static int8_t fwd_cos_bit_col_dct_dct_4[4] = {15, 15, 15, 15};
-static int8_t fwd_cos_bit_row_dct_dct_4[4] = {15, 14, 14, 14};
+static const int8_t fwd_shift_dct_dct_4[3] = {4, 0, -2};
+static const int8_t fwd_stage_range_col_dct_dct_4[4] = {15, 16, 17, 17};
+static const int8_t fwd_stage_range_row_dct_dct_4[4] = {17, 18, 18, 18};
+static const int8_t fwd_cos_bit_col_dct_dct_4[4] = {15, 15, 15, 15};
+static const int8_t fwd_cos_bit_row_dct_dct_4[4] = {15, 14, 14, 14};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_dct_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 4,
-    .stage_num_row = 4,
-
-    .shift = fwd_shift_dct_dct_4,
-    .stage_range_col = fwd_stage_range_col_dct_dct_4,
-    .stage_range_row = fwd_stage_range_row_dct_dct_4,
-    .cos_bit_col = fwd_cos_bit_col_dct_dct_4,
-    .cos_bit_row = fwd_cos_bit_row_dct_dct_4,
-    .txfm_func_col = vp10_fdct4_new,
-    .txfm_func_row = vp10_fdct4_new};
+    4,                              // .txfm_size
+    4,                              // .stage_num_col
+    4,                              // .stage_num_row
+    fwd_shift_dct_dct_4,            // .shift
+    fwd_stage_range_col_dct_dct_4,  // .stage_range_col
+    fwd_stage_range_row_dct_dct_4,  // .stage_range_row
+    fwd_cos_bit_col_dct_dct_4,      // .cos_bit_col
+    fwd_cos_bit_row_dct_dct_4,      // .cos_bit_row
+    vp10_fdct4_new,                 // .txfm_func_col
+    vp10_fdct4_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_dct_8 ----------------
-static int8_t fwd_shift_dct_dct_8[3] = {5, -3, -1};
-static int8_t fwd_stage_range_col_dct_dct_8[6] = {16, 17, 18, 19, 19, 19};
-static int8_t fwd_stage_range_row_dct_dct_8[6] = {16, 17, 18, 18, 18, 18};
-static int8_t fwd_cos_bit_col_dct_dct_8[6] = {15, 15, 14, 13, 13, 13};
-static int8_t fwd_cos_bit_row_dct_dct_8[6] = {15, 15, 14, 14, 14, 14};
+static const int8_t fwd_shift_dct_dct_8[3] = {5, -3, -1};
+static const int8_t fwd_stage_range_col_dct_dct_8[6] = {16, 17, 18, 19, 19, 19};
+static const int8_t fwd_stage_range_row_dct_dct_8[6] = {16, 17, 18, 18, 18, 18};
+static const int8_t fwd_cos_bit_col_dct_dct_8[6] = {15, 15, 14, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_dct_dct_8[6] = {15, 15, 14, 14, 14, 14};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_dct_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 6,
-    .stage_num_row = 6,
-
-    .shift = fwd_shift_dct_dct_8,
-    .stage_range_col = fwd_stage_range_col_dct_dct_8,
-    .stage_range_row = fwd_stage_range_row_dct_dct_8,
-    .cos_bit_col = fwd_cos_bit_col_dct_dct_8,
-    .cos_bit_row = fwd_cos_bit_row_dct_dct_8,
-    .txfm_func_col = vp10_fdct8_new,
-    .txfm_func_row = vp10_fdct8_new};
+    8,                              // .txfm_size
+    6,                              // .stage_num_col
+    6,                              // .stage_num_row
+    fwd_shift_dct_dct_8,            // .shift
+    fwd_stage_range_col_dct_dct_8,  // .stage_range_col
+    fwd_stage_range_row_dct_dct_8,  // .stage_range_row
+    fwd_cos_bit_col_dct_dct_8,      // .cos_bit_col
+    fwd_cos_bit_row_dct_dct_8,      // .cos_bit_row
+    vp10_fdct8_new,                 // .txfm_func_col
+    vp10_fdct8_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_dct_16 ----------------
-static int8_t fwd_shift_dct_dct_16[3] = {4, -3, -1};
-static int8_t fwd_stage_range_col_dct_dct_16[8] = {15, 16, 17, 18,
-                                                   19, 19, 19, 19};
-static int8_t fwd_stage_range_row_dct_dct_16[8] = {16, 17, 18, 19,
-                                                   19, 19, 19, 19};
-static int8_t fwd_cos_bit_col_dct_dct_16[8] = {15, 15, 15, 14, 13, 13, 13, 13};
-static int8_t fwd_cos_bit_row_dct_dct_16[8] = {15, 15, 14, 13, 13, 13, 13, 13};
+static const int8_t fwd_shift_dct_dct_16[3] = {4, -3, -1};
+static const int8_t fwd_stage_range_col_dct_dct_16[8] = {15, 16, 17, 18,
+                                                         19, 19, 19, 19};
+static const int8_t fwd_stage_range_row_dct_dct_16[8] = {16, 17, 18, 19,
+                                                         19, 19, 19, 19};
+static const int8_t fwd_cos_bit_col_dct_dct_16[8] = {15, 15, 15, 14,
+                                                     13, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_dct_dct_16[8] = {15, 15, 14, 13,
+                                                     13, 13, 13, 13};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_dct_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 8,
-    .stage_num_row = 8,
-
-    .shift = fwd_shift_dct_dct_16,
-    .stage_range_col = fwd_stage_range_col_dct_dct_16,
-    .stage_range_row = fwd_stage_range_row_dct_dct_16,
-    .cos_bit_col = fwd_cos_bit_col_dct_dct_16,
-    .cos_bit_row = fwd_cos_bit_row_dct_dct_16,
-    .txfm_func_col = vp10_fdct16_new,
-    .txfm_func_row = vp10_fdct16_new};
+    16,                              // .txfm_size
+    8,                               // .stage_num_col
+    8,                               // .stage_num_row
+    fwd_shift_dct_dct_16,            // .shift
+    fwd_stage_range_col_dct_dct_16,  // .stage_range_col
+    fwd_stage_range_row_dct_dct_16,  // .stage_range_row
+    fwd_cos_bit_col_dct_dct_16,      // .cos_bit_col
+    fwd_cos_bit_row_dct_dct_16,      // .cos_bit_row
+    vp10_fdct16_new,                 // .txfm_func_col
+    vp10_fdct16_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_dct_32 ----------------
-static int8_t fwd_shift_dct_dct_32[3] = {3, -3, -1};
-static int8_t fwd_stage_range_col_dct_dct_32[10] = {14, 15, 16, 17, 18,
-                                                    19, 19, 19, 19, 19};
-static int8_t fwd_stage_range_row_dct_dct_32[10] = {16, 17, 18, 19, 20,
-                                                    20, 20, 20, 20, 20};
-static int8_t fwd_cos_bit_col_dct_dct_32[10] = {15, 15, 15, 15, 14,
-                                                13, 13, 13, 13, 13};
-static int8_t fwd_cos_bit_row_dct_dct_32[10] = {15, 15, 14, 13, 12,
-                                                12, 12, 12, 12, 12};
+static const int8_t fwd_shift_dct_dct_32[3] = {3, -3, -1};
+static const int8_t fwd_stage_range_col_dct_dct_32[10] = {14, 15, 16, 17, 18,
+                                                          19, 19, 19, 19, 19};
+static const int8_t fwd_stage_range_row_dct_dct_32[10] = {16, 17, 18, 19, 20,
+                                                          20, 20, 20, 20, 20};
+static const int8_t fwd_cos_bit_col_dct_dct_32[10] = {15, 15, 15, 15, 14,
+                                                      13, 13, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_dct_dct_32[10] = {15, 15, 14, 13, 12,
+                                                      12, 12, 12, 12, 12};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_dct_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 10,
-    .stage_num_row = 10,
-
-    .shift = fwd_shift_dct_dct_32,
-    .stage_range_col = fwd_stage_range_col_dct_dct_32,
-    .stage_range_row = fwd_stage_range_row_dct_dct_32,
-    .cos_bit_col = fwd_cos_bit_col_dct_dct_32,
-    .cos_bit_row = fwd_cos_bit_row_dct_dct_32,
-    .txfm_func_col = vp10_fdct32_new,
-    .txfm_func_row = vp10_fdct32_new};
+    32,                              // .txfm_size
+    10,                              // .stage_num_col
+    10,                              // .stage_num_row
+    fwd_shift_dct_dct_32,            // .shift
+    fwd_stage_range_col_dct_dct_32,  // .stage_range_col
+    fwd_stage_range_row_dct_dct_32,  // .stage_range_row
+    fwd_cos_bit_col_dct_dct_32,      // .cos_bit_col
+    fwd_cos_bit_row_dct_dct_32,      // .cos_bit_row
+    vp10_fdct32_new,                 // .txfm_func_col
+    vp10_fdct32_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_adst_4 ----------------
-static int8_t fwd_shift_dct_adst_4[3] = {5, -2, -1};
-static int8_t fwd_stage_range_col_dct_adst_4[4] = {16, 17, 18, 18};
-static int8_t fwd_stage_range_row_dct_adst_4[6] = {16, 16, 16, 17, 17, 17};
-static int8_t fwd_cos_bit_col_dct_adst_4[4] = {15, 15, 14, 14};
-static int8_t fwd_cos_bit_row_dct_adst_4[6] = {15, 15, 15, 15, 15, 15};
+static const int8_t fwd_shift_dct_adst_4[3] = {5, -2, -1};
+static const int8_t fwd_stage_range_col_dct_adst_4[4] = {16, 17, 18, 18};
+static const int8_t fwd_stage_range_row_dct_adst_4[6] = {16, 16, 16,
+                                                         17, 17, 17};
+static const int8_t fwd_cos_bit_col_dct_adst_4[4] = {15, 15, 14, 14};
+static const int8_t fwd_cos_bit_row_dct_adst_4[6] = {15, 15, 15, 15, 15, 15};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_adst_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 4,
-    .stage_num_row = 6,
-
-    .shift = fwd_shift_dct_adst_4,
-    .stage_range_col = fwd_stage_range_col_dct_adst_4,
-    .stage_range_row = fwd_stage_range_row_dct_adst_4,
-    .cos_bit_col = fwd_cos_bit_col_dct_adst_4,
-    .cos_bit_row = fwd_cos_bit_row_dct_adst_4,
-    .txfm_func_col = vp10_fdct4_new,
-    .txfm_func_row = vp10_fadst4_new};
+    4,                               // .txfm_size
+    4,                               // .stage_num_col
+    6,                               // .stage_num_row
+    fwd_shift_dct_adst_4,            // .shift
+    fwd_stage_range_col_dct_adst_4,  // .stage_range_col
+    fwd_stage_range_row_dct_adst_4,  // .stage_range_row
+    fwd_cos_bit_col_dct_adst_4,      // .cos_bit_col
+    fwd_cos_bit_row_dct_adst_4,      // .cos_bit_row
+    vp10_fdct4_new,                  // .txfm_func_col
+    vp10_fadst4_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_adst_8 ----------------
-static int8_t fwd_shift_dct_adst_8[3] = {7, -3, -3};
-static int8_t fwd_stage_range_col_dct_adst_8[6] = {18, 19, 20, 21, 21, 21};
-static int8_t fwd_stage_range_row_dct_adst_8[8] = {18, 18, 18, 19,
-                                                   19, 20, 20, 20};
-static int8_t fwd_cos_bit_col_dct_adst_8[6] = {14, 13, 12, 11, 11, 11};
-static int8_t fwd_cos_bit_row_dct_adst_8[8] = {14, 14, 14, 13, 13, 12, 12, 12};
+static const int8_t fwd_shift_dct_adst_8[3] = {7, -3, -3};
+static const int8_t fwd_stage_range_col_dct_adst_8[6] = {18, 19, 20,
+                                                         21, 21, 21};
+static const int8_t fwd_stage_range_row_dct_adst_8[8] = {18, 18, 18, 19,
+                                                         19, 20, 20, 20};
+static const int8_t fwd_cos_bit_col_dct_adst_8[6] = {14, 13, 12, 11, 11, 11};
+static const int8_t fwd_cos_bit_row_dct_adst_8[8] = {14, 14, 14, 13,
+                                                     13, 12, 12, 12};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_adst_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 6,
-    .stage_num_row = 8,
-
-    .shift = fwd_shift_dct_adst_8,
-    .stage_range_col = fwd_stage_range_col_dct_adst_8,
-    .stage_range_row = fwd_stage_range_row_dct_adst_8,
-    .cos_bit_col = fwd_cos_bit_col_dct_adst_8,
-    .cos_bit_row = fwd_cos_bit_row_dct_adst_8,
-    .txfm_func_col = vp10_fdct8_new,
-    .txfm_func_row = vp10_fadst8_new};
+    8,                               // .txfm_size
+    6,                               // .stage_num_col
+    8,                               // .stage_num_row
+    fwd_shift_dct_adst_8,            // .shift
+    fwd_stage_range_col_dct_adst_8,  // .stage_range_col
+    fwd_stage_range_row_dct_adst_8,  // .stage_range_row
+    fwd_cos_bit_col_dct_adst_8,      // .cos_bit_col
+    fwd_cos_bit_row_dct_adst_8,      // .cos_bit_row
+    vp10_fdct8_new,                  // .txfm_func_col
+    vp10_fadst8_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_adst_16 ----------------
-static int8_t fwd_shift_dct_adst_16[3] = {4, -1, -3};
-static int8_t fwd_stage_range_col_dct_adst_16[8] = {15, 16, 17, 18,
-                                                    19, 19, 19, 19};
-static int8_t fwd_stage_range_row_dct_adst_16[10] = {18, 18, 18, 19, 19,
-                                                     20, 20, 21, 21, 21};
-static int8_t fwd_cos_bit_col_dct_adst_16[8] = {15, 15, 15, 14, 13, 13, 13, 13};
-static int8_t fwd_cos_bit_row_dct_adst_16[10] = {14, 14, 14, 13, 13,
-                                                 12, 12, 11, 11, 11};
+static const int8_t fwd_shift_dct_adst_16[3] = {4, -1, -3};
+static const int8_t fwd_stage_range_col_dct_adst_16[8] = {15, 16, 17, 18,
+                                                          19, 19, 19, 19};
+static const int8_t fwd_stage_range_row_dct_adst_16[10] = {18, 18, 18, 19, 19,
+                                                           20, 20, 21, 21, 21};
+static const int8_t fwd_cos_bit_col_dct_adst_16[8] = {15, 15, 15, 14,
+                                                      13, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_dct_adst_16[10] = {14, 14, 14, 13, 13,
+                                                       12, 12, 11, 11, 11};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_adst_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 8,
-    .stage_num_row = 10,
-
-    .shift = fwd_shift_dct_adst_16,
-    .stage_range_col = fwd_stage_range_col_dct_adst_16,
-    .stage_range_row = fwd_stage_range_row_dct_adst_16,
-    .cos_bit_col = fwd_cos_bit_col_dct_adst_16,
-    .cos_bit_row = fwd_cos_bit_row_dct_adst_16,
-    .txfm_func_col = vp10_fdct16_new,
-    .txfm_func_row = vp10_fadst16_new};
+    16,                               // .txfm_size
+    8,                                // .stage_num_col
+    10,                               // .stage_num_row
+    fwd_shift_dct_adst_16,            // .shift
+    fwd_stage_range_col_dct_adst_16,  // .stage_range_col
+    fwd_stage_range_row_dct_adst_16,  // .stage_range_row
+    fwd_cos_bit_col_dct_adst_16,      // .cos_bit_col
+    fwd_cos_bit_row_dct_adst_16,      // .cos_bit_row
+    vp10_fdct16_new,                  // .txfm_func_col
+    vp10_fadst16_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_dct_adst_32 ----------------
-static int8_t fwd_shift_dct_adst_32[3] = {3, -1, -3};
-static int8_t fwd_stage_range_col_dct_adst_32[10] = {14, 15, 16, 17, 18,
-                                                     19, 19, 19, 19, 19};
-static int8_t fwd_stage_range_row_dct_adst_32[12] = {18, 18, 18, 19, 19, 20,
-                                                     20, 21, 21, 22, 22, 22};
-static int8_t fwd_cos_bit_col_dct_adst_32[10] = {15, 15, 15, 15, 14,
-                                                 13, 13, 13, 13, 13};
-static int8_t fwd_cos_bit_row_dct_adst_32[12] = {14, 14, 14, 13, 13, 12,
-                                                 12, 11, 11, 10, 10, 10};
+static const int8_t fwd_shift_dct_adst_32[3] = {3, -1, -3};
+static const int8_t fwd_stage_range_col_dct_adst_32[10] = {14, 15, 16, 17, 18,
+                                                           19, 19, 19, 19, 19};
+static const int8_t fwd_stage_range_row_dct_adst_32[12] = {
+    18, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 22};
+static const int8_t fwd_cos_bit_col_dct_adst_32[10] = {15, 15, 15, 15, 14,
+                                                       13, 13, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_dct_adst_32[12] = {14, 14, 14, 13, 13, 12,
+                                                       12, 11, 11, 10, 10, 10};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_dct_adst_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 10,
-    .stage_num_row = 12,
-
-    .shift = fwd_shift_dct_adst_32,
-    .stage_range_col = fwd_stage_range_col_dct_adst_32,
-    .stage_range_row = fwd_stage_range_row_dct_adst_32,
-    .cos_bit_col = fwd_cos_bit_col_dct_adst_32,
-    .cos_bit_row = fwd_cos_bit_row_dct_adst_32,
-    .txfm_func_col = vp10_fdct32_new,
-    .txfm_func_row = vp10_fadst32_new};
+    32,                               // .txfm_size
+    10,                               // .stage_num_col
+    12,                               // .stage_num_row
+    fwd_shift_dct_adst_32,            // .shift
+    fwd_stage_range_col_dct_adst_32,  // .stage_range_col
+    fwd_stage_range_row_dct_adst_32,  // .stage_range_row
+    fwd_cos_bit_col_dct_adst_32,      // .cos_bit_col
+    fwd_cos_bit_row_dct_adst_32,      // .cos_bit_row
+    vp10_fdct32_new,                  // .txfm_func_col
+    vp10_fadst32_new};                // .txfm_func_row;
 
 //  ---------------- config fwd_adst_adst_4 ----------------
-static int8_t fwd_shift_adst_adst_4[3] = {6, 1, -5};
-static int8_t fwd_stage_range_col_adst_adst_4[6] = {17, 17, 18, 19, 19, 19};
-static int8_t fwd_stage_range_row_adst_adst_4[6] = {20, 20, 20, 21, 21, 21};
-static int8_t fwd_cos_bit_col_adst_adst_4[6] = {15, 15, 14, 13, 13, 13};
-static int8_t fwd_cos_bit_row_adst_adst_4[6] = {12, 12, 12, 11, 11, 11};
+static const int8_t fwd_shift_adst_adst_4[3] = {6, 1, -5};
+static const int8_t fwd_stage_range_col_adst_adst_4[6] = {17, 17, 18,
+                                                          19, 19, 19};
+static const int8_t fwd_stage_range_row_adst_adst_4[6] = {20, 20, 20,
+                                                          21, 21, 21};
+static const int8_t fwd_cos_bit_col_adst_adst_4[6] = {15, 15, 14, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_adst_adst_4[6] = {12, 12, 12, 11, 11, 11};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_adst_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 6,
-    .stage_num_row = 6,
-
-    .shift = fwd_shift_adst_adst_4,
-    .stage_range_col = fwd_stage_range_col_adst_adst_4,
-    .stage_range_row = fwd_stage_range_row_adst_adst_4,
-    .cos_bit_col = fwd_cos_bit_col_adst_adst_4,
-    .cos_bit_row = fwd_cos_bit_row_adst_adst_4,
-    .txfm_func_col = vp10_fadst4_new,
-    .txfm_func_row = vp10_fadst4_new};
+    4,                                // .txfm_size
+    6,                                // .stage_num_col
+    6,                                // .stage_num_row
+    fwd_shift_adst_adst_4,            // .shift
+    fwd_stage_range_col_adst_adst_4,  // .stage_range_col
+    fwd_stage_range_row_adst_adst_4,  // .stage_range_row
+    fwd_cos_bit_col_adst_adst_4,      // .cos_bit_col
+    fwd_cos_bit_row_adst_adst_4,      // .cos_bit_row
+    vp10_fadst4_new,                  // .txfm_func_col
+    vp10_fadst4_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_adst_8 ----------------
-static int8_t fwd_shift_adst_adst_8[3] = {3, -1, -1};
-static int8_t fwd_stage_range_col_adst_adst_8[8] = {14, 14, 15, 16,
-                                                    16, 17, 17, 17};
-static int8_t fwd_stage_range_row_adst_adst_8[8] = {16, 16, 16, 17,
-                                                    17, 18, 18, 18};
-static int8_t fwd_cos_bit_col_adst_adst_8[8] = {15, 15, 15, 15, 15, 15, 15, 15};
-static int8_t fwd_cos_bit_row_adst_adst_8[8] = {15, 15, 15, 15, 15, 14, 14, 14};
+static const int8_t fwd_shift_adst_adst_8[3] = {3, -1, -1};
+static const int8_t fwd_stage_range_col_adst_adst_8[8] = {14, 14, 15, 16,
+                                                          16, 17, 17, 17};
+static const int8_t fwd_stage_range_row_adst_adst_8[8] = {16, 16, 16, 17,
+                                                          17, 18, 18, 18};
+static const int8_t fwd_cos_bit_col_adst_adst_8[8] = {15, 15, 15, 15,
+                                                      15, 15, 15, 15};
+static const int8_t fwd_cos_bit_row_adst_adst_8[8] = {15, 15, 15, 15,
+                                                      15, 14, 14, 14};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_adst_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 8,
-    .stage_num_row = 8,
-
-    .shift = fwd_shift_adst_adst_8,
-    .stage_range_col = fwd_stage_range_col_adst_adst_8,
-    .stage_range_row = fwd_stage_range_row_adst_adst_8,
-    .cos_bit_col = fwd_cos_bit_col_adst_adst_8,
-    .cos_bit_row = fwd_cos_bit_row_adst_adst_8,
-    .txfm_func_col = vp10_fadst8_new,
-    .txfm_func_row = vp10_fadst8_new};
+    8,                                // .txfm_size
+    8,                                // .stage_num_col
+    8,                                // .stage_num_row
+    fwd_shift_adst_adst_8,            // .shift
+    fwd_stage_range_col_adst_adst_8,  // .stage_range_col
+    fwd_stage_range_row_adst_adst_8,  // .stage_range_row
+    fwd_cos_bit_col_adst_adst_8,      // .cos_bit_col
+    fwd_cos_bit_row_adst_adst_8,      // .cos_bit_row
+    vp10_fadst8_new,                  // .txfm_func_col
+    vp10_fadst8_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_adst_16 ----------------
-static int8_t fwd_shift_adst_adst_16[3] = {2, 0, -2};
-static int8_t fwd_stage_range_col_adst_adst_16[10] = {13, 13, 14, 15, 15,
-                                                      16, 16, 17, 17, 17};
-static int8_t fwd_stage_range_row_adst_adst_16[10] = {17, 17, 17, 18, 18,
-                                                      19, 19, 20, 20, 20};
-static int8_t fwd_cos_bit_col_adst_adst_16[10] = {15, 15, 15, 15, 15,
-                                                  15, 15, 15, 15, 15};
-static int8_t fwd_cos_bit_row_adst_adst_16[10] = {15, 15, 15, 14, 14,
-                                                  13, 13, 12, 12, 12};
+static const int8_t fwd_shift_adst_adst_16[3] = {2, 0, -2};
+static const int8_t fwd_stage_range_col_adst_adst_16[10] = {13, 13, 14, 15, 15,
+                                                            16, 16, 17, 17, 17};
+static const int8_t fwd_stage_range_row_adst_adst_16[10] = {17, 17, 17, 18, 18,
+                                                            19, 19, 20, 20, 20};
+static const int8_t fwd_cos_bit_col_adst_adst_16[10] = {15, 15, 15, 15, 15,
+                                                        15, 15, 15, 15, 15};
+static const int8_t fwd_cos_bit_row_adst_adst_16[10] = {15, 15, 15, 14, 14,
+                                                        13, 13, 12, 12, 12};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_adst_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 10,
-    .stage_num_row = 10,
-
-    .shift = fwd_shift_adst_adst_16,
-    .stage_range_col = fwd_stage_range_col_adst_adst_16,
-    .stage_range_row = fwd_stage_range_row_adst_adst_16,
-    .cos_bit_col = fwd_cos_bit_col_adst_adst_16,
-    .cos_bit_row = fwd_cos_bit_row_adst_adst_16,
-    .txfm_func_col = vp10_fadst16_new,
-    .txfm_func_row = vp10_fadst16_new};
+    16,                                // .txfm_size
+    10,                                // .stage_num_col
+    10,                                // .stage_num_row
+    fwd_shift_adst_adst_16,            // .shift
+    fwd_stage_range_col_adst_adst_16,  // .stage_range_col
+    fwd_stage_range_row_adst_adst_16,  // .stage_range_row
+    fwd_cos_bit_col_adst_adst_16,      // .cos_bit_col
+    fwd_cos_bit_row_adst_adst_16,      // .cos_bit_row
+    vp10_fadst16_new,                  // .txfm_func_col
+    vp10_fadst16_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_adst_32 ----------------
-static int8_t fwd_shift_adst_adst_32[3] = {4, -2, -3};
-static int8_t fwd_stage_range_col_adst_adst_32[12] = {15, 15, 16, 17, 17, 18,
-                                                      18, 19, 19, 20, 20, 20};
-static int8_t fwd_stage_range_row_adst_adst_32[12] = {18, 18, 18, 19, 19, 20,
-                                                      20, 21, 21, 22, 22, 22};
-static int8_t fwd_cos_bit_col_adst_adst_32[12] = {15, 15, 15, 15, 15, 14,
-                                                  14, 13, 13, 12, 12, 12};
-static int8_t fwd_cos_bit_row_adst_adst_32[12] = {14, 14, 14, 13, 13, 12,
-                                                  12, 11, 11, 10, 10, 10};
+static const int8_t fwd_shift_adst_adst_32[3] = {4, -2, -3};
+static const int8_t fwd_stage_range_col_adst_adst_32[12] = {
+    15, 15, 16, 17, 17, 18, 18, 19, 19, 20, 20, 20};
+static const int8_t fwd_stage_range_row_adst_adst_32[12] = {
+    18, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 22};
+static const int8_t fwd_cos_bit_col_adst_adst_32[12] = {15, 15, 15, 15, 15, 14,
+                                                        14, 13, 13, 12, 12, 12};
+static const int8_t fwd_cos_bit_row_adst_adst_32[12] = {14, 14, 14, 13, 13, 12,
+                                                        12, 11, 11, 10, 10, 10};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_adst_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 12,
-    .stage_num_row = 12,
-
-    .shift = fwd_shift_adst_adst_32,
-    .stage_range_col = fwd_stage_range_col_adst_adst_32,
-    .stage_range_row = fwd_stage_range_row_adst_adst_32,
-    .cos_bit_col = fwd_cos_bit_col_adst_adst_32,
-    .cos_bit_row = fwd_cos_bit_row_adst_adst_32,
-    .txfm_func_col = vp10_fadst32_new,
-    .txfm_func_row = vp10_fadst32_new};
+    32,                                // .txfm_size
+    12,                                // .stage_num_col
+    12,                                // .stage_num_row
+    fwd_shift_adst_adst_32,            // .shift
+    fwd_stage_range_col_adst_adst_32,  // .stage_range_col
+    fwd_stage_range_row_adst_adst_32,  // .stage_range_row
+    fwd_cos_bit_col_adst_adst_32,      // .cos_bit_col
+    fwd_cos_bit_row_adst_adst_32,      // .cos_bit_row
+    vp10_fadst32_new,                  // .txfm_func_col
+    vp10_fadst32_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_dct_4 ----------------
-static int8_t fwd_shift_adst_dct_4[3] = {5, -4, 1};
-static int8_t fwd_stage_range_col_adst_dct_4[6] = {16, 16, 17, 18, 18, 18};
-static int8_t fwd_stage_range_row_adst_dct_4[4] = {14, 15, 15, 15};
-static int8_t fwd_cos_bit_col_adst_dct_4[6] = {15, 15, 15, 14, 14, 14};
-static int8_t fwd_cos_bit_row_adst_dct_4[4] = {15, 15, 15, 15};
+static const int8_t fwd_shift_adst_dct_4[3] = {5, -4, 1};
+static const int8_t fwd_stage_range_col_adst_dct_4[6] = {16, 16, 17,
+                                                         18, 18, 18};
+static const int8_t fwd_stage_range_row_adst_dct_4[4] = {14, 15, 15, 15};
+static const int8_t fwd_cos_bit_col_adst_dct_4[6] = {15, 15, 15, 14, 14, 14};
+static const int8_t fwd_cos_bit_row_adst_dct_4[4] = {15, 15, 15, 15};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_dct_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 6,
-    .stage_num_row = 4,
-
-    .shift = fwd_shift_adst_dct_4,
-    .stage_range_col = fwd_stage_range_col_adst_dct_4,
-    .stage_range_row = fwd_stage_range_row_adst_dct_4,
-    .cos_bit_col = fwd_cos_bit_col_adst_dct_4,
-    .cos_bit_row = fwd_cos_bit_row_adst_dct_4,
-    .txfm_func_col = vp10_fadst4_new,
-    .txfm_func_row = vp10_fdct4_new};
+    4,                               // .txfm_size
+    6,                               // .stage_num_col
+    4,                               // .stage_num_row
+    fwd_shift_adst_dct_4,            // .shift
+    fwd_stage_range_col_adst_dct_4,  // .stage_range_col
+    fwd_stage_range_row_adst_dct_4,  // .stage_range_row
+    fwd_cos_bit_col_adst_dct_4,      // .cos_bit_col
+    fwd_cos_bit_row_adst_dct_4,      // .cos_bit_row
+    vp10_fadst4_new,                 // .txfm_func_col
+    vp10_fdct4_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_dct_8 ----------------
-static int8_t fwd_shift_adst_dct_8[3] = {5, 1, -5};
-static int8_t fwd_stage_range_col_adst_dct_8[8] = {16, 16, 17, 18,
-                                                   18, 19, 19, 19};
-static int8_t fwd_stage_range_row_adst_dct_8[6] = {20, 21, 22, 22, 22, 22};
-static int8_t fwd_cos_bit_col_adst_dct_8[8] = {15, 15, 15, 14, 14, 13, 13, 13};
-static int8_t fwd_cos_bit_row_adst_dct_8[6] = {12, 11, 10, 10, 10, 10};
+static const int8_t fwd_shift_adst_dct_8[3] = {5, 1, -5};
+static const int8_t fwd_stage_range_col_adst_dct_8[8] = {16, 16, 17, 18,
+                                                         18, 19, 19, 19};
+static const int8_t fwd_stage_range_row_adst_dct_8[6] = {20, 21, 22,
+                                                         22, 22, 22};
+static const int8_t fwd_cos_bit_col_adst_dct_8[8] = {15, 15, 15, 14,
+                                                     14, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_adst_dct_8[6] = {12, 11, 10, 10, 10, 10};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_dct_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 8,
-    .stage_num_row = 6,
-
-    .shift = fwd_shift_adst_dct_8,
-    .stage_range_col = fwd_stage_range_col_adst_dct_8,
-    .stage_range_row = fwd_stage_range_row_adst_dct_8,
-    .cos_bit_col = fwd_cos_bit_col_adst_dct_8,
-    .cos_bit_row = fwd_cos_bit_row_adst_dct_8,
-    .txfm_func_col = vp10_fadst8_new,
-    .txfm_func_row = vp10_fdct8_new};
+    8,                               // .txfm_size
+    8,                               // .stage_num_col
+    6,                               // .stage_num_row
+    fwd_shift_adst_dct_8,            // .shift
+    fwd_stage_range_col_adst_dct_8,  // .stage_range_col
+    fwd_stage_range_row_adst_dct_8,  // .stage_range_row
+    fwd_cos_bit_col_adst_dct_8,      // .cos_bit_col
+    fwd_cos_bit_row_adst_dct_8,      // .cos_bit_row
+    vp10_fadst8_new,                 // .txfm_func_col
+    vp10_fdct8_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_dct_16 ----------------
-static int8_t fwd_shift_adst_dct_16[3] = {4, -3, -1};
-static int8_t fwd_stage_range_col_adst_dct_16[10] = {15, 15, 16, 17, 17,
-                                                     18, 18, 19, 19, 19};
-static int8_t fwd_stage_range_row_adst_dct_16[8] = {16, 17, 18, 19,
-                                                    19, 19, 19, 19};
-static int8_t fwd_cos_bit_col_adst_dct_16[10] = {15, 15, 15, 15, 15,
-                                                 14, 14, 13, 13, 13};
-static int8_t fwd_cos_bit_row_adst_dct_16[8] = {15, 15, 14, 13, 13, 13, 13, 13};
+static const int8_t fwd_shift_adst_dct_16[3] = {4, -3, -1};
+static const int8_t fwd_stage_range_col_adst_dct_16[10] = {15, 15, 16, 17, 17,
+                                                           18, 18, 19, 19, 19};
+static const int8_t fwd_stage_range_row_adst_dct_16[8] = {16, 17, 18, 19,
+                                                          19, 19, 19, 19};
+static const int8_t fwd_cos_bit_col_adst_dct_16[10] = {15, 15, 15, 15, 15,
+                                                       14, 14, 13, 13, 13};
+static const int8_t fwd_cos_bit_row_adst_dct_16[8] = {15, 15, 14, 13,
+                                                      13, 13, 13, 13};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_dct_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 10,
-    .stage_num_row = 8,
-
-    .shift = fwd_shift_adst_dct_16,
-    .stage_range_col = fwd_stage_range_col_adst_dct_16,
-    .stage_range_row = fwd_stage_range_row_adst_dct_16,
-    .cos_bit_col = fwd_cos_bit_col_adst_dct_16,
-    .cos_bit_row = fwd_cos_bit_row_adst_dct_16,
-    .txfm_func_col = vp10_fadst16_new,
-    .txfm_func_row = vp10_fdct16_new};
+    16,                               // .txfm_size
+    10,                               // .stage_num_col
+    8,                                // .stage_num_row
+    fwd_shift_adst_dct_16,            // .shift
+    fwd_stage_range_col_adst_dct_16,  // .stage_range_col
+    fwd_stage_range_row_adst_dct_16,  // .stage_range_row
+    fwd_cos_bit_col_adst_dct_16,      // .cos_bit_col
+    fwd_cos_bit_row_adst_dct_16,      // .cos_bit_row
+    vp10_fadst16_new,                 // .txfm_func_col
+    vp10_fdct16_new};                 // .txfm_func_row;
 
 //  ---------------- config fwd_adst_dct_32 ----------------
-static int8_t fwd_shift_adst_dct_32[3] = {5, -4, -2};
-static int8_t fwd_stage_range_col_adst_dct_32[12] = {16, 16, 17, 18, 18, 19,
-                                                     19, 20, 20, 21, 21, 21};
-static int8_t fwd_stage_range_row_adst_dct_32[10] = {17, 18, 19, 20, 21,
-                                                     21, 21, 21, 21, 21};
-static int8_t fwd_cos_bit_col_adst_dct_32[12] = {15, 15, 15, 14, 14, 13,
-                                                 13, 12, 12, 11, 11, 11};
-static int8_t fwd_cos_bit_row_adst_dct_32[10] = {15, 14, 13, 12, 11,
-                                                 11, 11, 11, 11, 11};
+static const int8_t fwd_shift_adst_dct_32[3] = {5, -4, -2};
+static const int8_t fwd_stage_range_col_adst_dct_32[12] = {
+    16, 16, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21};
+static const int8_t fwd_stage_range_row_adst_dct_32[10] = {17, 18, 19, 20, 21,
+                                                           21, 21, 21, 21, 21};
+static const int8_t fwd_cos_bit_col_adst_dct_32[12] = {15, 15, 15, 14, 14, 13,
+                                                       13, 12, 12, 11, 11, 11};
+static const int8_t fwd_cos_bit_row_adst_dct_32[10] = {15, 14, 13, 12, 11,
+                                                       11, 11, 11, 11, 11};
 
 static const TXFM_2D_CFG fwd_txfm_2d_cfg_adst_dct_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 12,
-    .stage_num_row = 10,
-
-    .shift = fwd_shift_adst_dct_32,
-    .stage_range_col = fwd_stage_range_col_adst_dct_32,
-    .stage_range_row = fwd_stage_range_row_adst_dct_32,
-    .cos_bit_col = fwd_cos_bit_col_adst_dct_32,
-    .cos_bit_row = fwd_cos_bit_row_adst_dct_32,
-    .txfm_func_col = vp10_fadst32_new,
-    .txfm_func_row = vp10_fdct32_new};
+    32,                               // .txfm_size
+    12,                               // .stage_num_col
+    10,                               // .stage_num_row
+    fwd_shift_adst_dct_32,            // .shift
+    fwd_stage_range_col_adst_dct_32,  // .stage_range_col
+    fwd_stage_range_row_adst_dct_32,  // .stage_range_row
+    fwd_cos_bit_col_adst_dct_32,      // .cos_bit_col
+    fwd_cos_bit_row_adst_dct_32,      // .cos_bit_row
+    vp10_fadst32_new,                 // .txfm_func_col
+    vp10_fdct32_new};                 // .txfm_func_row;
 
 #endif  // VP10_FWD_TXFM2D_CFG_H_
diff --git a/vp10/common/vp10_inv_txfm1d.c b/vp10/common/vp10_inv_txfm1d.c
index b64b601..606ca55 100644
--- a/vp10/common/vp10_inv_txfm1d.c
+++ b/vp10/common/vp10_inv_txfm1d.c
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include <stdlib.h>
 #include "vp10/common/vp10_inv_txfm1d.h"
 #if CONFIG_COEFFICIENT_RANGE_CHECKING
 #define range_check(stage, input, buf, size, bit)                         \
@@ -24,7 +25,7 @@
           printf("%d,", input[j]);                                        \
         }                                                                 \
         printf("\n");                                                     \
-        assert(0, "vp10_inv_txfm1d.c: range_check overflow");             \
+        assert(0);                                                        \
       }                                                                   \
     }                                                                     \
   }
diff --git a/vp10/common/vp10_inv_txfm2d_cfg.h b/vp10/common/vp10_inv_txfm2d_cfg.h
index 8cd76b5..fc552fe 100644
--- a/vp10/common/vp10_inv_txfm2d_cfg.h
+++ b/vp10/common/vp10_inv_txfm2d_cfg.h
@@ -20,17 +20,16 @@
 static const int8_t inv_cos_bit_row_dct_dct_4[4] = {15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_dct_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 4,
-    .stage_num_row = 4,
-
-    .shift = inv_shift_dct_dct_4,
-    .stage_range_col = inv_stage_range_col_dct_dct_4,
-    .stage_range_row = inv_stage_range_row_dct_dct_4,
-    .cos_bit_col = inv_cos_bit_col_dct_dct_4,
-    .cos_bit_row = inv_cos_bit_row_dct_dct_4,
-    .txfm_func_col = vp10_idct4_new,
-    .txfm_func_row = vp10_idct4_new};
+    4,                              // .txfm_size
+    4,                              // .stage_num_col
+    4,                              // .stage_num_row
+    inv_shift_dct_dct_4,            // .shift
+    inv_stage_range_col_dct_dct_4,  // .stage_range_col
+    inv_stage_range_row_dct_dct_4,  // .stage_range_row
+    inv_cos_bit_col_dct_dct_4,      // .cos_bit_col
+    inv_cos_bit_row_dct_dct_4,      // .cos_bit_row
+    vp10_idct4_new,                 // .txfm_func_col
+    vp10_idct4_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_dct_8 ----------------
 static const int8_t inv_shift_dct_dct_8[2] = {0, -5};
@@ -40,17 +39,16 @@
 static const int8_t inv_cos_bit_row_dct_dct_8[6] = {15, 15, 15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_dct_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 6,
-    .stage_num_row = 6,
-
-    .shift = inv_shift_dct_dct_8,
-    .stage_range_col = inv_stage_range_col_dct_dct_8,
-    .stage_range_row = inv_stage_range_row_dct_dct_8,
-    .cos_bit_col = inv_cos_bit_col_dct_dct_8,
-    .cos_bit_row = inv_cos_bit_row_dct_dct_8,
-    .txfm_func_col = vp10_idct8_new,
-    .txfm_func_row = vp10_idct8_new};
+    8,                              // .txfm_size
+    6,                              // .stage_num_col
+    6,                              // .stage_num_row
+    inv_shift_dct_dct_8,            // .shift
+    inv_stage_range_col_dct_dct_8,  // .stage_range_col
+    inv_stage_range_row_dct_dct_8,  // .stage_range_row
+    inv_cos_bit_col_dct_dct_8,      // .cos_bit_col
+    inv_cos_bit_row_dct_dct_8,      // .cos_bit_row
+    vp10_idct8_new,                 // .txfm_func_col
+    vp10_idct8_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_dct_16 ----------------
 static const int8_t inv_shift_dct_dct_16[2] = {0, -6};
@@ -64,17 +62,16 @@
                                                      14, 14, 14, 14};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_dct_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 8,
-    .stage_num_row = 8,
-
-    .shift = inv_shift_dct_dct_16,
-    .stage_range_col = inv_stage_range_col_dct_dct_16,
-    .stage_range_row = inv_stage_range_row_dct_dct_16,
-    .cos_bit_col = inv_cos_bit_col_dct_dct_16,
-    .cos_bit_row = inv_cos_bit_row_dct_dct_16,
-    .txfm_func_col = vp10_idct16_new,
-    .txfm_func_row = vp10_idct16_new};
+    16,                              // .txfm_size
+    8,                               // .stage_num_col
+    8,                               // .stage_num_row
+    inv_shift_dct_dct_16,            // .shift
+    inv_stage_range_col_dct_dct_16,  // .stage_range_col
+    inv_stage_range_row_dct_dct_16,  // .stage_range_row
+    inv_cos_bit_col_dct_dct_16,      // .cos_bit_col
+    inv_cos_bit_row_dct_dct_16,      // .cos_bit_row
+    vp10_idct16_new,                 // .txfm_func_col
+    vp10_idct16_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_dct_32 ----------------
 static const int8_t inv_shift_dct_dct_32[2] = {-1, -6};
@@ -88,17 +85,16 @@
                                                       13, 13, 13, 13, 13};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_dct_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 10,
-    .stage_num_row = 10,
-
-    .shift = inv_shift_dct_dct_32,
-    .stage_range_col = inv_stage_range_col_dct_dct_32,
-    .stage_range_row = inv_stage_range_row_dct_dct_32,
-    .cos_bit_col = inv_cos_bit_col_dct_dct_32,
-    .cos_bit_row = inv_cos_bit_row_dct_dct_32,
-    .txfm_func_col = vp10_idct32_new,
-    .txfm_func_row = vp10_idct32_new};
+    32,                              // .txfm_size
+    10,                              // .stage_num_col
+    10,                              // .stage_num_row
+    inv_shift_dct_dct_32,            // .shift
+    inv_stage_range_col_dct_dct_32,  // .stage_range_col
+    inv_stage_range_row_dct_dct_32,  // .stage_range_row
+    inv_cos_bit_col_dct_dct_32,      // .cos_bit_col
+    inv_cos_bit_row_dct_dct_32,      // .cos_bit_row
+    vp10_idct32_new,                 // .txfm_func_col
+    vp10_idct32_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_adst_4 ----------------
 static const int8_t inv_shift_dct_adst_4[2] = {1, -5};
@@ -109,17 +105,16 @@
 static const int8_t inv_cos_bit_row_dct_adst_4[6] = {15, 15, 15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_adst_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 4,
-    .stage_num_row = 6,
-
-    .shift = inv_shift_dct_adst_4,
-    .stage_range_col = inv_stage_range_col_dct_adst_4,
-    .stage_range_row = inv_stage_range_row_dct_adst_4,
-    .cos_bit_col = inv_cos_bit_col_dct_adst_4,
-    .cos_bit_row = inv_cos_bit_row_dct_adst_4,
-    .txfm_func_col = vp10_idct4_new,
-    .txfm_func_row = vp10_iadst4_new};
+    4,                               // .txfm_size
+    4,                               // .stage_num_col
+    6,                               // .stage_num_row
+    inv_shift_dct_adst_4,            // .shift
+    inv_stage_range_col_dct_adst_4,  // .stage_range_col
+    inv_stage_range_row_dct_adst_4,  // .stage_range_row
+    inv_cos_bit_col_dct_adst_4,      // .cos_bit_col
+    inv_cos_bit_row_dct_adst_4,      // .cos_bit_row
+    vp10_idct4_new,                  // .txfm_func_col
+    vp10_iadst4_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_adst_8 ----------------
 static const int8_t inv_shift_dct_adst_8[2] = {-1, -4};
@@ -132,17 +127,16 @@
                                                      15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_adst_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 6,
-    .stage_num_row = 8,
-
-    .shift = inv_shift_dct_adst_8,
-    .stage_range_col = inv_stage_range_col_dct_adst_8,
-    .stage_range_row = inv_stage_range_row_dct_adst_8,
-    .cos_bit_col = inv_cos_bit_col_dct_adst_8,
-    .cos_bit_row = inv_cos_bit_row_dct_adst_8,
-    .txfm_func_col = vp10_idct8_new,
-    .txfm_func_row = vp10_iadst8_new};
+    8,                               // .txfm_size
+    6,                               // .stage_num_col
+    8,                               // .stage_num_row
+    inv_shift_dct_adst_8,            // .shift
+    inv_stage_range_col_dct_adst_8,  // .stage_range_col
+    inv_stage_range_row_dct_adst_8,  // .stage_range_row
+    inv_cos_bit_col_dct_adst_8,      // .cos_bit_col
+    inv_cos_bit_row_dct_adst_8,      // .cos_bit_row
+    vp10_idct8_new,                  // .txfm_func_col
+    vp10_iadst8_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_adst_16 ----------------
 static const int8_t inv_shift_dct_adst_16[2] = {1, -7};
@@ -156,17 +150,16 @@
                                                        14, 14, 14, 14, 14};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_adst_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 8,
-    .stage_num_row = 10,
-
-    .shift = inv_shift_dct_adst_16,
-    .stage_range_col = inv_stage_range_col_dct_adst_16,
-    .stage_range_row = inv_stage_range_row_dct_adst_16,
-    .cos_bit_col = inv_cos_bit_col_dct_adst_16,
-    .cos_bit_row = inv_cos_bit_row_dct_adst_16,
-    .txfm_func_col = vp10_idct16_new,
-    .txfm_func_row = vp10_iadst16_new};
+    16,                               // .txfm_size
+    8,                                // .stage_num_col
+    10,                               // .stage_num_row
+    inv_shift_dct_adst_16,            // .shift
+    inv_stage_range_col_dct_adst_16,  // .stage_range_col
+    inv_stage_range_row_dct_adst_16,  // .stage_range_row
+    inv_cos_bit_col_dct_adst_16,      // .cos_bit_col
+    inv_cos_bit_row_dct_adst_16,      // .cos_bit_row
+    vp10_idct16_new,                  // .txfm_func_col
+    vp10_iadst16_new};                // .txfm_func_row;
 
 //  ---------------- config inv_dct_adst_32 ----------------
 static const int8_t inv_shift_dct_adst_32[2] = {-1, -6};
@@ -180,17 +173,16 @@
                                                        13, 13, 13, 13, 13, 13};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_dct_adst_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 10,
-    .stage_num_row = 12,
-
-    .shift = inv_shift_dct_adst_32,
-    .stage_range_col = inv_stage_range_col_dct_adst_32,
-    .stage_range_row = inv_stage_range_row_dct_adst_32,
-    .cos_bit_col = inv_cos_bit_col_dct_adst_32,
-    .cos_bit_row = inv_cos_bit_row_dct_adst_32,
-    .txfm_func_col = vp10_idct32_new,
-    .txfm_func_row = vp10_iadst32_new};
+    32,                               // .txfm_size
+    10,                               // .stage_num_col
+    12,                               // .stage_num_row
+    inv_shift_dct_adst_32,            // .shift
+    inv_stage_range_col_dct_adst_32,  // .stage_range_col
+    inv_stage_range_row_dct_adst_32,  // .stage_range_row
+    inv_cos_bit_col_dct_adst_32,      // .cos_bit_col
+    inv_cos_bit_row_dct_adst_32,      // .cos_bit_row
+    vp10_idct32_new,                  // .txfm_func_col
+    vp10_iadst32_new};                // .txfm_func_row;
 
 //  ---------------- config inv_adst_adst_4 ----------------
 static const int8_t inv_shift_adst_adst_4[2] = {0, -4};
@@ -202,17 +194,16 @@
 static const int8_t inv_cos_bit_row_adst_adst_4[6] = {15, 15, 15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_adst_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 6,
-    .stage_num_row = 6,
-
-    .shift = inv_shift_adst_adst_4,
-    .stage_range_col = inv_stage_range_col_adst_adst_4,
-    .stage_range_row = inv_stage_range_row_adst_adst_4,
-    .cos_bit_col = inv_cos_bit_col_adst_adst_4,
-    .cos_bit_row = inv_cos_bit_row_adst_adst_4,
-    .txfm_func_col = vp10_iadst4_new,
-    .txfm_func_row = vp10_iadst4_new};
+    4,                                // .txfm_size
+    6,                                // .stage_num_col
+    6,                                // .stage_num_row
+    inv_shift_adst_adst_4,            // .shift
+    inv_stage_range_col_adst_adst_4,  // .stage_range_col
+    inv_stage_range_row_adst_adst_4,  // .stage_range_row
+    inv_cos_bit_col_adst_adst_4,      // .cos_bit_col
+    inv_cos_bit_row_adst_adst_4,      // .cos_bit_row
+    vp10_iadst4_new,                  // .txfm_func_col
+    vp10_iadst4_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_adst_8 ----------------
 static const int8_t inv_shift_adst_adst_8[2] = {-1, -4};
@@ -226,17 +217,16 @@
                                                       15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_adst_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 8,
-    .stage_num_row = 8,
-
-    .shift = inv_shift_adst_adst_8,
-    .stage_range_col = inv_stage_range_col_adst_adst_8,
-    .stage_range_row = inv_stage_range_row_adst_adst_8,
-    .cos_bit_col = inv_cos_bit_col_adst_adst_8,
-    .cos_bit_row = inv_cos_bit_row_adst_adst_8,
-    .txfm_func_col = vp10_iadst8_new,
-    .txfm_func_row = vp10_iadst8_new};
+    8,                                // .txfm_size
+    8,                                // .stage_num_col
+    8,                                // .stage_num_row
+    inv_shift_adst_adst_8,            // .shift
+    inv_stage_range_col_adst_adst_8,  // .stage_range_col
+    inv_stage_range_row_adst_adst_8,  // .stage_range_row
+    inv_cos_bit_col_adst_adst_8,      // .cos_bit_col
+    inv_cos_bit_row_adst_adst_8,      // .cos_bit_row
+    vp10_iadst8_new,                  // .txfm_func_col
+    vp10_iadst8_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_adst_16 ----------------
 static const int8_t inv_shift_adst_adst_16[2] = {0, -6};
@@ -250,17 +240,16 @@
                                                         14, 14, 14, 14, 14};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_adst_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 10,
-    .stage_num_row = 10,
-
-    .shift = inv_shift_adst_adst_16,
-    .stage_range_col = inv_stage_range_col_adst_adst_16,
-    .stage_range_row = inv_stage_range_row_adst_adst_16,
-    .cos_bit_col = inv_cos_bit_col_adst_adst_16,
-    .cos_bit_row = inv_cos_bit_row_adst_adst_16,
-    .txfm_func_col = vp10_iadst16_new,
-    .txfm_func_row = vp10_iadst16_new};
+    16,                                // .txfm_size
+    10,                                // .stage_num_col
+    10,                                // .stage_num_row
+    inv_shift_adst_adst_16,            // .shift
+    inv_stage_range_col_adst_adst_16,  // .stage_range_col
+    inv_stage_range_row_adst_adst_16,  // .stage_range_row
+    inv_cos_bit_col_adst_adst_16,      // .cos_bit_col
+    inv_cos_bit_row_adst_adst_16,      // .cos_bit_row
+    vp10_iadst16_new,                  // .txfm_func_col
+    vp10_iadst16_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_adst_32 ----------------
 static const int8_t inv_shift_adst_adst_32[2] = {-1, -6};
@@ -274,104 +263,103 @@
                                                         13, 13, 13, 13, 13, 13};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_adst_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 12,
-    .stage_num_row = 12,
-
-    .shift = inv_shift_adst_adst_32,
-    .stage_range_col = inv_stage_range_col_adst_adst_32,
-    .stage_range_row = inv_stage_range_row_adst_adst_32,
-    .cos_bit_col = inv_cos_bit_col_adst_adst_32,
-    .cos_bit_row = inv_cos_bit_row_adst_adst_32,
-    .txfm_func_col = vp10_iadst32_new,
-    .txfm_func_row = vp10_iadst32_new};
+    32,                                // .txfm_size
+    12,                                // .stage_num_col
+    12,                                // .stage_num_row
+    inv_shift_adst_adst_32,            // .shift
+    inv_stage_range_col_adst_adst_32,  // .stage_range_col
+    inv_stage_range_row_adst_adst_32,  // .stage_range_row
+    inv_cos_bit_col_adst_adst_32,      // .cos_bit_col
+    inv_cos_bit_row_adst_adst_32,      // .cos_bit_row
+    vp10_iadst32_new,                  // .txfm_func_col
+    vp10_iadst32_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_dct_4 ----------------
 static const int8_t inv_shift_adst_dct_4[2] = {1, -5};
-static const int8_t inv_stage_range_col_adst_dct_4[6] = {17, 17, 17, 17, 16, 16};
+static const int8_t inv_stage_range_col_adst_dct_4[6] = {17, 17, 17,
+                                                         17, 16, 16};
 static const int8_t inv_stage_range_row_adst_dct_4[4] = {16, 16, 16, 16};
 static const int8_t inv_cos_bit_col_adst_dct_4[6] = {15, 15, 15, 15, 15, 15};
 static const int8_t inv_cos_bit_row_adst_dct_4[4] = {15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_dct_4 = {
-    .txfm_size = 4,
-    .stage_num_col = 6,
-    .stage_num_row = 4,
-
-    .shift = inv_shift_adst_dct_4,
-    .stage_range_col = inv_stage_range_col_adst_dct_4,
-    .stage_range_row = inv_stage_range_row_adst_dct_4,
-    .cos_bit_col = inv_cos_bit_col_adst_dct_4,
-    .cos_bit_row = inv_cos_bit_row_adst_dct_4,
-    .txfm_func_col = vp10_iadst4_new,
-    .txfm_func_row = vp10_idct4_new};
+    4,                               // .txfm_size
+    6,                               // .stage_num_col
+    4,                               // .stage_num_row
+    inv_shift_adst_dct_4,            // .shift
+    inv_stage_range_col_adst_dct_4,  // .stage_range_col
+    inv_stage_range_row_adst_dct_4,  // .stage_range_row
+    inv_cos_bit_col_adst_dct_4,      // .cos_bit_col
+    inv_cos_bit_row_adst_dct_4,      // .cos_bit_row
+    vp10_iadst4_new,                 // .txfm_func_col
+    vp10_idct4_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_dct_8 ----------------
 static const int8_t inv_shift_adst_dct_8[2] = {-1, -4};
 static const int8_t inv_stage_range_col_adst_dct_8[8] = {16, 16, 16, 16,
-                                                   16, 16, 15, 15};
-static const int8_t inv_stage_range_row_adst_dct_8[6] = {17, 17, 17, 17, 17, 17};
-static const int8_t inv_cos_bit_col_adst_dct_8[8] = {15, 15, 15, 15, 15, 15, 15, 15};
+                                                         16, 16, 15, 15};
+static const int8_t inv_stage_range_row_adst_dct_8[6] = {17, 17, 17,
+                                                         17, 17, 17};
+static const int8_t inv_cos_bit_col_adst_dct_8[8] = {15, 15, 15, 15,
+                                                     15, 15, 15, 15};
 static const int8_t inv_cos_bit_row_adst_dct_8[6] = {15, 15, 15, 15, 15, 15};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_dct_8 = {
-    .txfm_size = 8,
-    .stage_num_col = 8,
-    .stage_num_row = 6,
-
-    .shift = inv_shift_adst_dct_8,
-    .stage_range_col = inv_stage_range_col_adst_dct_8,
-    .stage_range_row = inv_stage_range_row_adst_dct_8,
-    .cos_bit_col = inv_cos_bit_col_adst_dct_8,
-    .cos_bit_row = inv_cos_bit_row_adst_dct_8,
-    .txfm_func_col = vp10_iadst8_new,
-    .txfm_func_row = vp10_idct8_new};
+    8,                               // .txfm_size
+    8,                               // .stage_num_col
+    6,                               // .stage_num_row
+    inv_shift_adst_dct_8,            // .shift
+    inv_stage_range_col_adst_dct_8,  // .stage_range_col
+    inv_stage_range_row_adst_dct_8,  // .stage_range_row
+    inv_cos_bit_col_adst_dct_8,      // .cos_bit_col
+    inv_cos_bit_row_adst_dct_8,      // .cos_bit_row
+    vp10_iadst8_new,                 // .txfm_func_col
+    vp10_idct8_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_dct_16 ----------------
 static const int8_t inv_shift_adst_dct_16[2] = {-1, -5};
 static const int8_t inv_stage_range_col_adst_dct_16[10] = {17, 17, 17, 17, 17,
-                                                     17, 17, 17, 16, 16};
+                                                           17, 17, 17, 16, 16};
 static const int8_t inv_stage_range_row_adst_dct_16[8] = {18, 18, 18, 18,
-                                                    18, 18, 18, 18};
+                                                          18, 18, 18, 18};
 static const int8_t inv_cos_bit_col_adst_dct_16[10] = {15, 15, 15, 15, 15,
-                                                 15, 15, 15, 15, 15};
-static const int8_t inv_cos_bit_row_adst_dct_16[8] = {14, 14, 14, 14, 14, 14, 14, 14};
+                                                       15, 15, 15, 15, 15};
+static const int8_t inv_cos_bit_row_adst_dct_16[8] = {14, 14, 14, 14,
+                                                      14, 14, 14, 14};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_dct_16 = {
-    .txfm_size = 16,
-    .stage_num_col = 10,
-    .stage_num_row = 8,
-
-    .shift = inv_shift_adst_dct_16,
-    .stage_range_col = inv_stage_range_col_adst_dct_16,
-    .stage_range_row = inv_stage_range_row_adst_dct_16,
-    .cos_bit_col = inv_cos_bit_col_adst_dct_16,
-    .cos_bit_row = inv_cos_bit_row_adst_dct_16,
-    .txfm_func_col = vp10_iadst16_new,
-    .txfm_func_row = vp10_idct16_new};
+    16,                               // .txfm_size
+    10,                               // .stage_num_col
+    8,                                // .stage_num_row
+    inv_shift_adst_dct_16,            // .shift
+    inv_stage_range_col_adst_dct_16,  // .stage_range_col
+    inv_stage_range_row_adst_dct_16,  // .stage_range_row
+    inv_cos_bit_col_adst_dct_16,      // .cos_bit_col
+    inv_cos_bit_row_adst_dct_16,      // .cos_bit_row
+    vp10_iadst16_new,                 // .txfm_func_col
+    vp10_idct16_new};                 // .txfm_func_row;
 
 //  ---------------- config inv_adst_dct_32 ----------------
 static const int8_t inv_shift_adst_dct_32[2] = {-1, -6};
-static const int8_t inv_stage_range_col_adst_dct_32[12] = {18, 18, 18, 18, 18, 18,
-                                                     18, 18, 18, 18, 17, 17};
+static const int8_t inv_stage_range_col_adst_dct_32[12] = {
+    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 17, 17};
 static const int8_t inv_stage_range_row_adst_dct_32[10] = {19, 19, 19, 19, 19,
-                                                     19, 19, 19, 19, 19};
+                                                           19, 19, 19, 19, 19};
 static const int8_t inv_cos_bit_col_adst_dct_32[12] = {14, 14, 14, 14, 14, 14,
-                                                 14, 14, 14, 14, 14, 15};
+                                                       14, 14, 14, 14, 14, 15};
 static const int8_t inv_cos_bit_row_adst_dct_32[10] = {13, 13, 13, 13, 13,
-                                                 13, 13, 13, 13, 13};
+                                                       13, 13, 13, 13, 13};
 
 static const TXFM_2D_CFG inv_txfm_2d_cfg_adst_dct_32 = {
-    .txfm_size = 32,
-    .stage_num_col = 12,
-    .stage_num_row = 10,
-
-    .shift = inv_shift_adst_dct_32,
-    .stage_range_col = inv_stage_range_col_adst_dct_32,
-    .stage_range_row = inv_stage_range_row_adst_dct_32,
-    .cos_bit_col = inv_cos_bit_col_adst_dct_32,
-    .cos_bit_row = inv_cos_bit_row_adst_dct_32,
-    .txfm_func_col = vp10_iadst32_new,
-    .txfm_func_row = vp10_idct32_new};
+    32,                               // .txfm_size
+    12,                               // .stage_num_col
+    10,                               // .stage_num_row
+    inv_shift_adst_dct_32,            // .shift
+    inv_stage_range_col_adst_dct_32,  // .stage_range_col
+    inv_stage_range_row_adst_dct_32,  // .stage_range_row
+    inv_cos_bit_col_adst_dct_32,      // .cos_bit_col
+    inv_cos_bit_row_adst_dct_32,      // .cos_bit_row
+    vp10_iadst32_new,                 // .txfm_func_col
+    vp10_idct32_new};                 // .txfm_func_row;
 
 #endif  // VP10_INV_TXFM2D_CFG_H_
diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c
index a26f969..ec1a5fb 100644
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -132,6 +132,10 @@
     vp10_diff_update_prob(r, &fc->zeromv_prob[i]);
   for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
     vp10_diff_update_prob(r, &fc->refmv_prob[i]);
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    vp10_diff_update_prob(r, &fc->drl_prob0[i]);
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    vp10_diff_update_prob(r, &fc->drl_prob1[i]);
 #if CONFIG_EXT_INTER
   vp10_diff_update_prob(r, &fc->new2mv_prob);
 #endif  // CONFIG_EXT_INTER
diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c
index 8d26c62..78ddf1a 100644
--- a/vp10/decoder/decodemv.c
+++ b/vp10/decoder/decodemv.c
@@ -147,6 +147,45 @@
 #endif
 }
 
+#if CONFIG_REF_MV
+static void read_drl_idx(const VP10_COMMON *cm,
+                         MACROBLOCKD *xd,
+                         MB_MODE_INFO *mbmi,
+                         vpx_reader *r) {
+  uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
+  mbmi->ref_mv_idx = 0;
+
+  if (xd->ref_mv_count[ref_frame_type] > 2) {
+    uint8_t drl0_ctx = vp10_drl_ctx(xd->ref_mv_stack[ref_frame_type], 0);
+    vpx_prob drl0_prob = cm->fc->drl_prob0[drl0_ctx];
+    if (vpx_read(r, drl0_prob)) {
+      mbmi->ref_mv_idx = 1;
+      if (xd->counts)
+        ++xd->counts->drl_mode0[drl0_ctx][1];
+      if (xd->ref_mv_count[ref_frame_type] > 3) {
+        uint8_t drl1_ctx =
+            vp10_drl_ctx(xd->ref_mv_stack[ref_frame_type], 1);
+        vpx_prob drl1_prob = cm->fc->drl_prob1[drl1_ctx];
+        if (vpx_read(r, drl1_prob)) {
+          mbmi->ref_mv_idx = 2;
+          if (xd->counts)
+            ++xd->counts->drl_mode1[drl1_ctx][1];
+
+          return;
+        }
+
+        if (xd->counts)
+          ++xd->counts->drl_mode1[drl1_ctx][0];
+      }
+      return;
+    }
+
+    if (xd->counts)
+      ++xd->counts->drl_mode0[drl0_ctx][0];
+  }
+}
+#endif
+
 #if CONFIG_EXT_INTER
 static PREDICTION_MODE read_inter_compound_mode(VP10_COMMON *cm,
                                                 MACROBLOCKD *xd,
@@ -1056,17 +1095,8 @@
 #endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
                                    r, mode_ctx);
 #if CONFIG_REF_MV
-      if (mbmi->mode == NEARMV) {
-        uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
-        if (xd->ref_mv_count[ref_frame_type] > 2) {
-          if (vpx_read_bit(r)) {
-            mbmi->ref_mv_idx = 1;
-            if (xd->ref_mv_count[ref_frame_type] > 3)
-              if (vpx_read_bit(r))
-                mbmi->ref_mv_idx = 2;
-          }
-        }
-      }
+      if (mbmi->mode == NEARMV)
+        read_drl_idx(cm, xd, mbmi, r);
 #endif
     }
   }
@@ -1279,9 +1309,6 @@
 #if CONFIG_VAR_TX
   BLOCK_SIZE bsize = mbmi->sb_type;
 #endif  // CONFIG_VAR_TX
-#if CONFIG_SUPERTX
-  (void) supertx_enabled;
-#endif  // CONFIG_SUPERTX
 
   mbmi->mv[0].as_int = 0;
   mbmi->mv[1].as_int = 0;
@@ -1294,7 +1321,7 @@
 
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
     if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
         !mbmi->skip && inter_block) {
       const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c
index d4bd122..73111c8 100644
--- a/vp10/encoder/bitstream.c
+++ b/vp10/encoder/bitstream.c
@@ -177,6 +177,28 @@
 #endif
 }
 
+#if CONFIG_REF_MV
+static void write_drl_idx(const VP10_COMMON *cm,
+                          const MB_MODE_INFO *mbmi,
+                          const MB_MODE_INFO_EXT *mbmi_ext,
+                          vpx_writer *w) {
+  uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
+  if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) {
+    uint8_t drl0_ctx =
+        vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0);
+    vpx_prob drl0_prob = cm->fc->drl_prob0[drl0_ctx];
+    vpx_write(w, mbmi->ref_mv_idx != 0, drl0_prob);
+    if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 &&
+        mbmi->ref_mv_idx > 0) {
+      uint8_t drl1_ctx =
+          vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1);
+      vpx_prob drl1_prob = cm->fc->drl_prob1[drl1_ctx];
+      vpx_write(w, mbmi->ref_mv_idx != 1, drl1_prob);
+    }
+  }
+}
+#endif
+
 #if CONFIG_EXT_INTER
 static void write_inter_compound_mode(VP10_COMMON *cm, vpx_writer *w,
                                       PREDICTION_MODE mode,
@@ -312,7 +334,12 @@
   for (i = 0; i < REFMV_MODE_CONTEXTS; ++i)
     vp10_cond_prob_diff_update(w, &cm->fc->refmv_prob[i],
                                counts->refmv_mode[i]);
-
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    vp10_cond_prob_diff_update(w, &cm->fc->drl_prob0[i],
+                               counts->drl_mode0[i]);
+  for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
+    vp10_cond_prob_diff_update(w, &cm->fc->drl_prob1[i],
+                               counts->drl_mode1[i]);
 #if CONFIG_EXT_INTER
   vp10_cond_prob_diff_update(w, &cm->fc->new2mv_prob, counts->new2mv_mode);
 #endif  // CONFIG_EXT_INTER
@@ -994,15 +1021,8 @@
                          mode_ctx);
 
 #if CONFIG_REF_MV
-        if (mode == NEARMV) {
-          uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
-          if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) {
-            vpx_write_bit(w, mbmi->ref_mv_idx != 0);
-            if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 &&
-                mbmi->ref_mv_idx > 0)
-              vpx_write_bit(w, mbmi->ref_mv_idx != 1);
-          }
-        }
+        if (mode == NEARMV)
+          write_drl_idx(cm, mbmi, mbmi_ext, w);
 #endif
       }
     }
@@ -1306,7 +1326,7 @@
   } else {
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
 #endif
     pack_inter_mode_mvs(cpi, m,
 #if CONFIG_SUPERTX
diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c
index 859ec49..ed56006 100644
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -233,7 +233,7 @@
 
 #if CONFIG_VAR_TX
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
   xd->max_tx_size = max_txsize_lookup[bsize];
 #endif
 
@@ -1822,6 +1822,28 @@
                                 has_second_ref(mbmi),
 #endif  // CONFIG_EXT_INTER
                                 mode_ctx);
+
+        if (mode == NEARMV) {
+          uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame);
+          if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) {
+            uint8_t drl0_ctx =
+                vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0);
+            if (mbmi->ref_mv_idx == 0)
+              ++counts->drl_mode0[drl0_ctx][0];
+            else
+              ++counts->drl_mode0[drl0_ctx][1];
+
+            if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 &&
+                mbmi->ref_mv_idx > 0) {
+              uint8_t drl1_ctx =
+                  vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1);
+              if (mbmi->ref_mv_idx == 1)
+                ++counts->drl_mode1[drl1_ctx][0];
+              else
+                ++counts->drl_mode1[drl1_ctx][1];
+            }
+          }
+        }
 #if CONFIG_EXT_INTER
         }
 #endif  // CONFIG_EXT_INTER
@@ -2260,7 +2282,7 @@
 
 #if CONFIG_VAR_TX
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
 #endif
   pc_tree->partitioning = partition;
   save_context(x, mi_row, mi_col, a, l, sa, sl,
@@ -2586,7 +2608,7 @@
 
 #if CONFIG_VAR_TX
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
 #endif
   restore_context(x, mi_row, mi_col, a, l, sa, sl,
 #if CONFIG_VAR_TX
@@ -2875,7 +2897,8 @@
 #endif
   TOKENEXTRA *tp_orig = *tp;
   PICK_MODE_CONTEXT *ctx = &pc_tree->none;
-  int i, pl;
+  int i;
+  const int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
   BLOCK_SIZE subsize;
   RD_COST this_rdc, sum_rdc, best_rdc;
 #if CONFIG_SUPERTX
@@ -2947,7 +2970,7 @@
 
 #if CONFIG_VAR_TX
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
   save_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
   save_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3021,7 +3044,6 @@
                      bsize, ctx, best_rdc.rdcost);
     if (this_rdc.rate != INT_MAX) {
       if (bsize >= BLOCK_8X8) {
-        pl = partition_plane_context(xd, mi_row, mi_col, bsize);
         this_rdc.rate += cpi->partition_cost[pl][PARTITION_NONE];
         this_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
                                  this_rdc.rate, this_rdc.dist);
@@ -3109,7 +3131,7 @@
     }
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
     restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
     restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3164,7 +3186,7 @@
 #if CONFIG_VAR_TX
           xd->above_txfm_context = cm->above_txfm_context + mi_col;
           xd->left_txfm_context =
-              xd->left_txfm_context_buffer + (mi_row & 0x07);
+              xd->left_txfm_context_buffer + (mi_row & MI_MASK);
           restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
           restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3288,7 +3310,6 @@
     }
 
     if (sum_rdc.rdcost < best_rdc.rdcost && i == 4) {
-      pl = partition_plane_context(xd, mi_row, mi_col, bsize);
       sum_rdc.rate += cpi->partition_cost[pl][PARTITION_SPLIT];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
                               sum_rdc.rate, sum_rdc.dist);
@@ -3312,7 +3333,7 @@
     }
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
     restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
     restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3427,7 +3448,6 @@
 #endif  // CONFIG_SUPERTX
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
-      pl = partition_plane_context(xd, mi_row, mi_col, bsize);
       sum_rdc.rate += cpi->partition_cost[pl][PARTITION_HORZ];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate, sum_rdc.dist);
 #if CONFIG_SUPERTX
@@ -3444,7 +3464,7 @@
     }
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
     restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
     restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -3556,7 +3576,6 @@
 #endif  // CONFIG_SUPERTX
 
     if (sum_rdc.rdcost < best_rdc.rdcost) {
-      pl = partition_plane_context(xd, mi_row, mi_col, bsize);
       sum_rdc.rate += cpi->partition_cost[pl][PARTITION_VERT];
       sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv,
                               sum_rdc.rate, sum_rdc.dist);
@@ -3574,7 +3593,7 @@
     }
 #if CONFIG_VAR_TX
     xd->above_txfm_context = cm->above_txfm_context + mi_col;
-    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+    xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
     restore_context(x, mi_row, mi_col, a, l, sa, sl, ta, tl, bsize);
 #else
     restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize);
@@ -4247,7 +4266,7 @@
   int idx, idy;
 
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
 
   for (idy = 0; idy < mi_height; idy += bh)
     for (idx = 0; idx < mi_width; idx += bh)
@@ -4311,7 +4330,7 @@
   int idx, idy;
 
   xd->above_txfm_context = cm->above_txfm_context + mi_col;
-  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & 0x07);
+  xd->left_txfm_context = xd->left_txfm_context_buffer + (mi_row & MI_MASK);
 
   for (idy = 0; idy < mi_height; idy += bh)
     for (idx = 0; idx < mi_width; idx += bh)
@@ -5191,6 +5210,11 @@
   ext_tx_set = get_ext_tx_set(tx_size, bsize, 1);
 #endif  // CONFIG_EXT_TX
   for (tx_type = DCT_DCT; tx_type < TX_TYPES; ++tx_type) {
+#if CONFIG_VAR_TX
+    ENTROPY_CONTEXT ctxa[16], ctxl[16];
+    const struct macroblockd_plane *const pd = &xd->plane[0];
+    int coeff_ctx = 1;
+#endif  // CONFIG_VAR_TX
 #if CONFIG_EXT_TX
     if (!ext_tx_used_inter[ext_tx_set][tx_type])
       continue;
@@ -5204,12 +5228,23 @@
       continue;
 #endif  // CONFIG_EXT_TX
     mbmi->tx_type = tx_type;
-    vp10_txfm_rd_in_plane_supertx(x,
+
 #if CONFIG_VAR_TX
-                                  cpi,
-#endif
-                                  &this_rate, &this_dist, &pnskip,
+    this_rate = 0;
+    this_dist = 0;
+    pnsse = 0;
+    pnskip = 1;
+
+    vp10_get_entropy_contexts(bsize, tx_size, pd, ctxa, ctxl);
+    coeff_ctx = combine_entropy_contexts(ctxa[0], ctxl[0]);
+    vp10_tx_block_rd_b(cpi, x, tx_size,
+                       0, 0, 0, 0,
+                       bsize, coeff_ctx,
+                       &this_rate, &this_dist, &pnsse, &pnskip);
+#else
+    vp10_txfm_rd_in_plane_supertx(x, &this_rate, &this_dist, &pnskip,
                                   &pnsse, INT64_MAX, 0, bsize, tx_size, 0);
+#endif  // CONFIG_VAR_TX
 
 #if CONFIG_EXT_TX
     if (get_ext_tx_types(tx_size, bsize, 1) > 1 &&
diff --git a/vp10/encoder/encoder.h b/vp10/encoder/encoder.h
index 940c9a5..f7c6013 100644
--- a/vp10/encoder/encoder.h
+++ b/vp10/encoder/encoder.h
@@ -474,6 +474,8 @@
   int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2];
   int zeromv_mode_cost[ZEROMV_MODE_CONTEXTS][2];
   int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
+  int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
+  int drl_mode_cost1[DRL_MODE_CONTEXTS][2];
 #if CONFIG_EXT_INTER
   int new2mv_mode_cost[2];
 #endif  // CONFIG_EXT_INTER
diff --git a/vp10/encoder/rd.c b/vp10/encoder/rd.c
index 1aac719..8498ce9 100644
--- a/vp10/encoder/rd.c
+++ b/vp10/encoder/rd.c
@@ -382,6 +382,16 @@
       cpi->refmv_mode_cost[i][0] = vp10_cost_bit(cm->fc->refmv_prob[i], 0);
       cpi->refmv_mode_cost[i][1] = vp10_cost_bit(cm->fc->refmv_prob[i], 1);
     }
+
+    for (i = 0; i < DRL_MODE_CONTEXTS; ++i) {
+      cpi->drl_mode_cost0[i][0] = vp10_cost_bit(cm->fc->drl_prob0[i], 0);
+      cpi->drl_mode_cost0[i][1] = vp10_cost_bit(cm->fc->drl_prob0[i], 1);
+    }
+
+    for (i = 0; i < DRL_MODE_CONTEXTS; ++i) {
+      cpi->drl_mode_cost1[i][0] = vp10_cost_bit(cm->fc->drl_prob1[i], 0);
+      cpi->drl_mode_cost1[i][1] = vp10_cost_bit(cm->fc->drl_prob1[i], 1);
+    }
 #if CONFIG_EXT_INTER
     cpi->new2mv_mode_cost[0] = vp10_cost_bit(cm->fc->new2mv_prob, 0);
     cpi->new2mv_mode_cost[1] = vp10_cost_bit(cm->fc->new2mv_prob, 1);
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index f227272..9e29ce6 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -1842,6 +1842,39 @@
   }
 }
 
+static void pick_intra_angle_routine_sby(VP10_COMP *cpi, MACROBLOCK *x,
+                                         int *rate, int *rate_tokenonly,
+                                         int64_t *distortion, int *skippable,
+                                         int *best_angle_delta,
+                                         TX_SIZE *best_tx_size,
+                                         TX_TYPE *best_tx_type,
+                                         INTRA_FILTER *best_filter,
+                                         BLOCK_SIZE bsize, int rate_overhead,
+                                         int64_t *best_rd) {
+  int this_rate, this_rate_tokenonly, s;
+  int64_t this_distortion, this_rd;
+  MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi;
+  super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
+                  &s, NULL, bsize, *best_rd);
+  if (this_rate_tokenonly == INT_MAX)
+    return;
+
+  this_rate = this_rate_tokenonly + rate_overhead;
+  this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
+
+  if (this_rd < *best_rd) {
+    *best_rd            = this_rd;
+    *best_angle_delta   = mbmi->angle_delta[0];
+    *best_tx_size       = mbmi->tx_size;
+    *best_filter        = mbmi->intra_filter;
+    *best_tx_type       = mbmi->tx_type;
+    *rate               = this_rate;
+    *rate_tokenonly     = this_rate_tokenonly;
+    *distortion         = this_distortion;
+    *skippable          = s;
+  }
+}
+
 static int64_t rd_pick_intra_angle_sby(VP10_COMP *cpi, MACROBLOCK *x,
                                        int *rate, int *rate_tokenonly,
                                        int64_t *distortion, int *skippable,
@@ -1917,24 +1950,14 @@
           if ((FILTER_FAST_SEARCH || !pick_intra_filter(p_angle)) &&
               filter != INTRA_FILTER_LINEAR)
             continue;
-          super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
-                          &s, NULL, bsize, best_rd);
-          if (this_rate_tokenonly == INT_MAX)
-            continue;
-          this_rate = this_rate_tokenonly + rate_overhead +
-              cpi->intra_filter_cost[intra_filter_ctx][filter];
-          this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
-          if (this_rd < best_rd) {
-            best_rd             = this_rd;
-            best_angle_delta    = mbmi->angle_delta[0];
-            best_tx_size        = mbmi->tx_size;
-            best_filter         = mbmi->intra_filter;
-            best_tx_type        = mbmi->tx_type;
-            *rate               = this_rate;
-            *rate_tokenonly     = this_rate_tokenonly;
-            *distortion         = this_distortion;
-            *skippable          = s;
-          }
+          pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly,
+                                       distortion, skippable,
+                                       &best_angle_delta, &best_tx_size,
+                                       &best_tx_type, &best_filter, bsize,
+                                       rate_overhead +
+                                       cpi->intra_filter_cost
+                                       [intra_filter_ctx][filter],
+                                       &best_rd);
         }
       }
     }
@@ -1949,26 +1972,14 @@
         if ((FILTER_FAST_SEARCH || !pick_intra_filter(p_angle)) &&
             filter != INTRA_FILTER_LINEAR)
           continue;
-        super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
-                        &s, NULL, bsize, best_rd);
-        if (this_rate_tokenonly == INT_MAX)
-          continue;
-
-        this_rate = this_rate_tokenonly + rate_overhead +
-            cpi->intra_filter_cost[intra_filter_ctx][filter];
-        this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
-
-        if (this_rd < best_rd) {
-          best_rd             = this_rd;
-          best_angle_delta    = mbmi->angle_delta[0];
-          best_tx_size        = mbmi->tx_size;
-          best_filter         = mbmi->intra_filter;
-          best_tx_type        = mbmi->tx_type;
-          *rate               = this_rate;
-          *rate_tokenonly     = this_rate_tokenonly;
-          *distortion         = this_distortion;
-          *skippable          = s;
-        }
+        pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly,
+                                     distortion, skippable,
+                                     &best_angle_delta, &best_tx_size,
+                                     &best_tx_type, &best_filter, bsize,
+                                     rate_overhead +
+                                     cpi->intra_filter_cost
+                                     [intra_filter_ctx][filter],
+                                     &best_rd);
       }
     }
   }
@@ -1980,26 +1991,12 @@
     if (pick_intra_filter(p_angle)) {
       for (filter = INTRA_FILTER_LINEAR + 1; filter < INTRA_FILTERS; ++filter) {
         mic->mbmi.intra_filter = filter;
-        super_block_yrd(cpi, x, &this_rate_tokenonly, &this_distortion,
-                        &s, NULL, bsize, best_rd);
-        if (this_rate_tokenonly == INT_MAX)
-          continue;
-
-        this_rate = this_rate_tokenonly + rate_overhead +
-            cpi->intra_filter_cost[intra_filter_ctx][filter];
-        this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
-
-        if (this_rd < best_rd) {
-          best_rd             = this_rd;
-          best_angle_delta    = mbmi->angle_delta[0];
-          best_tx_size        = mbmi->tx_size;
-          best_filter         = mbmi->intra_filter;
-          best_tx_type        = mbmi->tx_type;
-          *rate               = this_rate;
-          *rate_tokenonly     = this_rate_tokenonly;
-          *distortion         = this_distortion;
-          *skippable          = s;
-        }
+        pick_intra_angle_routine_sby(cpi, x, rate, rate_tokenonly,
+                                     distortion, skippable,
+                                     &best_angle_delta, &best_tx_size,
+                                     &best_tx_type, &best_filter, bsize,
+                                     rate_overhead + cpi->intra_filter_cost
+                                     [intra_filter_ctx][filter], &best_rd);
       }
     }
   }
@@ -2317,10 +2314,10 @@
 }
 
 #if CONFIG_VAR_TX
-static void tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
-                          int blk_row, int blk_col, int plane, int block,
-                          int plane_bsize, int coeff_ctx,
-                          int *rate, int64_t *dist, int64_t *bsse, int *skip) {
+void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
+                        int blk_row, int blk_col, int plane, int block,
+                        int plane_bsize, int coeff_ctx,
+                        int *rate, int64_t *dist, int64_t *bsse, int *skip) {
   MACROBLOCKD *xd = &x->e_mbd;
   const struct macroblock_plane *const p = &x->plane[plane];
   struct macroblockd_plane *const pd = &xd->plane[plane];
@@ -2531,8 +2528,8 @@
 
   if (cpi->common.tx_mode == TX_MODE_SELECT || tx_size == TX_4X4) {
     mbmi->inter_tx_size[tx_idx] = tx_size;
-    tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
-                  plane_bsize, coeff_ctx, rate, dist, bsse, skip);
+    vp10_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
+                       plane_bsize, coeff_ctx, rate, dist, bsse, skip);
 
     if ((RDCOST(x->rdmult, x->rddiv, *rate, *dist) >=
          RDCOST(x->rdmult, x->rddiv, zero_blk_rate, *bsse) || *skip == 1) &&
@@ -2863,8 +2860,8 @@
         break;
     }
     coeff_ctx = combine_entropy_contexts(ta[0], tl[0]);
-    tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
-                  plane_bsize, coeff_ctx, rate, dist, bsse, skip);
+    vp10_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
+                       plane_bsize, coeff_ctx, rate, dist, bsse, skip);
     for (i = 0; i < (1 << tx_size); ++i) {
       ta[i] = !(p->eobs[block] == 0);
       tl[i] = !(p->eobs[block] == 0);
@@ -3082,6 +3079,32 @@
   }
 }
 
+static void pick_intra_angle_routine_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
+                                          int *rate, int *rate_tokenonly,
+                                          int64_t *distortion, int *skippable,
+                                          int *best_angle_delta,
+                                          BLOCK_SIZE bsize, int rate_overhead,
+                                          int64_t *best_rd) {
+  MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi;
+  int this_rate_tokenonly, this_rate, s;
+  int64_t this_distortion, this_sse, this_rd;
+
+  if (!super_block_uvrd(cpi, x, &this_rate_tokenonly,
+                        &this_distortion, &s, &this_sse, bsize, *best_rd))
+    return;
+
+  this_rate = this_rate_tokenonly + rate_overhead;
+  this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
+  if (this_rd < *best_rd) {
+    *best_rd          = this_rd;
+    *best_angle_delta = mbmi->angle_delta[1];
+    *rate             = this_rate;
+    *rate_tokenonly   = this_rate_tokenonly;
+    *distortion       = this_distortion;
+    *skippable        = s;
+  }
+}
+
 static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
                                     PICK_MODE_CONTEXT *ctx,
                                     int *rate, int *rate_tokenonly,
@@ -3134,38 +3157,20 @@
     if (best_i >= 0) {
       for (j = 0; j < level2; ++j) {
         mbmi->angle_delta[1] = deltas_level2[best_i][j];
-        if (!super_block_uvrd(cpi, x, &this_rate_tokenonly,
-                              &this_distortion, &s, &this_sse, bsize, best_rd))
-          continue;
-        this_rate = this_rate_tokenonly + rate_overhead;
-        this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
-        if (this_rd < best_rd) {
-          best_rd          = this_rd;
-          best_angle_delta = mbmi->angle_delta[1];
-          *rate            = this_rate;
-          *rate_tokenonly  = this_rate_tokenonly;
-          *distortion      = this_distortion;
-          *skippable       = s;
-        }
+        pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly,
+                                      distortion, skippable,
+                                      &best_angle_delta, bsize,
+                                      rate_overhead, &best_rd);
       }
     }
   } else {
     for (angle_delta = -MAX_ANGLE_DELTAS; angle_delta <= MAX_ANGLE_DELTAS;
         ++angle_delta) {
       mbmi->angle_delta[1] = angle_delta;
-      if (!super_block_uvrd(cpi, x, &this_rate_tokenonly,
-                            &this_distortion, &s, &this_sse, bsize, best_rd))
-        continue;
-      this_rate = this_rate_tokenonly + rate_overhead;
-      this_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_distortion);
-      if (this_rd < best_rd) {
-        best_rd          = this_rd;
-        best_angle_delta = mbmi->angle_delta[1];
-        *rate            = this_rate;
-        *rate_tokenonly  = this_rate_tokenonly;
-        *distortion      = this_distortion;
-        *skippable       = s;
-      }
+      pick_intra_angle_routine_sbuv(cpi, x, rate, rate_tokenonly,
+                                    distortion, skippable,
+                                    &best_angle_delta, bsize,
+                                    rate_overhead, &best_rd);
     }
   }
 
@@ -6437,7 +6442,9 @@
         int ref_idx;
         int ref_set = VPXMIN(2, mbmi_ext->ref_mv_count[ref_frame_type] - 2);
 
-        rate2 += vp10_cost_bit(128, 0);
+        uint8_t drl0_ctx =
+            vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0);
+        rate2 += cpi->drl_mode_cost0[drl0_ctx][0];
 
         if (this_rd < INT64_MAX) {
           if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
@@ -6497,9 +6504,13 @@
                                            dummy_filter_cache);
           }
 
-          tmp_rate += vp10_cost_bit(128, 1);
-          if (mbmi_ext->ref_mv_count[ref_frame_type] > 3)
-            tmp_rate += vp10_cost_bit(128, ref_idx);
+          tmp_rate += cpi->drl_mode_cost0[drl0_ctx][1];
+
+          if (mbmi_ext->ref_mv_count[ref_frame_type] > 3) {
+            uint8_t drl1_ctx =
+                vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1);
+            tmp_rate += cpi->drl_mode_cost1[drl1_ctx][ref_idx];
+          }
 
           if (tmp_alt_rd < INT64_MAX) {
             if (RDCOST(x->rdmult, x->rddiv,
diff --git a/vp10/encoder/rdopt.h b/vp10/encoder/rdopt.h
index 62b0aea..a6394fa 100644
--- a/vp10/encoder/rdopt.h
+++ b/vp10/encoder/rdopt.h
@@ -74,6 +74,13 @@
                                     int64_t best_rd_so_far);
 
 #if CONFIG_SUPERTX
+#if CONFIG_VAR_TX
+void vp10_tx_block_rd_b(const VP10_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
+                        int blk_row, int blk_col, int plane, int block,
+                        int plane_bsize, int coeff_ctx,
+                        int *rate, int64_t *dist, int64_t *bsse, int *skip);
+#endif
+
 void vp10_txfm_rd_in_plane_supertx(MACROBLOCK *x,
 #if CONFIG_VAR_TX
                                    const VP10_COMP *cpi,