From: Fiona Glaser Date: Thu, 5 Jun 2008 03:28:48 +0000 (-0600) Subject: Use a gaussian window for cplxblur X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6c98f6f5798e31634b47aee0a18d7ecd5eff3e1;p=libx264 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. --- 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;