Commit 9ca6b46c authored by Marco's avatar Marco

vp9: Adjust gf period for high average Q and overshoot.

For 1 pass vbr mode.
Increase the gf interval for case where average Q is close to
max and high overshoot is detected.

Small increase in overall avg_psnr/sssim metrics (~0.2/0.1%) for ytlive,
but improves the low-end (low bitrate) for several clips (less overshoot).

Change-Id: Ifba40f25b4861b2e0d9832c82d5359a6a3dce9f2
parent 9cc1f692
......@@ -337,6 +337,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
rc->total_actual_bits = 0;
rc->total_target_bits = 0;
rc->total_target_vs_actual = 0;
rc->avg_intersize_gfint = 0;
rc->frames_since_key = 8; // Sensible default for first frame.
rc->this_key_frame_forced = 0;
......@@ -1419,6 +1420,10 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
rc->total_target_vs_actual = rc->total_actual_bits - rc->total_target_bits;
if (!cpi->refresh_golden_frame && !cpi->refresh_alt_ref_frame) {
rc->avg_intersize_gfint += rc->projected_frame_size;
}
if (!cpi->use_svc || is_two_pass_svc(cpi)) {
if (is_altref_enabled(cpi) && cpi->refresh_alt_ref_frame &&
(cm->frame_type != KEY_FRAME))
......@@ -1500,6 +1505,8 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) {
cm->frame_type = INTER_FRAME;
}
if (rc->frames_till_gf_update_due == 0) {
rc->avg_intersize_gfint =
rc->avg_intersize_gfint / (rc->baseline_gf_interval + 1);
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cpi->oxcf.pass == 0) {
vp9_cyclic_refresh_set_golden_update(cpi);
} else {
......@@ -1510,6 +1517,13 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) {
if ((rc->frames_to_key <= 7 * rc->baseline_gf_interval >> 2) &&
(rc->frames_to_key > rc->baseline_gf_interval)) {
rc->baseline_gf_interval = rc->frames_to_key >> 1;
} else {
// Increase gf interval at high Q and high overshoot.
if (cm->current_video_frame > 30 &&
rc->avg_frame_qindex[INTER_FRAME] > (7 * rc->worst_quality) >> 3 &&
rc->avg_intersize_gfint > (5 * rc->avg_frame_bandwidth) >> 1) {
rc->baseline_gf_interval = (3 * rc->baseline_gf_interval) >> 1;
}
}
rc->frames_till_gf_update_due = rc->baseline_gf_interval;
// NOTE: frames_till_gf_update_due must be <= frames_to_key.
......@@ -1522,6 +1536,7 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) {
cpi->refresh_golden_frame = 1;
rc->source_alt_ref_pending = USE_ALTREF_FOR_ONE_PASS;
rc->gfu_boost = DEFAULT_GF_BOOST;
rc->avg_intersize_gfint = 0;
}
if (cm->frame_type == KEY_FRAME)
target = calc_iframe_target_size_one_pass_vbr(cpi);
......
......@@ -162,6 +162,7 @@ typedef struct {
uint64_t avg_source_sad;
int high_source_sad;
int count_last_scene_change;
int avg_intersize_gfint;
} RATE_CONTROL;
struct VP9_COMP;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment