[x265] [PATCH 2 of 7] add maxLog2CUSize to param and use in place of g_maxLog2CUSize

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Wed Jun 21 08:44:52 CEST 2017


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1497268317 -19800
#      Mon Jun 12 17:21:57 2017 +0530
# Node ID 624374a3b21cba624bee8002bcbdb4fa0917a6fe
# Parent  68b27c44790d200ceb95b26962a84c8230d29eba
add maxLog2CUSize to param and use in place of g_maxLog2CUSize

diff -r 68b27c44790d -r 624374a3b21c source/CMakeLists.txt
--- a/source/CMakeLists.txt	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/CMakeLists.txt	Mon Jun 12 17:21:57 2017 +0530
@@ -29,7 +29,7 @@
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 122)
+set(X265_BUILD 123)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 68b27c44790d -r 624374a3b21c source/common/cudata.cpp
--- a/source/common/cudata.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/common/cudata.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -130,7 +130,7 @@
     if (!s_partSet[0])
     {
         s_numPartInCUSize = 1 << g_unitSizeDepth;
-        switch (g_maxLog2CUSize)
+        switch (param.maxLog2CUSize)
         {
         case 6:
             s_partSet[0] = bcast256;
@@ -280,8 +280,8 @@
     m_encData       = frame.m_encData;
     m_slice         = m_encData->m_slice;
     m_cuAddr        = cuAddr;
-    m_cuPelX        = (cuAddr % m_slice->m_sps->numCuInWidth) << g_maxLog2CUSize;
-    m_cuPelY        = (cuAddr / m_slice->m_sps->numCuInWidth) << g_maxLog2CUSize;
+    m_cuPelX        = (cuAddr % m_slice->m_sps->numCuInWidth) << m_slice->m_param->maxLog2CUSize;
+    m_cuPelY        = (cuAddr / m_slice->m_sps->numCuInWidth) << m_slice->m_param->maxLog2CUSize;
     m_absIdxInCTU   = 0;
     m_numPartitions = NUM_4x4_PARTITIONS;
     m_bFirstRowInSlice = (uint8_t)firstRowInSlice;
@@ -290,7 +290,7 @@
 
     /* sequential memsets */
     m_partSet((uint8_t*)m_qp, (uint8_t)qp);
-    m_partSet(m_log2CUSize,   (uint8_t)g_maxLog2CUSize);
+    m_partSet(m_log2CUSize,   (uint8_t)m_slice->m_param->maxLog2CUSize);
     m_partSet(m_lumaIntraDir, (uint8_t)ALL_IDX);
     m_partSet(m_chromaIntraDir, (uint8_t)ALL_IDX);
     m_partSet(m_tqBypass,     (uint8_t)frame.m_encData->m_param->bLossless);
@@ -392,7 +392,7 @@
 
     memcpy(m_distortion + offset, subCU.m_distortion, childGeom.numPartitions * sizeof(sse_t));
 
-    uint32_t tmp = 1 << ((g_maxLog2CUSize - childGeom.depth) * 2);
+    uint32_t tmp = 1 << ((m_slice->m_param->maxLog2CUSize - childGeom.depth) * 2);
     uint32_t tmp2 = subPartIdx * tmp;
     memcpy(m_trCoeff[0] + tmp2, subCU.m_trCoeff[0], sizeof(coeff_t)* tmp);
 
@@ -491,7 +491,7 @@
 
     memcpy(ctu.m_distortion + m_absIdxInCTU, m_distortion, m_numPartitions * sizeof(sse_t));
 
-    uint32_t tmpY = 1 << ((g_maxLog2CUSize - depth) * 2);
+    uint32_t tmpY = 1 << ((m_slice->m_param->maxLog2CUSize - depth) * 2);
     uint32_t tmpY2 = m_absIdxInCTU << (LOG2_UNIT_SIZE * 2);
     memcpy(ctu.m_trCoeff[0] + tmpY2, m_trCoeff[0], sizeof(coeff_t)* tmpY);
 
@@ -570,7 +570,7 @@
     m_partCopy(ctu.m_tuDepth + m_absIdxInCTU, m_tuDepth);
     m_partCopy(ctu.m_cbf[0] + m_absIdxInCTU, m_cbf[0]);
 
-    uint32_t tmpY = 1 << ((g_maxLog2CUSize - depth) * 2);
+    uint32_t tmpY = 1 << ((m_slice->m_param->maxLog2CUSize - depth) * 2);
     uint32_t tmpY2 = m_absIdxInCTU << (LOG2_UNIT_SIZE * 2);
     memcpy(ctu.m_trCoeff[0] + tmpY2, m_trCoeff[0], sizeof(coeff_t)* tmpY);
 
@@ -2131,7 +2131,7 @@
                 cu->log2CUSize = log2CUSize;
                 cu->childOffset = childIdx - cuIdx;
                 cu->absPartIdx = g_depthScanIdx[yOffset][xOffset] * 4;
-                cu->numPartitions = (NUM_4x4_PARTITIONS >> ((g_maxLog2CUSize - cu->log2CUSize) * 2));
+                cu->numPartitions = (NUM_4x4_PARTITIONS >> ((g_log2Size[maxCUSize] - cu->log2CUSize) * 2));
                 cu->depth = g_log2Size[maxCUSize] - log2CUSize;
                 cu->geomRecurId = cuIdx;
 
diff -r 68b27c44790d -r 624374a3b21c source/common/frame.cpp
--- a/source/common/frame.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/common/frame.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -63,8 +63,8 @@
 
     if (param->bCTUInfo)
     {
-        uint32_t widthInCTU = (m_param->sourceWidth + param->maxCUSize - 1) >> g_maxLog2CUSize;
-        uint32_t heightInCTU = (m_param->sourceHeight +  param->maxCUSize - 1) >> g_maxLog2CUSize;
+        uint32_t widthInCTU = (m_param->sourceWidth + param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+        uint32_t heightInCTU = (m_param->sourceHeight +  param->maxCUSize - 1) >> m_param->maxLog2CUSize;
         uint32_t numCTUsInFrame = widthInCTU * heightInCTU;
         CHECKED_MALLOC_ZERO(m_addOnDepth, uint8_t *, numCTUsInFrame);
         CHECKED_MALLOC_ZERO(m_addOnCtuInfo, uint8_t *, numCTUsInFrame);
@@ -188,8 +188,8 @@
 
     if (m_ctuInfo)
     {
-        uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-        uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+        uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+        uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
         uint32_t numCUsInFrame = widthInCU * heightInCU;
         for (uint32_t i = 0; i < numCUsInFrame; i++)
         {
diff -r 68b27c44790d -r 624374a3b21c source/encoder/analysis.cpp
--- a/source/encoder/analysis.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/analysis.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -182,7 +182,7 @@
             memcpy(ctu.m_cuDepth, m_frame->m_addOnDepth[ctu.m_cuAddr], sizeof(uint8_t) * numPartition);
             //Calculate log2CUSize from depth
             for (uint32_t i = 0; i < cuGeom.numPartitions; i++)
-                ctu.m_log2CUSize[i] = (uint8_t)g_maxLog2CUSize - ctu.m_cuDepth[i];
+                ctu.m_log2CUSize[i] = (uint8_t)m_param->maxLog2CUSize - ctu.m_cuDepth[i];
         }
     }
 
@@ -265,7 +265,7 @@
             }
             //Calculate log2CUSize from depth
             for (uint32_t i = 0; i < cuGeom.numPartitions; i++)
-                ctu.m_log2CUSize[i] = (uint8_t)g_maxLog2CUSize - ctu.m_cuDepth[i];
+                ctu.m_log2CUSize[i] = (uint8_t)m_param->maxLog2CUSize - ctu.m_cuDepth[i];
 
             qprdRefine (ctu, cuGeom, qp, qp);
             return *m_modeDepth[0].bestMode;
diff -r 68b27c44790d -r 624374a3b21c source/encoder/api.cpp
--- a/source/encoder/api.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/api.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -361,8 +361,8 @@
 
     if (param->analysisMode)
     {
-        uint32_t widthInCU = (param->sourceWidth + param->maxCUSize - 1) >> g_maxLog2CUSize;
-        uint32_t heightInCU = (param->sourceHeight + param->maxCUSize - 1) >> g_maxLog2CUSize;
+        uint32_t widthInCU = (param->sourceWidth + param->maxCUSize - 1) >> param->maxLog2CUSize;
+        uint32_t heightInCU = (param->sourceHeight + param->maxCUSize - 1) >> param->maxLog2CUSize;
 
         uint32_t numCUsInFrame   = widthInCU * heightInCU;
         pic->analysisData.numCUsInFrame = numCUsInFrame;
diff -r 68b27c44790d -r 624374a3b21c source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/dpb.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -107,8 +107,8 @@
 
             if (curFrame->m_ctuInfo != NULL)
             {
-                uint32_t widthInCU = (curFrame->m_param->sourceWidth + curFrame->m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-                uint32_t heightInCU = (curFrame->m_param->sourceHeight + curFrame->m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+                uint32_t widthInCU = (curFrame->m_param->sourceWidth + curFrame->m_param->maxCUSize - 1) >> curFrame->m_param->maxLog2CUSize;
+                uint32_t heightInCU = (curFrame->m_param->sourceHeight + curFrame->m_param->maxCUSize - 1) >> curFrame->m_param->maxLog2CUSize;
                 uint32_t numCUsInFrame = widthInCU * heightInCU;
                 for (uint32_t i = 0; i < numCUsInFrame; i++)
                 {
diff -r 68b27c44790d -r 624374a3b21c source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/encoder.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -1109,8 +1109,8 @@
                 x265_analysis_data* analysis = &frameEnc->m_analysisData;
                 analysis->poc = frameEnc->m_poc;
                 analysis->sliceType = frameEnc->m_lowres.sliceType;
-                uint32_t widthInCU       = (m_param->sourceWidth  + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-                uint32_t heightInCU      = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+                uint32_t widthInCU       = (m_param->sourceWidth  + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+                uint32_t heightInCU      = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
 
                 uint32_t numCUsInFrame   = widthInCU * heightInCU;
                 analysis->numCUsInFrame  = numCUsInFrame;
@@ -1183,8 +1183,8 @@
 
 void Encoder::copyCtuInfo(x265_ctu_info_t** frameCtuInfo, int poc)
 {
-    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
     Frame* curFrame;
     Frame* prevFrame = NULL;
     int32_t* frameCTU;
@@ -1988,10 +1988,10 @@
     sps->numPartitions = NUM_4x4_PARTITIONS;
     sps->numPartInCUSize = 1 << g_unitSizeDepth;
 
-    sps->log2MinCodingBlockSize = g_maxLog2CUSize - g_maxCUDepth;
+    sps->log2MinCodingBlockSize = m_param->maxLog2CUSize - g_maxCUDepth;
     sps->log2DiffMaxMinCodingBlockSize = g_maxCUDepth;
     uint32_t maxLog2TUSize = (uint32_t)g_log2Size[m_param->maxTUSize];
-    sps->quadtreeTULog2MaxSize = X265_MIN(g_maxLog2CUSize, maxLog2TUSize);
+    sps->quadtreeTULog2MaxSize = X265_MIN((uint32_t)m_param->maxLog2CUSize, maxLog2TUSize);
     sps->quadtreeTULog2MinSize = 2;
     sps->quadtreeTUMaxDepthInter = m_param->tuQTMaxInterDepth;
     sps->quadtreeTUMaxDepthIntra = m_param->tuQTMaxIntraDepth;
@@ -2642,6 +2642,7 @@
             p->bHDROpt = 0;
         }
     }
+    p->maxLog2CUSize = g_log2Size[p->maxCUSize];
 }
 
 void Encoder::allocAnalysis(x265_analysis_data* analysis)
@@ -2773,8 +2774,8 @@
 {
     analysis->analysisFramedata = NULL;
     analysis2PassFrameData *analysisFrameData = (analysis2PassFrameData*)analysis->analysisFramedata;
-    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
 
     uint32_t numCUsInFrame = widthInCU * heightInCU;
     CHECKED_MALLOC_ZERO(analysisFrameData, analysis2PassFrameData, 1);
@@ -3075,8 +3076,8 @@
 }\
 
     uint32_t depthBytes = 0;
-    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
     uint32_t numCUsInFrame = widthInCU * heightInCU;
 
     int poc; uint32_t frameRecordSize;
@@ -3385,8 +3386,8 @@
 }\
 
     uint32_t depthBytes = 0;
-    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
-    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;
     uint32_t numCUsInFrame = widthInCU * heightInCU;
     analysis2PassFrameData* analysisFrameData = (analysis2PassFrameData*)analysis2Pass->analysisFramedata;
 
diff -r 68b27c44790d -r 624374a3b21c source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/frameencoder.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -1366,8 +1366,8 @@
                 cuStat.baseQp = curEncData.m_rowStat[row].rowQp;
 
             /* TODO: use defines from slicetype.h for lowres block size */
-            uint32_t block_y = (ctu->m_cuPelY >> g_maxLog2CUSize) * noOfBlocks;
-            uint32_t block_x = (ctu->m_cuPelX >> g_maxLog2CUSize) * noOfBlocks;
+            uint32_t block_y = (ctu->m_cuPelY >> m_param->maxLog2CUSize) * noOfBlocks;
+            uint32_t block_x = (ctu->m_cuPelX >> m_param->maxLog2CUSize) * noOfBlocks;
             
             cuStat.vbvCost = 0;
             cuStat.intraVbvCost = 0;
diff -r 68b27c44790d -r 624374a3b21c source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/encoder/sao.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -791,9 +791,9 @@
         // WARNING: *) May read beyond bound on video than ctuWidth or ctuHeight is NOT multiple of cuSize
         X265_CHECK((ctuWidth == ctuHeight) || (m_chromaFormat != X265_CSP_I420), "video size check failure\n");
         if (plane)
-            primitives.chroma[m_chromaFormat].cu[g_maxLog2CUSize - 2].sub_ps(diff, MAX_CU_SIZE, fenc0, rec0, stride, stride);
+            primitives.chroma[m_chromaFormat].cu[m_param->maxLog2CUSize - 2].sub_ps(diff, MAX_CU_SIZE, fenc0, rec0, stride, stride);
         else
-           primitives.cu[g_maxLog2CUSize - 2].sub_ps(diff, MAX_CU_SIZE, fenc0, rec0, stride, stride);
+           primitives.cu[m_param->maxLog2CUSize - 2].sub_ps(diff, MAX_CU_SIZE, fenc0, rec0, stride, stride);
     }
     else
     {
diff -r 68b27c44790d -r 624374a3b21c source/x265-extras.cpp
--- a/source/x265-extras.cpp	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/x265-extras.cpp	Mon Jun 12 17:21:57 2017 +0530
@@ -116,7 +116,7 @@
                 {
                     /* PU statistics */
                     size = param.maxCUSize;
-                    for (uint32_t i = 0; i< g_maxLog2CUSize - (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
+                    for (uint32_t i = 0; i< param.maxLog2CUSize - (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
                     {
                         fprintf(csvfp, ", Intra %dx%d", size, size);
                         fprintf(csvfp, ", Skip %dx%d", size, size);
@@ -224,7 +224,7 @@
 
     if (level >= 2)
     {
-        for (uint32_t i = 0; i < g_maxLog2CUSize - (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
+        for (uint32_t i = 0; i < param.maxLog2CUSize - (uint32_t)g_log2Size[param.minCUSize] + 1; i++)
         {
             fprintf(csvfp, ", %.2lf%%", frameStats->puStats.percentIntraPu[i]);
             fprintf(csvfp, ", %.2lf%%", frameStats->puStats.percentSkipPu[i]);
diff -r 68b27c44790d -r 624374a3b21c source/x265.h
--- a/source/x265.h	Wed Jun 21 11:05:02 2017 +0530
+++ b/source/x265.h	Mon Jun 12 17:21:57 2017 +0530
@@ -1459,6 +1459,8 @@
     /* Enable motion vector refinement in load mode*/
     int       mvRefine;
 
+    /* Log of maximum CTU size */
+    uint32_t  maxLog2CUSize;
 } x265_param;
 
 /* x265_param_alloc:


More information about the x265-devel mailing list