[x265] [PATCH 4 of 4] Statistics maxLumaLevel in Frame Level

Min Chen chenm003 at 163.com
Thu Aug 13 05:22:18 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1439426801 25200
# Node ID 128db3baec386bacf0fd102c7e99ecf82c165657
# Parent  caf9562dc947f93e8ee237574575e9b67d494fc8
Statistics maxLumaLevel in Frame Level
---
 source/common/framedata.h       |    1 -
 source/encoder/encoder.cpp      |   20 +++++++++++++++++++-
 source/encoder/frameencoder.cpp |    8 --------
 3 files changed, 19 insertions(+), 10 deletions(-)

diff -r caf9562dc947 -r 128db3baec38 source/common/framedata.h
--- a/source/common/framedata.h	Wed Aug 12 17:15:13 2015 -0700
+++ b/source/common/framedata.h	Wed Aug 12 17:46:41 2015 -0700
@@ -75,7 +75,6 @@
     uint64_t    cntIntra[NUM_CU_DEPTH];
     uint64_t    cuInterDistribution[NUM_CU_DEPTH][INTER_MODES];
     uint64_t    cuIntraDistribution[NUM_CU_DEPTH][INTRA_MODES];
-    uint16_t    maxLumaLevel;
 
     FrameStats()
     {
diff -r caf9562dc947 -r 128db3baec38 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Aug 12 17:15:13 2015 -0700
+++ b/source/encoder/encoder.cpp	Wed Aug 12 17:46:41 2015 -0700
@@ -1164,7 +1164,25 @@
         frameStats->avgLumaDistortion       = curFrame->m_encData->m_frameStats.avgLumaDistortion;
         frameStats->avgPsyEnergy            = curFrame->m_encData->m_frameStats.avgPsyEnergy;
         frameStats->avgLumaLevel            = curFrame->m_encData->m_frameStats.avgLumaLevel;
-        frameStats->maxLumaLevel            = curFrame->m_encData->m_frameStats.maxLumaLevel;
+
+        // Statistics Maximum LumaLevel for (csvlog_level >= 2)
+        {
+            const pixel *pix = curFrame->m_fencPic->m_picOrg[0];
+            const intptr_t stride = curFrame->m_fencPic->m_stride;
+
+            pixel maxLumaLevel = 0;
+            for(uint32_t y = 0; y < curFrame->m_fencPic->m_picHeight; y++)
+            {
+                for(uint32_t x = 0; x < curFrame->m_fencPic->m_picWidth; x++)
+                {
+                    if (pix[x] > maxLumaLevel)
+                        maxLumaLevel = pix[x];
+                }
+                pix += stride;
+            }
+            frameStats->maxLumaLevel = maxLumaLevel;
+        }
+
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
         {
             frameStats->cuStats.percentSkipCu[depth]  = curFrame->m_encData->m_frameStats.percentSkipCu[depth];
diff -r caf9562dc947 -r 128db3baec38 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Aug 12 17:15:13 2015 -0700
+++ b/source/encoder/frameencoder.cpp	Wed Aug 12 17:46:41 2015 -0700
@@ -594,8 +594,6 @@
         m_frame->m_encData->m_frameStats.psyEnergy        += m_rows[i].rowStats.psyEnergy;
         m_frame->m_encData->m_frameStats.lumaLevel        += m_rows[i].rowStats.lumaLevel;
 
-        if (m_rows[i].rowStats.maxLumaLevel > m_frame->m_encData->m_frameStats.maxLumaLevel)
-            m_frame->m_encData->m_frameStats.maxLumaLevel = m_rows[i].rowStats.maxLumaLevel;
         for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++)
         {
             m_frame->m_encData->m_frameStats.cntSkipCu[depth] += m_rows[i].rowStats.cntSkipCu[depth];
@@ -995,12 +993,6 @@
         static const pixel dummy_zero[MAX_CU_SIZE] = {0};
         uint32_t ctuLumaLevel = primitives.pu[best.fencYuv->m_part].sad(best.fencYuv->m_buf[0], best.fencYuv->m_size, dummy_zero, 0);
         uint32_t ctuNoOfPixels = best.fencYuv->m_size * best.fencYuv->m_size;
-        for (uint32_t i = 0; i < ctuNoOfPixels; i++)
-        {
-            pixel p = best.fencYuv->m_buf[0][i];
-            if (p > curRow.rowStats.maxLumaLevel)
-                curRow.rowStats.maxLumaLevel = p;
-        }
         curRow.rowStats.lumaLevel += (double)(ctuLumaLevel) / ctuNoOfPixels;
 
         curEncData.m_cuStat[cuAddr].totalBits = best.totalBits;



More information about the x265-devel mailing list