From a047e7cdf8a00701df141e8d72937541f4a88e0d Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 3 Dec 2014 10:19:54 -0800 Subject: [PATCH] Increase delta-qp for aq=3 mode, after key frame. For a few refresh periods after key frame, use large qp-delta to increase quality ramp-up. Change-Id: Ib5a150fb2dfa6bafd0d4e6b5d28dfd0724b61319 --- vp9/encoder/vp9_aq_cyclicrefresh.c | 17 ++++++++++++++--- vp9/encoder/vp9_aq_cyclicrefresh.h | 3 +++ vp9/encoder/vp9_ratectrl.c | 11 +++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.c b/vp9/encoder/vp9_aq_cyclicrefresh.c index bc68b3756..5f1c8ce74 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.c +++ b/vp9/encoder/vp9_aq_cyclicrefresh.c @@ -319,6 +319,20 @@ void vp9_cyclic_refresh_update_map(VP9_COMP *const cpi) { cr->sb_index = i; } +// Set/update global/frame level cyclic refresh parameters. +void vp9_cyclic_refresh_update_parameters(VP9_COMP *const cpi) { + const RATE_CONTROL *const rc = &cpi->rc; + CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; + cr->percent_refresh = 10; + // Use larger delta-qp (increase rate_ratio_qdelta) for first few (~4) + // periods of the refresh cycle, after a key frame. This corresponds to ~40 + // frames with cr->percent_refresh = 10. + if (rc->frames_since_key < 40) + cr->rate_ratio_qdelta = 3.0; + else + cr->rate_ratio_qdelta = 2.0; +} + // Setup cyclic background refresh: set delta q and segmentation map. void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) { VP9_COMMON *const cm = &cpi->common; @@ -343,9 +357,6 @@ void vp9_cyclic_refresh_setup(VP9_COMP *const cpi) { int qindex2; const double q = vp9_convert_qindex_to_q(cm->base_qindex, cm->bit_depth); vp9_clear_system_state(); - // Some of these parameters may be set via codec-control function later. - cr->percent_refresh = 10; - cr->rate_ratio_qdelta = 2.0; cr->max_qdelta_perc = 50; cr->min_block_size = BLOCK_8X8; cr->time_for_refresh = 0; diff --git a/vp9/encoder/vp9_aq_cyclicrefresh.h b/vp9/encoder/vp9_aq_cyclicrefresh.h index 3fc677646..656d7605b 100644 --- a/vp9/encoder/vp9_aq_cyclicrefresh.h +++ b/vp9/encoder/vp9_aq_cyclicrefresh.h @@ -53,6 +53,9 @@ void vp9_cyclic_refresh_update__map(struct VP9_COMP *const cpi); // Update the actual number of blocks that were applied the segment delta q. void vp9_cyclic_refresh_update_actual_count(struct VP9_COMP *const cpi); +// Set/update global/frame level refresh parameters. +void vp9_cyclic_refresh_update_parameters(struct VP9_COMP *const cpi); + // Setup cyclic background refresh: set delta q and segmentation map. void vp9_cyclic_refresh_setup(struct VP9_COMP *const cpi); diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index e96c9046d..37b6718bf 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1483,6 +1483,12 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) { target = calc_pframe_target_size_one_pass_cbr(cpi); } } + + // Any update/change of global cyclic refresh parameters (amount/delta-qp) + // should be done here, before the frame qp is selected. + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + vp9_cyclic_refresh_update_parameters(cpi); + vp9_rc_set_frame_target(cpi, target); rc->frames_till_gf_update_due = INT_MAX; rc->baseline_gf_interval = INT_MAX; @@ -1516,6 +1522,11 @@ void vp9_rc_get_one_pass_cbr_params(VP9_COMP *cpi) { rc->gfu_boost = DEFAULT_GF_BOOST; } + // Any update/change of global cyclic refresh parameters (amount/delta-qp) + // should be done here, before the frame qp is selected. + if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) + vp9_cyclic_refresh_update_parameters(cpi); + if (cm->frame_type == KEY_FRAME) target = calc_iframe_target_size_one_pass_cbr(cpi); else