From 8d9b1a7d82f691cc4f0afca6bfaadcc8d818ac26 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 26 Nov 2018 09:43:07 -0800 Subject: [PATCH] Fix ARF rate allocation for cq mode In the limited test set, it improves the cq mode compression performance by 1.9% in PSNR and 6% in SSIM as compared to use same quantization parameter for all ARFs. Change-Id: I35c4d7097b5838ab0b92d7f9937520721e3bb84b --- vp9/encoder/vp9_ratectrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 779529b..d081f1a 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1364,6 +1364,16 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, // Constrained quality use slightly lower active best. active_best_quality = active_best_quality * 15 / 16; + // Modify best quality for second level arfs. For mode VPX_Q this + // becomes the baseline frame q. + if (gf_group->rf_level[gf_group_index] == GF_ARF_LOW) { + const int layer_depth = gf_group->layer_depth[gf_group_index]; + // linearly fit the frame q depending on the layer depth index from + // the base layer ARF. + active_best_quality = + ((layer_depth - 1) * q + active_best_quality + layer_depth / 2) / + layer_depth; + } } else if (oxcf->rc_mode == VPX_Q) { if (!cpi->refresh_alt_ref_frame) { active_best_quality = cq_level; -- 2.7.4