Merge ref-mv into codebase

Change-Id: I96e386678f6227f3ca735c9be2725cb9795b3296
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index fbdd0c0..a2c85ce 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -70,9 +70,6 @@
 };
 #endif
 static struct av1_token partition_encodings[PARTITION_TYPES];
-#if !CONFIG_REF_MV
-static struct av1_token inter_mode_encodings[INTER_MODES];
-#endif
 #if CONFIG_EXT_INTER
 static const struct av1_token
     inter_compound_mode_encodings[INTER_COMPOUND_MODES] = {
@@ -162,9 +159,6 @@
   av1_tokens_from_tree(intra_mode_encodings, av1_intra_mode_tree);
   av1_tokens_from_tree(switchable_interp_encodings, av1_switchable_interp_tree);
   av1_tokens_from_tree(partition_encodings, av1_partition_tree);
-#if !CONFIG_REF_MV
-  av1_tokens_from_tree(inter_mode_encodings, av1_inter_mode_tree);
-#endif
 
 #if CONFIG_PALETTE
   av1_tokens_from_tree(palette_size_encodings, av1_palette_size_tree);
@@ -251,7 +245,6 @@
 
 static void write_inter_mode(aom_writer *w, PREDICTION_MODE mode,
                              FRAME_CONTEXT *ec_ctx, const int16_t mode_ctx) {
-#if CONFIG_REF_MV
   const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
   const aom_prob newmv_prob = ec_ctx->newmv_prob[newmv_ctx];
 
@@ -283,23 +276,8 @@
   }
 
 #undef IS_NEWMV_MODE
-
-#else  // !CONFIG_REF_MV
-  assert(is_inter_mode(mode));
-#if CONFIG_EC_MULTISYMBOL
-  aom_write_symbol(w, av1_inter_mode_ind[INTER_OFFSET(mode)],
-                   ec_ctx->inter_mode_cdf[mode_ctx], INTER_MODES);
-#else
-  {
-    const aom_prob *const inter_probs = ec_ctx->inter_mode_probs[mode_ctx];
-    av1_write_token(w, av1_inter_mode_tree, inter_probs,
-                    &inter_mode_encodings[INTER_OFFSET(mode)]);
-  }
-#endif
-#endif
 }
 
-#if CONFIG_REF_MV
 static void write_drl_idx(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
                           const MB_MODE_INFO_EXT *mbmi_ext, aom_writer *w) {
   uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
@@ -341,7 +319,6 @@
     return;
   }
 }
-#endif
 
 #if CONFIG_EXT_INTER
 static void write_inter_compound_mode(AV1_COMMON *cm, aom_writer *w,
@@ -497,7 +474,6 @@
   }
 }
 
-#if CONFIG_REF_MV
 static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
                                     FRAME_COUNTS *counts) {
   int i;
@@ -519,7 +495,6 @@
     av1_cond_prob_diff_update(w, &cm->fc->drl_prob[i], counts->drl_mode[i],
                               probwt);
 }
-#endif
 
 #if CONFIG_EXT_INTER
 static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
@@ -1734,9 +1709,6 @@
 #else
   FRAME_CONTEXT *ec_ctx = cm->fc;
 #endif
-#if !CONFIG_REF_MV
-  nmv_context *nmvc = &ec_ctx->nmvc;
-#endif
   const MODE_INFO *mi = xd->mi[0];
 
   const struct segmentation *const seg = &cm->seg;
@@ -1880,7 +1852,6 @@
     int16_t mode_ctx;
     write_ref_frames(cm, xd, w);
 
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
     if (is_compound)
       mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
@@ -1888,9 +1859,6 @@
 #endif  // CONFIG_EXT_INTER
       mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                            mbmi->ref_frame, bsize, -1);
-#else  // CONFIG_REF_MV
-    mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
-#endif  // CONFIG_REF_MV
 
     // If segment skip is not enabled code the mode.
     if (!segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
@@ -1902,7 +1870,6 @@
 #endif  // CONFIG_EXT_INTER
           write_inter_mode(w, mode, ec_ctx, mode_ctx);
 
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
         if (mode == NEWMV || mode == NEW_NEWMV ||
             have_nearmv_in_inter_mode(mode))
@@ -1912,7 +1879,6 @@
           write_drl_idx(cm, mbmi, mbmi_ext, w);
         else
           assert(mbmi->ref_mv_idx == 0);
-#endif
       }
     }
 
@@ -1928,13 +1894,11 @@
         for (idx = 0; idx < 2; idx += num_4x4_w) {
           const int j = idy * 2 + idx;
           const PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
           if (!is_compound)
 #endif  // CONFIG_EXT_INTER
             mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                                  mbmi->ref_frame, bsize, j);
-#endif
 #if CONFIG_EXT_INTER
           if (is_inter_compound_mode(b_mode))
             write_inter_compound_mode(cm, w, b_mode, mode_ctx);
@@ -1948,45 +1912,35 @@
           if (b_mode == NEWMV) {
 #endif  // CONFIG_EXT_INTER
             for (ref = 0; ref < 1 + is_compound; ++ref) {
-#if CONFIG_REF_MV
               int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
               int nmv_ctx = av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                                         mbmi_ext->ref_mv_stack[rf_type], ref,
                                         mbmi->ref_mv_idx);
               nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
               av1_encode_mv(cpi, w, &mi->bmi[j].as_mv[ref].as_mv,
 #if CONFIG_EXT_INTER
                             &mi->bmi[j].ref_mv[ref].as_mv,
 #else
-#if CONFIG_REF_MV
                             &mi->bmi[j].pred_mv[ref].as_mv,
-#else
-                            &mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0].as_mv,
-#endif  // CONFIG_REF_MV
 #endif  // CONFIG_EXT_INTER
                             nmvc, allow_hp);
             }
           }
 #if CONFIG_EXT_INTER
           else if (b_mode == NEAREST_NEWMV || b_mode == NEAR_NEWMV) {
-#if CONFIG_REF_MV
             int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
             int nmv_ctx = av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                                       mbmi_ext->ref_mv_stack[rf_type], 1,
                                       mbmi->ref_mv_idx);
             nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
             av1_encode_mv(cpi, w, &mi->bmi[j].as_mv[1].as_mv,
                           &mi->bmi[j].ref_mv[1].as_mv, nmvc, allow_hp);
           } else if (b_mode == NEW_NEARESTMV || b_mode == NEW_NEARMV) {
-#if CONFIG_REF_MV
             int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
             int nmv_ctx = av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                                       mbmi_ext->ref_mv_stack[rf_type], 0,
                                       mbmi->ref_mv_idx);
             nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
             av1_encode_mv(cpi, w, &mi->bmi[j].as_mv[0].as_mv,
                           &mi->bmi[j].ref_mv[0].as_mv, nmvc, allow_hp);
           }
@@ -2001,37 +1955,31 @@
 #endif  // CONFIG_EXT_INTER
         int_mv ref_mv;
         for (ref = 0; ref < 1 + is_compound; ++ref) {
-#if CONFIG_REF_MV
           int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
           int nmv_ctx = av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                                     mbmi_ext->ref_mv_stack[rf_type], ref,
                                     mbmi->ref_mv_idx);
           nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
           ref_mv = mbmi_ext->ref_mvs[mbmi->ref_frame[ref]][0];
           av1_encode_mv(cpi, w, &mbmi->mv[ref].as_mv, &ref_mv.as_mv, nmvc,
                         allow_hp);
         }
 #if CONFIG_EXT_INTER
       } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) {
-#if CONFIG_REF_MV
         int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
         int nmv_ctx =
             av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                         mbmi_ext->ref_mv_stack[rf_type], 1, mbmi->ref_mv_idx);
         nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
         av1_encode_mv(cpi, w, &mbmi->mv[1].as_mv,
                       &mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_mv, nmvc,
                       allow_hp);
       } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) {
-#if CONFIG_REF_MV
         int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
         int nmv_ctx =
             av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                         mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
         nmv_context *nmvc = &ec_ctx->nmvc[nmv_ctx];
-#endif
         av1_encode_mv(cpi, w, &mbmi->mv[0].as_mv,
                       &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv, nmvc,
                       allow_hp);
@@ -4623,14 +4571,6 @@
   AV1_COMMON *const cm = &cpi->common;
   int frame;
   for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) {
-#if !CONFIG_REF_MV
-    // With ref-mv, clearing unused global motion models here is
-    // unsafe, and we need to rely on the recode loop to do it
-    // instead. See av1_find_mv_refs for details.
-    if (!cpi->td.rd_counts.global_motion_used[frame]) {
-      set_default_warp_params(&cm->global_motion[frame]);
-    }
-#endif
     write_global_motion_params(
         &cm->global_motion[frame], &cm->prev_frame->global_motion[frame],
         cm->fc->global_motion_types_prob, w, cm->allow_high_precision_mv);
@@ -4762,16 +4702,7 @@
                          header_bc);
 #endif  // CONFIG_EC_ADAPT
   } else {
-#if CONFIG_REF_MV
     update_inter_mode_probs(cm, header_bc, counts);
-#else
-#if !CONFIG_EC_ADAPT
-    for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
-      prob_diff_update(av1_inter_mode_tree, cm->fc->inter_mode_probs[i],
-                       counts->inter_mode[i], INTER_MODES, probwt, header_bc);
-    }
-#endif
-#endif
 #if CONFIG_EXT_INTER
     update_inter_compound_mode_probs(cm, probwt, header_bc);
 
@@ -4860,12 +4791,7 @@
     }
 #endif
 
-    av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc,
-#if CONFIG_REF_MV
-                        counts->mv);
-#else
-                        &counts->mv);
-#endif
+    av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc, counts->mv);
 #if !CONFIG_EC_ADAPT
     update_ext_tx_probs(cm, header_bc);
 #endif
@@ -4882,11 +4808,7 @@
   av1_coef_head_cdfs(fc);
 #endif
   av1_coef_pareto_cdfs(fc);
-#if CONFIG_REF_MV
   for (i = 0; i < NMV_CONTEXTS; ++i) av1_set_mv_cdfs(&fc->nmvc[i]);
-#else
-  av1_set_mv_cdfs(&fc->nmvc);
-#endif
 #if CONFIG_EC_MULTISYMBOL
   av1_set_mode_cdfs(cm);
 #endif
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 39e08d5..a674050 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -17,9 +17,7 @@
 #if CONFIG_PVQ
 #include "av1/encoder/encint.h"
 #endif
-#if CONFIG_REF_MV
 #include "av1/common/mvref_common.h"
-#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -79,13 +77,11 @@
   int dc_sign_ctx[MAX_MB_PLANE]
                  [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)];
 #endif
-#if CONFIG_REF_MV
   uint8_t ref_mv_count[MODE_CTX_REF_FRAMES];
   CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE];
 #if CONFIG_EXT_INTER
   int16_t compound_mode_context[MODE_CTX_REF_FRAMES];
 #endif  // CONFIG_EXT_INTER
-#endif
 } MB_MODE_INFO_EXT;
 
 typedef struct {
@@ -141,19 +137,12 @@
   unsigned int pred_sse[TOTAL_REFS_PER_FRAME];
   int pred_mv_sad[TOTAL_REFS_PER_FRAME];
 
-#if CONFIG_REF_MV
   int *nmvjointcost;
   int nmv_vec_cost[NMV_CONTEXTS][MV_JOINTS];
   int *nmvcost[NMV_CONTEXTS][2];
   int *nmvcost_hp[NMV_CONTEXTS][2];
   int **mv_cost_stack[NMV_CONTEXTS];
   int *nmvjointsadcost;
-#else
-  int nmvjointcost[MV_JOINTS];
-  int *nmvcost[2];
-  int *nmvcost_hp[2];
-  int nmvjointsadcost[MV_JOINTS];
-#endif
 
   int **mvcost;
   int *nmvsadcost[2];
@@ -174,10 +163,8 @@
 
 #if CONFIG_VAR_TX
   uint8_t blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
-#if CONFIG_REF_MV
   uint8_t blk_skip_drl[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
 #endif
-#endif
 
   int skip;
 
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 60b2f30..981773b 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1067,7 +1067,6 @@
   }
 }
 
-#if CONFIG_REF_MV
 static void set_ref_and_pred_mvs(MACROBLOCK *const x, int_mv *const mi_pred_mv,
                                  int8_t rf_type) {
   MACROBLOCKD *const xd = &x->e_mbd;
@@ -1116,7 +1115,6 @@
   }
 #endif  // CONFIG_EXT_INTER
 }
-#endif  // CONFIG_REF_MV
 
 static void update_state(const AV1_COMP *const cpi, ThreadData *td,
                          PICK_MODE_CONTEXT *ctx, int mi_row, int mi_col,
@@ -1144,9 +1142,7 @@
   const int mi_height = mi_size_high[bsize];
   const int unify_bsize = CONFIG_CB4X4;
 
-#if CONFIG_REF_MV
   int8_t rf_type;
-#endif
 
 #if !CONFIG_SUPERTX
   assert(mi->mbmi.sb_type == bsize);
@@ -1159,13 +1155,11 @@
   reset_intmv_filter_type(cm, xd, mbmi);
 #endif
 
-#if CONFIG_REF_MV
   rf_type = av1_ref_frame_type(mbmi->ref_frame);
   if (x->mbmi_ext->ref_mv_count[rf_type] > 1 &&
       (mbmi->sb_type >= BLOCK_8X8 || unify_bsize)) {
     set_ref_and_pred_mvs(x, mi->mbmi.pred_mv, rf_type);
   }
-#endif  // CONFIG_REF_MV
 
   // If segmentation in use
   if (seg->enabled) {
@@ -1339,9 +1333,7 @@
   MV_REF *const frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
   int w, h;
 
-#if CONFIG_REF_MV
   int8_t rf_type;
-#endif
 
   *mi_addr = *mi;
   *x->mbmi_ext = ctx->mbmi_ext;
@@ -1352,13 +1344,11 @@
   reset_intmv_filter_type(cm, xd, mbmi);
 #endif
 
-#if CONFIG_REF_MV
   rf_type = av1_ref_frame_type(mbmi->ref_frame);
   if (x->mbmi_ext->ref_mv_count[rf_type] > 1 &&
       (mbmi->sb_type >= BLOCK_8X8 || unify_bsize)) {
     set_ref_and_pred_mvs(x, mi->mbmi.pred_mv, rf_type);
   }
-#endif  // CONFIG_REF_MV
 
   // If segmentation in use
   if (seg->enabled) {
@@ -2020,7 +2010,6 @@
   ctx->dist = rd_cost->dist;
 }
 
-#if CONFIG_REF_MV
 static void update_inter_mode_stats(FRAME_COUNTS *counts, PREDICTION_MODE mode,
                                     int16_t mode_context) {
   int16_t mode_ctx = mode_context & NEWMV_CTX_MASK;
@@ -2050,7 +2039,6 @@
     }
   }
 }
-#endif
 
 static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
                          int mi_col
@@ -2242,12 +2230,8 @@
     if (inter_block &&
         !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
       int16_t mode_ctx;
-#if !CONFIG_REF_MV
-      mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
-#endif
       if (bsize >= BLOCK_8X8 || unify_bsize) {
         const PREDICTION_MODE mode = mbmi->mode;
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
         if (has_second_ref(mbmi)) {
           mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
@@ -2298,14 +2282,6 @@
             }
           }
         }
-#else
-#if CONFIG_EXT_INTER
-        if (is_inter_compound_mode(mode))
-          ++counts->inter_compound_mode[mode_ctx][INTER_COMPOUND_OFFSET(mode)];
-        else
-#endif  // CONFIG_EXT_INTER
-          ++counts->inter_mode[mode_ctx][INTER_OFFSET(mode)];
-#endif
       } else {
         const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
         const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
@@ -2314,7 +2290,6 @@
           for (idx = 0; idx < 2; idx += num_4x4_w) {
             const int j = idy * 2 + idx;
             const PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
             if (has_second_ref(mbmi)) {
               mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
@@ -2328,15 +2303,6 @@
 #if CONFIG_EXT_INTER
             }
 #endif  // CONFIG_EXT_INTER
-#else
-#if CONFIG_EXT_INTER
-            if (is_inter_compound_mode(b_mode))
-              ++counts->inter_compound_mode[mode_ctx]
-                                           [INTER_COMPOUND_OFFSET(b_mode)];
-            else
-#endif  // CONFIG_EXT_INTER
-              ++counts->inter_mode[mode_ctx][INTER_OFFSET(b_mode)];
-#endif
           }
         }
       }
@@ -5179,9 +5145,7 @@
 
   x->min_partition_size = AOMMIN(x->min_partition_size, cm->sb_size);
   x->max_partition_size = AOMMIN(x->max_partition_size, cm->sb_size);
-#if CONFIG_REF_MV
   cm->setup_mi(cm);
-#endif
 
   xd->mi = cm->mi_grid_visible;
   xd->mi[0] = cm->mi;
@@ -5364,10 +5328,8 @@
 
 #if CONFIG_VAR_TX
   x->txb_split_count = 0;
-#if CONFIG_REF_MV
   av1_zero(x->blk_skip_drl);
 #endif
-#endif
 
   if (cpi->sf.partition_search_type == VAR_BASED_PARTITION &&
       cpi->td.var_root[0] == NULL)
diff --git a/av1/encoder/encodemv.c b/av1/encoder/encodemv.c
index a2a53f8..064fdc6 100644
--- a/av1/encoder/encodemv.c
+++ b/av1/encoder/encodemv.c
@@ -171,7 +171,6 @@
 void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
                          nmv_context_counts *const nmv_counts) {
   int i;
-#if CONFIG_REF_MV
   int nmv_ctx = 0;
   for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) {
     nmv_context *const mvc = &cm->fc->nmvc[nmv_ctx];
@@ -213,46 +212,6 @@
       }
     }
   }
-#else
-  nmv_context *const mvc = &cm->fc->nmvc;
-  nmv_context_counts *const counts = nmv_counts;
-
-#if !CONFIG_EC_ADAPT
-  write_mv_update(av1_mv_joint_tree, mvc->joints, counts->joints, MV_JOINTS, w);
-
-  for (i = 0; i < 2; ++i) {
-    int j;
-    nmv_component *comp = &mvc->comps[i];
-    nmv_component_counts *comp_counts = &counts->comps[i];
-
-    update_mv(w, comp_counts->sign, &comp->sign, MV_UPDATE_PROB);
-    write_mv_update(av1_mv_class_tree, comp->classes, comp_counts->classes,
-                    MV_CLASSES, w);
-    write_mv_update(av1_mv_class0_tree, comp->class0, comp_counts->class0,
-                    CLASS0_SIZE, w);
-    for (j = 0; j < MV_OFFSET_BITS; ++j)
-      update_mv(w, comp_counts->bits[j], &comp->bits[j], MV_UPDATE_PROB);
-  }
-
-  for (i = 0; i < 2; ++i) {
-    int j;
-    for (j = 0; j < CLASS0_SIZE; ++j) {
-      write_mv_update(av1_mv_fp_tree, mvc->comps[i].class0_fp[j],
-                      counts->comps[i].class0_fp[j], MV_FP_SIZE, w);
-    }
-    write_mv_update(av1_mv_fp_tree, mvc->comps[i].fp, counts->comps[i].fp,
-                    MV_FP_SIZE, w);
-  }
-#endif  // !CONFIG_EC_ADAPT
-
-  if (usehp) {
-    for (i = 0; i < 2; ++i) {
-      update_mv(w, counts->comps[i].class0_hp, &mvc->comps[i].class0_hp,
-                MV_UPDATE_PROB);
-      update_mv(w, counts->comps[i].hp, &mvc->comps[i].hp, MV_UPDATE_PROB);
-    }
-  }
-#endif
 }
 
 void av1_encode_mv(AV1_COMP *cpi, aom_writer *w, const MV *mv, const MV *ref,
@@ -306,135 +265,101 @@
 
 #if CONFIG_EXT_INTER
 static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext,
-                    const int_mv mvs[2],
-#if CONFIG_REF_MV
-                    const int_mv pred_mvs[2],
-#endif
+                    const int_mv mvs[2], const int_mv pred_mvs[2],
                     nmv_context_counts *nmv_counts) {
   int i;
   PREDICTION_MODE mode = mbmi->mode;
-#if !CONFIG_REF_MV
-  nmv_context_counts *counts = nmv_counts;
-#endif
 
   if (mode == NEWMV || mode == NEW_NEWMV) {
     for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
       const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0].as_mv;
       const MV diff = { mvs[i].as_mv.row - ref->row,
                         mvs[i].as_mv.col - ref->col };
-#if CONFIG_REF_MV
       int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
       int nmv_ctx =
           av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                       mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx);
       nmv_context_counts *counts = &nmv_counts[nmv_ctx];
       (void)pred_mvs;
-#endif
       av1_inc_mv(&diff, counts, 1);
     }
   } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) {
     const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_mv;
     const MV diff = { mvs[1].as_mv.row - ref->row,
                       mvs[1].as_mv.col - ref->col };
-#if CONFIG_REF_MV
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 1, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
-#endif
     av1_inc_mv(&diff, counts, 1);
   } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) {
     const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_mv;
     const MV diff = { mvs[0].as_mv.row - ref->row,
                       mvs[0].as_mv.col - ref->col };
-#if CONFIG_REF_MV
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
-#endif
     av1_inc_mv(&diff, counts, 1);
   }
 }
 
 static void inc_mvs_sub8x8(const MODE_INFO *mi, int block, const int_mv mvs[2],
-#if CONFIG_REF_MV
                            const MB_MODE_INFO_EXT *mbmi_ext,
-#endif
                            nmv_context_counts *nmv_counts) {
   int i;
   PREDICTION_MODE mode = mi->bmi[block].as_mode;
-#if CONFIG_REF_MV
   const MB_MODE_INFO *mbmi = &mi->mbmi;
-#else
-  nmv_context_counts *counts = nmv_counts;
-#endif
 
   if (mode == NEWMV || mode == NEW_NEWMV) {
     for (i = 0; i < 1 + has_second_ref(&mi->mbmi); ++i) {
       const MV *ref = &mi->bmi[block].ref_mv[i].as_mv;
       const MV diff = { mvs[i].as_mv.row - ref->row,
                         mvs[i].as_mv.col - ref->col };
-#if CONFIG_REF_MV
       int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
       int nmv_ctx =
           av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                       mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx);
       nmv_context_counts *counts = &nmv_counts[nmv_ctx];
-#endif
       av1_inc_mv(&diff, counts, 1);
     }
   } else if (mode == NEAREST_NEWMV || mode == NEAR_NEWMV) {
     const MV *ref = &mi->bmi[block].ref_mv[1].as_mv;
     const MV diff = { mvs[1].as_mv.row - ref->row,
                       mvs[1].as_mv.col - ref->col };
-#if CONFIG_REF_MV
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 1, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
-#endif
     av1_inc_mv(&diff, counts, 1);
   } else if (mode == NEW_NEARESTMV || mode == NEW_NEARMV) {
     const MV *ref = &mi->bmi[block].ref_mv[0].as_mv;
     const MV diff = { mvs[0].as_mv.row - ref->row,
                       mvs[0].as_mv.col - ref->col };
-#if CONFIG_REF_MV
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], 0, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
-#endif
     av1_inc_mv(&diff, counts, 1);
   }
 }
 #else
 static void inc_mvs(const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext,
-                    const int_mv mvs[2],
-#if CONFIG_REF_MV
-                    const int_mv pred_mvs[2],
-#endif
+                    const int_mv mvs[2], const int_mv pred_mvs[2],
                     nmv_context_counts *nmv_counts) {
   int i;
-#if !CONFIG_REF_MV
-  nmv_context_counts *counts = nmv_counts;
-#endif
 
   for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
-#if CONFIG_REF_MV
     int8_t rf_type = av1_ref_frame_type(mbmi->ref_frame);
     int nmv_ctx =
         av1_nmv_ctx(mbmi_ext->ref_mv_count[rf_type],
                     mbmi_ext->ref_mv_stack[rf_type], i, mbmi->ref_mv_idx);
     nmv_context_counts *counts = &nmv_counts[nmv_ctx];
     const MV *ref = &pred_mvs[i].as_mv;
-#else
-    const MV *ref = &mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0].as_mv;
-#endif
     const MV diff = { mvs[i].as_mv.row - ref->row,
                       mvs[i].as_mv.col - ref->col };
     av1_inc_mv(&diff, counts, 1);
@@ -464,20 +389,11 @@
 
 #if CONFIG_EXT_INTER
         if (have_newmv_in_inter_mode(mi->bmi[i].as_mode))
-          inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv,
-#if CONFIG_REF_MV
-                         mbmi_ext, td->counts->mv);
-#else
-                         &td->counts->mv);
-#endif
+          inc_mvs_sub8x8(mi, i, mi->bmi[i].as_mv, mbmi_ext, td->counts->mv);
 #else
         if (mi->bmi[i].as_mode == NEWMV)
-          inc_mvs(mbmi, mbmi_ext, mi->bmi[i].as_mv,
-#if CONFIG_REF_MV
-                  mi->bmi[i].pred_mv, td->counts->mv);
-#else
-                  &td->counts->mv);
-#endif
+          inc_mvs(mbmi, mbmi_ext, mi->bmi[i].as_mv, mi->bmi[i].pred_mv,
+                  td->counts->mv);
 #endif  // CONFIG_EXT_INTER
       }
     }
@@ -487,11 +403,6 @@
 #else
     if (mbmi->mode == NEWMV)
 #endif  // CONFIG_EXT_INTER
-      inc_mvs(mbmi, mbmi_ext, mbmi->mv,
-#if CONFIG_REF_MV
-              mbmi->pred_mv, td->counts->mv);
-#else
-              &td->counts->mv);
-#endif
+      inc_mvs(mbmi, mbmi_ext, mbmi->mv, mbmi->pred_mv, td->counts->mv);
   }
 }
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 8579b90..0a0d43e 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -246,7 +246,6 @@
   MACROBLOCK *const mb = &cpi->td.mb;
   cpi->common.allow_high_precision_mv = allow_high_precision_mv;
 
-#if CONFIG_REF_MV
   if (cpi->common.allow_high_precision_mv) {
     int i;
     for (i = 0; i < NMV_CONTEXTS; ++i) {
@@ -260,15 +259,6 @@
       mb->mvsadcost = mb->nmvsadcost;
     }
   }
-#else
-  if (cpi->common.allow_high_precision_mv) {
-    mb->mvcost = mb->nmvcost_hp;
-    mb->mvsadcost = mb->nmvcost_hp;
-  } else {
-    mb->mvcost = mb->nmvcost;
-    mb->mvsadcost = mb->nmvcost;
-  }
-#endif
 }
 
 static BLOCK_SIZE select_sb_size(const AV1_COMP *const cpi) {
@@ -512,23 +502,17 @@
 static void save_coding_context(AV1_COMP *cpi) {
   CODING_CONTEXT *const cc = &cpi->coding_context;
   AV1_COMMON *cm = &cpi->common;
-#if CONFIG_REF_MV
   int i;
-#endif
 
-// Stores a snapshot of key state variables which can subsequently be
-// restored with a call to av1_restore_coding_context. These functions are
-// intended for use in a re-code loop in av1_compress_frame where the
-// quantizer value is adjusted between loop iterations.
-#if CONFIG_REF_MV
+  // Stores a snapshot of key state variables which can subsequently be
+  // restored with a call to av1_restore_coding_context. These functions are
+  // intended for use in a re-code loop in av1_compress_frame where the
+  // quantizer value is adjusted between loop iterations.
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     av1_copy(cc->nmv_vec_cost[i], cpi->td.mb.nmv_vec_cost[i]);
     av1_copy(cc->nmv_costs, cpi->nmv_costs);
     av1_copy(cc->nmv_costs_hp, cpi->nmv_costs_hp);
   }
-#else
-  av1_copy(cc->nmvjointcost, cpi->td.mb.nmvjointcost);
-#endif
 
   av1_copy(cc->nmvcosts, cpi->nmvcosts);
   av1_copy(cc->nmvcosts_hp, cpi->nmvcosts_hp);
@@ -542,21 +526,15 @@
 static void restore_coding_context(AV1_COMP *cpi) {
   CODING_CONTEXT *const cc = &cpi->coding_context;
   AV1_COMMON *cm = &cpi->common;
-#if CONFIG_REF_MV
   int i;
-#endif
 
-// Restore key state variables to the snapshot state stored in the
-// previous call to av1_save_coding_context.
-#if CONFIG_REF_MV
+  // Restore key state variables to the snapshot state stored in the
+  // previous call to av1_save_coding_context.
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     av1_copy(cpi->td.mb.nmv_vec_cost[i], cc->nmv_vec_cost[i]);
     av1_copy(cpi->nmv_costs, cc->nmv_costs);
     av1_copy(cpi->nmv_costs_hp, cc->nmv_costs_hp);
   }
-#else
-  av1_copy(cpi->td.mb.nmvjointcost, cc->nmvjointcost);
-#endif
 
   av1_copy(cpi->nmvcosts, cc->nmvcosts);
   av1_copy(cpi->nmvcosts_hp, cc->nmvcosts_hp);
@@ -2111,15 +2089,6 @@
 #endif
 #define log2f(x) (log(x) / (float)M_LOG2_E)
 
-#if !CONFIG_REF_MV
-static void cal_nmvjointsadcost(int *mvjointsadcost) {
-  mvjointsadcost[0] = 600;
-  mvjointsadcost[1] = 300;
-  mvjointsadcost[2] = 300;
-  mvjointsadcost[3] = 300;
-}
-#endif
-
 static void cal_nmvsadcosts(int *mvsadcost[2]) {
   int i = 1;
 
@@ -2228,12 +2197,10 @@
 
   realloc_segmentation_maps(cpi);
 
-#if CONFIG_REF_MV
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     memset(cpi->nmv_costs, 0, sizeof(cpi->nmv_costs));
     memset(cpi->nmv_costs_hp, 0, sizeof(cpi->nmv_costs_hp));
   }
-#endif
 
   memset(cpi->nmvcosts, 0, sizeof(cpi->nmvcosts));
   memset(cpi->nmvcosts_hp, 0, sizeof(cpi->nmvcosts_hp));
@@ -2301,20 +2268,12 @@
 
   cpi->first_time_stamp_ever = INT64_MAX;
 
-#if CONFIG_REF_MV
   for (i = 0; i < NMV_CONTEXTS; ++i) {
     cpi->td.mb.nmvcost[i][0] = &cpi->nmv_costs[i][0][MV_MAX];
     cpi->td.mb.nmvcost[i][1] = &cpi->nmv_costs[i][1][MV_MAX];
     cpi->td.mb.nmvcost_hp[i][0] = &cpi->nmv_costs_hp[i][0][MV_MAX];
     cpi->td.mb.nmvcost_hp[i][1] = &cpi->nmv_costs_hp[i][1][MV_MAX];
   }
-#else
-  cal_nmvjointsadcost(cpi->td.mb.nmvjointsadcost);
-  cpi->td.mb.nmvcost[0] = &cpi->nmvcosts[0][MV_MAX];
-  cpi->td.mb.nmvcost[1] = &cpi->nmvcosts[1][MV_MAX];
-  cpi->td.mb.nmvcost_hp[0] = &cpi->nmvcosts_hp[0][MV_MAX];
-  cpi->td.mb.nmvcost_hp[1] = &cpi->nmvcosts_hp[1][MV_MAX];
-#endif
   cpi->td.mb.nmvsadcost[0] = &cpi->nmvsadcosts[0][MV_MAX];
   cpi->td.mb.nmvsadcost[1] = &cpi->nmvsadcosts[1][MV_MAX];
   cal_nmvsadcosts(cpi->td.mb.nmvsadcost);
@@ -3059,11 +3018,8 @@
             cpi->gmparams_cost[i]) {
       set_default_warp_params(&cm->global_motion[i]);
       cpi->gmparams_cost[i] = 0;
-#if CONFIG_REF_MV
       recode = 1;
-#else
       recode |= (rdc->global_motion_used[i] > 0);
-#endif
     }
   }
   return recode;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 3e297c8..40668df 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -58,11 +58,9 @@
   int nmvcosts[2][MV_VALS];
   int nmvcosts_hp[2][MV_VALS];
 
-#if CONFIG_REF_MV
   int nmv_vec_cost[NMV_CONTEXTS][MV_JOINTS];
   int nmv_costs[NMV_CONTEXTS][2][MV_VALS];
   int nmv_costs_hp[NMV_CONTEXTS][2][MV_VALS];
-#endif
 
   // 0 = Intra, Last, GF, ARF
   signed char last_ref_lf_deltas[TOTAL_REFS_PER_FRAME];
@@ -433,10 +431,8 @@
 
   CODING_CONTEXT coding_context;
 
-#if CONFIG_REF_MV
   int nmv_costs[NMV_CONTEXTS][2][MV_VALS];
   int nmv_costs_hp[NMV_CONTEXTS][2][MV_VALS];
-#endif
 
   int nmvcosts[2][MV_VALS];
   int nmvcosts_hp[2][MV_VALS];
@@ -544,12 +540,10 @@
   search_site_config ss_cfg;
 
   int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES];
-#if CONFIG_REF_MV
   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];
-#endif
 
   unsigned int inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
 #if CONFIG_EXT_INTER
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index f06e569..cffa26b 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -330,7 +330,6 @@
   }
 }
 
-#if CONFIG_REF_MV
 void av1_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int ref,
                     int ref_mv_idx) {
   MB_MODE_INFO_EXT *mbmi_ext = x->mbmi_ext;
@@ -343,16 +342,13 @@
   x->mvsadcost = x->mvcost;
   x->nmvjointsadcost = x->nmvjointcost;
 }
-#endif
 
 void av1_initialize_rd_consts(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCK *const x = &cpi->td.mb;
   RD_OPT *const rd = &cpi->rd;
   int i;
-#if CONFIG_REF_MV
   int nmv_ctx;
-#endif
 
   aom_clear_system_state();
 
@@ -363,7 +359,6 @@
 
   set_block_thresholds(cm, rd);
 
-#if CONFIG_REF_MV
   for (nmv_ctx = 0; nmv_ctx < NMV_CONTEXTS; ++nmv_ctx) {
     av1_build_nmv_cost_table(
         x->nmv_vec_cost[nmv_ctx],
@@ -375,11 +370,6 @@
   x->nmvjointcost = x->nmv_vec_cost[0];
   x->mvsadcost = x->mvcost;
   x->nmvjointsadcost = x->nmvjointcost;
-#else
-  av1_build_nmv_cost_table(
-      x->nmvjointcost, cm->allow_high_precision_mv ? x->nmvcost_hp : x->nmvcost,
-      &cm->fc->nmvc, cm->allow_high_precision_mv);
-#endif
 
   if (cpi->oxcf.pass != 1) {
     av1_fill_token_costs(x->token_costs, cm->fc->coef_probs);
@@ -425,7 +415,6 @@
     fill_mode_costs(cpi);
 
     if (!frame_is_intra_only(cm)) {
-#if CONFIG_REF_MV
       for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i) {
         cpi->newmv_mode_cost[i][0] = av1_cost_bit(cm->fc->newmv_prob[i], 0);
         cpi->newmv_mode_cost[i][1] = av1_cost_bit(cm->fc->newmv_prob[i], 1);
@@ -445,11 +434,6 @@
         cpi->drl_mode_cost0[i][0] = av1_cost_bit(cm->fc->drl_prob[i], 0);
         cpi->drl_mode_cost0[i][1] = av1_cost_bit(cm->fc->drl_prob[i], 1);
       }
-#else
-      for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
-        av1_cost_tokens((int *)cpi->inter_mode_cost[i],
-                        cm->fc->inter_mode_probs[i], av1_inter_mode_tree);
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
       for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
         av1_cost_tokens((int *)cpi->inter_compound_mode_cost[i],
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index c0ac1f7..d4e54ea 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -454,10 +454,8 @@
 
 void av1_init_me_luts(void);
 
-#if CONFIG_REF_MV
 void av1_set_mvcost(MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame, int ref,
                     int ref_mv_idx);
-#endif
 
 void av1_get_entropy_contexts(BLOCK_SIZE bsize, TX_SIZE tx_size,
                               const struct macroblockd_plane *pd,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index cbe6402..737d9cd 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1923,9 +1923,7 @@
     // transforms should be considered for pruning
     prune = prune_tx_types(cpi, bs, x, xd, -1);
 
-#if CONFIG_REF_MV
   if (mbmi->ref_mv_idx > 0 && tx_type != DCT_DCT) return 1;
-#endif  // CONFIG_REF_MV
   if (FIXED_TX_TYPE && tx_type != get_default_tx_type(0, xd, 0, tx_size))
     return 1;
   if (!is_inter && x->use_default_intra_tx_type &&
@@ -2190,9 +2188,7 @@
 #endif
     TX_TYPE tx_type;
     for (tx_type = tx_start; tx_type < tx_end; ++tx_type) {
-#if CONFIG_REF_MV
       if (mbmi->ref_mv_idx > 0 && tx_type != DCT_DCT) continue;
-#endif  // CONFIG_REF_MV
       const TX_SIZE rect_tx_size = max_txsize_rect_lookup[bs];
       RD_STATS this_rd_stats;
       int ext_tx_set =
@@ -4890,7 +4886,6 @@
   }
 #endif
 
-#if CONFIG_REF_MV
   int mode_cost = 0;
   int16_t mode_ctx = mode_context & NEWMV_CTX_MASK;
   int16_t is_all_zero_mv = mode_context & (1 << ALL_ZERO_FLAG_OFFSET);
@@ -4921,10 +4916,6 @@
       return mode_cost;
     }
   }
-#else
-  assert(is_inter_mode(mode));
-  return cpi->inter_mode_cost[mode_context][INTER_OFFSET(mode)];
-#endif  // CONFIG_REF_MV
 }
 
 #if CONFIG_EXT_INTER
@@ -4973,7 +4964,6 @@
         lower_mv_precision(&this_mv[0].as_mv, 0);
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_REF_MV
       for (idx = 0; idx < 1 + is_compound; ++idx) {
         this_mv[idx] = seg_mvs[mbmi->ref_frame[idx]];
         av1_set_mvcost(x, mbmi->ref_frame[idx], idx, mbmi->ref_mv_idx);
@@ -4983,17 +4973,6 @@
       }
       (void)mvjcost;
       (void)mvcost;
-#else
-      thismvcost += av1_mv_bit_cost(&this_mv[0].as_mv, &best_ref_mv[0]->as_mv,
-                                    mvjcost, mvcost, MV_COST_WEIGHT_SUB);
-#if !CONFIG_EXT_INTER
-      if (is_compound) {
-        this_mv[1].as_int = seg_mvs[mbmi->ref_frame[1]].as_int;
-        thismvcost += av1_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv,
-                                      mvjcost, mvcost, MV_COST_WEIGHT_SUB);
-      }
-#endif  // !CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
       break;
     case NEARMV:
     case NEARESTMV:
@@ -5031,14 +5010,10 @@
         lower_mv_precision(&this_mv[0].as_mv, 0);
       if (!cpi->common.allow_high_precision_mv)
         lower_mv_precision(&this_mv[1].as_mv, 0);
-#if CONFIG_REF_MV
       av1_set_mvcost(x, mbmi->ref_frame[0], 0, mbmi->ref_mv_idx);
-#endif
       thismvcost += av1_mv_bit_cost(&this_mv[0].as_mv, &best_ref_mv[0]->as_mv,
                                     mvjcost, mvcost, MV_COST_WEIGHT_SUB);
-#if CONFIG_REF_MV
       av1_set_mvcost(x, mbmi->ref_frame[1], 1, mbmi->ref_mv_idx);
-#endif
       thismvcost += av1_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv,
                                     mvjcost, mvcost, MV_COST_WEIGHT_SUB);
       break;
@@ -5047,9 +5022,7 @@
       this_mv[0].as_int = seg_mvs[mbmi->ref_frame[0]].as_int;
       if (!cpi->common.allow_high_precision_mv)
         lower_mv_precision(&this_mv[0].as_mv, 0);
-#if CONFIG_REF_MV
       av1_set_mvcost(x, mbmi->ref_frame[0], 0, mbmi->ref_mv_idx);
-#endif
       thismvcost += av1_mv_bit_cost(&this_mv[0].as_mv, &best_ref_mv[0]->as_mv,
                                     mvjcost, mvcost, MV_COST_WEIGHT_SUB);
       this_mv[1].as_int = frame_mv[mode][mbmi->ref_frame[1]].as_int;
@@ -5060,9 +5033,7 @@
       this_mv[1].as_int = seg_mvs[mbmi->ref_frame[1]].as_int;
       if (!cpi->common.allow_high_precision_mv)
         lower_mv_precision(&this_mv[1].as_mv, 0);
-#if CONFIG_REF_MV
       av1_set_mvcost(x, mbmi->ref_frame[1], 1, mbmi->ref_mv_idx);
-#endif
       thismvcost += av1_mv_bit_cost(&this_mv[1].as_mv, &best_ref_mv[1]->as_mv,
                                     mvjcost, mvcost, MV_COST_WEIGHT_SUB);
       break;
@@ -5099,7 +5070,6 @@
 
   mic->bmi[i].as_mode = mode;
 
-#if CONFIG_REF_MV
   if (mode == NEWMV) {
     mic->bmi[i].pred_mv[0].as_int =
         mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_int;
@@ -5110,13 +5080,11 @@
     mic->bmi[i].pred_mv[0].as_int = this_mv[0].as_int;
     if (is_compound) mic->bmi[i].pred_mv[1].as_int = this_mv[1].as_int;
   }
-#endif  // CONFIG_REF_MV
 
   for (idy = 0; idy < num_4x4_blocks_high; ++idy)
     for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
       memmove(&mic->bmi[i + idy * 2 + idx], &mic->bmi[i], sizeof(mic->bmi[i]));
 
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
   if (is_compound)
     mode_ctx = mbmi_ext->compound_mode_context[mbmi->ref_frame[0]];
@@ -5124,9 +5092,6 @@
 #endif  // CONFIG_EXT_INTER
     mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                          mbmi->ref_frame, mbmi->sb_type, i);
-#else  // CONFIG_REF_MV
-  mode_ctx = mbmi_ext->mode_context[mbmi->ref_frame[0]];
-#endif  // CONFIG_REF_MV
   return cost_mv_ref(cpi, mode, mode_ctx) + thismvcost;
 }
 
@@ -5248,9 +5213,7 @@
   int64_t bsse;
   int64_t brdcost;
   int_mv mvs[2];
-#if CONFIG_REF_MV
   int_mv pred_mv[2];
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
   int_mv ref_mv[2];
 #endif  // CONFIG_EXT_INTER
@@ -5317,9 +5280,9 @@
 // TODO(aconverse): Find out if this is still productive then clean up or remove
 static int check_best_zero_mv(
     const AV1_COMP *const cpi, const int16_t mode_context[TOTAL_REFS_PER_FRAME],
-#if CONFIG_REF_MV && CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER
     const int16_t compound_mode_context[TOTAL_REFS_PER_FRAME],
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
     int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], int this_mode,
     const MV_REFERENCE_FRAME ref_frames[2], const BLOCK_SIZE bsize, int block,
     int mi_row, int mi_col) {
@@ -5351,21 +5314,12 @@
       frame_mv[this_mode][ref_frames[0]].as_int == zeromv[0].as_int &&
       (ref_frames[1] <= INTRA_FRAME ||
        frame_mv[this_mode][ref_frames[1]].as_int == zeromv[1].as_int)) {
-#if CONFIG_REF_MV
     int16_t rfc =
         av1_mode_context_analyzer(mode_context, ref_frames, bsize, block);
-#else
-    int16_t rfc = mode_context[ref_frames[0]];
-#endif  // CONFIG_REF_MV
     int c1 = cost_mv_ref(cpi, NEARMV, rfc);
     int c2 = cost_mv_ref(cpi, NEARESTMV, rfc);
     int c3 = cost_mv_ref(cpi, ZEROMV, rfc);
 
-#if !CONFIG_REF_MV
-    (void)bsize;
-    (void)block;
-#endif  // !CONFIG_REF_MV
-
     if (this_mode == NEARMV) {
       if (c1 > c3) return 0;
     } else if (this_mode == NEARESTMV) {
@@ -5391,11 +5345,7 @@
             this_mode == ZERO_ZEROMV) &&
            frame_mv[this_mode][ref_frames[0]].as_int == zeromv[0].as_int &&
            frame_mv[this_mode][ref_frames[1]].as_int == zeromv[1].as_int) {
-#if CONFIG_REF_MV
     int16_t rfc = compound_mode_context[ref_frames[0]];
-#else
-    int16_t rfc = mode_context[ref_frames[0]];
-#endif  // CONFIG_REF_MV
     int c1 = cost_mv_ref(cpi, NEAREST_NEARMV, rfc);
     int c2 = cost_mv_ref(cpi, NEAREST_NEARESTMV, rfc);
     int c3 = cost_mv_ref(cpi, ZERO_ZEROMV, rfc);
@@ -5592,9 +5542,7 @@
     best_mv->col >>= 3;
     best_mv->row >>= 3;
 
-#if CONFIG_REF_MV
     av1_set_mvcost(x, refs[id], id, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
 
     // Small-range full-pixel motion search.
     bestsme =
@@ -5669,9 +5617,7 @@
       for (i = 0; i < MAX_MB_PLANE; i++)
         xd->plane[i].pre[ref] = backup_yv12[ref][i];
     }
-#if CONFIG_REF_MV
     av1_set_mvcost(x, refs[ref], ref, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER && !CONFIG_CB4X4
     if (bsize >= BLOCK_8X8)
 #endif  // CONFIG_EXT_INTER && !CONFIG_CB4X4
@@ -5687,7 +5633,7 @@
   }
 }
 
-#if CONFIG_REF_MV && !CONFIG_EXT_INTER
+#if !CONFIG_EXT_INTER
 static void update_mv_search_and_seg_mvs(
     int *const run_mv_search, int_mv *const seg_mvs, int has_second_rf,
     const MV_REFERENCE_FRAME *const ref_frame,
@@ -5710,7 +5656,7 @@
     }
   }
 }
-#endif  // CONFIG_REF_MV && !CONFIG_EXT_INTER
+#endif  // !CONFIG_EXT_INTER
 
 static int64_t rd_pick_inter_best_sub8x8_mode(
     const AV1_COMP *const cpi, MACROBLOCK *x, int_mv *best_ref_mv,
@@ -5722,9 +5668,7 @@
 #endif  // CONFIG_EXT_INTER
     BEST_SEG_INFO *bsi_buf, int filter_idx, int mi_row, int mi_col) {
   BEST_SEG_INFO *bsi = bsi_buf + filter_idx;
-#if CONFIG_REF_MV
   int_mv tmp_ref_mv[2];
-#endif  // CONFIG_REF_MV
   MACROBLOCKD *xd = &x->e_mbd;
   MODE_INFO *mi = xd->mi[0];
   MB_MODE_INFO *mbmi = &mi->mbmi;
@@ -5773,7 +5717,6 @@
 
   for (idx = 0; idx < 4; ++idx) bsi->modes[idx] = ZEROMV;
 
-#if CONFIG_REF_MV
   for (idx = 0; idx < 4; ++idx) {
     for (k = NEARESTMV; k <= NEWMV; ++k) {
       bsi->rdstat[idx][INTER_OFFSET(k)].pred_mv[0].as_int = INVALID_MV;
@@ -5783,7 +5726,6 @@
       bsi->rdstat[idx][INTER_OFFSET(k)].mvs[1].as_int = INVALID_MV;
     }
   }
-#endif  // CONFIG_REF_MV
 
   memcpy(t_above, pd->above_context, sizeof(t_above));
   memcpy(t_left, pd->left_context, sizeof(t_left));
@@ -5805,10 +5747,8 @@
       int64_t new_best_rd = INT64_MAX;
       const int index = idy * 2 + idx;
       int ref;
-#if CONFIG_REF_MV
       CANDIDATE_MV ref_mv_stack[2][MAX_REF_MV_STACK_SIZE];
       uint8_t ref_mv_count[2];
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
       int_mv ref_mvs_sub8x8[2][2];
 #endif  // CONFIG_EXT_INTER
@@ -5835,21 +5775,17 @@
         frame_mv[ZEROMV][frame].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
         av1_append_sub8x8_mvs_for_idx(cm, xd, index, ref, mi_row, mi_col,
-#if CONFIG_REF_MV
                                       ref_mv_stack[ref], &ref_mv_count[ref],
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
                                       mv_ref_list,
 #endif  // CONFIG_EXT_INTER
                                       &frame_mv[NEARESTMV][frame],
                                       &frame_mv[NEARMV][frame]);
 
-#if CONFIG_REF_MV
         tmp_ref_mv[ref] = frame_mv[NEARESTMV][mbmi->ref_frame[ref]];
         lower_mv_precision(&tmp_ref_mv[ref].as_mv, cm->allow_high_precision_mv);
         bsi->ref_mv[ref] = &tmp_ref_mv[ref];
         mbmi_ext->ref_mvs[frame][0] = tmp_ref_mv[ref];
-#endif  // CONFIG_REF_MV
 
 #if CONFIG_EXT_INTER
         mv_ref_list[0].as_int = frame_mv[NEARESTMV][frame].as_int;
@@ -5917,7 +5853,6 @@
         bsi->rdstat[index][mode_idx].brdcost = INT64_MAX;
         if (!(inter_mode_mask & (1 << this_mode))) continue;
 
-#if CONFIG_REF_MV
         run_mv_search = 2;
 #if !CONFIG_EXT_INTER
         if (filter_idx > 0 && this_mode == NEWMV) {
@@ -5938,7 +5873,6 @@
           }
         }
 #endif  // !CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
 
 #if CONFIG_GLOBAL_MOTION
         if (cm->global_motion[mbmi->ref_frame[0]].wmtype == IDENTITY &&
@@ -5947,9 +5881,9 @@
 #endif  // CONFIG_GLOBAL_MOTION
 
           if (!check_best_zero_mv(cpi, mbmi_ext->mode_context,
-#if CONFIG_REF_MV && CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER
                                   mbmi_ext->compound_mode_context,
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
                                   frame_mv, this_mode, mbmi->ref_frame, bsize,
                                   index, mi_row, mi_col))
             continue;
@@ -5990,13 +5924,6 @@
           bsi->mvp.as_int = bsi->ref_mv[0]->as_int;
 #else
 // use previous block's result as next block's MV predictor.
-#if !CONFIG_REF_MV
-          if (index > 0) {
-            bsi->mvp.as_int = mi->bmi[index - 1].as_mv[0].as_int;
-            if (index == 2)
-              bsi->mvp.as_int = mi->bmi[index - 2].as_mv[0].as_int;
-          }
-#endif  // !CONFIG_REF_MV
 #endif  // CONFIG_EXT_INTER
           max_mv = (index == 0) ? (int)x->max_mv_context[mbmi->ref_frame[0]]
                                 : AOMMAX(abs(bsi->mvp.as_mv.row),
@@ -6013,13 +5940,8 @@
             step_param = cpi->mv_step_param;
           }
 
-#if CONFIG_REF_MV
           mvp_full.row = bsi->ref_mv[0]->as_mv.row >> 3;
           mvp_full.col = bsi->ref_mv[0]->as_mv.col >> 3;
-#else
-          mvp_full.row = bsi->mvp.as_mv.row >> 3;
-          mvp_full.col = bsi->mvp.as_mv.col >> 3;
-#endif  // CONFIG_REF_MV
 
           if (cpi->sf.adaptive_motion_search) {
             mvp_full.row = x->pred_mv[mbmi->ref_frame[0]].row >> 3;
@@ -6034,9 +5956,7 @@
 
           x->best_mv.as_int = x->second_best_mv.as_int = INVALID_MV;
 
-#if CONFIG_REF_MV
           av1_set_mvcost(x, mbmi->ref_frame[0], 0, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
           bestsme = av1_full_pixel_search(
               cpi, x, bsize, &mvp_full, step_param, sadpb,
               cpi->sf.mv.subpel_search_method != SUBPEL_TREE ? cost_list : NULL,
@@ -6218,7 +6138,6 @@
           if (num_4x4_blocks_high > 1)
             bsi->rdstat[index + 2][mode_idx].mvs[ref].as_int =
                 mode_mv[this_mode][ref].as_int;
-#if CONFIG_REF_MV
           bsi->rdstat[index][mode_idx].pred_mv[ref].as_int =
               mi->bmi[index].pred_mv[ref].as_int;
           if (num_4x4_blocks_wide > 1)
@@ -6227,7 +6146,6 @@
           if (num_4x4_blocks_high > 1)
             bsi->rdstat[index + 2][mode_idx].pred_mv[ref].as_int =
                 mi->bmi[index].pred_mv[ref].as_int;
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
           bsi->rdstat[index][mode_idx].ref_mv[ref].as_int =
               bsi->ref_mv[ref]->as_int;
@@ -6289,7 +6207,6 @@
 
           if (!subpelmv && have_ref &&
               ref_bsi->rdstat[index][mode_idx].brdcost < INT64_MAX) {
-#if CONFIG_REF_MV
             bsi->rdstat[index][mode_idx].byrate =
                 ref_bsi->rdstat[index][mode_idx].byrate;
             bsi->rdstat[index][mode_idx].bdist =
@@ -6311,10 +6228,6 @@
             memcpy(bsi->rdstat[index][mode_idx].tl,
                    ref_bsi->rdstat[index][mode_idx].tl,
                    sizeof(bsi->rdstat[index][mode_idx].tl));
-#else
-            memcpy(&bsi->rdstat[index][mode_idx],
-                   &ref_bsi->rdstat[index][mode_idx], sizeof(SEG_RDSTAT));
-#endif  // CONFIG_REF_MV
             if (num_4x4_blocks_wide > 1)
               bsi->rdstat[index + 1][mode_idx].eobs =
                   ref_bsi->rdstat[index + 1][mode_idx].eobs;
@@ -6323,7 +6236,6 @@
                   ref_bsi->rdstat[index + 2][mode_idx].eobs;
 
             if (bsi->rdstat[index][mode_idx].brdcost < new_best_rd) {
-#if CONFIG_REF_MV
               // If the NEWMV mode is using the same motion vector as the
               // NEARESTMV mode, skip the rest rate-distortion calculations
               // and use the inferred motion vector modes.
@@ -6340,7 +6252,6 @@
                     continue;
                 }
               }
-#endif  // CONFIG_REF_MV
               mode_selected = this_mode;
               new_best_rd = bsi->rdstat[index][mode_idx].brdcost;
 #if CONFIG_PVQ
@@ -6371,7 +6282,6 @@
         }
 
         if (bsi->rdstat[index][mode_idx].brdcost < new_best_rd) {
-#if CONFIG_REF_MV
           // If the NEWMV mode is using the same motion vector as the
           // NEARESTMV mode, skip the rest rate-distortion calculations
           // and use the inferred motion vector modes.
@@ -6388,7 +6298,6 @@
                 continue;
             }
           }
-#endif  // CONFIG_REF_MV
           mode_selected = this_mode;
           new_best_rd = bsi->rdstat[index][mode_idx].brdcost;
 
@@ -6599,11 +6508,9 @@
     mi->bmi[idx].as_mv[0].as_int = bsi->rdstat[idx][mode_idx].mvs[0].as_int;
     if (has_second_ref(mbmi))
       mi->bmi[idx].as_mv[1].as_int = bsi->rdstat[idx][mode_idx].mvs[1].as_int;
-#if CONFIG_REF_MV
     mi->bmi[idx].pred_mv[0] = bsi->rdstat[idx][mode_idx].pred_mv[0];
     if (has_second_ref(mbmi))
       mi->bmi[idx].pred_mv[1] = bsi->rdstat[idx][mode_idx].pred_mv[1];
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
     mi->bmi[idx].ref_mv[0].as_int = bsi->rdstat[idx][mode_idx].ref_mv[0].as_int;
     if (has_second_rf)
@@ -6803,15 +6710,13 @@
   av1_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf);
 
   // Gets an initial list of candidate vectors from neighbours and orders them
-  av1_find_mv_refs(
-      cm, xd, mi, ref_frame,
-#if CONFIG_REF_MV
-      &mbmi_ext->ref_mv_count[ref_frame], mbmi_ext->ref_mv_stack[ref_frame],
+  av1_find_mv_refs(cm, xd, mi, ref_frame, &mbmi_ext->ref_mv_count[ref_frame],
+                   mbmi_ext->ref_mv_stack[ref_frame],
 #if CONFIG_EXT_INTER
-      mbmi_ext->compound_mode_context,
+                   mbmi_ext->compound_mode_context,
 #endif  // CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
-      candidates, mi_row, mi_col, NULL, NULL, mbmi_ext->mode_context);
+                   candidates, mi_row, mi_col, NULL, NULL,
+                   mbmi_ext->mode_context);
 
   // Candidate refinement carried out at encoder and decoder
   av1_find_best_ref_mvs(cm->allow_high_precision_mv, candidates,
@@ -6877,9 +6782,7 @@
 
   av1_set_mv_search_range(&x->mv_limits, &ref_mv);
 
-#if CONFIG_REF_MV
   av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
 
   // Work out the size of the first step in the mv step search.
   // 0 here is maximum length first step. 1 is AOMMAX >> 1 etc.
@@ -7099,9 +7002,7 @@
   pred_mv[1] = x->mbmi_ext->ref_mvs[ref][1].as_mv;
   pred_mv[2] = x->pred_mv[ref];
 
-#if CONFIG_REF_MV
   av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
 
   if (scaled_ref_frame) {
     // Swap out the reference frame for a version that's been scaled to
@@ -7872,9 +7773,7 @@
       } else {
         *rate_mv = 0;
         for (i = 0; i < 2; ++i) {
-#if CONFIG_REF_MV
           av1_set_mvcost(x, refs[i], i, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
           *rate_mv += av1_mv_bit_cost(
               &frame_mv[refs[i]].as_mv, &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
               x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
@@ -7882,18 +7781,14 @@
       }
     } else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) {
       frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
-#if CONFIG_REF_MV
       av1_set_mvcost(x, refs[1], 1, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
       *rate_mv = av1_mv_bit_cost(&frame_mv[refs[1]].as_mv,
                                  &mbmi_ext->ref_mvs[refs[1]][0].as_mv,
                                  x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
     } else {
       assert(this_mode == NEW_NEARESTMV || this_mode == NEW_NEARMV);
       frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
-#if CONFIG_REF_MV
       av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
       *rate_mv = av1_mv_bit_cost(&frame_mv[refs[0]].as_mv,
                                  &mbmi_ext->ref_mvs[refs[0]][0].as_mv,
                                  x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
@@ -7908,9 +7803,7 @@
     } else {
       *rate_mv = 0;
       for (i = 0; i < 2; ++i) {
-#if CONFIG_REF_MV
         av1_set_mvcost(x, refs[i], i, mbmi->ref_mv_idx);
-#endif  // CONFIG_REF_MV
         *rate_mv += av1_mv_bit_cost(&frame_mv[refs[i]].as_mv,
                                     &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
                                     x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
@@ -8448,9 +8341,7 @@
       cpi->interintra_mode_cost[size_group_lookup[bsize]];
 #endif  // CONFIG_INTERINTRA
   const int is_comp_interintra_pred = (mbmi->ref_frame[1] == INTRA_FRAME);
-#if CONFIG_REF_MV
   uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
-#endif  // CONFIG_REF_MV
 #else
   int_mv *const single_newmv = args->single_newmv;
 #endif  // CONFIG_EXT_INTER
@@ -8490,7 +8381,6 @@
   assert(!is_comp_interintra_pred || is_interintra_allowed(mbmi));
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
   if (is_comp_pred)
     mode_ctx = mbmi_ext->compound_mode_context[refs[0]];
@@ -8498,9 +8388,6 @@
 #endif  // CONFIG_EXT_INTER
     mode_ctx = av1_mode_context_analyzer(mbmi_ext->mode_context,
                                          mbmi->ref_frame, bsize, -1);
-#else   // CONFIG_REF_MV
-  mode_ctx = mbmi_ext->mode_context[refs[0]];
-#endif  // CONFIG_REF_MV
 
 #if CONFIG_HIGHBITDEPTH
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
@@ -8540,7 +8427,6 @@
     mbmi->mv[i].as_int = cur_mv[i].as_int;
   }
 
-#if CONFIG_REF_MV
 #if CONFIG_EXT_INTER
   if (this_mode == NEAREST_NEARESTMV)
 #else
@@ -8621,7 +8507,6 @@
     }
   }
 #endif  // CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
 
   // do first prediction into the destination buffer. Do the next
   // prediction into a temporary buffer. Then keep track of which one
@@ -8654,7 +8539,7 @@
 #else
     rd_stats->rate += AOMMIN(cost_mv_ref(cpi, this_mode, mode_ctx),
                              cost_mv_ref(cpi, NEARESTMV, mode_ctx));
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
   } else {
     rd_stats->rate += cost_mv_ref(cpi, this_mode, mode_ctx);
   }
@@ -9595,10 +9480,8 @@
   int64_t best_pred_diff[REFERENCE_MODES];
   int64_t best_pred_rd[REFERENCE_MODES];
   MB_MODE_INFO best_mbmode;
-#if CONFIG_REF_MV
   int rate_skip0 = av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
   int rate_skip1 = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
-#endif  // CONFIG_REF_MV
   int best_mode_skippable = 0;
   int midx, best_mode_index = -1;
   unsigned int ref_costs_single[TOTAL_REFS_PER_FRAME];
@@ -9749,9 +9632,9 @@
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
     x->pred_mv_sad[ref_frame] = INT_MAX;
     x->mbmi_ext->mode_context[ref_frame] = 0;
-#if CONFIG_REF_MV && CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER
     x->mbmi_ext->compound_mode_context[ref_frame] = 0;
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
     if (cpi->ref_frame_flags & flag_list[ref_frame]) {
       assert(get_ref_frame_buffer(cpi, ref_frame) != NULL);
       setup_buffer_inter(cpi, x, ref_frame, bsize, mi_row, mi_col,
@@ -9781,7 +9664,6 @@
 #endif  // CONFIG_EXT_INTER
   }
 
-#if CONFIG_REF_MV
   for (; ref_frame < MODE_CTX_REF_FRAMES; ++ref_frame) {
     MODE_INFO *const mi = xd->mi[0];
     int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame];
@@ -9806,7 +9688,6 @@
         mbmi_ext->mode_context[ref_frame] &= ~(1 << ALL_ZERO_FLAG_OFFSET);
     }
   }
-#endif  // CONFIG_REF_MV
 
 #if CONFIG_MOTION_VAR
   av1_count_overlappable_neighbors(cm, xd, mi_row, mi_col);
@@ -9987,9 +9868,7 @@
     int skippable = 0;
     int this_skip2 = 0;
     int64_t total_sse = INT64_MAX;
-#if CONFIG_REF_MV
     uint8_t ref_frame_type;
-#endif  // CONFIG_REF_MV
 #if CONFIG_PVQ
     od_encode_rollback(&x->daala_enc, &pre_buf);
 #endif  // CONFIG_PVQ
@@ -9997,9 +9876,7 @@
     this_mode = av1_mode_order[mode_index].mode;
     ref_frame = av1_mode_order[mode_index].ref_frame[0];
     second_ref_frame = av1_mode_order[mode_index].ref_frame[1];
-#if CONFIG_REF_MV
     mbmi->ref_mv_idx = 0;
-#endif  // CONFIG_REF_MV
 
 #if CONFIG_EXT_INTER
     if (ref_frame > INTRA_FRAME && second_ref_frame == INTRA_FRAME) {
@@ -10137,9 +10014,9 @@
 #endif  // CONFIG_GLOBAL_MOTION
       const MV_REFERENCE_FRAME ref_frames[2] = { ref_frame, second_ref_frame };
       if (!check_best_zero_mv(cpi, mbmi_ext->mode_context,
-#if CONFIG_REF_MV && CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER
                               mbmi_ext->compound_mode_context,
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
                               frame_mv, this_mode, ref_frames, bsize, -1,
                               mi_row, mi_col))
         continue;
@@ -10330,7 +10207,6 @@
         rate2 += intra_cost_penalty;
       distortion2 = distortion_y + distortion_uv;
     } else {
-#if CONFIG_REF_MV
       int_mv backup_ref_mv[2];
 
 #if !SUB8X8_COMP_REF
@@ -10339,7 +10215,6 @@
 
       backup_ref_mv[0] = mbmi_ext->ref_mvs[ref_frame][0];
       if (comp_pred) backup_ref_mv[1] = mbmi_ext->ref_mvs[second_ref_frame][0];
-#endif  // CONFIG_REF_MV
 #if CONFIG_EXT_INTER
       if (second_ref_frame == INTRA_FRAME) {
         if (best_single_inter_ref != ref_frame) continue;
@@ -10359,7 +10234,6 @@
 #endif  // CONFIG_FILTER_INTRA
       }
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_REF_MV
       mbmi->ref_mv_idx = 0;
       ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
 
@@ -10404,7 +10278,6 @@
 #if CONFIG_EXT_INTER
       }
 #endif  // CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
       {
         RD_STATS rd_stats, rd_stats_y, rd_stats_uv;
         av1_init_rd_stats(&rd_stats);
@@ -10435,7 +10308,6 @@
         rate_uv = rd_stats_uv.rate;
       }
 
-#if CONFIG_REF_MV
 // TODO(jingning): This needs some refactoring to improve code quality
 // and reduce redundant steps.
 #if CONFIG_EXT_INTER
@@ -10677,7 +10549,6 @@
       }
       mbmi_ext->ref_mvs[ref_frame][0] = backup_ref_mv[0];
       if (comp_pred) mbmi_ext->ref_mvs[second_ref_frame][0] = backup_ref_mv[1];
-#endif  // CONFIG_REF_MV
 
       if (this_rd == INT64_MAX) continue;
 
@@ -10724,14 +10595,9 @@
         // Cost the skip mb case
         rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
       } else if (ref_frame != INTRA_FRAME && !xd->lossless[mbmi->segment_id]) {
-#if CONFIG_REF_MV
         if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv + rate_skip0,
                    distortion2) <
             RDCOST(x->rdmult, x->rddiv, rate_skip1, total_sse)) {
-#else
-        if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
-            RDCOST(x->rdmult, x->rddiv, 0, total_sse)) {
-#endif  // CONFIG_REF_MV
           // Add in the cost of the no skip flag.
           rate2 += av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
         } else {
@@ -11104,9 +10970,7 @@
                                          best_mbmode.ref_frame[1] };
     int comp_pred_mode = refs[1] > INTRA_FRAME;
     int_mv zeromv[2];
-#if CONFIG_REF_MV
     const uint8_t rf_type = av1_ref_frame_type(best_mbmode.ref_frame);
-#endif  // CONFIG_REF_MV
 #if CONFIG_GLOBAL_MOTION
     zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
                                             cm->allow_high_precision_mv, bsize,
@@ -11122,7 +10986,6 @@
     zeromv[0].as_int = 0;
     zeromv[1].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
-#if CONFIG_REF_MV
     if (!comp_pred_mode) {
       int ref_set = (mbmi_ext->ref_mv_count[rf_type] >= 2)
                         ? AOMMIN(2, mbmi_ext->ref_mv_count[rf_type] - 2)
@@ -11218,72 +11081,8 @@
       }
 #endif  // CONFIG_EXT_INTER
     }
-#else
-#if CONFIG_EXT_INTER
-    if (!comp_pred_mode) {
-#endif  // CONFIG_EXT_INTER
-      if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int &&
-          ((comp_pred_mode &&
-            frame_mv[NEARESTMV][refs[1]].as_int == best_mbmode.mv[1].as_int) ||
-           !comp_pred_mode))
-        best_mbmode.mode = NEARESTMV;
-      else if (frame_mv[NEARMV][refs[0]].as_int == best_mbmode.mv[0].as_int &&
-               ((comp_pred_mode &&
-                 frame_mv[NEARMV][refs[1]].as_int ==
-                     best_mbmode.mv[1].as_int) ||
-                !comp_pred_mode))
-        best_mbmode.mode = NEARMV;
-      else if (best_mbmode.mv[0].as_int == zeromv[0].as_int &&
-               ((comp_pred_mode &&
-                 best_mbmode.mv[1].as_int == zeromv[1].as_int) ||
-                !comp_pred_mode))
-        best_mbmode.mode = ZEROMV;
-#if CONFIG_EXT_INTER
-    } else {
-#if CONFIG_GLOBAL_MOTION
-      zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
-                                              cm->allow_high_precision_mv,
-                                              bsize, mi_col, mi_row, 0)
-                             .as_int;
-      zeromv[1].as_int = comp_pred_mode
-                             ? gm_get_motion_vector(&cm->global_motion[refs[1]],
-                                                    cm->allow_high_precision_mv,
-                                                    bsize, mi_col, mi_row, 0)
-                                   .as_int
-                             : 0;
-#else
-      zeromv[0].as_int = 0;
-      zeromv[1].as_int = 0;
-#endif  // CONFIG_GLOBAL_MOTION
-      if (frame_mv[NEAREST_NEARESTMV][refs[0]].as_int ==
-              best_mbmode.mv[0].as_int &&
-          frame_mv[NEAREST_NEARESTMV][refs[1]].as_int ==
-              best_mbmode.mv[1].as_int)
-        best_mbmode.mode = NEAREST_NEARESTMV;
-      else if (frame_mv[NEAREST_NEARMV][refs[0]].as_int ==
-                   best_mbmode.mv[0].as_int &&
-               frame_mv[NEAREST_NEARMV][refs[1]].as_int ==
-                   best_mbmode.mv[1].as_int)
-        best_mbmode.mode = NEAREST_NEARMV;
-      else if (frame_mv[NEAR_NEARESTMV][refs[0]].as_int ==
-                   best_mbmode.mv[0].as_int &&
-               frame_mv[NEAR_NEARESTMV][refs[1]].as_int ==
-                   best_mbmode.mv[1].as_int)
-        best_mbmode.mode = NEAR_NEARESTMV;
-      else if (frame_mv[NEAR_NEARMV][refs[0]].as_int ==
-                   best_mbmode.mv[0].as_int &&
-               frame_mv[NEAR_NEARMV][refs[1]].as_int ==
-                   best_mbmode.mv[1].as_int)
-        best_mbmode.mode = NEAR_NEARMV;
-      else if (best_mbmode.mv[0].as_int == zeromv[0].as_int &&
-               best_mbmode.mv[1].as_int == zeromv[1].as_int)
-        best_mbmode.mode = ZERO_ZEROMV;
-    }
-#endif  // CONFIG_EXT_INTER
-#endif  // CONFIG_REF_MV
   }
 
-#if CONFIG_REF_MV
   // Make sure that the ref_mv_idx is only nonzero when we're
   // using a mode which can support ref_mv_idx
   if (best_mbmode.ref_mv_idx != 0 &&
@@ -11332,7 +11131,6 @@
       }
     }
   }
-#endif  // CONFIG_REF_MV
 
   if (best_mode_index < 0 || best_rd >= best_rd_so_far) {
     rd_cost->rate = INT_MAX;
@@ -11405,14 +11203,12 @@
   }
 #endif  // CONFIG_GLOBAL_MOTION
 
-#if CONFIG_REF_MV
   for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
     if (mbmi->mode != NEWMV)
       mbmi->pred_mv[i].as_int = mbmi->mv[i].as_int;
     else
       mbmi->pred_mv[i].as_int = mbmi_ext->ref_mvs[mbmi->ref_frame[i]][0].as_int;
   }
-#endif  // CONFIG_REF_MV
 
   for (i = 0; i < REFERENCE_MODES; ++i) {
     if (best_pred_rd[i] == INT64_MAX)
@@ -11495,10 +11291,8 @@
   mbmi->tx_size = max_txsize_lookup[bsize];
   x->skip = 1;
 
-#if CONFIG_REF_MV
   mbmi->ref_mv_idx = 0;
   mbmi->pred_mv[0].as_int = 0;
-#endif  // CONFIG_REF_MV
 
   mbmi->motion_mode = SIMPLE_TRANSLATION;
 #if CONFIG_MOTION_VAR
@@ -11687,9 +11481,9 @@
 
   for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
     x->mbmi_ext->mode_context[ref_frame] = 0;
-#if CONFIG_REF_MV && CONFIG_EXT_INTER
+#if CONFIG_EXT_INTER
     x->mbmi_ext->compound_mode_context[ref_frame] = 0;
-#endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
+#endif  // CONFIG_EXT_INTER
     if (cpi->ref_frame_flags & flag_list[ref_frame]) {
       setup_buffer_inter(cpi, x, ref_frame, bsize, mi_row, mi_col,
                          frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb);
@@ -11726,9 +11520,7 @@
     ref_frame = av1_ref_order[ref_index].ref_frame[0];
     second_ref_frame = av1_ref_order[ref_index].ref_frame[1];
 
-#if CONFIG_REF_MV
     mbmi->ref_mv_idx = 0;
-#endif  // CONFIG_REF_MV
 
     // Look at the reference frame of the best mode so far and set the
     // skip mask to look at a subset of the remaining modes.
@@ -12326,10 +12118,8 @@
     for (i = 0; i < 4; ++i)
       memcpy(&xd->mi[0]->bmi[i], &best_bmodes[i], sizeof(b_mode_info));
 
-#if CONFIG_REF_MV
     mbmi->pred_mv[0].as_int = xd->mi[0]->bmi[3].pred_mv[0].as_int;
     mbmi->pred_mv[1].as_int = xd->mi[0]->bmi[3].pred_mv[1].as_int;
-#endif  // CONFIG_REF_MV
     mbmi->mv[0].as_int = xd->mi[0]->bmi[3].as_mv[0].as_int;
     mbmi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int;
   }
diff --git a/av1/encoder/temporal_filter.c b/av1/encoder/temporal_filter.c
index de962fe..98feb87 100644
--- a/av1/encoder/temporal_filter.c
+++ b/av1/encoder/temporal_filter.c
@@ -281,12 +281,10 @@
 
   av1_set_mv_search_range(&x->mv_limits, &best_ref_mv1);
 
-#if CONFIG_REF_MV
   x->mvcost = x->mv_cost_stack[0];
   x->nmvjointcost = x->nmv_vec_cost[0];
   x->mvsadcost = x->mvcost;
   x->nmvjointsadcost = x->nmvjointcost;
-#endif
 
   // Ignore mv costing by sending NULL pointer instead of cost arrays
   av1_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1,