From 8a79769aff63c41e2db42af7a0afeec289789dcb Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 13 May 2016 11:41:37 -0700 Subject: [PATCH] vp9: Update to rc-metric for keeping track of average frame size. Rename and change to how its updated. Only affects 1 pass vbr. Small change in metrics (< ~0.1%) on ytlive set. Change-Id: Ibb1fe485699b6c4a8194951c8f229abe2f64b9a5 --- vp9/encoder/vp9_ratectrl.c | 11 ++++------- vp9/encoder/vp9_ratectrl.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 0ec93a9..b8a5e6e 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -337,7 +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->avg_size_inter = 0; rc->avg_frame_low_motion = 0; rc->high_source_sad = 0; rc->count_last_scene_change = 0; @@ -1471,7 +1471,8 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) { if (cm->frame_type != KEY_FRAME) compute_frame_low_motion(cpi); if (!cpi->refresh_golden_frame && !cpi->refresh_alt_ref_frame) - rc->avg_intersize_gfint += rc->projected_frame_size; + rc->avg_size_inter = ROUND_POWER_OF_TWO( + rc->avg_size_inter * 3 + rc->projected_frame_size, 2); } } @@ -1547,8 +1548,6 @@ 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); rc->gfu_boost = DEFAULT_GF_BOOST; if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cpi->oxcf.pass == 0) { vp9_cyclic_refresh_set_golden_update(cpi); @@ -1559,7 +1558,7 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { // 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->avg_size_inter > (5 * rc->avg_frame_bandwidth) >> 1) { rc->baseline_gf_interval = (3 * rc->baseline_gf_interval) >> 1; } else if (cm->current_video_frame > 30 && rc->avg_frame_low_motion < 20) { @@ -1571,7 +1570,6 @@ void vp9_rc_get_one_pass_vbr_params(VP9_COMP *cpi) { rc->frames_till_gf_update_due = rc->baseline_gf_interval; cpi->refresh_golden_frame = 1; rc->source_alt_ref_pending = USE_ALTREF_FOR_ONE_PASS; - rc->avg_intersize_gfint = 0; } if (cm->frame_type == KEY_FRAME) target = calc_iframe_target_size_one_pass_vbr(cpi); @@ -2160,7 +2158,6 @@ void vp9_avg_source_sad(VP9_COMP *cpi) { target = calc_pframe_target_size_one_pass_vbr(cpi); vp9_rc_set_frame_target(cpi, target); rc->count_last_scene_change = 0; - rc->avg_intersize_gfint = 0; } else { rc->count_last_scene_change++; } diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h index eef1940..893905e 100644 --- a/vp9/encoder/vp9_ratectrl.h +++ b/vp9/encoder/vp9_ratectrl.h @@ -162,7 +162,7 @@ typedef struct { uint64_t avg_source_sad; int high_source_sad; int count_last_scene_change; - int avg_intersize_gfint; + int avg_size_inter; int avg_frame_low_motion; } RATE_CONTROL; -- 2.7.4