Deprecate cpi->preserve_alt_as_gld flag

The control functionality has been covered by the new reference
frame scheduling system. Remove this control flag. The coding
performance for lowres and midres remains unchanged in speed 1 for
150 frames. It improves the ugc360 set by 0.1% in PSNR and SSIM.

STATS_CHANGED

Change-Id: Ia7b1f058f4327ccaf01ea0d1b148464321fc05d6
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index 7d56023..f25c7a6 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -853,18 +853,10 @@
                  ref_map_index);
       break;
     case OVERLAY_UPDATE:
-      if (cpi->preserve_arf_as_gld || cm->show_existing_frame) {
-        ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
-                                  &ref_buffer_stack->arf_stack_size);
-        stack_push(ref_buffer_stack->gld_stack,
-                   &ref_buffer_stack->gld_stack_size, ref_map_index);
-      } else {
-        stack_pop(ref_buffer_stack->arf_stack,
-                  &ref_buffer_stack->arf_stack_size);
-        update_arf_stack(cpi, ref_map_index, ref_buffer_stack);
-        stack_push(ref_buffer_stack->gld_stack,
-                   &ref_buffer_stack->gld_stack_size, ref_map_index);
-      }
+      ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
+                                &ref_buffer_stack->arf_stack_size);
+      stack_push(ref_buffer_stack->gld_stack, &ref_buffer_stack->gld_stack_size,
+                 ref_map_index);
       break;
     case INTNL_OVERLAY_UPDATE:
       ref_map_index = stack_pop(ref_buffer_stack->arf_stack,
@@ -1052,11 +1044,9 @@
       refresh_mask |= cpi->ext_refresh_alt2_ref_frame << ref_frame_map_idx;
 
     if (frame_update_type == OVERLAY_UPDATE) {
-      if (!cpi->preserve_arf_as_gld) {
-        ref_frame_map_idx = get_ref_frame_map_idx(cm, ALTREF_FRAME);
-        if (ref_frame_map_idx != INVALID_IDX)
-          refresh_mask |= cpi->ext_refresh_golden_frame << ref_frame_map_idx;
-      }
+      ref_frame_map_idx = get_ref_frame_map_idx(cm, ALTREF_FRAME);
+      if (ref_frame_map_idx != INVALID_IDX)
+        refresh_mask |= cpi->ext_refresh_golden_frame << ref_frame_map_idx;
     } else {
       ref_frame_map_idx = get_ref_frame_map_idx(cm, GOLDEN_FRAME);
       if (ref_frame_map_idx != INVALID_IDX)
@@ -1127,21 +1117,7 @@
                      ->lst_stack[ref_buffer_stack->lst_stack_size - 1];
       }
       break;
-    case OVERLAY_UPDATE:
-      if (!cpi->preserve_arf_as_gld) {
-        if (free_fb_index != INVALID_IDX) {
-          refresh_mask = 1 << free_fb_index;
-        } else if (ref_buffer_stack->arf_stack_size) {
-          refresh_mask =
-              1 << ref_buffer_stack
-                       ->arf_stack[ref_buffer_stack->arf_stack_size - 1];
-        } else {
-          refresh_mask =
-              1 << ref_buffer_stack
-                       ->lst_stack[ref_buffer_stack->lst_stack_size - 1];
-        }
-      }
-      break;
+    case OVERLAY_UPDATE: break;
     case INTNL_OVERLAY_UPDATE: break;
     default: assert(0); break;
   }
@@ -1173,14 +1149,7 @@
       refresh_mask |= 1 << get_ref_frame_map_idx(cm, LAST3_FRAME);
       refresh_mask |= 1 << get_ref_frame_map_idx(cm, GOLDEN_FRAME);
       break;
-    case OVERLAY_UPDATE:
-      if (!cpi->preserve_arf_as_gld) {
-        // The result of our OVERLAY should become the GOLDEN_FRAME but we'd
-        // like to keep the old GOLDEN as our new ALTREF.  So we refresh the
-        // ALTREF and swap around the ALTREF and GOLDEN references.
-        refresh_mask |= 1 << get_ref_frame_map_idx(cm, ALTREF_FRAME);
-      }
-      break;
+    case OVERLAY_UPDATE: break;
     case ARF_UPDATE:
       refresh_mask |= 1 << get_ref_frame_map_idx(cm, ALTREF_FRAME);
       break;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 92fed66..6426bb9 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -1008,7 +1008,6 @@
   // Stores the default value of skip flag depending on chroma format
   // Set as 1 for monochrome and 3 for other color formats
   int default_interp_skip_flags;
-  int preserve_arf_as_gld;
   MultiThreadHandle multi_thread_ctxt;
   void (*row_mt_sync_read_ptr)(AV1RowMTSync *const, int, int);
   void (*row_mt_sync_write_ptr)(AV1RowMTSync *const, int, int, const int);
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index 51700a5..47a1f23 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -799,7 +799,6 @@
       !(cpi->lookahead->sz < rc->baseline_gf_interval - 1) &&
       (cpi->oxcf.gf_max_pyr_height > MIN_PYRAMID_LVL);
   rc->source_alt_ref_pending = use_alt_ref;
-  cpi->preserve_arf_as_gld = use_alt_ref;
 
   // Set up the structure of this Group-Of-Pictures (same as GF_GROUP)
   av1_gop_setup_structure(cpi, frame_params);
@@ -1134,13 +1133,9 @@
     rc->gfu_boost =
         calc_arf_boost(cpi, alt_offset, (i - 1), (i - 1), &f_boost, &b_boost);
     rc->source_alt_ref_pending = 1;
-
-    // do not replace ARFs with overlay frames, and keep it as GOLDEN_REF
-    cpi->preserve_arf_as_gld = 1;
   } else {
     rc->gfu_boost = AOMMAX((int)boost_score, MIN_ARF_GF_BOOST);
     rc->source_alt_ref_pending = 0;
-    cpi->preserve_arf_as_gld = 0;
   }
 
   // Set the interval until the next gf.