[x265-commits] [x265] refine initializeGeoms()

Satoshi Nakagawa nakagawa424 at oki.com
Wed Nov 12 00:51:47 CET 2014


details:   http://hg.videolan.org/x265/rev/98fb658f3229
branches:  
changeset: 8832:98fb658f3229
user:      Satoshi Nakagawa <nakagawa424 at oki.com>
date:      Tue Nov 11 19:30:19 2014 +0900
description:
refine initializeGeoms()

diffstat:

 source/common/cudata.cpp        |  10 +++---
 source/common/cudata.h          |   2 +-
 source/encoder/frameencoder.cpp |  59 +++++++++++++++++++++++++---------------
 source/encoder/frameencoder.h   |   2 +-
 4 files changed, 43 insertions(+), 30 deletions(-)

diffs (144 lines):

diff -r 306ef9782a30 -r 98fb658f3229 source/common/cudata.cpp
--- a/source/common/cudata.cpp	Tue Nov 11 13:29:36 2014 -0600
+++ b/source/common/cudata.cpp	Tue Nov 11 19:30:19 2014 +0900
@@ -2078,7 +2078,7 @@ void CUData::getTUEntropyCodingParameter
 
 #define CU_SET_FLAG(bitfield, flag, value) (bitfield) = ((bitfield) & (~(flag))) | ((~((value) - 1)) & (flag))
 
-void CUData::calcCTUGeoms(uint32_t picWidth, uint32_t picHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]) const
+void CUData::calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS])
 {
     // Initialize the coding blocks inside the CTB
     for (uint32_t log2CUSize = g_log2Size[maxCUSize], rangeCUIdx = 0; log2CUSize >= MIN_LOG2_CU_SIZE; log2CUSize--)
@@ -2093,10 +2093,10 @@ void CUData::calcCTUGeoms(uint32_t picWi
                 uint32_t depthIdx = g_depthScanIdx[sbY][sbX];
                 uint32_t cuIdx = rangeCUIdx + depthIdx;
                 uint32_t childIdx = rangeCUIdx + sbWidth * sbWidth + (depthIdx << 2);
-                uint32_t px = m_cuPelX + sbX * blockSize;
-                uint32_t py = m_cuPelY + sbY * blockSize;
-                int32_t presentFlag = px < picWidth && py < picHeight;
-                int32_t splitMandatoryFlag = presentFlag && !lastLevelFlag && (px + blockSize > picWidth || py + blockSize > picHeight);
+                uint32_t px = sbX * blockSize;
+                uint32_t py = sbY * blockSize;
+                int32_t presentFlag = px < ctuWidth && py < ctuHeight;
+                int32_t splitMandatoryFlag = presentFlag && !lastLevelFlag && (px + blockSize > ctuWidth || py + blockSize > ctuHeight);
                 
                 /* Offset of the luma CU in the X, Y direction in terms of pixels from the CTU origin */
                 uint32_t xOffset = (sbX * blockSize) >> 3;
diff -r 306ef9782a30 -r 98fb658f3229 source/common/cudata.h
--- a/source/common/cudata.h	Tue Nov 11 13:29:36 2014 -0600
+++ b/source/common/cudata.h	Tue Nov 11 19:30:19 2014 +0900
@@ -158,7 +158,7 @@ public:
     CUData();
 
     void     initialize(const CUDataMemPool& dataPool, uint32_t depth, int csp, int instance);
-    void     calcCTUGeoms(uint32_t picWidth, uint32_t picHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]) const;
+    static void calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]);
 
     void     initCTU(const Frame& frame, uint32_t cuAddr, int qp);
     void     initSubCU(const CUData& ctu, const CUGeom& cuGeom);
diff -r 306ef9782a30 -r 98fb658f3229 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Nov 11 13:29:36 2014 -0600
+++ b/source/encoder/frameencoder.cpp	Tue Nov 11 19:30:19 2014 +0900
@@ -138,11 +138,12 @@ bool FrameEncoder::init(Encoder *top, in
 }
 
 /* Generate a complete list of unique geom sets for the current picture dimensions */
-bool FrameEncoder::initializeGeoms(const FrameData& encData)
+bool FrameEncoder::initializeGeoms()
 {
     /* Geoms only vary between CTUs in the presence of picture edges */
-    int heightRem = m_param->sourceHeight & (m_param->maxCUSize - 1);
-    int widthRem = m_param->sourceWidth & (m_param->maxCUSize - 1);
+    int maxCUSize = m_param->maxCUSize;
+    int heightRem = m_param->sourceHeight & (maxCUSize - 1);
+    int widthRem = m_param->sourceWidth & (maxCUSize - 1);
     int allocGeoms = 1; // body
     if (heightRem && widthRem)
         allocGeoms = 4; // body, right, bottom, corner
@@ -154,33 +155,45 @@ bool FrameEncoder::initializeGeoms(const
     if (!m_cuGeoms || !m_ctuGeomMap)
         return false;
 
-    CUGeom cuLocalData[CUGeom::MAX_GEOMS];
-    memset(cuLocalData, 0, sizeof(cuLocalData)); // temporal fix for memcmp
+    // body
+    CUData::calcCTUGeoms(maxCUSize, maxCUSize, maxCUSize, m_cuGeoms);
+    memset(m_ctuGeomMap, 0, sizeof(uint32_t) * m_numRows * m_numCols);
+    if (allocGeoms == 1)
+        return true;
 
-    int countGeoms = 0;
-    for (uint32_t ctuAddr = 0; ctuAddr < m_numRows * m_numCols; ctuAddr++)
+    int countGeoms = 1;
+    if (widthRem)
     {
-        /* TODO: detach this logic from TComDataCU */
-        encData.m_picCTU[ctuAddr].initCTU(*m_frame, ctuAddr, 0);
-        encData.m_picCTU[ctuAddr].calcCTUGeoms(m_param->sourceWidth, m_param->sourceHeight, m_param->maxCUSize, cuLocalData);
+        // right
+        CUData::calcCTUGeoms(widthRem, maxCUSize, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
+        for (int i = 0; i < m_numRows; i++)
+        {
+            uint32_t ctuAddr = m_numCols * (i + 1) - 1;
+            m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
+        }
+        countGeoms++;
+    }
+    if (heightRem)
+    {
+        // bottom
+        CUData::calcCTUGeoms(maxCUSize, heightRem, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
+        for (uint32_t i = 0; i < m_numCols; i++)
+        {
+            uint32_t ctuAddr = m_numCols * (m_numRows - 1) + i;
+            m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
+        }
+        countGeoms++;
 
-        m_ctuGeomMap[ctuAddr] = MAX_INT;
-        for (int i = 0; i < countGeoms; i++)
+        if (widthRem)
         {
-            if (!memcmp(cuLocalData, m_cuGeoms + i * CUGeom::MAX_GEOMS, sizeof(CUGeom) * CUGeom::MAX_GEOMS))
-            {
-                m_ctuGeomMap[ctuAddr] = i * CUGeom::MAX_GEOMS;
-                break;
-            }
-        }
+            // corner
+            CUData::calcCTUGeoms(widthRem, heightRem, maxCUSize, m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS);
 
-        if (m_ctuGeomMap[ctuAddr] == MAX_INT)
-        {
-            X265_CHECK(countGeoms < allocGeoms, "geometry match check failure\n");
+            uint32_t ctuAddr = m_numCols * m_numRows - 1;
             m_ctuGeomMap[ctuAddr] = countGeoms * CUGeom::MAX_GEOMS;
-            memcpy(m_cuGeoms + countGeoms * CUGeom::MAX_GEOMS, cuLocalData, sizeof(CUGeom) * CUGeom::MAX_GEOMS);
             countGeoms++;
         }
+        X265_CHECK(countGeoms == allocGeoms, "geometry match check failure\n");
     }
 
     return true;
@@ -193,7 +206,7 @@ bool FrameEncoder::startCompressFrame(Fr
     curFrame->m_encData->m_slice->m_mref = m_mref;
     if (!m_cuGeoms)
     {
-        if (!initializeGeoms(*curFrame->m_encData))
+        if (!initializeGeoms())
             return false;
     }
     m_enable.trigger();
diff -r 306ef9782a30 -r 98fb658f3229 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h	Tue Nov 11 13:29:36 2014 -0600
+++ b/source/encoder/frameencoder.h	Tue Nov 11 19:30:19 2014 +0900
@@ -185,7 +185,7 @@ public:
 
 protected:
 
-    bool initializeGeoms(const FrameData& encData);
+    bool initializeGeoms();
 
     /* analyze / compress frame, can be run in parallel within reference constraints */
     void compressFrame();


More information about the x265-commits mailing list