From 997ac14c6ab3b7504407223913c39182145e829a Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 9 Jun 2015 14:58:32 -0700 Subject: [PATCH] Adjust some parameters for cyclic refresh for low bitrates. Reduce motion threshold and boost factor for second segment, for low bitrates, at low resolutions for now. This is to reduce the rate fluctuation/frame dropping that occurs at these low bitrates. Change-Id: Ia66c3be41831882fca8c1e4fe104f5ea8fbe7142 --- vp9/encoder/vp9_aq_cyclicrefresh.c | 21 ++++++++++++++++++++- vp9/encoder/vp9_aq_cyclicrefresh.h | 3 --- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.c b/vp9/encoder/vp9_aq_cyclicrefresh.c index 4b1c959..71c1e0b 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.c +++ b/vp9/encoder/vp9_aq_cyclicrefresh.c @@ -48,6 +48,8 @@ struct CYCLIC_REFRESH { int16_t motion_thresh; // Rate target ratio to set q delta. double rate_ratio_qdelta; + // Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2. + double rate_boost_fac; double low_content_avg; int qindex_delta_seg1; int qindex_delta_seg2; @@ -93,6 +95,19 @@ static int apply_cyclic_refresh_bitrate(const VP9_COMMON *cm, return 1; } +static void adjust_cyclic_refresh_parameters(VP9_COMP *const cpi) { + const VP9_COMMON *const cm = &cpi->common; + const RATE_CONTROL *const rc = &cpi->rc; + CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; + // Adjust some parameters, currently only for low resolutions at low bitrates. + if (cm->width <= 352 && + cm->height <= 288 && + rc->avg_frame_bandwidth < 3400) { + cr->motion_thresh = 4; + cr->rate_boost_fac = 1.25; + } +} + // Check if this coding block, of size bsize, should be considered for refresh // (lower-qp coding). Decision can be based on various factors, such as // size of the coding block (i.e., below min_block size rejected), coding @@ -462,6 +477,7 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) { vp9_clear_system_state(); cr->max_qdelta_perc = 50; cr->time_for_refresh = 0; + cr->rate_boost_fac = 1.7; // Set rate threshold to some multiple (set to 2 for now) of the target // rate (target is given by sb64_target_rate and scaled by 256). cr->thresh_rate_sb = ((int64_t)(rc->sb64_target_rate) << 8) << 2; @@ -470,6 +486,9 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) { // vp9_convert_qindex_to_q(), vp9_ac_quant(), ac_qlookup*[]. cr->thresh_dist_sb = ((int64_t)(q * q)) << 2; cr->motion_thresh = 32; + + adjust_cyclic_refresh_parameters(cpi); + // Set up segmentation. // Clear down the segment map. vp9_enable_segmentation(&cm->seg); @@ -505,7 +524,7 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) { // Set a more aggressive (higher) q delta for segment BOOST2. qindex_delta = compute_deltaq(cpi, cm->base_qindex, MIN(CR_MAX_RATE_TARGET_RATIO, - CR_BOOST2_FAC * cr->rate_ratio_qdelta)); + cr->rate_boost_fac * cr->rate_ratio_qdelta)); cr->qindex_delta_seg2 = qindex_delta; vp9_set_segdata(seg, CR_SEGMENT_ID_BOOST2, SEG_LVL_ALT_Q, qindex_delta); diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.h b/vp9/encoder/vp9_aq_cyclicrefresh.h index 21f114b..99bb98e 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.h +++ b/vp9/encoder/vp9_aq_cyclicrefresh.h @@ -27,9 +27,6 @@ extern "C" { // Maximum rate target ratio for setting segment delta-qp. #define CR_MAX_RATE_TARGET_RATIO 4.0 -// Boost factor for rate target ratio, for segment CR_SEGMENT_ID_BOOST2. -#define CR_BOOST2_FAC 1.7 - struct VP9_COMP; struct CYCLIC_REFRESH; -- 2.7.4