Remove VAR_REFS experiment

This experiment has been abandonned.

Change-Id: Ieabc6f365651e2d116a4505a3cc202add94d1386
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 9860107..452a408 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -558,9 +558,6 @@
   int idx;
   YV12_BUFFER_CONFIG *buf;
   struct scale_factors sf;
-#if CONFIG_VAR_REFS
-  int is_valid;
-#endif  // CONFIG_VAR_REFS
 } RefBuffer;
 
 #if CONFIG_ADAPT_SCAN
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index f965b13..65c2f46 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -646,29 +646,6 @@
 #endif
 }
 
-#if CONFIG_VAR_REFS
-#define LAST_IS_VALID(cm) ((cm)->frame_refs[LAST_FRAME - 1].is_valid)
-#define LAST2_IS_VALID(cm) ((cm)->frame_refs[LAST2_FRAME - 1].is_valid)
-#define LAST3_IS_VALID(cm) ((cm)->frame_refs[LAST3_FRAME - 1].is_valid)
-#define GOLDEN_IS_VALID(cm) ((cm)->frame_refs[GOLDEN_FRAME - 1].is_valid)
-#define BWDREF_IS_VALID(cm) ((cm)->frame_refs[BWDREF_FRAME - 1].is_valid)
-#define ALTREF2_IS_VALID(cm) ((cm)->frame_refs[ALTREF2_FRAME - 1].is_valid)
-#define ALTREF_IS_VALID(cm) ((cm)->frame_refs[ALTREF_FRAME - 1].is_valid)
-
-#define L_OR_L2(cm) (LAST_IS_VALID(cm) || LAST2_IS_VALID(cm))
-#define L_AND_L2(cm) (LAST_IS_VALID(cm) && LAST2_IS_VALID(cm))
-#define L_AND_L3(cm) (LAST_IS_VALID(cm) && LAST3_IS_VALID(cm))
-#define L_AND_G(cm) (LAST_IS_VALID(cm) && GOLDEN_IS_VALID(cm))
-
-#define L3_OR_G(cm) (LAST3_IS_VALID(cm) || GOLDEN_IS_VALID(cm))
-#define L3_AND_G(cm) (LAST3_IS_VALID(cm) && GOLDEN_IS_VALID(cm))
-
-#define BWD_OR_ALT2(cm) (BWDREF_IS_VALID(cm) || ALTREF2_IS_VALID(cm))
-#define BWD_AND_ALT2(cm) (BWDREF_IS_VALID(cm) && ALTREF2_IS_VALID(cm))
-#define BWD_OR_ALT(cm) (BWDREF_IS_VALID(cm) || ALTREF_IS_VALID(cm))
-#define BWD_AND_ALT(cm) (BWDREF_IS_VALID(cm) && ALTREF_IS_VALID(cm))
-#endif  // CONFIG_VAR_REFS
-
 static INLINE int mi_cols_aligned_to_sb(const AV1_COMMON *cm) {
   return ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
 }
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 0b124b3..fc951bb 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2630,38 +2630,6 @@
   }
 }
 
-#if CONFIG_VAR_REFS
-static void check_valid_ref_frames(AV1_COMMON *cm) {
-  MV_REFERENCE_FRAME ref_frame;
-  // TODO(zoeliu): To handle ALTREF_FRAME the same way as do with other
-  //               reference frames: Current encoder invalid ALTREF when ALTREF
-  //               is the same as LAST, but invalid all the other references
-  //               when they are the same as ALTREF.
-  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
-    RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - LAST_FRAME];
-
-    if (ref_buf->idx != INVALID_IDX) {
-      ref_buf->is_valid = 1;
-
-      MV_REFERENCE_FRAME ref;
-      for (ref = LAST_FRAME; ref < ref_frame; ++ref) {
-        RefBuffer *const buf = &cm->frame_refs[ref - LAST_FRAME];
-        if (buf->is_valid && buf->idx == ref_buf->idx) {
-          if (ref_frame != ALTREF_FRAME || ref == LAST_FRAME) {
-            ref_buf->is_valid = 0;
-            break;
-          } else {
-            buf->is_valid = 0;
-          }
-        }
-      }
-    } else {
-      ref_buf->is_valid = 0;
-    }
-  }
-}
-#endif  // CONFIG_VAR_REFS
-
 static int read_global_motion_params(WarpedMotionParams *params,
                                      const WarpedMotionParams *ref_params,
                                      struct aom_read_bit_buffer *rb,
@@ -2930,9 +2898,6 @@
     for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
       cm->frame_refs[i].idx = INVALID_IDX;
       cm->frame_refs[i].buf = NULL;
-#if CONFIG_VAR_REFS
-      cm->frame_refs[i].is_valid = 0;
-#endif  // CONFIG_VAR_REFS
     }
 
 #if CONFIG_FRAME_SIZE
@@ -3076,10 +3041,6 @@
 #endif  // CONFIG_REFERENCE_BUFFER
       }
 
-#if CONFIG_VAR_REFS
-      check_valid_ref_frames(cm);
-#endif  // CONFIG_VAR_REFS
-
 #if CONFIG_FRAME_SIZE
       if (cm->error_resilient_mode == 0 && frame_size_override_flag) {
         setup_frame_size_with_refs(cm, rb);
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index c63caa7..ec5f577 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1437,26 +1437,14 @@
                                                     aom_reader *r) {
   const int ctx = av1_get_comp_reference_type_context(xd);
   COMP_REFERENCE_TYPE comp_ref_type;
-#if CONFIG_VAR_REFS
-  if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm)) {
-    if (L_AND_L2(cm) || L_AND_L3(cm) || L_AND_G(cm) || BWD_AND_ALT(cm)) {
-#endif  // CONFIG_VAR_REFS
 #if CONFIG_NEW_MULTISYMBOL
-      (void)cm;
-      comp_ref_type = (COMP_REFERENCE_TYPE)aom_read_symbol(
-          r, xd->tile_ctx->comp_ref_type_cdf[ctx], 2, ACCT_STR);
+  (void)cm;
+  comp_ref_type = (COMP_REFERENCE_TYPE)aom_read_symbol(
+      r, xd->tile_ctx->comp_ref_type_cdf[ctx], 2, ACCT_STR);
 #else
   comp_ref_type = (COMP_REFERENCE_TYPE)aom_read(
       r, cm->fc->comp_ref_type_prob[ctx], ACCT_STR);
 #endif
-#if CONFIG_VAR_REFS
-    } else {
-      comp_ref_type = BIDIR_COMP_REFERENCE;
-    }
-  } else {
-    comp_ref_type = UNIDIR_COMP_REFERENCE;
-  }
-#endif  // CONFIG_VAR_REFS
   FRAME_COUNTS *counts = xd->counts;
   if (counts) ++counts->comp_ref_type[ctx][comp_ref_type];
   return comp_ref_type;  // UNIDIR_COMP_REFERENCE or BIDIR_COMP_REFERENCE
@@ -1564,14 +1552,7 @@
       if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
         const int ctx = av1_get_pred_context_uni_comp_ref_p(xd);
         int bit;
-#if CONFIG_VAR_REFS
-        if ((L_AND_L2(cm) || L_AND_L3(cm) || L_AND_G(cm)) && BWD_AND_ALT(cm))
-#endif  // CONFIG_VAR_REFS
-          bit = READ_REF_BIT2(uni_comp_ref_p);
-#if CONFIG_VAR_REFS
-        else
-          bit = BWD_AND_ALT(cm);
-#endif  // CONFIG_VAR_REFS
+        bit = READ_REF_BIT2(uni_comp_ref_p);
         if (counts) ++counts->uni_comp_ref[ctx][0][bit];
 
         if (bit) {
@@ -1580,27 +1561,13 @@
         } else {
           const int ctx1 = av1_get_pred_context_uni_comp_ref_p1(xd);
           int bit1;
-#if CONFIG_VAR_REFS
-          if (L_AND_L2(cm) && (L_AND_L3(cm) || L_AND_G(cm)))
-#endif  // CONFIG_VAR_REFS
-            bit1 = READ_REF_BIT2(uni_comp_ref_p1);
-#if CONFIG_VAR_REFS
-          else
-            bit1 = L_AND_L3(cm) || L_AND_G(cm);
-#endif  // CONFIG_VAR_REFS
+          bit1 = READ_REF_BIT2(uni_comp_ref_p1);
           if (counts) ++counts->uni_comp_ref[ctx1][1][bit1];
 
           if (bit1) {
             const int ctx2 = av1_get_pred_context_uni_comp_ref_p2(xd);
             int bit2;
-#if CONFIG_VAR_REFS
-            if (L_AND_L3(cm) && L_AND_G(cm))
-#endif  // CONFIG_VAR_REFS
-              bit2 = READ_REF_BIT2(uni_comp_ref_p2);
-#if CONFIG_VAR_REFS
-            else
-              bit2 = L_AND_G(cm);
-#endif  // CONFIG_VAR_REFS
+            bit2 = READ_REF_BIT2(uni_comp_ref_p2);
             if (counts) ++counts->uni_comp_ref[ctx2][2][bit2];
 
             if (bit2) {
@@ -1630,74 +1597,29 @@
 #endif  // CONFIG_ONE_SIDED_COMPOUND || CONFIG_FRAME_SIGN_BIAS)
 
       const int ctx = av1_get_pred_context_comp_ref_p(cm, xd);
-#if CONFIG_VAR_REFS
-      int bit;
-      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
-      if (L_OR_L2(cm) && L3_OR_G(cm))
-        bit = READ_REF_BIT(comp_ref_p);
-      else
-        bit = L3_OR_G(cm);
-#else   // !CONFIG_VAR_REFS
       const int bit = READ_REF_BIT(comp_ref_p);
-#endif  // CONFIG_VAR_REFS
       if (counts) ++counts->comp_ref[ctx][0][bit];
 
       // Decode forward references.
       if (!bit) {
         const int ctx1 = av1_get_pred_context_comp_ref_p1(cm, xd);
-#if CONFIG_VAR_REFS
-        int bit1;
-        // Test need to explicitly code (L) vs (L2) branch node in tree
-        if (L_AND_L2(cm))
-          bit1 = READ_REF_BIT(comp_ref_p1);
-        else
-          bit1 = LAST_IS_VALID(cm);
-#else   // !CONFIG_VAR_REFS
         const int bit1 = READ_REF_BIT(comp_ref_p1);
-#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->comp_ref[ctx1][1][bit1];
         ref_frame[!idx] = cm->comp_fwd_ref[bit1 ? 0 : 1];
       } else {
         const int ctx2 = av1_get_pred_context_comp_ref_p2(cm, xd);
-#if CONFIG_VAR_REFS
-        int bit2;
-        // Test need to explicitly code (L3) vs (G) branch node in tree
-        if (L3_AND_G(cm))
-          bit2 = READ_REF_BIT(comp_ref_p2);
-        else
-          bit2 = GOLDEN_IS_VALID(cm);
-#else   // !CONFIG_VAR_REFS
         const int bit2 = READ_REF_BIT(comp_ref_p2);
-#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->comp_ref[ctx2][2][bit2];
         ref_frame[!idx] = cm->comp_fwd_ref[bit2 ? 3 : 2];
       }
 
       // Decode backward references.
       const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd);
-#if CONFIG_VAR_REFS
-      int bit_bwd;
-      // Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
-      const int bit_bwd_uncertain = BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm);
-      if (bit_bwd_uncertain)
-        bit_bwd = READ_REF_BIT(comp_bwdref_p);
-      else
-        bit_bwd = ALTREF_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
       const int bit_bwd = READ_REF_BIT(comp_bwdref_p);
-#endif  // CONFIG_VAR_REFS
       if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
       if (!bit_bwd) {
         const int ctx1_bwd = av1_get_pred_context_comp_bwdref_p1(cm, xd);
-#if CONFIG_VAR_REFS
-        int bit1_bwd;
-        if (BWD_AND_ALT2(cm))
-          bit1_bwd = READ_REF_BIT(comp_bwdref_p1);
-        else
-          bit1_bwd = ALTREF2_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
         const int bit1_bwd = READ_REF_BIT(comp_bwdref_p1);
-#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->comp_bwdref[ctx1_bwd][1][bit1_bwd];
         ref_frame[idx] = cm->comp_bwd_ref[bit1_bwd];
       } else {
@@ -1705,45 +1627,16 @@
       }
     } else if (mode == SINGLE_REFERENCE) {
       const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
-#if CONFIG_VAR_REFS
-      int bit0;
-      // Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT2,ALT) branch node
-      // in tree
-      if ((L_OR_L2(cm) || L3_OR_G(cm)) &&
-          (BWD_OR_ALT2(cm) || ALTREF_IS_VALID(cm)))
-        bit0 = READ_REF_BIT(single_ref_p1);
-      else
-        bit0 = (BWD_OR_ALT2(cm) || ALTREF_IS_VALID(cm));
-#else   // !CONFIG_VAR_REFS
       const int bit0 = READ_REF_BIT(single_ref_p1);
-#endif  // CONFIG_VAR_REFS
       if (counts) ++counts->single_ref[ctx0][0][bit0];
 
       if (bit0) {
         const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
-#if CONFIG_VAR_REFS
-        int bit1;
-        // Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
-        const int bit1_uncertain = BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm);
-        if (bit1_uncertain)
-          bit1 = READ_REF_BIT(single_ref_p2);
-        else
-          bit1 = ALTREF_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
         const int bit1 = READ_REF_BIT(single_ref_p2);
-#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->single_ref[ctx1][1][bit1];
         if (!bit1) {
           const int ctx5 = av1_get_pred_context_single_ref_p6(xd);
-#if CONFIG_VAR_REFS
-          int bit5;
-          if (BWD_AND_ALT2(cm))
-            bit5 = READ_REF_BIT(single_ref_p6);
-          else
-            bit5 = ALTREF2_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
           const int bit5 = READ_REF_BIT(single_ref_p6);
-#endif  // CONFIG_VAR_REFS
           if (counts) ++counts->single_ref[ctx5][5][bit5];
           ref_frame[0] = bit5 ? ALTREF2_FRAME : BWDREF_FRAME;
         } else {
@@ -1751,43 +1644,16 @@
         }
       } else {
         const int ctx2 = av1_get_pred_context_single_ref_p3(xd);
-#if CONFIG_VAR_REFS
-        int bit2;
-        // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
-        if (L_OR_L2(cm) && L3_OR_G(cm))
-          bit2 = READ_REF_BIT(single_ref_p3);
-        else
-          bit2 = L3_OR_G(cm);
-#else  // !CONFIG_VAR_REFS
         const int bit2 = READ_REF_BIT(single_ref_p3);
-#endif  // CONFIG_VAR_REFS
         if (counts) ++counts->single_ref[ctx2][2][bit2];
         if (bit2) {
           const int ctx4 = av1_get_pred_context_single_ref_p5(xd);
-#if CONFIG_VAR_REFS
-          int bit4;
-          // Test need to explicitly code (L3) vs (G) branch node in tree
-          if (L3_AND_G(cm))
-            bit4 = READ_REF_BIT(single_ref_p5);
-          else
-            bit4 = GOLDEN_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
           const int bit4 = READ_REF_BIT(single_ref_p5);
-#endif  // CONFIG_VAR_REFS
           if (counts) ++counts->single_ref[ctx4][4][bit4];
           ref_frame[0] = bit4 ? GOLDEN_FRAME : LAST3_FRAME;
         } else {
           const int ctx3 = av1_get_pred_context_single_ref_p4(xd);
-#if CONFIG_VAR_REFS
-          int bit3;
-          // Test need to explicitly code (L) vs (L2) branch node in tree
-          if (L_AND_L2(cm))
-            bit3 = READ_REF_BIT(single_ref_p4);
-          else
-            bit3 = LAST2_IS_VALID(cm);
-#else  // !CONFIG_VAR_REFS
           const int bit3 = READ_REF_BIT(single_ref_p4);
-#endif  // CONFIG_VAR_REFS
           if (counts) ++counts->single_ref[ctx3][3][bit3];
           ref_frame[0] = bit3 ? LAST2_FRAME : LAST_FRAME;
         }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 6a99d0e..ca429b5 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -828,51 +828,26 @@
       const COMP_REFERENCE_TYPE comp_ref_type = has_uni_comp_refs(mbmi)
                                                     ? UNIDIR_COMP_REFERENCE
                                                     : BIDIR_COMP_REFERENCE;
-#if CONFIG_VAR_REFS
-      if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm))
-        if (L_AND_L2(cm) || L_AND_L3(cm) || L_AND_G(cm) || BWD_AND_ALT(cm))
-#endif  // CONFIG_VAR_REFS
 #if CONFIG_NEW_MULTISYMBOL
-          aom_write_symbol(w, comp_ref_type,
-                           av1_get_comp_reference_type_cdf(xd), 2);
+      aom_write_symbol(w, comp_ref_type, av1_get_comp_reference_type_cdf(xd),
+                       2);
 #else
       aom_write(w, comp_ref_type, av1_get_comp_reference_type_prob(cm, xd));
 #endif
-#if CONFIG_VAR_REFS
-        else
-          assert(comp_ref_type == BIDIR_COMP_REFERENCE);
-      else
-        assert(comp_ref_type == UNIDIR_COMP_REFERENCE);
-#endif  // CONFIG_VAR_REFS
 
       if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
         const int bit = mbmi->ref_frame[0] == BWDREF_FRAME;
-#if CONFIG_VAR_REFS
-        if ((L_AND_L2(cm) || L_AND_L3(cm) || L_AND_G(cm)) && BWD_AND_ALT(cm))
-#endif  // CONFIG_VAR_REFS
-          WRITE_REF_BIT2(bit, uni_comp_ref_p);
+        WRITE_REF_BIT2(bit, uni_comp_ref_p);
 
         if (!bit) {
           assert(mbmi->ref_frame[0] == LAST_FRAME);
-#if CONFIG_VAR_REFS
-          if (L_AND_L2(cm) && (L_AND_L3(cm) || L_AND_G(cm))) {
-#endif  // CONFIG_VAR_REFS
-            const int bit1 = mbmi->ref_frame[1] == LAST3_FRAME ||
-                             mbmi->ref_frame[1] == GOLDEN_FRAME;
-            WRITE_REF_BIT2(bit1, uni_comp_ref_p1);
-            if (bit1) {
-#if CONFIG_VAR_REFS
-              if (L_AND_L3(cm) && L_AND_G(cm)) {
-#endif  // CONFIG_VAR_REFS
-                const int bit2 = mbmi->ref_frame[1] == GOLDEN_FRAME;
-                WRITE_REF_BIT2(bit2, uni_comp_ref_p2);
-#if CONFIG_VAR_REFS
-              }
-#endif  // CONFIG_VAR_REFS
-            }
-#if CONFIG_VAR_REFS
+          const int bit1 = mbmi->ref_frame[1] == LAST3_FRAME ||
+                           mbmi->ref_frame[1] == GOLDEN_FRAME;
+          WRITE_REF_BIT2(bit1, uni_comp_ref_p1);
+          if (bit1) {
+            const int bit2 = mbmi->ref_frame[1] == GOLDEN_FRAME;
+            WRITE_REF_BIT2(bit2, uni_comp_ref_p2);
           }
-#endif  // CONFIG_VAR_REFS
         } else {
           assert(mbmi->ref_frame[1] == ALTREF_FRAME);
         }
@@ -885,111 +860,46 @@
 
       const int bit = (mbmi->ref_frame[0] == GOLDEN_FRAME ||
                        mbmi->ref_frame[0] == LAST3_FRAME);
-#if CONFIG_VAR_REFS
-      // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
-      if (L_OR_L2(cm) && L3_OR_G(cm))
-#endif  // CONFIG_VAR_REFS
-        WRITE_REF_BIT(bit, comp_ref_p);
+      WRITE_REF_BIT(bit, comp_ref_p);
 
       if (!bit) {
-#if CONFIG_VAR_REFS
-        // Test need to explicitly code (L) vs (L2) branch node in tree
-        if (L_AND_L2(cm)) {
-#endif  // CONFIG_VAR_REFS
-          const int bit1 = mbmi->ref_frame[0] == LAST_FRAME;
-          WRITE_REF_BIT(bit1, comp_ref_p1);
-#if CONFIG_VAR_REFS
-        }
-#endif  // CONFIG_VAR_REFS
+        const int bit1 = mbmi->ref_frame[0] == LAST_FRAME;
+        WRITE_REF_BIT(bit1, comp_ref_p1);
       } else {
-#if CONFIG_VAR_REFS
-        // Test need to explicitly code (L3) vs (G) branch node in tree
-        if (L3_AND_G(cm)) {
-#endif  // CONFIG_VAR_REFS
-          const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
-          WRITE_REF_BIT(bit2, comp_ref_p2);
-#if CONFIG_VAR_REFS
-        }
-#endif  // CONFIG_VAR_REFS
+        const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
+        WRITE_REF_BIT(bit2, comp_ref_p2);
       }
 
-#if CONFIG_VAR_REFS
-      // Test need to explicitly code (BWD,ALT2) vs (ALT) branch node in tree
-      if (BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm)) {
-#endif  // CONFIG_VAR_REFS
-        const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
-        WRITE_REF_BIT(bit_bwd, comp_bwdref_p);
+      const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
+      WRITE_REF_BIT(bit_bwd, comp_bwdref_p);
 
-        if (!bit_bwd) {
-#if CONFIG_VAR_REFS
-          // Test need to explicitly code (BWD,ALT2) vs (ALT) branch node in
-          // tree
-          if (BWD_AND_ALT2(cm))
-#endif  // CONFIG_VAR_REFS
-            WRITE_REF_BIT(mbmi->ref_frame[1] == ALTREF2_FRAME, comp_bwdref_p1);
-        }
-#if CONFIG_VAR_REFS
+      if (!bit_bwd) {
+        WRITE_REF_BIT(mbmi->ref_frame[1] == ALTREF2_FRAME, comp_bwdref_p1);
       }
-#endif  // CONFIG_VAR_REFS
 
     } else {
       const int bit0 = (mbmi->ref_frame[0] <= ALTREF_FRAME &&
                         mbmi->ref_frame[0] >= BWDREF_FRAME);
-#if CONFIG_VAR_REFS
-      // Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT2,ALT) branch node
-      // in tree
-      if ((L_OR_L2(cm) || L3_OR_G(cm)) &&
-          (BWD_OR_ALT2(cm) || ALTREF_IS_VALID(cm)))
-#endif  // CONFIG_VAR_REFS
-        WRITE_REF_BIT(bit0, single_ref_p1);
+      WRITE_REF_BIT(bit0, single_ref_p1);
 
       if (bit0) {
-#if CONFIG_VAR_REFS
-        // Test need to explicitly code (BWD,ALT2) vs (ALT) branch node in tree
-        if (BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm)) {
-#endif  // CONFIG_VAR_REFS
-          const int bit1 = mbmi->ref_frame[0] == ALTREF_FRAME;
-          WRITE_REF_BIT(bit1, single_ref_p2);
+        const int bit1 = mbmi->ref_frame[0] == ALTREF_FRAME;
+        WRITE_REF_BIT(bit1, single_ref_p2);
 
-          if (!bit1) {
-#if CONFIG_VAR_REFS
-            // Test need to explicitly code (BWD) vs (ALT2) branch node in tree
-            if (BWD_AND_ALT2(cm))
-#endif  // CONFIG_VAR_REFS
-              WRITE_REF_BIT(mbmi->ref_frame[0] == ALTREF2_FRAME, single_ref_p6);
-          }
-#if CONFIG_VAR_REFS
+        if (!bit1) {
+          WRITE_REF_BIT(mbmi->ref_frame[0] == ALTREF2_FRAME, single_ref_p6);
         }
-#endif  // CONFIG_VAR_REFS
       } else {
         const int bit2 = (mbmi->ref_frame[0] == LAST3_FRAME ||
                           mbmi->ref_frame[0] == GOLDEN_FRAME);
-#if CONFIG_VAR_REFS
-        // Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
-        if (L_OR_L2(cm) && L3_OR_G(cm))
-#endif  // CONFIG_VAR_REFS
-          WRITE_REF_BIT(bit2, single_ref_p3);
+        WRITE_REF_BIT(bit2, single_ref_p3);
 
         if (!bit2) {
-#if CONFIG_VAR_REFS
-          // Test need to explicitly code (L) vs (L2) branch node in tree
-          if (L_AND_L2(cm)) {
-#endif  // CONFIG_VAR_REFS
-            const int bit3 = mbmi->ref_frame[0] != LAST_FRAME;
-            WRITE_REF_BIT(bit3, single_ref_p4);
-#if CONFIG_VAR_REFS
-          }
-#endif  // CONFIG_VAR_REFS
+          const int bit3 = mbmi->ref_frame[0] != LAST_FRAME;
+          WRITE_REF_BIT(bit3, single_ref_p4);
         } else {
-#if CONFIG_VAR_REFS
-          // Test need to explicitly code (L3) vs (G) branch node in tree
-          if (L3_AND_G(cm)) {
-#endif  // CONFIG_VAR_REFS
-            const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME;
-            WRITE_REF_BIT(bit4, single_ref_p5);
-#if CONFIG_VAR_REFS
-          }
-#endif  // CONFIG_VAR_REFS
+          const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME;
+          WRITE_REF_BIT(bit4, single_ref_p5);
         }
       }
     }
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 8a2d9e2..7b5c0cc 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3592,42 +3592,6 @@
   }
 }
 
-#if CONFIG_VAR_REFS
-static void enc_check_valid_ref_frames(AV1_COMP *const cpi) {
-  AV1_COMMON *const cm = &cpi->common;
-  MV_REFERENCE_FRAME ref_frame;
-
-  // TODO(zoeliu): To handle ALTREF_FRAME the same way as do with other
-  //               reference frames. Current encoder invalid ALTREF when ALTREF
-  //               is the same as LAST, but invalid all the other references
-  //               when they are the same as ALTREF.
-  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
-    int ref_buf_idx = get_ref_frame_buf_idx(cpi, ref_frame);
-    RefBuffer *const ref_buf = &cm->frame_refs[ref_frame - LAST_FRAME];
-
-    if (ref_buf_idx != INVALID_IDX) {
-      ref_buf->is_valid = 1;
-
-      MV_REFERENCE_FRAME ref;
-      for (ref = LAST_FRAME; ref < ref_frame; ++ref) {
-        int buf_idx = get_ref_frame_buf_idx(cpi, ref);
-        RefBuffer *const buf = &cm->frame_refs[ref - LAST_FRAME];
-        if (buf->is_valid && buf_idx == ref_buf_idx) {
-          if (ref_frame != ALTREF_FRAME || ref == LAST_FRAME) {
-            ref_buf->is_valid = 0;
-            break;
-          } else {
-            buf->is_valid = 0;
-          }
-        }
-      }
-    } else {
-      ref_buf->is_valid = 0;
-    }
-  }
-}
-#endif  // CONFIG_VAR_REFS
-
 #if USE_GF16_MULTI_LAYER
 static void update_reference_frames_gf16(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
@@ -4320,11 +4284,6 @@
     }
   }
 
-#if CONFIG_VAR_REFS
-  // Check duplicate reference frames
-  enc_check_valid_ref_frames(cpi);
-#endif  // CONFIG_VAR_REFS
-
 #if CONFIG_INTRABC
 #if CONFIG_HIGHBITDEPTH
   av1_setup_scale_factors_for_frame(&xd->sf_identity, cm->width, cm->height,
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 3bc1937..df67ed9 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -198,6 +198,5 @@
 set(CONFIG_TXK_SEL 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TXMG 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_UNPOISON_PARTITION_CTX 0 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_VAR_REFS 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_VAR_TX_NO_TX_MODE 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_XIPHRC 0 CACHE NUMBER "AV1 experiment flag.")
diff --git a/configure b/configure
index 8eb34f4..93492fb 100755
--- a/configure
+++ b/configure
@@ -312,7 +312,6 @@
     one_sided_compound
     ext_comp_refs
     smooth_hv
-    var_refs
     lgt
     lgt_from_pred
     ncobmc_adapt_weight