From 8bb92e382de7d527f1f788cb0618aec485ffcee8 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Wed, 17 Oct 2018 11:48:10 -0700 Subject: [PATCH] For keyframe-only coding do not boost in q mode If we are using keyframe only coding - either coding a single frame, or a sequence of keyframes - in the end-usage=q mode, use the cq_level directly as the quality of each coded frame, rather than boost them. Ported from AV1: 563a0d1eb92bdc1e987df071a568d8406c4ffa92 Change-Id: I6dc929b8b4f0aa18e279139077f3a87958c92245 --- vp9/encoder/vp9_ratectrl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 76e310ac2..8d1d265f6 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1216,10 +1216,16 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, ASSIGN_MINQ_TABLE(cm->bit_depth, inter_minq); if (frame_is_intra_only(cm)) { - // Handle the special case for key frames forced when we have reached - // the maximum key frame interval. Here force the Q to a range - // based on the ambient Q to reduce the risk of popping. - if (rc->this_key_frame_forced) { + if (rc->frames_to_key == 1 && oxcf->rc_mode == VPX_Q) { + // If the next frame is also a key frame or the current frame is the + // only frame in the sequence in AOM_Q mode, just use the cq_level + // as q. + active_best_quality = cq_level; + active_worst_quality = cq_level; + } else if (rc->this_key_frame_forced) { + // Handle the special case for key frames forced when we have reached + // the maximum key frame interval. Here force the Q to a range + // based on the ambient Q to reduce the risk of popping. double last_boosted_q; int delta_qindex; int qindex; -- 2.40.0