Merge ext_interp and dual_filter

Change-Id: I0ebd6951d2b42869ae872b33f63a07db03e99c62
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 094698b..9c0d3bf 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -181,7 +181,7 @@
 #endif  // CONFIG_LOOP_RESTORATION
 
 #if CONFIG_EC_MULTISYMBOL
-  /* This hack is necessary when CONFIG_EXT_INTERP is enabled because the five
+  /* This hack is necessary when CONFIG_DUAL_FILTER is enabled because the five
       SWITCHABLE_FILTERS are not consecutive, e.g., 0, 1, 2, 3, 4, when doing
       an in-order traversal of the av1_switchable_interp_tree structure. */
   av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
@@ -1076,24 +1076,12 @@
   int dir;
 #endif
   if (cm->interp_filter == SWITCHABLE) {
-#if CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
     if (!av1_is_interp_needed(xd)) {
       assert(mbmi->interp_filter[0] == EIGHTTAP_REGULAR);
       return;
     }
-#else
-    if (!av1_is_interp_needed(xd)) {
-#if CONFIG_DUAL_FILTER
-      assert(mbmi->interp_filter[0] == EIGHTTAP_REGULAR);
-      assert(mbmi->interp_filter[1] == EIGHTTAP_REGULAR);
-#else
-      assert(mbmi->interp_filter == EIGHTTAP_REGULAR);
-#endif
-      return;
-    }
 #endif  // CONFIG_DUAL_FILTER
-#endif  // CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
     for (dir = 0; dir < 2; ++dir) {
       if (has_subpel_mv_component(xd->mi[0], xd, dir) ||
@@ -1428,9 +1416,9 @@
       }
     }
 
-#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
+#if !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
     write_mb_interp_filter(cpi, xd, w);
-#endif  // !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
+#endif  // !CONFIG_DUAL_FILTER && !CONFIG_WARPED_MOTION
 
     if (bsize < BLOCK_8X8 && !unify_bsize) {
       const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
@@ -1647,9 +1635,9 @@
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode != WARPED_CAUSAL)
 #endif  // CONFIG_WARPED_MOTION
-#if CONFIG_EXT_INTERP || CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION
+#if CONFIG_DUAL_FILTER || CONFIG_WARPED_MOTION
       write_mb_interp_filter(cpi, xd, w);
-#endif  // CONFIG_EXT_INTERP || CONFIG_DUAL_FILTE || CONFIG_WARPED_MOTION
+#endif  // CONFIG_DUAL_FILTE || CONFIG_WARPED_MOTION
   }
 
   write_tx_type(cm, mbmi,
@@ -1865,12 +1853,12 @@
     xd->left_txfm_context =
         xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK);
 #endif
-#if CONFIG_EXT_INTERP
+#if CONFIG_DUAL_FILTER
     // av1_is_interp_needed needs the ref frame buffers set up to look
     // up if they are scaled. av1_is_interp_needed is in turn needed by
     // write_switchable_interp_filter, which is called by pack_inter_mode_mvs.
     set_ref_ptrs(cm, xd, m->mbmi.ref_frame[0], m->mbmi.ref_frame[1]);
-#endif  // CONFIG_EXT_INTERP
+#endif  // CONFIG_DUAL_FILTER
 #if 0
     // NOTE(zoeliu): For debug
     if (cm->current_video_frame == FRAME_TO_CHECK && cm->show_frame == 1) {
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 1933345..196bcaf 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1191,7 +1191,7 @@
       }
 #endif  // CONFIG_GLOBAL_MOTION
       if (cm->interp_filter == SWITCHABLE
-#if CONFIG_EXT_INTERP
+#if CONFIG_DUAL_FILTER
           && av1_is_interp_needed(xd)
 #endif
 #if CONFIG_WARPED_MOTION
@@ -1371,7 +1371,7 @@
 #endif  // CONFIG_GLOBAL_MOTION
 
     if (cm->interp_filter == SWITCHABLE
-#if CONFIG_EXT_INTERP
+#if CONFIG_DUAL_FILTER
         && av1_is_interp_needed(xd)
 #endif
             ) {
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 64b94b9..5771946 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -849,15 +849,10 @@
 int av1_get_switchable_rate(const AV1_COMP *cpi, const MACROBLOCKD *xd) {
   const AV1_COMMON *const cm = &cpi->common;
   if (cm->interp_filter == SWITCHABLE) {
-#if CONFIG_EXT_INTERP
-    if (av1_is_interp_needed(xd))
-#endif
-    {
-      const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-      const int ctx = av1_get_pred_context_switchable_interp(xd);
-      return SWITCHABLE_INTERP_RATE_FACTOR *
-             cpi->switchable_interp_costs[ctx][mbmi->interp_filter];
-    }
+    const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
+    const int ctx = av1_get_pred_context_switchable_interp(xd);
+    return SWITCHABLE_INTERP_RATE_FACTOR *
+           cpi->switchable_interp_costs[ctx][mbmi->interp_filter];
   }
   return 0;
 }
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index f9ab467..4316b91 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -57,18 +57,11 @@
 #endif
 #if CONFIG_DUAL_FILTER
 #define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
-#if CONFIG_EXT_INTERP
 static const int filter_sets[DUAL_FILTER_SET_SIZE][2] = {
   { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 0 }, { 1, 1 },
   { 1, 2 }, { 1, 3 }, { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 },
   { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 },
 };
-#else   // CONFIG_EXT_INTERP
-static const int filter_sets[DUAL_FILTER_SET_SIZE][2] = {
-  { 0, 0 }, { 0, 1 }, { 0, 2 }, { 1, 0 }, { 1, 1 },
-  { 1, 2 }, { 2, 0 }, { 2, 1 }, { 2, 2 },
-};
-#endif  // CONFIG_EXT_INTERP
 #endif  // CONFIG_DUAL_FILTER
 
 #if CONFIG_EXT_REFS
@@ -7441,7 +7434,7 @@
     assign_filter =
         predict_interp_filter(cpi, x, bsize, mi_row, mi_col, single_filter);
 #endif
-#if CONFIG_EXT_INTERP || CONFIG_DUAL_FILTER
+#if CONFIG_DUAL_FILTER
     if (!av1_is_interp_needed(xd)) assign_filter = EIGHTTAP_REGULAR;
 #endif
   } else {
@@ -7535,7 +7528,7 @@
         mbmi->interp_filter = best_filter;
 #endif
       } else {
-#if !CONFIG_EXT_INTERP && !CONFIG_DUAL_FILTER
+#if !CONFIG_DUAL_FILTER
         int tmp_rs;
         InterpFilter best_filter = mbmi->interp_filter;
         rs = av1_get_switchable_rate(cpi, xd);
@@ -7843,16 +7836,12 @@
         av1_cost_bit(cm->fc->interintra_prob[size_group_lookup[bsize]], 0);
   }
 
-#if CONFIG_EXT_INTERP
-  if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE) {
 #if CONFIG_DUAL_FILTER
+  if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE) {
     for (i = 0; i < 4; ++i) mbmi->interp_filter[i] = EIGHTTAP_REGULAR;
-#else
-    mbmi->interp_filter = EIGHTTAP_REGULAR;
-#endif
     pred_exists = 0;
   }
-#endif  // CONFIG_EXT_INTERP
+#endif  // CONFIG_DUAL_FILTER
   if (pred_exists == 0) {
     int tmp_rate;
     int64_t tmp_dist;
@@ -7946,19 +7935,15 @@
 #else
         tmp_rate2 = rate2_nocoeff - rate_mv + tmp_rate_mv;
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
         if (!has_subpel_mv_component(xd->mi[0], xd, 0))
           mbmi->interp_filter[0] = EIGHTTAP_REGULAR;
         if (!has_subpel_mv_component(xd->mi[0], xd, 1))
           mbmi->interp_filter[1] = EIGHTTAP_REGULAR;
-#else
-        if (!av1_is_interp_needed(xd)) mbmi->interp_filter = EIGHTTAP_REGULAR;
-#endif  // CONFIG_DUAL_FILTER
         // This is not quite correct with CONFIG_DUAL_FILTER when a filter
         // is needed in only one direction
         if (!av1_is_interp_needed(xd)) tmp_rate2 -= rs;
-#endif  // CONFIG_EXT_INTERP
+#endif  // CONFIG_DUAL_FILTER
         av1_build_inter_predictors_sb(xd, mi_row, mi_col, &orig_dst, bsize);
 #if CONFIG_EXT_INTER
       } else {
@@ -10387,9 +10372,9 @@
   if (cm->interp_filter != BILINEAR) {
     best_filter = EIGHTTAP_REGULAR;
     if (cm->interp_filter == SWITCHABLE &&
-#if CONFIG_EXT_INTERP
+#if CONFIG_DUAL_FILTER
         av1_is_interp_needed(xd) &&
-#endif  // CONFIG_EXT_INTERP
+#endif  // CONFIG_DUAL_FILTER
         x->source_variance >= cpi->sf.disable_filter_search_var_thresh) {
       int rs;
       int best_rs = INT_MAX;
@@ -10901,18 +10886,12 @@
                 compound_seg_newmvs,
 #endif  // CONFIG_EXT_INTER
                 bsi, switchable_filter_index, mi_row, mi_col);
-#if CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
             if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE &&
                 (mbmi->interp_filter[0] != EIGHTTAP_REGULAR ||
                  mbmi->interp_filter[1] != EIGHTTAP_REGULAR))  // invalid config
               continue;
-#else
-            if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE &&
-                mbmi->interp_filter != EIGHTTAP_REGULAR)  // invalid config
-              continue;
-#endif
-#endif  // CONFIG_EXT_INTERP
+#endif  // CONFIG_DUAL_FILTER
             if (tmp_rd == INT64_MAX) continue;
             rs = av1_get_switchable_rate(cpi, xd);
             rs_rd = RDCOST(x->rdmult, x->rddiv, rs, 0);
@@ -10986,7 +10965,6 @@
             compound_seg_newmvs,
 #endif  // CONFIG_EXT_INTER
             bsi, 0, mi_row, mi_col);
-#if CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
         if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE &&
             (mbmi->interp_filter[0] != EIGHTTAP_REGULAR ||
@@ -10994,12 +10972,7 @@
           mbmi->interp_filter[0] = EIGHTTAP_REGULAR;
           mbmi->interp_filter[1] = EIGHTTAP_REGULAR;
         }
-#else
-        if (!av1_is_interp_needed(xd) && cm->interp_filter == SWITCHABLE &&
-            mbmi->interp_filter != EIGHTTAP_REGULAR)
-          mbmi->interp_filter = EIGHTTAP_REGULAR;
 #endif  // CONFIG_DUAL_FILTER
-#endif  // CONFIG_EXT_INTERP
         if (tmp_rd == INT64_MAX) continue;
       } else {
         total_sse = tmp_best_sse;