[x265] [PATCH] stats: use input source pictures to calculate avgerage and max luma level

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Thu Aug 6 07:02:45 CEST 2015


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1438837146 -19800
#      Thu Aug 06 10:29:06 2015 +0530
# Node ID 9fcc0e6bdc54758478e37e988e640fb52303d28b
# Parent  377a996a8d74110f838ff2e3cef1c42781d6d730
stats: use input source pictures to calculate avgerage and max luma level

diff -r 377a996a8d74 -r 9fcc0e6bdc54 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Aug 05 15:09:14 2015 +0530
+++ b/source/encoder/frameencoder.cpp	Thu Aug 06 10:29:06 2015 +0530
@@ -988,16 +988,17 @@
             for (int n = 0; n < INTRA_MODES; n++)
                 curRow.rowStats.cuIntraDistribution[depth][n] += frameLog.cuIntraDistribution[depth][n];
         }
-        uint64_t ctuLumaLevel = 0;
-        uint64_t ctuNoOfPixels = 0;
-        for (uint32_t i = 0; i < (best.reconYuv.m_size * best.reconYuv.m_size); i++)
+
+        /* calculate maximum and average luma levels */
+        uint32_t ctuLumaLevel = 0;
+        uint32_t ctuNoOfPixels = best.fencYuv->m_size * best.fencYuv->m_size;
+        for (uint32_t i = 0; i < ctuNoOfPixels; i++)
         {
-            ctuLumaLevel += *(best.reconYuv.m_buf[0] + i);
-            ctuNoOfPixels++;
-            if ((*(best.reconYuv.m_buf[0] + i)) > curRow.rowStats.maxLumaLevel)
-                curRow.rowStats.maxLumaLevel = *(best.reconYuv.m_buf[0] + i);
+            pixel p = best.fencYuv->m_buf[0][i];
+            ctuLumaLevel += p;
+            curRow.rowStats.maxLumaLevel = X265_MAX(p, curRow.rowStats.maxLumaLevel);
         }
-        curRow.rowStats.lumaLevel += (double)(ctuLumaLevel / ctuNoOfPixels);
+        curRow.rowStats.lumaLevel += (double)(ctuLumaLevel) / ctuNoOfPixels;
 
         curEncData.m_cuStat[cuAddr].totalBits = best.totalBits;
         x265_emms();


More information about the x265-devel mailing list