<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 27, 2013 at 11:52 PM, Aarthi Thirumalai <span dir="ltr"><<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Aarthi Thirumalai<br>
# Date 1380343364 -19800<br>
# Sat Sep 28 10:12:44 2013 +0530<br>
# Node ID 1d27b6c649ab4580b1fef5ff8b65bb3e1ffa83b6<br>
# Parent f8684226fc3aa8b94f698381b628412bfa63b6cc<br>
compute global ssim /psnr if their respective knobs are turned ON<br>
<br>
diff -r f8684226fc3a -r 1d27b6c649ab source/Lib/TLibEncoder/TEncTop.cpp<br>
--- a/source/Lib/TLibEncoder/TEncTop.cpp Sat Sep 28 10:01:18 2013 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncTop.cpp Sat Sep 28 10:12:44 2013 +0530<br>
@@ -70,6 +70,7 @@<br>
m_frameEncoder = NULL;<br>
m_rateControl = NULL;<br>
m_dpb = NULL;<br>
+ m_globalSsim = 0;<br>
<br>
#if ENC_DEC_TRACE<br>
g_hTrace = fopen("TraceEnc.txt", "wb");<br>
@@ -493,7 +494,7 @@<br>
int width = recon->getWidth() - getPad(0);<br>
int height = recon->getHeight() - getPad(1);<br>
int size = width * height;<br>
-<br>
+ double ssim = 0;<br>
UInt64 ssdY = computeSSD(orig->getLumaAddr(), recon->getLumaAddr(), stride, width, height);<br>
<br>
height >>= 1;<br>
@@ -585,6 +586,13 @@<br>
m_analyzeB.addResult(psnrY, psnrU, psnrV, (double)bits);<br>
}<br>
<br>
+ if (param.bEnableSsim)<br>
+ {<br>
+ ssim += pic->getSlice()->m_ssim / pic->getSlice()->m_ssimCnt;<br>
+ m_globalSsim += ssim;<br>
+ }<br>
+<br>
+<br>
if (param.logLevel >= X265_LOG_DEBUG)<br>
{<br>
char c = (slice->isIntra() ? 'I' : slice->isInterP() ? 'P' : 'B');<br>
@@ -599,7 +607,11 @@<br>
slice->getSliceQp(),<br>
bits);<br>
<br>
- fprintf(stderr, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);<br>
+ if(param.bEnablePsnr)<br>
+ fprintf(stderr, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);<br></blockquote><div><br></div><div>white-space</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ if(param.bEnableSsim)<br>
+ fprintf(stderr, " SSIM Y:%.5f ",ssim);<br>
<br>
if (!slice->isIntra())<br>
{<br>
diff -r f8684226fc3a -r 1d27b6c649ab source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Sat Sep 28 10:01:18 2013 +0530<br>
+++ b/source/encoder/encoder.cpp Sat Sep 28 10:12:44 2013 +0530<br>
@@ -429,13 +429,16 @@<br>
EXTERN_CYCLE_COUNTER(ME);<br>
<br>
extern "C"<br>
-void x265_encoder_close(x265_t *encoder, double *outPsnr)<br>
+void x265_encoder_close(x265_t *encoder, double *outPsnr, double *outSsim)<br>
{<br>
double globalPsnr = encoder->printSummary();<br>
<br>
if (outPsnr)<br>
*outPsnr = globalPsnr;<br>
<br>
+ if (outSsim)<br>
+ *outSsim = encoder->getSSIM();<br>
+<br>
REPORT_CYCLE_COUNTER(ME);<br>
<br>
encoder->destroy();<br>
diff -r f8684226fc3a -r 1d27b6c649ab source/x265.h<br>
--- a/source/x265.h Sat Sep 28 10:01:18 2013 +0530<br>
+++ b/source/x265.h Sat Sep 28 10:12:44 2013 +0530<br>
@@ -346,7 +346,7 @@<br>
<br>
/* x265_encoder_close:<br>
* close an encoder handler. Optionally return the global PSNR value (6 * psnrY + psnrU + psnrV) / 8 */<br>
-void x265_encoder_close(x265_t *, double *globalPsnr);<br>
+void x265_encoder_close(x265_t *, double *globalPsnr, double *globalSsim);<br></blockquote><div><br></div><div>Previous comments apply. It would be better to make a new function to query stats. Ideally the stats would be returned via a structure defined in x265.h</div>
<div><br></div><div>--</div><div>Steve Borho</div></div></div></div>