<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 27, 2015 at 3:18 PM, Divya Manivannan <span dir="ltr"><<a href="mailto:divya@multicorewareinc.com" target="_blank">divya@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 Divya Manivannan <<a href="mailto:divya@multicorewareinc.com" target="_blank">divya@multicorewareinc.com</a>><br>
# Date 1437990335 -19800<br>
#      Mon Jul 27 15:15:35 2015 +0530<br>
# Node ID 8c160e96251d2bd88afb6adff5d117a0b75d1412<br>
# Parent  b015514a93868e2dcf431d2e94b147861076a376<br>
stats: average and maximum luma level per frame<br>
<br>
diff -r b015514a9386 -r 8c160e96251d source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt     Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/CMakeLists.txt     Mon Jul 27 15:15:35 2015 +0530<br>
@@ -30,7 +30,7 @@<br>
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
<br>
 # X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 67)<br>
+set(X265_BUILD 68)<br>
 configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" target="_blank">x265.def.in</a>"<br>
                "${PROJECT_BINARY_DIR}/x265.def")<br>
 configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
diff -r b015514a9386 -r 8c160e96251d source/common/framedata.h<br>
--- a/source/common/framedata.h Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/common/framedata.h Mon Jul 27 15:15:35 2015 +0530<br>
@@ -55,6 +55,7 @@<br>
     double      avgLumaDistortion;<br>
     double      avgChromaDistortion;<br>
     double      avgPsyEnergy;<br>
+    double      avgLumaLevel;<br>
     double      percentIntraNxN;<br>
     double      percentSkipCu[NUM_CU_DEPTH];<br>
     double      percentMergeCu[NUM_CU_DEPTH];<br>
@@ -67,12 +68,15 @@<br>
     uint64_t    lumaDistortion;<br>
     uint64_t    chromaDistortion;<br>
     uint64_t    psyEnergy;<br>
+    uint64_t    lumaLevel;<br>
+    uint64_t    noOfPixels;<br>
     uint64_t    cntSkipCu[NUM_CU_DEPTH];<br>
     uint64_t    cntMergeCu[NUM_CU_DEPTH];<br>
     uint64_t    cntInter[NUM_CU_DEPTH];<br>
     uint64_t    cntIntra[NUM_CU_DEPTH];<br>
     uint64_t    cuInterDistribution[NUM_CU_DEPTH][INTER_MODES];<br>
     uint64_t    cuIntraDistribution[NUM_CU_DEPTH][INTRA_MODES];<br>
+    uint16_t    maxLumaLevel;<br>
<br>
     FrameStats()<br>
     {<br>
diff -r b015514a9386 -r 8c160e96251d source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/encoder/encoder.cpp        Mon Jul 27 15:15:35 2015 +0530<br>
@@ -1168,6 +1168,8 @@<br>
         frameStats->avgChromaDistortion     = curFrame->m_encData->m_frameStats.avgChromaDistortion;<br>
         frameStats->avgLumaDistortion       = curFrame->m_encData->m_frameStats.avgLumaDistortion;<br>
         frameStats->avgPsyEnergy            = curFrame->m_encData->m_frameStats.avgPsyEnergy;<br>
+        frameStats->avgLumaLevel            = curFrame->m_encData->m_frameStats.avgLumaLevel;<br>
+        frameStats->maxLumaLevel            = curFrame->m_encData->m_frameStats.maxLumaLevel;<br>
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)<br>
         {<br>
             frameStats->cuStats.percentSkipCu[depth]  = curFrame->m_encData->m_frameStats.percentSkipCu[depth];<br>
diff -r b015514a9386 -r 8c160e96251d source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp   Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/encoder/frameencoder.cpp   Mon Jul 27 15:15:35 2015 +0530<br>
@@ -591,6 +591,11 @@<br>
         m_frame->m_encData->m_frameStats.lumaDistortion   += m_rows[i].rowStats.lumaDistortion;<br>
         m_frame->m_encData->m_frameStats.chromaDistortion += m_rows[i].rowStats.chromaDistortion;<br>
         m_frame->m_encData->m_frameStats.psyEnergy        += m_rows[i].rowStats.psyEnergy;<br>
+        m_frame->m_encData->m_frameStats.lumaLevel        += m_rows[i].rowStats.lumaLevel;<br>
+        m_frame->m_encData->m_frameStats.noOfPixels       += m_rows[i].rowStats.noOfPixels;<br>
+<br>
+        if (m_rows[i].rowStats.maxLumaLevel > m_frame->m_encData->m_frameStats.maxLumaLevel)<br>
+            m_frame->m_encData->m_frameStats.maxLumaLevel = m_rows[i].rowStats.maxLumaLevel;<br>
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)<br>
         {<br>
             m_frame->m_encData->m_frameStats.cntSkipCu[depth] += m_rows[i].rowStats.cntSkipCu[depth];<br>
@@ -604,6 +609,7 @@<br>
     m_frame->m_encData->m_frameStats.avgLumaDistortion   = (double)(m_frame->m_encData->m_frameStats.lumaDistortion / m_frame->m_encData->m_frameStats.totalCtu);<br>
     m_frame->m_encData->m_frameStats.avgChromaDistortion = (double)(m_frame->m_encData->m_frameStats.chromaDistortion / m_frame->m_encData->m_frameStats.totalCtu);<br>
     m_frame->m_encData->m_frameStats.avgPsyEnergy        = (double)(m_frame->m_encData->m_frameStats.psyEnergy / m_frame->m_encData->m_frameStats.totalCtu);<br>
+    m_frame->m_encData->m_frameStats.avgLumaLevel        = (double)(m_frame->m_encData->m_frameStats.lumaLevel / m_frame->m_encData->m_frameStats.noOfPixels);<br></blockquote><div><br></div><div>I was trying to figure out whether a better approach is to average per CTU. With float/double datatypes - overflow is not a problem, but precision is. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
     m_frame->m_encData->m_frameStats.percentIntraNxN     = (double)(m_frame->m_encData->m_frameStats.cntIntraNxN * 100) / m_frame->m_encData->m_frameStats.totalCu;<br>
     for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)<br>
     {<br>
@@ -983,6 +989,13 @@<br>
             for (int n = 0; n < INTRA_MODES; n++)<br>
                 curRow.rowStats.cuIntraDistribution[depth][n] += frameLog.cuIntraDistribution[depth][n];<br>
         }<br>
+        for (uint32_t i = 0; i < (best.reconYuv.m_size * best.reconYuv.m_size); i++)<br>
+        {<br>
+            curRow.rowStats.lumaLevel += *(best.reconYuv.m_buf[0] + i);<br>
+            curRow.rowStats.noOfPixels++;<br>
+            if ((*(best.reconYuv.m_buf[0] + i)) > curRow.rowStats.maxLumaLevel)<br>
+                curRow.rowStats.maxLumaLevel = *(best.reconYuv.m_buf[0] + i);<br>
+        }<br>
<br>
         curEncData.m_cuStat[cuAddr].totalBits = best.totalBits;<br>
         x265_emms();<br>
diff -r b015514a9386 -r 8c160e96251d source/x265-extras.cpp<br>
--- a/source/x265-extras.cpp    Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/x265-extras.cpp    Mon Jul 27 15:15:35 2015 +0530<br>
@@ -107,7 +107,7 @@<br>
                         fprintf(csvfp, ", Merge %dx%d", size, size);<br>
                         size /= 2;<br>
                     }<br>
-                    fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma Distortion, Avg psyEnergy");<br>
+                    fprintf(csvfp, ", Avg Luma Distortion, Avg Chroma Distortion, Avg psyEnergy, Avg Luma Level, Max Luma Level");<br>
                 }<br>
                 fprintf(csvfp, "\n");<br>
             }<br>
@@ -179,7 +179,7 @@<br>
             fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.percentSkipCu[depth]);<br>
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)<br>
             fprintf(csvfp, ", %5.2lf%%", frameStats->cuStats.percentMergeCu[depth]);<br>
-        fprintf(csvfp, ", %.2lf, %.2lf, %.2lf", frameStats->avgLumaDistortion, frameStats->avgChromaDistortion, frameStats->avgPsyEnergy);<br>
+        fprintf(csvfp, ", %.2lf, %.2lf, %.2lf, %.2lf, %d", frameStats->avgLumaDistortion, frameStats->avgChromaDistortion, frameStats->avgPsyEnergy, frameStats->avgLumaLevel, frameStats->maxLumaLevel);<br>
     }<br>
     fprintf(csvfp, "\n");<br>
     fflush(stderr);<br>
diff -r b015514a9386 -r 8c160e96251d source/x265.h<br>
--- a/source/x265.h     Sun Jul 26 16:12:32 2015 +0530<br>
+++ b/source/x265.h     Mon Jul 27 15:15:35 2015 +0530<br>
@@ -132,12 +132,14 @@<br>
     double           avgLumaDistortion;<br>
     double           avgChromaDistortion;<br>
     double           avgPsyEnergy;<br>
+    double           avgLumaLevel;<br>
     uint64_t         bits;<br>
     int              encoderOrder;<br>
     int              poc;<br>
     int              countRowBlocks;<br>
     int              list0POC[16];<br>
     int              list1POC[16];<br>
+    uint16_t         maxLumaLevel;<br>
     char             sliceType;<br>
     x265_cu_stats    cuStats;<br>
 } x265_frame_stats;<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>