From c98aab086a2d8f99c53b501ec165c2a804d49725 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 4 Jun 2008 21:28:48 -0600 Subject: [PATCH] Use a gaussian window for cplxblur Cplxblur was originally intended to use a gaussian window, but in its current form did not. This change provides a tiny improvement to 2pass ratecontrol. --- encoder/ratecontrol.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index e071726a..a049f74a 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -1801,15 +1801,17 @@ static int init_pass2( x264_t *h ) weight *= 1 - pow( (float)rcj->i_count / rcc->nmb, 2 ); if(weight < .0001) break; - weight_sum += weight; - cplx_sum += weight * (qscale2bits(rcj, 1) - rcj->misc_bits); + double gaussian_weight = weight * exp(-j*j/200.0); + weight_sum += gaussian_weight; + cplx_sum += gaussian_weight * (qscale2bits(rcj, 1) - rcj->misc_bits); } /* weighted average of cplx of past frames */ weight = 1.0; for(j=0; j<=cplxblur*2 && j<=i; j++){ ratecontrol_entry_t *rcj = &rcc->entry[i-j]; - weight_sum += weight; - cplx_sum += weight * (qscale2bits(rcj, 1) - rcj->misc_bits); + double gaussian_weight = weight * exp(-j*j/200.0); + weight_sum += gaussian_weight; + cplx_sum += gaussian_weight * (qscale2bits(rcj, 1) - rcj->misc_bits); weight *= 1 - pow( (float)rcj->i_count / rcc->nmb, 2 ); if(weight < .0001) break; -- 2.47.3