[x265] [PATCH 3 of 5] compute global ssim /psnr if their respective knobs are turned ON

Aarthi Thirumalai aarthi at multicorewareinc.com
Sat Sep 28 06:52:49 CEST 2013


# HG changeset patch
# User Aarthi Thirumalai
# Date 1380343364 -19800
#      Sat Sep 28 10:12:44 2013 +0530
# Node ID 1d27b6c649ab4580b1fef5ff8b65bb3e1ffa83b6
# Parent  f8684226fc3aa8b94f698381b628412bfa63b6cc
compute global ssim /psnr if their respective knobs are turned ON

diff -r f8684226fc3a -r 1d27b6c649ab source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Sat Sep 28 10:01:18 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Sat Sep 28 10:12:44 2013 +0530
@@ -70,6 +70,7 @@
     m_frameEncoder = NULL;
     m_rateControl = NULL;
     m_dpb = NULL;
+    m_globalSsim = 0;
 
 #if ENC_DEC_TRACE
     g_hTrace = fopen("TraceEnc.txt", "wb");
@@ -493,7 +494,7 @@
     int width  = recon->getWidth() - getPad(0);
     int height = recon->getHeight() - getPad(1);
     int size = width * height;
-
+    double ssim = 0;
     UInt64 ssdY = computeSSD(orig->getLumaAddr(), recon->getLumaAddr(), stride, width, height);
 
     height >>= 1;
@@ -585,6 +586,13 @@
         m_analyzeB.addResult(psnrY, psnrU, psnrV, (double)bits);
     }
 
+     if (param.bEnableSsim)
+     {
+        ssim += pic->getSlice()->m_ssim / pic->getSlice()->m_ssimCnt;
+        m_globalSsim += ssim;
+     }
+     
+
     if (param.logLevel >= X265_LOG_DEBUG)
     {
         char c = (slice->isIntra() ? 'I' : slice->isInterP() ? 'P' : 'B');
@@ -599,7 +607,11 @@
                 slice->getSliceQp(),
                 bits);
 
-        fprintf(stderr, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);
+        if(param.bEnablePsnr)
+            fprintf(stderr, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);
+
+        if(param.bEnableSsim)
+            fprintf(stderr, " SSIM Y:%.5f ",ssim); 
 
         if (!slice->isIntra())
         {
diff -r f8684226fc3a -r 1d27b6c649ab source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Sat Sep 28 10:01:18 2013 +0530
+++ b/source/encoder/encoder.cpp	Sat Sep 28 10:12:44 2013 +0530
@@ -429,13 +429,16 @@
 EXTERN_CYCLE_COUNTER(ME);
 
 extern "C"
-void x265_encoder_close(x265_t *encoder, double *outPsnr)
+void x265_encoder_close(x265_t *encoder, double *outPsnr, double *outSsim)
 {
     double globalPsnr = encoder->printSummary();
 
     if (outPsnr)
         *outPsnr = globalPsnr;
 
+    if (outSsim)
+        *outSsim = encoder->getSSIM();
+
     REPORT_CYCLE_COUNTER(ME);
 
     encoder->destroy();
diff -r f8684226fc3a -r 1d27b6c649ab source/x265.h
--- a/source/x265.h	Sat Sep 28 10:01:18 2013 +0530
+++ b/source/x265.h	Sat Sep 28 10:12:44 2013 +0530
@@ -346,7 +346,7 @@
 
 /* x265_encoder_close:
  *      close an encoder handler.  Optionally return the global PSNR value (6 * psnrY + psnrU + psnrV) / 8 */
-void    x265_encoder_close(x265_t *, double *globalPsnr);
+void    x265_encoder_close(x265_t *, double *globalPsnr, double *globalSsim);
 
 /***
  * Release library static allocations


More information about the x265-devel mailing list