]> granicus.if.org Git - libx264/commitdiff
Fix bug in weightp analysis
authorFiona Glaser <fiona@x264.com>
Wed, 25 Nov 2009 06:37:02 +0000 (22:37 -0800)
committerFiona Glaser <fiona@x264.com>
Wed, 25 Nov 2009 06:37:02 +0000 (22:37 -0800)
Weights weren't reset upon early terminations, so old (wrong) weights could stick around.
Small compression improvement.

encoder/slicetype.c

index 45495c1261307184c30616c15a976f743b5d0d87..c392cfe1e3ddc1834e391191edbb3a49269ec8ff 100644 (file)
@@ -190,7 +190,10 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
 
     //early termination
     if( fabs( ref_mean - fenc_mean ) < 0.5 && fabsf( 1 - (float)fenc_var / ref_var ) < epsilon )
+    {
+        SET_WEIGHT( weights[0], 0, 1, 0, 0 );
         return;
+    }
 
     guess_scale = ref_var ? (float)fenc_var/ref_var : 0;
     get_h264_weight( round( guess_scale * 128 ), 0, &weights[0] );
@@ -211,7 +214,10 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
     origscore = minscore = x264_weight_cost( h, fenc, mcbuf, 0 );
 
     if( !minscore )
+    {
+        SET_WEIGHT( weights[0], 0, 1, 0, 0 );
         return;
+    }
 
     // This gives a slight improvement due to rounding errors but only tests
     // one offset on lookahead.