[x265] [PATCH 2 of 4] improve ctuLumaLevel logic by Sad and CMOV

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


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1439423217 25200
# Node ID 09846d1566428a73d70d2fcf2d50324c0dfbbb7f
# Parent  f627a263bb5c1dcf274ab281a02670449ae891fc
improve ctuLumaLevel logic by Sad and CMOV
---
 source/encoder/frameencoder.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff -r f627a263bb5c -r 09846d156642 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Aug 12 16:35:27 2015 -0700
+++ b/source/encoder/frameencoder.cpp	Wed Aug 12 16:46:57 2015 -0700
@@ -992,13 +992,14 @@
         }
 
         /* calculate maximum and average luma levels */
-        uint32_t ctuLumaLevel = 0;
+        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];
-            ctuLumaLevel += p;
-            curRow.rowStats.maxLumaLevel = X265_MAX(p, curRow.rowStats.maxLumaLevel);
+            if (p > curRow.rowStats.maxLumaLevel)
+                curRow.rowStats.maxLumaLevel = p;
         }
         curRow.rowStats.lumaLevel += (double)(ctuLumaLevel) / ctuNoOfPixels;
 



More information about the x265-devel mailing list