Add a new experiment of REF_ADAPT

Noticed that some ALTREF_FRAMEs could have used compound modes for its
prediction but have been labeled as SINGLE_REFERENCE mode in the frame
header. This experiment is to remove the COMPOUND_REFERENCE mode from
the frame-level reference mode choices and only leave SINGLE_REFERENCE
and REFERENCE_MODE_SELECT the two choices in the frame header.

When turning on both ext-refs and ref-adapt, compared against ext-refs
itself, a small gain is achieved. In PSNR, the bitrate saving gains are
as follows:

lowres: Avg -0.120%; BDRate -0.128%
midres: Avg -0.155%; BDRate -0.128%

Change-Id: I2cfff8a6b7eaa65ef863dbdbc4dd086d3b586f8c
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 754a472..25afeda 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4696,6 +4696,7 @@
   av1_setup_block_planes(xd, cm->subsampling_x, cm->subsampling_y);
 }
 
+#if !CONFIG_REF_ADAPT
 static int check_dual_ref_flags(AV1_COMP *cpi) {
   const int ref_flags = cpi->ref_frame_flags;
 
@@ -4710,6 +4711,7 @@
             !!(ref_flags & AOM_ALT_FLAG)) >= 2;
   }
 }
+#endif  // !CONFIG_REF_ADAPT
 
 #if !CONFIG_VAR_TX
 static void reset_skip_tx_size(AV1_COMMON *cm, TX_SIZE max_tx_size) {
@@ -5190,7 +5192,14 @@
     int64_t *const mode_thrs = rd_opt->prediction_type_threshes[frame_type];
     const int is_alt_ref = frame_type == ALTREF_FRAME;
 
-    /* prediction (compound, single or hybrid) mode selection */
+/* prediction (compound, single or hybrid) mode selection */
+#if CONFIG_REF_ADAPT
+    // NOTE(zoeliu): "is_alt_ref" is true only for OVERLAY/INTNL_OVERLAY frames
+    if (is_alt_ref || !cpi->allow_comp_inter_inter)
+      cm->reference_mode = SINGLE_REFERENCE;
+    else
+      cm->reference_mode = REFERENCE_MODE_SELECT;
+#else
     if (is_alt_ref || !cpi->allow_comp_inter_inter)
       cm->reference_mode = SINGLE_REFERENCE;
     else if (mode_thrs[COMPOUND_REFERENCE] > mode_thrs[SINGLE_REFERENCE] &&
@@ -5201,6 +5210,7 @@
       cm->reference_mode = SINGLE_REFERENCE;
     else
       cm->reference_mode = REFERENCE_MODE_SELECT;
+#endif  // CONFIG_REF_ADAPT
 
 #if CONFIG_DUAL_FILTER
     cm->interp_filter = SWITCHABLE;
@@ -5223,9 +5233,11 @@
       if (comp_count_zero == 0) {
         cm->reference_mode = SINGLE_REFERENCE;
         av1_zero(counts->comp_inter);
+#if !CONFIG_REF_ADAPT
       } else if (single_count_zero == 0) {
         cm->reference_mode = COMPOUND_REFERENCE;
         av1_zero(counts->comp_inter);
+#endif  // !CONFIG_REF_ADAPT
       }
     }