From c09e95fc7da1c91db3cef34dc61010ab33443eea Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Tue, 26 Mar 2019 10:45:22 -0700 Subject: [PATCH] vp9-rtc: Disable cyclic refresh under some conditions cyclic refresh does not work for speeds <= 4, so disable it for this case. And dynamically disable it when average_qp is close to MAXQ (only for non-svc), to improve quality/rate control at very low bitrates. Change-Id: I447be43aef0fbb80f4a30d81e11658b58744eae5 --- vp9/encoder/vp9_aq_cyclicrefresh.c | 5 ++++- vp9/encoder/vp9_speed_features.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.c b/vp9/encoder/vp9_aq_cyclicrefresh.c index b3b5460..adb12c1 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.c +++ b/vp9/encoder/vp9_aq_cyclicrefresh.c @@ -481,6 +481,7 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { int thresh_low_motion = 20; int qp_thresh = VPXMIN((cpi->oxcf.content == VP9E_CONTENT_SCREEN) ? 35 : 20, rc->best_quality << 1); + int qp_max_thresh = 117 * MAXQ >> 7; cr->apply_cyclic_refresh = 1; if (frame_is_intra_only(cm) || cpi->svc.temporal_layer_id > 0 || is_lossless_requested(&cpi->oxcf) || @@ -488,7 +489,9 @@ void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { (cpi->use_svc && cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame) || (!cpi->use_svc && rc->avg_frame_low_motion < thresh_low_motion && - rc->frames_since_key > 40)) { + rc->frames_since_key > 40) || + (!cpi->use_svc && rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh && + rc->frames_since_key > 20)) { cr->apply_cyclic_refresh = 0; return; } diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 8366425..55bd106 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -793,6 +793,10 @@ static void set_rt_speed_feature_framesize_independent( // small step_param for all spatial layers. sf->mv.fullpel_search_step_param = 2; } + // TODO(marpan): There is regression for aq-mode=3 speed <= 4, force it + // off for now. + if (speed <= 4 && cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + cpi->oxcf.aq_mode = 0; } void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi, int speed) { -- 2.7.4