From a00c56373ea7d12bf6b1ab8060ccdb4af03c1794 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Mon, 21 Jun 2021 17:22:51 -0700 Subject: rc: turn off gf constrain for external RC Added a new flag in rate control which turns off gf interval constrain on key frame frequency for external RC. It remains on for libvpx. Change-Id: I18bb0d8247a421193f023619f906d0362b873b31 --- vp9/encoder/vp9_ratectrl.c | 4 +++- vp9/encoder/vp9_ratectrl.h | 4 ++++ vp9/ratectrl_rtc.cc | 6 ++---- vp9/ratectrl_rtc.h | 2 -- 4 files changed, 9 insertions(+), 7 deletions(-) (limited to 'vp9') diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index dbbd458c9..26e1d5381 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -407,6 +407,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { rc->source_alt_ref_active = 0; rc->frames_till_gf_update_due = 0; + rc->constrain_gf_key_freq_onepass_vbr = 1; rc->ni_av_qi = oxcf->worst_allowed_q; rc->ni_tot_qi = 0; rc->ni_frames = 0; @@ -2083,7 +2084,8 @@ void vp9_set_gf_update_one_pass_vbr(VP9_COMP *const cpi) { rc->gfu_boost = DEFAULT_GF_BOOST >> 1; rc->af_ratio_onepass_vbr = VPXMIN(15, VPXMAX(5, 3 * rc->gfu_boost / 400)); } - adjust_gfint_frame_constraint(cpi, rc->frames_to_key); + if (rc->constrain_gf_key_freq_onepass_vbr) + adjust_gfint_frame_constraint(cpi, rc->frames_to_key); rc->frames_till_gf_update_due = rc->baseline_gf_interval; cpi->refresh_golden_frame = 1; rc->source_alt_ref_pending = 0; diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h index bdddd2df8..83a12cde7 100644 --- a/vp9/encoder/vp9_ratectrl.h +++ b/vp9/encoder/vp9_ratectrl.h @@ -207,6 +207,10 @@ typedef struct { int preserve_arf_as_gld; int preserve_next_arf_as_gld; int show_arf_as_gld; + + // Flag to constrain golden frame interval on key frame frequency for 1 pass + // VBR. + int constrain_gf_key_freq_onepass_vbr; } RATE_CONTROL; struct VP9_COMP; diff --git a/vp9/ratectrl_rtc.cc b/vp9/ratectrl_rtc.cc index 8455ca9a3..2595a2bc0 100644 --- a/vp9/ratectrl_rtc.cc +++ b/vp9/ratectrl_rtc.cc @@ -46,7 +46,6 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { oxcf->content = VP9E_CONTENT_DEFAULT; oxcf->drop_frames_water_mark = 0; cm->current_video_frame = 0; - oxcf->key_freq = rc_cfg.key_freq; rc->kf_boost = DEFAULT_KF_BOOST; UpdateRateControl(rc_cfg); @@ -60,7 +59,7 @@ void VP9RateControlRTC::InitRateControl(const VP9RateControlRtcConfig &rc_cfg) { rc->rc_2_frame = 0; vp9_rc_init_minq_luts(); vp9_rc_init(oxcf, 0, rc); - rc->frames_to_key = oxcf->key_freq; + rc->constrain_gf_key_freq_onepass_vbr = 0; cpi_->sf.use_nonrd_pick_mode = 1; } @@ -152,8 +151,7 @@ void VP9RateControlRTC::ComputeQP(const VP9FrameParamsQpRTC &frame_params) { target = vp9_calc_pframe_target_size_one_pass_cbr(cpi_); } else if (cpi_->oxcf.rc_mode == VPX_VBR) { if (cm->frame_type == KEY_FRAME) { - cpi_->rc.this_key_frame_forced = - cm->current_video_frame != 0 && cpi_->rc.frames_to_key == 0; + cpi_->rc.this_key_frame_forced = cm->current_video_frame != 0; cpi_->rc.frames_to_key = cpi_->oxcf.key_freq; } vp9_set_gf_update_one_pass_vbr(cpi_); diff --git a/vp9/ratectrl_rtc.h b/vp9/ratectrl_rtc.h index a1f276712..c7c0505e3 100644 --- a/vp9/ratectrl_rtc.h +++ b/vp9/ratectrl_rtc.h @@ -51,8 +51,6 @@ struct VP9RateControlRtcConfig { int ts_rate_decimator[VPX_TS_MAX_LAYERS]; // vbr, cbr enum vpx_rc_mode rc_mode; - // key frame frequency - int key_freq; }; struct VP9FrameParamsQpRTC { -- cgit v1.2.3