Align cur_frame_index usage in gf_group
Use it to track the displayed frame index. Update for a show frame.
Align its usage in the encoder. Slight compression gains:
overall PSNR avg PSNR SSIM
lowres -0.059 -0.109 -0.059
ugc360p -0.071 -0.050 -0.174
BUG=aomedia:2728
STATS_CHANGED
Change-Id: I67ea0ba7819bb39fca9b055750a2b5ff4c849fd6
diff --git a/av1/encoder/gop_structure.c b/av1/encoder/gop_structure.c
index 511bc86..5bae430 100644
--- a/av1/encoder/gop_structure.c
+++ b/av1/encoder/gop_structure.c
@@ -43,7 +43,6 @@
while (++start < end) {
gf_group->update_type[*frame_ind] = LF_UPDATE;
gf_group->arf_src_offset[*frame_ind] = 0;
- ++*cur_frame_idx;
gf_group->cur_frame_idx[*frame_ind] = *cur_frame_idx;
gf_group->frame_disp_idx[*frame_ind] = start;
gf_group->layer_depth[*frame_ind] = MAX_ARF_LAYERS;
@@ -52,6 +51,7 @@
gf_group->max_layer_depth =
AOMMAX(gf_group->max_layer_depth, layer_depth);
++(*frame_ind);
+ ++(*cur_frame_idx);
}
} else {
const int m = (start + end) / 2;
@@ -75,12 +75,12 @@
// Overlay for internal ARF.
gf_group->update_type[*frame_ind] = INTNL_OVERLAY_UPDATE;
gf_group->arf_src_offset[*frame_ind] = 0;
- ++(*cur_frame_idx);
gf_group->cur_frame_idx[*frame_ind] = *cur_frame_idx;
gf_group->frame_disp_idx[*frame_ind] = m;
gf_group->arf_boost[*frame_ind] = 0;
gf_group->layer_depth[*frame_ind] = layer_depth;
++(*frame_ind);
+ ++(*cur_frame_idx);
// Frames displayed after this internal ARF.
set_multi_layer_params(twopass, gf_group, rc, frame_info, m, end,
@@ -103,12 +103,15 @@
gf_group->update_type[frame_index] = first_frame_update_type;
gf_group->arf_src_offset[frame_index] = 0;
- ++cur_frame_index;
gf_group->cur_frame_idx[frame_index] = cur_frame_index;
gf_group->layer_depth[frame_index] =
first_frame_update_type == OVERLAY_UPDATE ? MAX_ARF_LAYERS + 1 : 0;
gf_group->max_layer_depth = 0;
++frame_index;
+ // TODO(jingning): Increase cur_frame_index when a frame is displayed.
+ // When key frame is decomposed into an ARF and overlay frame, increase
+ // cur_frame_index after the overlay frame.
+ ++cur_frame_index;
// ALTREF.
const int use_altref = gf_group->max_layer_depth_allowed > 0;
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index e6ef254..4cb72ed 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -925,6 +925,7 @@
int process_frame_count = 0;
const int gop_length =
AOMMIN(gf_group->size - 1 + use_arf, MAX_TPL_FRAME_IDX - 1);
+
for (gf_index = cur_frame_idx; gf_index <= gop_length; ++gf_index) {
TplDepFrame *tpl_frame = &tpl_data->tpl_frame[gf_index];
FRAME_UPDATE_TYPE frame_update_type = gf_group->update_type[gf_index];
@@ -945,7 +946,8 @@
} else {
int frame_display_index = gf_index == gf_group->size
? cpi->rc.baseline_gf_interval
- : gf_group->frame_disp_idx[gf_index];
+ : gf_group->cur_frame_idx[gf_index] +
+ gf_group->arf_src_offset[gf_index];
struct lookahead_entry *buf = av1_lookahead_peek(
cpi->lookahead, frame_display_index - anc_frame_offset,
cpi->compressor_stage);