]> granicus.if.org Git - libx264/commitdiff
Use a gaussian window for cplxblur
authorFiona Glaser <fiona@x264.com>
Thu, 5 Jun 2008 03:28:48 +0000 (21:28 -0600)
committerFiona Glaser <fiona@x264.com>
Thu, 5 Jun 2008 03:31:29 +0000 (21:31 -0600)
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

index e071726a607093e471c9684a76f0b1b352da4249..a049f74a7f4c79b43e2e5de4eb847b6aa95a6138 100644 (file)
@@ -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;