rtc-screen: Fix Q setting for forced key frames If the user in RTC sets/forces a key frame in the stream (this_key_frame_forced = 1) the q for that frame will be the last_boosted_qindex which can be very low, especially for screen, and cause very large encoded key frame size. This logic shouldn't be there for CBR, but for now disable it for screen only, where excessive frames size can occur due to this. This reduces the key frame size by ~3-20x (on slidechanges clip, depending on the scene change); quality is reduced, but gets cleaned up quickly with aq-mode=3. No change in stats for rtc sets (as no forced key frames are set by default). Change-Id: I606cfe617698e09859231b0bb80b5b7ae212737e
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c index 4d5825c..706e4ff 100644 --- a/av1/encoder/ratectrl.c +++ b/av1/encoder/ratectrl.c
@@ -1140,8 +1140,11 @@ *top_index = AOMMAX(*top_index, *bottom_index); } - // Special case code to try and match quality with forced key frames - if (current_frame->frame_type == KEY_FRAME && p_rc->this_key_frame_forced) { + // Special case code to try and match quality with forced key frames. + // Avoid this for screen mode, to prevent low q on key frame + // (to avoid possibly massive frame size). + if (current_frame->frame_type == KEY_FRAME && p_rc->this_key_frame_forced && + cpi->oxcf.tune_cfg.content != AOM_CONTENT_SCREEN) { q = p_rc->last_boosted_qindex; } else { q = av1_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality,