From e0d722f85f8599e324be2bebef9430155b25c329 Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Tue, 22 Sep 2015 18:58:24 +0300 Subject: [PATCH] Change the predictors update algorithm Keep predictor offsets more stable. This should fix VBV misprediction in frames with a large difference in complexity between the top and bottom parts. --- encoder/ratecontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index d49e2a22..78051ccc 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -2089,7 +2089,8 @@ static void update_predictor( predictor_t *p, float q, float var, float bits ) if( var < 10 ) return; float old_coeff = p->coeff / p->count; - float new_coeff = X264_MAX( bits*q / var, p->coeff_min ); + float old_offset = p->offset / p->count; + float new_coeff = X264_MAX( (bits*q - old_offset) / var, p->coeff_min ); float new_coeff_clipped = x264_clip3f( new_coeff, old_coeff/range, old_coeff*range ); float new_offset = bits*q - new_coeff_clipped * var; if( new_offset >= 0 ) -- 2.39.2