Log in

View Full Version : PSNR avg confusions


mancubit
18th January 2009, 01:55
i post this in newbies forum, cause i guess thats a newbie-question ;)

when i look at the results after i encode a video in x264 - there one line shows:

PSNR Mean Y:27.501 U:33.402 V:35.103 Avg:28.814 Global:28.708

uhm, why is avg 28.814?

when i calculate: PSNR Mean (Y + U + V)/3 then i get: 32.002
how is this average calculated? and what means "Global"?

hm, hope someone can help :)

Dark Shikari
18th January 2009, 01:58
static float x264_psnr( int64_t i_sqe, int64_t i_size )
{
double f_mse = (double)i_sqe / ((double)65025.0 * (double)i_size);
if( f_mse <= 0.0000000001 ) /* Max 100dB */
return 100;

return (float)(-10.0 * log( f_mse ) / log( 10.0 ));
}
....
h->stat.i_ssd_global[h->sh.i_type] += ssd[0] + ssd[1] + ssd[2];
h->stat.f_psnr_average[h->sh.i_type] += x264_psnr( ssd[0] + ssd[1] + ssd[2], 3 * h->param.i_width * h->param.i_height / 2 );
h->stat.f_psnr_mean_y[h->sh.i_type] += x264_psnr( ssd[0], h->param.i_width * h->param.i_height );
h->stat.f_psnr_mean_u[h->sh.i_type] += x264_psnr( ssd[1], h->param.i_width * h->param.i_height / 4 );
h->stat.f_psnr_mean_v[h->sh.i_type] += x264_psnr( ssd[2], h->param.i_width * h->param.i_height / 4 );

The "average PSNR" is not equal to the average of PSNR_Y, PSNR_U, and PSNR_V. It's equal to the PSNR based on the average of the SSD values of Y, U, and V. PSNR is a nonlinear scale.