Count cur_frame_idx for overlay frames as well.
This allows simpler calculation of tpl lookahead offset. Especially
if TPL is used at frames other than a Key frame of ALTREF.
Change-Id: I6697517cdec336194ddbc43f74da7ea358c02f76
diff --git a/av1/encoder/gop_structure.c b/av1/encoder/gop_structure.c
index 932281e..9ed418c 100644
--- a/av1/encoder/gop_structure.c
+++ b/av1/encoder/gop_structure.c
@@ -30,7 +30,7 @@
GF_GROUP *const gf_group, RATE_CONTROL *rc,
FRAME_INFO *frame_info, int start, int end,
int *cur_frame_idx, int *frame_ind,
- int arf_ind, int layer_depth) {
+ int layer_depth) {
const int num_frames_to_process = end - start - 1;
assert(num_frames_to_process >= 0);
if (num_frames_to_process == 0) return;
@@ -70,11 +70,12 @@
// Frames displayed before this internal ARF.
set_multi_layer_params(twopass, gf_group, rc, frame_info, start, m,
- cur_frame_idx, frame_ind, 1, layer_depth + 1);
+ cur_frame_idx, frame_ind, layer_depth + 1);
// 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;
@@ -83,7 +84,7 @@
// Frames displayed after this internal ARF.
set_multi_layer_params(twopass, gf_group, rc, frame_info, m, end,
- cur_frame_idx, frame_ind, arf_ind, layer_depth + 1);
+ cur_frame_idx, frame_ind, layer_depth + 1);
}
}
@@ -92,6 +93,7 @@
RATE_CONTROL *rc, FRAME_INFO *const frame_info, int gf_interval,
FRAME_UPDATE_TYPE first_frame_update_type) {
int frame_index = 0;
+ int cur_frame_index = 0;
// Keyframe / Overlay frame / Golden frame.
assert(gf_interval >= 1);
@@ -101,7 +103,8 @@
gf_group->update_type[frame_index] = first_frame_update_type;
gf_group->arf_src_offset[frame_index] = 0;
- gf_group->cur_frame_idx[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;
@@ -112,7 +115,7 @@
if (use_altref) {
gf_group->update_type[frame_index] = ARF_UPDATE;
gf_group->arf_src_offset[frame_index] = gf_interval - 1;
- gf_group->cur_frame_idx[frame_index] = 0;
+ gf_group->cur_frame_idx[frame_index] = cur_frame_index;
gf_group->frame_disp_idx[frame_index] = gf_interval;
gf_group->layer_depth[frame_index] = 1;
gf_group->arf_boost[frame_index] = cpi->rc.gfu_boost;
@@ -120,10 +123,9 @@
++frame_index;
}
- int cur_frame_index = 0;
// Rest of the frames.
set_multi_layer_params(twopass, gf_group, rc, frame_info, 0, gf_interval,
- &cur_frame_index, &frame_index, 0, use_altref + 1);
+ &cur_frame_index, &frame_index, use_altref + 1);
// The end frame will be Overlay frame for an ARF GOP; otherwise set it to
// be GF, for consistency, which will be updated in the next GOP.
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 669a14b..a43af38 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -904,7 +904,7 @@
int gf_index;
int use_arf = gf_group->update_type[1] == ARF_UPDATE;
- int anc_frame_offset = gf_group->cur_frame_idx[cur_frame_idx] + 1;
+ int anc_frame_offset = gf_group->cur_frame_idx[cur_frame_idx];
int process_frame_count = 0;
const int gop_length =
AOMMIN(gf_group->size - 1 + use_arf, MAX_TPL_FRAME_IDX - 1);