[x264-devel] Limit SSIM to 100db

Anton Mitrofanov git at videolan.org
Mon Jan 16 02:11:54 CET 2012


x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Fri Dec 16 18:17:00 2011 +0400| [f33c8cb0f8fff7a83100b3e9d15baba53c6f6a35] | committer: Jason Garrett-Glaser

Limit SSIM to 100db
Avoids floating point error for infinite SSIM (lossless).

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=f33c8cb0f8fff7a83100b3e9d15baba53c6f6a35
---

 encoder/encoder.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/encoder/encoder.c b/encoder/encoder.c
index 0ab200c..607ece1 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -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 )



More information about the x264-devel mailing list