Fix key frame related encoder failure in LAP In LAP mode, the previous key frame detection was placed after the first-pass stats stack gets updated. This will cause first-pass pointer fail to track the actual data array if a key frame is inserted into the bit-stream. This CL fixes the above problem. BUG=b/266972841 BUG=aomedia:3495 Change-Id: I95eae7d19e29faad6d22cfce9ef339e5d72971bc (cherry picked from commit 82104fc2425c1c7dc7b34329917f04de526a8873)
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c index d8b96c5..a9889e2 100644 --- a/av1/encoder/pass2_strategy.c +++ b/av1/encoder/pass2_strategy.c
@@ -3678,17 +3678,6 @@ if (oxcf->rc_cfg.mode == AOM_Q) rc->active_worst_quality = oxcf->rc_cfg.cq_level; - FIRSTPASS_STATS this_frame; - av1_zero(this_frame); - // call above fn - if (is_stat_consumption_stage(cpi)) { - if (cpi->gf_frame_index < gf_group->size || rc->frames_to_key == 0) { - process_first_pass_stats(cpi, &this_frame); - update_total_stats = 1; - } - } else { - rc->active_worst_quality = oxcf->rc_cfg.cq_level; - } if (cpi->gf_frame_index == gf_group->size) { if (cpi->ppi->lap_enabled && cpi->ppi->p_rc.enable_scenecut_detection) { @@ -3701,6 +3690,18 @@ } } + FIRSTPASS_STATS this_frame; + av1_zero(this_frame); + // call above fn + if (is_stat_consumption_stage(cpi)) { + if (cpi->gf_frame_index < gf_group->size || rc->frames_to_key == 0) { + process_first_pass_stats(cpi, &this_frame); + update_total_stats = 1; + } + } else { + rc->active_worst_quality = oxcf->rc_cfg.cq_level; + } + // Keyframe and section processing. FIRSTPASS_STATS this_frame_copy; this_frame_copy = this_frame;