Using localize remapped_ref_idx
Avoid changing cm->remapped_ref_idx in init_gop_frames_for_tpl
Pass in remapped_ref_idx in get_ref_frames()
Change-Id: I89cd067aba8c698b8630d7f90c7d4787140e5800
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index 4e5be4d..cdcc02a 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -496,11 +496,11 @@
}
// Update reference frame stack info.
-void av1_update_ref_frame_map(AV1_COMP *cpi,
+void av1_update_ref_frame_map(const AV1_COMP *cpi,
FRAME_UPDATE_TYPE frame_update_type,
REFBUF_STATE refbuf_state, int ref_map_index,
RefBufferStack *ref_buffer_stack) {
- AV1_COMMON *const cm = &cpi->common;
+ const AV1_COMMON *const cm = &cpi->common;
// TODO(jingning): Consider the S-frame same as key frame for the
// reference frame tracking purpose. The logic might be better
@@ -1140,15 +1140,13 @@
buffer_map[unmapped_idx].used = 1;
}
-static void get_ref_frames(AV1_COMP *const cpi,
+static void get_ref_frames(const AV1_COMP *const cpi,
RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
#if CONFIG_FRAME_PARALLEL_ENCODE_2
int gf_index, int is_parallel_encode,
#endif // CONFIG_FRAME_PARALLEL_ENCODE_2
- int cur_frame_disp) {
- AV1_COMMON *cm = &cpi->common;
- int *const remapped_ref_idx = cm->remapped_ref_idx;
-
+ int cur_frame_disp,
+ int remapped_ref_idx[REF_FRAMES]) {
int buf_map_idx = 0;
// Initialize reference frame mappings.
@@ -1353,7 +1351,7 @@
void av1_get_ref_frames(const RefBufferStack *ref_buffer_stack,
#if CONFIG_FRAME_PARALLEL_ENCODE
- AV1_COMP *cpi,
+ const AV1_COMP *cpi,
RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
int cur_frame_disp,
#if CONFIG_FRAME_PARALLEL_ENCODE_2
@@ -1363,12 +1361,11 @@
int remapped_ref_idx[REF_FRAMES]) {
#if CONFIG_FRAME_PARALLEL_ENCODE
(void)ref_buffer_stack;
- (void)remapped_ref_idx;
get_ref_frames(cpi, ref_frame_map_pairs,
#if CONFIG_FRAME_PARALLEL_ENCODE_2
gf_index, is_parallel_encode,
#endif // CONFIG_FRAME_PARALLEL_ENCODE_2
- cur_frame_disp);
+ cur_frame_disp, remapped_ref_idx);
return;
#else
const int *const arf_stack = ref_buffer_stack->arf_stack;
diff --git a/av1/encoder/encode_strategy.h b/av1/encoder/encode_strategy.h
index b7567cb..91fa86e 100644
--- a/av1/encoder/encode_strategy.h
+++ b/av1/encoder/encode_strategy.h
@@ -79,7 +79,7 @@
int av1_get_refresh_ref_frame_map(int refresh_frame_flags);
-void av1_update_ref_frame_map(AV1_COMP *cpi,
+void av1_update_ref_frame_map(const AV1_COMP *cpi,
FRAME_UPDATE_TYPE frame_update_type,
REFBUF_STATE refbuf_state, int ref_map_index,
RefBufferStack *ref_buffer_stack);
@@ -98,7 +98,7 @@
*/
void av1_get_ref_frames(const RefBufferStack *ref_buffer_stack,
#if CONFIG_FRAME_PARALLEL_ENCODE
- AV1_COMP *cpi,
+ const AV1_COMP *cpi,
RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
int cur_frame_disp,
#if CONFIG_FRAME_PARALLEL_ENCODE_2
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 0c1f112..554961d 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -1252,6 +1252,8 @@
#endif // CONFIG_FRAME_PARALLEL_ENCODE
RefBufferStack ref_buffer_stack = cpi->ref_buffer_stack;
+ int remapped_ref_idx[REF_FRAMES];
+
EncodeFrameParams frame_params = *init_frame_params;
TplParams *const tpl_data = &cpi->ppi->tpl_data;
@@ -1344,7 +1346,7 @@
gf_index, 0,
#endif // CONFIG_FRAME_PARALLEL_ENCODE_2
#endif // CONFIG_FRAME_PARALLEL_ENCODE
- cm->remapped_ref_idx);
+ remapped_ref_idx);
int refresh_mask = av1_get_refresh_frame_flags(
cpi, &frame_params, frame_update_type, gf_index,
@@ -1378,7 +1380,7 @@
for (int i = LAST_FRAME; i <= ALTREF_FRAME; ++i)
tpl_frame->ref_map_index[i - LAST_FRAME] =
- ref_picture_map[cm->remapped_ref_idx[i - LAST_FRAME]];
+ ref_picture_map[remapped_ref_idx[i - LAST_FRAME]];
if (refresh_mask) ref_picture_map[refresh_frame_map_index] = gf_index;
@@ -1440,7 +1442,7 @@
gf_index, 0,
#endif // CONFIG_FRAME_PARALLEL_ENCODE_2
#endif // CONFIG_FRAME_PARALLEL_ENCODE
- cm->remapped_ref_idx);
+ remapped_ref_idx);
int refresh_mask = av1_get_refresh_frame_flags(
cpi, &frame_params, frame_update_type, gf_index,
#if CONFIG_FRAME_PARALLEL_ENCODE
@@ -1480,19 +1482,6 @@
++extend_frame_count;
++frame_display_index;
}
-#if CONFIG_FRAME_PARALLEL_ENCODE
- TplDepFrame *tpl_frame = &tpl_data->tpl_frame[cur_frame_idx];
- const int true_disp = (int)(tpl_frame->frame_display_index);
- init_ref_map_pair(cpi, ref_frame_map_pairs);
-#endif // CONFIG_FRAME_PARALLEL_ENCODE
- av1_get_ref_frames(&cpi->ref_buffer_stack,
-#if CONFIG_FRAME_PARALLEL_ENCODE
- cpi, ref_frame_map_pairs, true_disp,
-#if CONFIG_FRAME_PARALLEL_ENCODE_2
- gf_index, 0,
-#endif // CONFIG_FRAME_PARALLEL_ENCODE_2
-#endif // CONFIG_FRAME_PARALLEL_ENCODE
- cm->remapped_ref_idx);
}
void av1_init_tpl_stats(TplParams *const tpl_data) {