Correct offset of gf index when key frame filtering mode is 2 When an overlay frame is enabled for compensating the filtered key frame, the gf_index of following inter frames will start from 2. To fetch user specified configurations about ref frames, this patch will map between the step index and gf_index based on an offset derived from whether an overlay for filtered key frame is involved. Change-Id: If5cf61ddb1ac02c0fda4b7664d048bf8b1f0c55c
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c index cc3897d..9a19b28 100644 --- a/av1/encoder/encode_strategy.c +++ b/av1/encoder/encode_strategy.c
@@ -49,8 +49,10 @@ const SubGOPStepCfg *get_subgop_step(const GF_GROUP *const gf_group, int index) { const SubGOPCfg *subgop_cfg = gf_group->subgop_cfg; + const int offset = gf_group->has_overlay_for_key_frame ? 2 : 1; if (subgop_cfg == NULL) return NULL; - return index == 0 ? gf_group->last_step_prev : &subgop_cfg->step[index - 1]; + return index == 0 ? gf_group->last_step_prev + : &subgop_cfg->step[index - offset]; } void av1_configure_buffer_updates( @@ -774,6 +776,7 @@ if (gf_index < 0) return 0; if (gf_group->subgop_cfg == NULL) return 0; if (gf_index == 0) return gf_group->last_step_prev != NULL; + if (gf_index == 1) return !gf_group->has_overlay_for_key_frame; return 1; }
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index 001a362..4e6584e 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -823,6 +823,7 @@ typedef struct { /*!\cond */ unsigned char is_user_specified; + unsigned char has_overlay_for_key_frame; unsigned char index; FRAME_UPDATE_TYPE update_type[MAX_STATIC_GF_GROUP_LENGTH]; unsigned char arf_src_offset[MAX_STATIC_GF_GROUP_LENGTH];
diff --git a/av1/encoder/gop_structure.c b/av1/encoder/gop_structure.c index 7fecbea..68e69be 100644 --- a/av1/encoder/gop_structure.c +++ b/av1/encoder/gop_structure.c
@@ -201,6 +201,7 @@ if (first_frame_update_type == KF_UPDATE && cpi->oxcf.kf_cfg.enable_keyframe_filtering > 1) { + gf_group->has_overlay_for_key_frame = 1; gf_group->update_type[frame_index] = ARF_UPDATE; gf_group->arf_src_offset[frame_index] = 0; gf_group->cur_frame_idx[frame_index] = cur_frame_index; @@ -320,6 +321,7 @@ key_frame ? KF_UPDATE : rc->source_alt_ref_active ? OVERLAY_UPDATE : GF_UPDATE; gf_group->is_user_specified = 0; + gf_group->has_overlay_for_key_frame = 0; gf_group->size = construct_multi_layer_gf_structure( cpi, twopass, gf_group, rc, frame_info, rc->baseline_gf_interval, first_frame_update_type);