From 761609bff45b02fc696b6fbb7b7a6e68176122d6 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 10 Dec 2018 14:02:51 -0800 Subject: [PATCH] Clean up condition logics in rc_pick_q_and_bounds_two_pass() Factor out common conditions for better readability. Change-Id: I2a2b576e7d3e5cf036e9e355fc7ce0509ecb3d7e --- vp9/encoder/vp9_ratectrl.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index b5c002a..4f60ea2 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1403,6 +1403,10 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, int active_worst_quality = cpi->twopass.active_worst_quality; int q; int *inter_minq; + const int boost_frame = + !rc->is_src_frame_alt_ref && + (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame); + ASSIGN_MINQ_TABLE(cm->bit_depth, inter_minq); if (oxcf->rc_mode == VPX_Q) @@ -1410,8 +1414,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, if (frame_is_intra_only(cm)) { pick_kf_q_bound_two_pass(cpi, &active_best_quality, &active_worst_quality); - } else if (!rc->is_src_frame_alt_ref && - (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) { + } else if (boost_frame) { // Use the lower of active_worst_quality and recent // average Q as basis for GF/ARF best Q limit unless last frame was // a key frame. @@ -1455,9 +1458,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, // Extension to max or min Q if undershoot or overshoot is outside // the permitted range. - if (frame_is_intra_only(cm) || - (!rc->is_src_frame_alt_ref && - (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame))) { + if (frame_is_intra_only(cm) || boost_frame) { active_best_quality -= (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast); active_worst_quality += (cpi->twopass.extend_maxq / 2); @@ -1465,13 +1466,9 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi, int *bottom_index, active_best_quality -= (cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast) / 2; active_worst_quality += cpi->twopass.extend_maxq; - } - // For normal frames do not allow an active minq lower than the q used for - // the last boosted frame. - if (!frame_is_intra_only(cm) && - (!(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) || - rc->is_src_frame_alt_ref)) { + // For normal frames do not allow an active minq lower than the q used for + // the last boosted frame. active_best_quality = VPXMAX(active_best_quality, rc->last_boosted_qindex); } -- 2.7.4