Commit 34843deb authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Henrik Gramner
Browse files

Fix float division by zero in weightp analysis

parent 1c317477
......@@ -297,11 +297,12 @@ void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int
float ref_mean[3];
for( int plane = 0; plane <= 2*!b_lookahead; plane++ )
{
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];
int zero_bias = !ref->i_pixel_ssd[plane];
float fenc_var = fenc->i_pixel_ssd[plane] + zero_bias;
float ref_var = ref->i_pixel_ssd[plane] + zero_bias;
guess_scale[plane] = sqrtf( fenc_var / ref_var );
fenc_mean[plane] = (float)fenc->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
ref_mean[plane] = (float) ref->i_pixel_sum[plane] / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
fenc_mean[plane] = (float)(fenc->i_pixel_sum[plane] + zero_bias) / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
ref_mean[plane] = (float)( ref->i_pixel_sum[plane] + zero_bias) / (fenc->i_lines[!!plane] * fenc->i_width[!!plane]) / (1 << (BIT_DEPTH - 8));
}
int chroma_denom = 7;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment