]> git.sesse.net Git - x264/commitdiff
Limit SSIM to 100db
authorAnton Mitrofanov <BugMaster@narod.ru>
Fri, 16 Dec 2011 14:17:00 +0000 (18:17 +0400)
committerFiona Glaser <fiona@x264.com>
Thu, 12 Jan 2012 20:07:53 +0000 (12:07 -0800)
Avoids floating point error for infinite SSIM (lossless).

encoder/encoder.c

index adac4f827c636aa3401ee588e358e95c4e559596..39fc40973af3ff917f5f8fbf367754c9e99c3610 100644 (file)
@@ -61,7 +61,11 @@ static double x264_psnr( double sqe, double size )
 
 static double x264_ssim( double ssim )
 {
-    return -10.0 * log10( 1 - ssim );
+    double inv_ssim = 1 - ssim;
+    if( inv_ssim <= 0.0000000001 ) /* Max 100dB */
+        return 100;
+
+    return -10.0 * log10( inv_ssim );
 }
 
 static void x264_frame_dump( x264_t *h )