Remove all named reference definitions in NRS

Change-Id: I9a6b33b3ece6f0363e33b5f3b9267bc991222cd7
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index ae32fc7..63e0c8f 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -473,7 +473,6 @@
   return has_second_ref(mbmi) && (!((mbmi->ref_frame[0] >= BWDREF_FRAME) ^
                                     (mbmi->ref_frame[1] >= BWDREF_FRAME)));
 }
-#endif  // !CONFIG_NEW_REF_SIGNALING
 
 static INLINE MV_REFERENCE_FRAME comp_ref0(int ref_idx) {
   static const MV_REFERENCE_FRAME lut[] = {
@@ -506,6 +505,7 @@
   assert(NELEMENTS(lut) == TOTAL_UNIDIR_COMP_REFS);
   return lut[ref_idx];
 }
+#endif  // !CONFIG_NEW_REF_SIGNALING
 
 PREDICTION_MODE av1_left_block_mode(const MB_MODE_INFO *left_mi);
 
diff --git a/av1/common/enums.h b/av1/common/enums.h
index 9549b29..1a98465 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -723,6 +723,7 @@
 #endif  // CONFIG_NEW_TX_PARTITION
 typedef uint8_t TXFM_CONTEXT;
 
+#if !CONFIG_NEW_REF_SIGNALING
 // An enum for single reference types (and some derived values).
 enum {
   NONE_FRAME = -1,
@@ -752,6 +753,7 @@
 
   SINGLE_REFS = FWD_REFS + BWD_REFS,
 };
+#endif  // !CONFIG_NEW_REF_SIGNALING
 
 #if CONFIG_NEW_REF_SIGNALING
 #define INTER_REFS_PER_FRAME 7
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index 172770f..c439086 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -73,20 +73,6 @@
                tile->mi_col_end - mi_col - 1);
 }
 
-static INLINE int8_t get_uni_comp_ref_idx(const MV_REFERENCE_FRAME *const rf) {
-  // Single ref pred
-  if (rf[1] <= INTRA_FRAME) return -1;
-
-  // Bi-directional comp ref pred
-  if ((rf[0] < BWDREF_FRAME) && (rf[1] >= BWDREF_FRAME)) return -1;
-
-  for (int8_t ref_idx = 0; ref_idx < TOTAL_UNIDIR_COMP_REFS; ++ref_idx) {
-    if (rf[0] == comp_ref0(ref_idx) && rf[1] == comp_ref1(ref_idx))
-      return ref_idx;
-  }
-  return -1;
-}
-
 #if CONFIG_NEW_REF_SIGNALING
 // Converts a pair of distinct indices (rf) each in [0, n-1],
 // to an combined index in [0, n*(n-1)/2].
@@ -177,6 +163,20 @@
 };
 // clang-format on
 
+static INLINE int8_t get_uni_comp_ref_idx(const MV_REFERENCE_FRAME *const rf) {
+  // Single ref pred
+  if (rf[1] <= INTRA_FRAME) return -1;
+
+  // Bi-directional comp ref pred
+  if ((rf[0] < BWDREF_FRAME) && (rf[1] >= BWDREF_FRAME)) return -1;
+
+  for (int8_t ref_idx = 0; ref_idx < TOTAL_UNIDIR_COMP_REFS; ++ref_idx) {
+    if (rf[0] == comp_ref0(ref_idx) && rf[1] == comp_ref1(ref_idx))
+      return ref_idx;
+  }
+  return -1;
+}
+
 static INLINE int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) {
   if (rf[1] > INTRA_FRAME) {
     const int8_t uni_comp_ref_idx = get_uni_comp_ref_idx(rf);
@@ -203,7 +203,6 @@
     rf[1] = NONE_FRAME;
   }
 }
-
 #endif  // CONFIG_NEW_REF_SIGNALING
 
 static uint16_t compound_mode_ctx_map[3][COMP_NEWMV_CTXS] = {
@@ -457,86 +456,6 @@
                             const MB_MODE_INFO *const mbmi);
 #endif  // CONFIG_REF_MV_BANK
 
-#if CONFIG_NEW_REF_SIGNALING
-// Temporary function to skip compound combinations that aren't
-// represented in av1_mode_defs. This will be needed until the bitstream
-// syntax is changed to support these combinations.
-static AOM_INLINE int skip_compound_search(int ref1, int ref2) {
-  assert(ref1 >= 0);
-  // Single reference case
-  if (ref2 <= INTRA_FRAME) return 0;
-  const int ind1 = ref1 - LAST_FRAME;
-  const int ind2 = ref2 - LAST_FRAME;
-
-  const int skip_comp[REF_FRAMES][REF_FRAMES] = {
-    {
-        1,
-        0,
-        0,
-        0,
-        0,
-        0,
-        0,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        0,
-        0,
-        0,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        0,
-        0,
-        0,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        0,
-        0,
-        0,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        1,
-        1,
-        0,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        1,
-        1,
-        1,
-    },
-    {
-        1,
-        1,
-        1,
-        1,
-        1,
-        1,
-        1,
-    },
-  };
-  return skip_comp[ind1][ind2];
-}
-#endif  // CONFIG_NEW_REF_SIGNALING
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index 9985117..808a2fe 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -26,11 +26,13 @@
   int base_qindex;
 } RefFrameMapPair;
 
+#if !CONFIG_NEW_REF_SIGNALING
 static const MV_REFERENCE_FRAME
     ref_frame_priority_order[INTER_REFS_PER_FRAME] = {
       LAST_FRAME,    ALTREF_FRAME, BWDREF_FRAME, GOLDEN_FRAME,
       ALTREF2_FRAME, LAST2_FRAME,  LAST3_FRAME,
     };
+#endif  // !CONFIG_NEW_REF_SIGNALING
 
 static INLINE void init_ref_map_pair(
     AV1_COMMON *cm, RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 1d3dba4..36cd895 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -3175,6 +3175,7 @@
                                                              AOM_ALT2_FLAG,
                                                              AOM_ALT_FLAG };
 
+#if !CONFIG_NEW_REF_SIGNALING
 // When more than 'max_allowed_refs' are available, we reduce the number of
 // reference frames one at a time based on this order.
 static const MV_REFERENCE_FRAME disable_order[] = {
@@ -3183,6 +3184,7 @@
   ALTREF2_FRAME,
   GOLDEN_FRAME,
 };
+#endif  // !CONFIG_NEW_REF_SIGNALING
 
 static INLINE int get_max_allowed_ref_frames(
     int selective_ref_frame, unsigned int max_reference_frames) {
@@ -3198,33 +3200,6 @@
 #endif  // CONFIG_NEW_REF_SIGNALING
 }
 
-static INLINE int get_ref_frame_flags(const SPEED_FEATURES *const sf,
-                                      const YV12_BUFFER_CONFIG **ref_frames,
-                                      const int ext_ref_frame_flags) {
-  // cpi->ext_flags.ref_frame_flags allows certain reference types to be
-  // disabled by the external interface.  These are set by
-  // av1_apply_encoding_flags(). Start with what the external interface allows,
-  // then suppress any reference types which we have found to be duplicates.
-  int flags = ext_ref_frame_flags;
-
-  for (int i = 1; i < INTER_REFS_PER_FRAME; ++i) {
-    const YV12_BUFFER_CONFIG *const this_ref = ref_frames[i];
-    // If this_ref has appeared before, mark the corresponding ref frame as
-    // invalid. For nonrd mode, only disable GOLDEN_FRAME if it's the same
-    // as LAST_FRAME or ALTREF_FRAME (if ALTREF is being used in nonrd).
-    int index = (sf->rt_sf.use_nonrd_pick_mode &&
-                 ref_frame_priority_order[i] == GOLDEN_FRAME)
-                    ? (1 + sf->rt_sf.use_nonrd_altref_frame)
-                    : i;
-    for (int j = 0; j < index; ++j) {
-      if (this_ref == ref_frames[j]) {
-        flags &= ~(1 << (ref_frame_priority_order[i] - 1));
-        break;
-      }
-    }
-  }
-  return flags;
-}
 #if CONFIG_NEW_REF_SIGNALING
 // Enforce the number of references for each arbitrary frame based on user
 // options and speed.
@@ -3291,6 +3266,34 @@
   }
   assert(total_valid_refs <= max_allowed_refs);
 }
+
+static INLINE int get_ref_frame_flags(const SPEED_FEATURES *const sf,
+                                      const YV12_BUFFER_CONFIG **ref_frames,
+                                      const int ext_ref_frame_flags) {
+  // cpi->ext_flags.ref_frame_flags allows certain reference types to be
+  // disabled by the external interface.  These are set by
+  // av1_apply_encoding_flags(). Start with what the external interface allows,
+  // then suppress any reference types which we have found to be duplicates.
+  int flags = ext_ref_frame_flags;
+
+  for (int i = 1; i < INTER_REFS_PER_FRAME; ++i) {
+    const YV12_BUFFER_CONFIG *const this_ref = ref_frames[i];
+    // If this_ref has appeared before, mark the corresponding ref frame as
+    // invalid. For nonrd mode, only disable GOLDEN_FRAME if it's the same
+    // as LAST_FRAME or ALTREF_FRAME (if ALTREF is being used in nonrd).
+    int index = (sf->rt_sf.use_nonrd_pick_mode &&
+                 ref_frame_priority_order[i] == GOLDEN_FRAME)
+                    ? (1 + sf->rt_sf.use_nonrd_altref_frame)
+                    : i;
+    for (int j = 0; j < index; ++j) {
+      if (this_ref == ref_frames[j]) {
+        flags &= ~(1 << (ref_frame_priority_order[i] - 1));
+        break;
+      }
+    }
+  }
+  return flags;
+}
 #endif  // CONFIG_NEW_REF_SIGNALING
 
 // Returns a Sequence Header OBU stored in an aom_fixed_buf_t, or NULL upon
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index f425371..2d22f2d 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -244,26 +244,6 @@
          USABLE_REF_MV_STACK_SIZE * sizeof(xd->ref_mv_stack[0][0]));
 }
 
-// This function prunes the mode if either of the reference frame falls in the
-// pruning list
-static INLINE int prune_ref(const MV_REFERENCE_FRAME *const ref_frame,
-                            const unsigned int *const ref_display_order_hint,
-                            const unsigned int frame_display_order_hint,
-                            const int *ref_frame_list) {
-  for (int i = 0; i < 2; i++) {
-    if (ref_frame_list[i] == NONE_FRAME) continue;
-
-    if (ref_frame[0] == ref_frame_list[i] ||
-        ref_frame[1] == ref_frame_list[i]) {
-      if (av1_encoder_get_relative_dist(
-              ref_display_order_hint[ref_frame_list[i] - LAST_FRAME],
-              frame_display_order_hint) < 0)
-        return 1;
-    }
-  }
-  return 0;
-}
-
 #if CONFIG_NEW_REF_SIGNALING
 static INLINE int prune_ref_by_selective_ref_frame_nrs(
     const AV1_COMP *const cpi, const MACROBLOCK *const x,
@@ -350,6 +330,26 @@
   return 0;
 }
 #else
+// This function prunes the mode if either of the reference frame falls in the
+// pruning list
+static INLINE int prune_ref(const MV_REFERENCE_FRAME *const ref_frame,
+                            const unsigned int *const ref_display_order_hint,
+                            const unsigned int frame_display_order_hint,
+                            const int *ref_frame_list) {
+  for (int i = 0; i < 2; i++) {
+    if (ref_frame_list[i] == NONE_FRAME) continue;
+
+    if (ref_frame[0] == ref_frame_list[i] ||
+        ref_frame[1] == ref_frame_list[i]) {
+      if (av1_encoder_get_relative_dist(
+              ref_display_order_hint[ref_frame_list[i] - LAST_FRAME],
+              frame_display_order_hint) < 0)
+        return 1;
+    }
+  }
+  return 0;
+}
+
 static INLINE int prune_ref_by_selective_ref_frame(
     const AV1_COMP *const cpi, const MACROBLOCK *const x,
     const MV_REFERENCE_FRAME *const ref_frame,
@@ -392,7 +392,6 @@
 
   return 0;
 }
-
 #endif  // CONFIG_NEW_REF_SIGNALING
 
 // This function will copy the best reference mode information from
diff --git a/av1/encoder/rdopt_utils.h b/av1/encoder/rdopt_utils.h
index 5c1d080..9e31acb 100644
--- a/av1/encoder/rdopt_utils.h
+++ b/av1/encoder/rdopt_utils.h
@@ -35,6 +35,7 @@
   MV_REFERENCE_FRAME ref_frame[2];
 } MODE_DEFINITION;
 
+#if !CONFIG_NEW_REF_SIGNALING
 // This array defines the mapping from the enums in THR_MODES to the actual
 // prediction modes and refrence frames
 #if CONFIG_NEW_INTER_MODES
@@ -488,29 +489,6 @@
 };
 #endif  // CONFIG_NEW_INTER_MODES
 
-static AOM_INLINE void restore_dst_buf(MACROBLOCKD *xd, const BUFFER_SET dst,
-                                       const int num_planes) {
-  for (int i = 0; i < num_planes; i++) {
-    xd->plane[i].dst.buf = dst.plane[i];
-    xd->plane[i].dst.stride = dst.stride[i];
-  }
-}
-
-/* clang-format on */
-// Calculate rd threshold based on ref best rd and relevant scaling factors
-static AOM_INLINE int64_t get_rd_thresh_from_best_rd(int64_t ref_best_rd,
-                                                     int mul_factor,
-                                                     int div_factor) {
-  int64_t rd_thresh = ref_best_rd;
-  if (div_factor != 0) {
-    rd_thresh = ref_best_rd < (div_factor * (INT64_MAX / mul_factor))
-                    ? ((ref_best_rd / div_factor) * mul_factor)
-                    : INT64_MAX;
-  }
-  return rd_thresh;
-}
-
-#if !CONFIG_NEW_REF_SIGNALING
 static AOM_INLINE THR_MODES
 get_prediction_mode_idx(PREDICTION_MODE this_mode, MV_REFERENCE_FRAME ref_frame,
                         MV_REFERENCE_FRAME second_ref_frame) {
@@ -537,6 +515,28 @@
 }
 #endif  // !CONFIG_NEW_REF_SIGNALING
 
+static AOM_INLINE void restore_dst_buf(MACROBLOCKD *xd, const BUFFER_SET dst,
+                                       const int num_planes) {
+  for (int i = 0; i < num_planes; i++) {
+    xd->plane[i].dst.buf = dst.plane[i];
+    xd->plane[i].dst.stride = dst.stride[i];
+  }
+}
+
+/* clang-format on */
+// Calculate rd threshold based on ref best rd and relevant scaling factors
+static AOM_INLINE int64_t get_rd_thresh_from_best_rd(int64_t ref_best_rd,
+                                                     int mul_factor,
+                                                     int div_factor) {
+  int64_t rd_thresh = ref_best_rd;
+  if (div_factor != 0) {
+    rd_thresh = ref_best_rd < (div_factor * (INT64_MAX / mul_factor))
+                    ? ((ref_best_rd / div_factor) * mul_factor)
+                    : INT64_MAX;
+  }
+  return rd_thresh;
+}
+
 static AOM_INLINE int inter_mode_data_block_idx(BLOCK_SIZE bsize) {
   if (bsize == BLOCK_4X4 || bsize == BLOCK_4X8 || bsize == BLOCK_8X4 ||
       bsize == BLOCK_4X16 || bsize == BLOCK_16X4) {