Change to damping in vbr_rate_correction() Code changed in line with VP9. Some gain in psnr and slightly larger in ssim (overall psnr, ssim): Low Res: -0.144, -0.385 UGC 360: -0.300, -0.486 Mid Res: -0.014, -0.182 HD Res Pending. STATS_CHANGED Change-Id: I41b303a390491ae2dd0806aeb9404e6bf88c94ec
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c index cd56c1f..e0e82e4 100644 --- a/av1/encoder/ratectrl.c +++ b/av1/encoder/ratectrl.c
@@ -1705,17 +1705,16 @@ RATE_CONTROL *const rc = &cpi->rc; int64_t vbr_bits_off_target = rc->vbr_bits_off_target; int max_delta; - double position_factor = 1.0; + const int frame_window = + AOMMIN(16, (int)cpi->twopass.total_stats.count - + cpi->common.current_frame.frame_number); - // How far through the clip are we. - // This number is used to damp the per frame rate correction. - // Range 0 - 1.0 - if (cpi->twopass.total_stats.count != 0.) { - position_factor = sqrt((double)cpi->common.current_frame.frame_number / - cpi->twopass.total_stats.count); - } - max_delta = (int)(position_factor * - ((*this_frame_target * VBR_PCT_ADJUSTMENT_LIMIT) / 100)); + max_delta = (vbr_bits_off_target > 0) + ? (int)(vbr_bits_off_target / frame_window) + : (int)(-vbr_bits_off_target / frame_window); + + max_delta = AOMMIN(max_delta, + ((*this_frame_target * VBR_PCT_ADJUSTMENT_LIMIT) / 100)); // vbr_bits_off_target > 0 means we have extra bits to spend if (vbr_bits_off_target > 0) {