Allow ducky_encode to control the reference frame scheduling

Allow the ducky_encode to control the reference frame scheduling
in libaom using the returns from qmode rc lib.

BUG=b/241257063

Change-Id: I25b442e30e285e244beedf9304d9d6e79257a149
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index e8badea..7817936 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -607,8 +607,16 @@
   const SVC *const svc = &cpi->svc;
   if (is_frame_droppable(svc, ext_refresh_frame_flags)) return 0;
 
-  int refresh_mask = 0;
+#if !CONFIG_REALTIME_ONLY
+  if (cpi->use_ducky_encode &&
+      cpi->ducky_encode_info.frame_info.gop_mode == DUCKY_ENCODE_GOP_MODE_RCL) {
+    int new_fb_map_idx = cpi->ppi->gf_group.update_ref_idx[gf_index];
+    if (new_fb_map_idx == INVALID_IDX) return 0;
+    return 1 << new_fb_map_idx;
+  }
+#endif  // !CONFIG_REALTIME_ONLY
 
+  int refresh_mask = 0;
   if (ext_refresh_frame_flags->update_pending) {
     if (svc->set_ref_frame_config) {
       for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; i++) {
@@ -953,6 +961,18 @@
   // Initialize reference frame mappings.
   for (int i = 0; i < REF_FRAMES; ++i) remapped_ref_idx[i] = INVALID_IDX;
 
+#if !CONFIG_REALTIME_ONLY
+  if (cpi->use_ducky_encode &&
+      cpi->ducky_encode_info.frame_info.gop_mode == DUCKY_ENCODE_GOP_MODE_RCL) {
+    for (int rf = LAST_FRAME; rf < REF_FRAMES; ++rf) {
+      if (cpi->ppi->gf_group.ref_frame_list[gf_index][rf] != INVALID_IDX) {
+        remapped_ref_idx[rf - LAST_FRAME] =
+            cpi->ppi->gf_group.ref_frame_list[gf_index][rf];
+      }
+    }
+  }
+#endif  // !CONFIG_REALTIME_ONLY
+
   RefBufMapData buffer_map[REF_FRAMES];
   int n_bufs = 0;
   memset(buffer_map, 0, REF_FRAMES * sizeof(buffer_map[0]));