]> granicus.if.org Git - libx264/commitdiff
Fix weightp analysis with high bit depth
authorFiona Glaser <fiona@x264.com>
Sat, 11 Dec 2010 21:37:09 +0000 (13:37 -0800)
committerFiona Glaser <fiona@x264.com>
Sat, 11 Dec 2010 22:43:32 +0000 (14:43 -0800)
encoder/slicetype.c

index 894c9f4c9fdd971c74bff90b534e4cf1898e818f..162238fc27fd0349ed74e1e23cc6706b8bd9fa45 100644 (file)
@@ -238,8 +238,8 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
         float fenc_var = fenc->i_pixel_ssd[plane] + !ref->i_pixel_ssd[plane];
         float ref_var  =  ref->i_pixel_ssd[plane] + !ref->i_pixel_ssd[plane];
         float guess_scale = sqrtf( fenc_var / ref_var );
-        float fenc_mean = (float)fenc->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]);
-        float ref_mean  = (float) ref->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]);
+        float fenc_mean = (float)fenc->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
+        float ref_mean  = (float) ref->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
 
         //early termination
         if( fabsf( ref_mean - fenc_mean ) < 0.5f && fabsf( 1.f - guess_scale ) < epsilon )