Add assertions to validate precomputed reference frame map - Compare the reference frame display order indices precomputed at the beginning of a GF group, with the indices inferred from the order hints of reference buffers in actual encoding process. - The check is controlled by macro CHECK_PRECOMPUTED_REF_FRAME_MAP, which is 0 by default. - The check is disabled on OVERLAY frames for now, because info in cpi->gf_group has been refreshed for next GOP when the check is performed for OVERLAY frames. Since we have not support inter-GOP ref frame map computation, the precomputed ref map for an OVERLAY frame is all -1 at this point (although it is meaningful before gf_group is refreshed). Change-Id: I570bb4ab4f16a9eef23043a89428b4162e11dfda
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 544cec4..bdf8db6 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -5164,6 +5164,8 @@ if (cm->allow_intrabc) cm->delta_q_info.delta_lf_present_flag = 0; } +#define CHECK_PRECOMPUTED_REF_FRAME_MAP 0 + void av1_encode_frame(AV1_COMP *cpi) { AV1_COMMON *const cm = &cpi->common; CurrentFrame *const current_frame = &cm->current_frame; @@ -5190,6 +5192,43 @@ enforce_max_ref_frames(cpi); av1_setup_frame_sign_bias(cm); +#if CHECK_PRECOMPUTED_REF_FRAME_MAP + GF_GROUP *gf_group = &cpi->twopass.gf_group; + // TODO(yuec): The check is disabled on OVERLAY frames for now, because info + // in cpi->gf_group has been refreshed for the next GOP when the check is + // performed for OVERLAY frames. Since we have not support inter-GOP ref + // frame map computation, the precomputed ref map for an OVERLAY frame is all + // -1 at this point (although it is meaning before gf_group is refreshed). + if (!frame_is_intra_only(cm) && gf_group->index != 0) { + const RefCntBuffer *const golden_buf = get_ref_frame_buf(cm, GOLDEN_FRAME); + + if (golden_buf) { + const int golden_order_hint = golden_buf->order_hint; + + for (int ref = LAST_FRAME; ref < EXTREF_FRAME; ++ref) { + const RefCntBuffer *const buf = get_ref_frame_buf(cm, ref); + const int ref_disp_idx_precomputed = + gf_group->ref_frame_disp_idx[gf_group->index][ref - LAST_FRAME]; + + (void)ref_disp_idx_precomputed; + + if (buf != NULL) { + const int ref_disp_idx = + get_relative_dist(&cm->seq_params.order_hint_info, + buf->order_hint, golden_order_hint); + + if (ref_disp_idx >= 0) + assert(ref_disp_idx == ref_disp_idx_precomputed); + else + assert(ref_disp_idx_precomputed == -1); + } else { + assert(ref_disp_idx_precomputed == -1); + } + } + } + } +#endif + #if CONFIG_MISMATCH_DEBUG mismatch_reset_frame(num_planes); #else