[x265-commits] [x265] entropy: simplify EstBitsSbac

Steve Borho steve at borho.org
Mon Aug 18 22:21:28 CEST 2014


details:   http://hg.videolan.org/x265/rev/b37e0a8471ca
branches:  
changeset: 7821:b37e0a8471ca
user:      Steve Borho <steve at borho.org>
date:      Sun Aug 17 03:54:49 2014 -0500
description:
entropy: simplify EstBitsSbac

There was no reason for significantBits to be a different type than all the
other fix15 bit costs. And NUM_QT_ROOT_CBF_CTX is 1
Subject: [x265] entropy: pass bIsLuma to estBit() instead of limited TextType range

details:   http://hg.videolan.org/x265/rev/92d07932c93c
branches:  
changeset: 7822:92d07932c93c
user:      Steve Borho <steve at borho.org>
date:      Sun Aug 17 04:02:31 2014 -0500
description:
entropy: pass bIsLuma to estBit() instead of limited TextType range

if the only options were TEXT_LUMA or TEXT_CHROMA, it is better to use a
bool argument and avoid ambiguity about TEXT_CHROMA_U or TEXT_CHROMA_V
Subject: [x265] quant: combine psy-rdoq scale and lambda into one variable

details:   http://hg.videolan.org/x265/rev/21506c40f704
branches:  
changeset: 7823:21506c40f704
user:      Steve Borho <steve at borho.org>
date:      Sun Aug 17 04:25:47 2014 -0500
description:
quant: combine psy-rdoq scale and lambda into one variable

Reduces the number of 64bit multiplies required per psy-value
evaluation
Subject: [x265] param: typo

details:   http://hg.videolan.org/x265/rev/b8356365135e
branches:  stable
changeset: 7824:b8356365135e
user:      Steve Borho <steve at borho.org>
date:      Mon Aug 18 14:05:02 2014 -0500
description:
param: typo
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/529ccfbed281
branches:  
changeset: 7825:529ccfbed281
user:      Steve Borho <steve at borho.org>
date:      Mon Aug 18 14:05:15 2014 -0500
description:
Merge with stable
Subject: [x265] encoder: fix deadlocks/crashes when picture is a single CTU row

details:   http://hg.videolan.org/x265/rev/eb2b3e34ea0d
branches:  stable
changeset: 7826:eb2b3e34ea0d
user:      Steve Borho <steve at borho.org>
date:      Mon Aug 18 15:08:27 2014 -0500
description:
encoder: fix deadlocks/crashes when picture is a single CTU row

1. if only one row per frame, disable WPP it is pointless
2. if only one row per frame, frame parallelism is (mostly) impossible
3. clamp rateControlUpdateStats() to be within row count range

diffstat:

 doc/reST/introduction.rst                          |    4 +-
 source/Lib/TLibCommon/TComDataCU.cpp               |   75 ++--
 source/Lib/TLibCommon/TComDataCU.h                 |    9 +-
 source/Lib/TLibCommon/TComPattern.cpp              |    4 +-
 source/Lib/TLibCommon/TComPicSym.cpp               |   14 +-
 source/Lib/TLibCommon/TComPicSym.h                 |    7 +
 source/Lib/TLibCommon/TComPicYuv.cpp               |   15 +-
 source/Lib/TLibCommon/TComPicYuv.h                 |    2 +-
 source/Lib/TLibCommon/TComRom.cpp                  |   42 +-
 source/Lib/TLibCommon/TComRom.h                    |   22 +-
 source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp |    5 +-
 source/Lib/TLibEncoder/TEncSearch.cpp              |   48 +-
 source/common/deblock.cpp                          |   31 +-
 source/common/deblock.h                            |    2 +-
 source/common/frame.cpp                            |    4 +-
 source/common/frame.h                              |    4 +
 source/common/param.cpp                            |   28 +-
 source/common/slice.h                              |    1 +
 source/encoder/analysis.cpp                        |  344 ++++++++++++++------
 source/encoder/analysis.h                          |   32 +-
 source/encoder/cturow.cpp                          |    8 +-
 source/encoder/cturow.h                            |   20 +-
 source/encoder/encoder.cpp                         |   60 ++-
 source/encoder/encoder.h                           |    1 +
 source/encoder/entropy.cpp                         |  151 +--------
 source/encoder/entropy.h                           |    6 +-
 source/encoder/frameencoder.cpp                    |   57 ++-
 source/encoder/frameencoder.h                      |    1 -
 28 files changed, 541 insertions(+), 456 deletions(-)

diffs (truncated from 2399 to 300 lines):

diff -r 13651e65b820 -r eb2b3e34ea0d doc/reST/introduction.rst
--- a/doc/reST/introduction.rst	Mon Aug 18 13:46:39 2014 -0500
+++ b/doc/reST/introduction.rst	Mon Aug 18 15:08:27 2014 -0500
@@ -74,8 +74,8 @@ executable software created from the x26
 responsible for understanding the laws in your country, and for
 licensing all applicable patent rights needed for use or distribution of
 software applications created from the x265 source code.  A good place
-to start is with the `Motion Picture Experts Group - Licensing Authority
-- HEVC Licensing Program<http://www.mpegla.com/main/PID/HEVC/default.aspx>`_.
+to start is with the Motion Picture Experts Group - Licensing Authority
+- HEVC Licensing Program.
 
 x265 is a registered trademark of MulticoreWare, Inc.  The x265 logo is
 a trademark of MulticoreWare, and may only be used with explicit written
diff -r 13651e65b820 -r eb2b3e34ea0d source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Mon Aug 18 13:46:39 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Mon Aug 18 15:08:27 2014 -0500
@@ -129,7 +129,7 @@ fail:
     return ok;
 }
 
-void TComDataCU::create(TComDataCU *cu, uint32_t numPartition, uint32_t cuSize, int csp, int index, bool isLossless)
+void TComDataCU::create(TComDataCU *cu, uint32_t numPartition, uint32_t cuSize, int unitSize, int csp, int index, bool isLossless)
 {
     m_hChromaShift = CHROMA_H_SHIFT(csp);
     m_vChromaShift = CHROMA_V_SHIFT(csp);
@@ -139,6 +139,12 @@ void TComDataCU::create(TComDataCU *cu, 
     m_slice         = NULL;
     m_numPartitions = numPartition;
 
+    uint32_t tmp = 4 * AMVP_DECIMATION_FACTOR / unitSize;
+    tmp = tmp * tmp;
+    X265_CHECK(tmp == (1 << (g_log2Size[tmp])), "unexpected pixel count\n");
+    tmp = g_log2Size[tmp];
+    m_unitMask = ~((1 << tmp) - 1);
+
     uint32_t sizeL = cuSize * cuSize;
     uint32_t sizeC = sizeL >> (m_hChromaShift + m_vChromaShift);
 
@@ -571,7 +577,7 @@ void TComDataCU::copyPartFrom(TComDataCU
 
 // Copy current predicted part to a CU in picture.
 // It is used to predict for next part
-void TComDataCU::copyToPic(uint32_t depth)
+void TComDataCU::copyToPic(uint8_t depth)
 {
     TComDataCU* cu = m_pic->getCU(m_cuAddr);
 
@@ -616,7 +622,7 @@ void TComDataCU::copyToPic(uint32_t dept
     m_cuMvField[1].copyTo(cu->getCUMvField(REF_PIC_LIST_1), m_absIdxInLCU);
 
     uint32_t tmpY  = 1 << ((g_maxLog2CUSize - depth) * 2);
-    uint32_t tmpY2 = m_absIdxInLCU << LOG2_UNIT_SIZE * 2;
+    uint32_t tmpY2 = m_absIdxInLCU << m_pic->getLog2UnitSize() * 2;
     memcpy(cu->getCoeffY() + tmpY2, m_trCoeff[0], sizeof(coeff_t) * tmpY);
 
     uint32_t tmpC  = tmpY  >> (m_hChromaShift + m_vChromaShift);
@@ -627,7 +633,7 @@ void TComDataCU::copyToPic(uint32_t dept
     if (m_slice->m_pps->bTransquantBypassEnabled)
     {
         uint32_t tmp  = 1 << ((g_maxLog2CUSize - depth) * 2);
-        uint32_t tmp2 = m_absIdxInLCU << LOG2_UNIT_SIZE * 2;
+        uint32_t tmp2 = m_absIdxInLCU << m_pic->getLog2UnitSize() * 2;
         memcpy(cu->getLumaOrigYuv() + tmp2, m_tqBypassOrigYuv[0], sizeof(pixel) * tmp);
 
         memcpy(cu->getChromaOrigYuv(1) + tmpC2, m_tqBypassOrigYuv[1], sizeof(pixel) * tmpC);
@@ -635,7 +641,7 @@ void TComDataCU::copyToPic(uint32_t dept
     }
 }
 
-void TComDataCU::copyCodedToPic(uint32_t depth)
+void TComDataCU::copyCodedToPic(uint8_t depth)
 {
     TComDataCU* cu = m_pic->getCU(m_cuAddr);
 
@@ -654,7 +660,7 @@ void TComDataCU::copyCodedToPic(uint32_t
     memcpy(cu->getCbf(TEXT_CHROMA_V) + m_absIdxInLCU, m_cbf[2], sizeInChar);
 
     uint32_t tmpY  = 1 << ((g_maxLog2CUSize - depth) * 2);
-    uint32_t tmpY2 = m_absIdxInLCU << LOG2_UNIT_SIZE * 2;
+    uint32_t tmpY2 = m_absIdxInLCU << m_pic->getLog2UnitSize() * 2;
     memcpy(cu->getCoeffY() + tmpY2, m_trCoeff[0], sizeof(coeff_t) * tmpY);
     tmpY  >>= m_hChromaShift + m_vChromaShift;
     tmpY2 >>= m_hChromaShift + m_vChromaShift;
@@ -662,7 +668,7 @@ void TComDataCU::copyCodedToPic(uint32_t
     memcpy(cu->m_trCoeff[2] + tmpY2, m_trCoeff[2], sizeof(coeff_t) * tmpY);
 }
 
-void TComDataCU::copyToPic(uint32_t depth, uint32_t partIdx, uint32_t partDepth)
+void TComDataCU::copyToPic(uint8_t depth, uint32_t partIdx, uint32_t partDepth)
 {
     TComDataCU* cu = m_pic->getCU(m_cuAddr);
     uint32_t qNumPart  = m_numPartitions >> (partDepth << 1);
@@ -707,7 +713,7 @@ void TComDataCU::copyToPic(uint32_t dept
     m_cuMvField[1].copyTo(cu->getCUMvField(REF_PIC_LIST_1), m_absIdxInLCU, partStart, qNumPart);
 
     uint32_t tmpY  = 1 << ((g_maxLog2CUSize - depth - partDepth) * 2);
-    uint32_t tmpY2 = partOffset << LOG2_UNIT_SIZE * 2;
+    uint32_t tmpY2 = partOffset << m_pic->getLog2UnitSize() * 2;
     memcpy(cu->getCoeffY() + tmpY2, m_trCoeff[0],  sizeof(coeff_t) * tmpY);
 
     uint32_t tmpC  = tmpY >> (m_hChromaShift + m_vChromaShift);
@@ -819,7 +825,7 @@ TComDataCU* TComDataCU::getPUAboveRight(
     uint32_t absPartIdxRT    = g_zscanToRaster[curPartUnitIdx];
     uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + m_pic->getUnitSize()) >= m_slice->m_sps->picWidthInLumaSamples)
         return NULL;
 
     if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUSize - 1, numPartInCUSize))
@@ -828,7 +834,7 @@ TComDataCU* TComDataCU::getPUAboveRight(
         {
             if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUSize + 1])
             {
-                uint32_t absZorderCUIdx  = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
+                uint32_t absZorderCUIdx  = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1;
                 arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUSize + 1];
                 if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUSize))
                 {
@@ -859,7 +865,7 @@ TComDataCU* TComDataCU::getPUBelowLeft(u
 {
     uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + m_pic->getUnitSize()) >= m_slice->m_sps->picHeightInLumaSamples)
     {
         return NULL;
     }
@@ -872,7 +878,7 @@ TComDataCU* TComDataCU::getPUBelowLeft(u
         {
             if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + numPartInCUSize - 1])
             {
-                uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) * m_pic->getNumPartInCUSize();
+                uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1) * m_pic->getNumPartInCUSize();
                 blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUSize - 1];
                 if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUSize))
                 {
@@ -897,7 +903,7 @@ TComDataCU* TComDataCU::getPUBelowLeftAd
 {
     uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (partUnitOffset << m_pic->getLog2UnitSize())) >=
         m_slice->m_sps->picHeightInLumaSamples)
     {
         return NULL;
@@ -911,7 +917,7 @@ TComDataCU* TComDataCU::getPUBelowLeftAd
         {
             if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUSize - 1])
             {
-                uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1) * m_pic->getNumPartInCUSize();
+                uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1) * m_pic->getNumPartInCUSize();
                 blPartUnitIdx = g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUSize - 1];
                 if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUSize))
                 {
@@ -940,7 +946,7 @@ TComDataCU* TComDataCU::getPUAboveRightA
 {
     uint32_t absPartIdxRT    = g_zscanToRaster[curPartUnitIdx];
 
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (partUnitOffset << LOG2_UNIT_SIZE)) >=
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (partUnitOffset << m_pic->getLog2UnitSize())) >=
         m_slice->m_sps->picWidthInLumaSamples)
     {
         return NULL;
@@ -954,7 +960,7 @@ TComDataCU* TComDataCU::getPUAboveRightA
         {
             if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset])
             {
-                uint32_t absZorderCUIdx  = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1;
+                uint32_t absZorderCUIdx  = g_zscanToRaster[m_absIdxInLCU] + (1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1;
                 arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset];
                 if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUSize))
                 {
@@ -998,7 +1004,8 @@ TComDataCU* TComDataCU::getPUAboveRightA
 TComDataCU* TComDataCU::getQpMinCuLeft(uint32_t& lPartUnitIdx, uint32_t curAbsIdxInLCU)
 {
     uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
-    uint32_t absZorderQpMinCUIdx = curAbsIdxInLCU & (0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
+    uint32_t absZorderQpMinCUIdx = (curAbsIdxInLCU >> ((g_maxCUDepth - m_slice->m_pps->maxCuDQPDepth) << 1)) <<
+        ((g_maxCUDepth - m_slice->m_pps->maxCuDQPDepth) << 1);
     uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
 
     // check for left LCU boundary
@@ -1022,7 +1029,8 @@ TComDataCU* TComDataCU::getQpMinCuLeft(u
 TComDataCU* TComDataCU::getQpMinCuAbove(uint32_t& aPartUnitIdx, uint32_t curAbsIdxInLCU)
 {
     uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
-    uint32_t absZorderQpMinCUIdx = curAbsIdxInLCU & (0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2);
+    uint32_t absZorderQpMinCUIdx = (curAbsIdxInLCU >> ((g_maxCUDepth - m_slice->m_pps->maxCuDQPDepth) << 1)) <<
+        ((g_maxCUDepth - m_slice->m_pps->maxCuDQPDepth) << 1);
     uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
 
     // check for top LCU boundary
@@ -1066,7 +1074,7 @@ int TComDataCU::getLastValidPartIdx(int 
 
 char TComDataCU::getLastCodedQP(uint32_t absPartIdx)
 {
-    uint32_t quPartIdxMask = 0xFF << (g_maxFullDepth - m_slice->m_pps->maxCuDQPDepth) * 2;
+    uint32_t quPartIdxMask = ~((1 << ((g_maxCUDepth - m_slice->m_pps->maxCuDQPDepth) << 1)) - 1);
     int lastValidPartIdx = getLastValidPartIdx(absPartIdx & quPartIdxMask);
 
     if (lastValidPartIdx >= 0)
@@ -1518,7 +1526,7 @@ void TComDataCU::getMvField(TComDataCU* 
 void TComDataCU::deriveLeftRightTopIdx(uint32_t partIdx, uint32_t& ruiPartIdxLT, uint32_t& ruiPartIdxRT)
 {
     ruiPartIdxLT = m_absIdxInLCU;
-    ruiPartIdxRT = g_rasterToZscan[g_zscanToRaster[ruiPartIdxLT] + (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1];
+    ruiPartIdxRT = g_rasterToZscan[g_zscanToRaster[ruiPartIdxLT] + (1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1];
 
     switch (m_partSizes[0])
     {
@@ -1559,7 +1567,7 @@ void TComDataCU::deriveLeftRightTopIdx(u
 
 void TComDataCU::deriveLeftBottomIdx(uint32_t partIdx, uint32_t& outPartIdxLB)
 {
-    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) * m_pic->getNumPartInCUSize()];
+    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + ((1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize() - 1)) - 1) * m_pic->getNumPartInCUSize()];
 
     switch (m_partSizes[0])
     {
@@ -1601,8 +1609,8 @@ void TComDataCU::deriveLeftBottomIdx(uin
 void TComDataCU::deriveRightBottomIdx(uint32_t partIdx, uint32_t& outPartIdxRB)
 {
     outPartIdxRB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] +
-                                   ((1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - 1)) - 1) * m_pic->getNumPartInCUSize() +
-                                   (1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE)) - 1];
+                                   ((1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize() - 1)) - 1) * m_pic->getNumPartInCUSize() +
+                                   (1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize())) - 1];
 
     switch (m_partSizes[0])
     {
@@ -1638,7 +1646,7 @@ void TComDataCU::deriveRightBottomIdx(ui
 
 void TComDataCU::deriveLeftRightTopIdxAdi(uint32_t& outPartIdxLT, uint32_t& outPartIdxRT, uint32_t partOffset, uint32_t partDepth)
 {
-    uint32_t numPartInWidth = 1 << (m_log2CUSize[0] - LOG2_UNIT_SIZE - partDepth);
+    uint32_t numPartInWidth = 1 << (m_log2CUSize[0] - m_pic->getLog2UnitSize() - partDepth);
 
     outPartIdxLT = m_absIdxInLCU + partOffset;
     outPartIdxRT = g_rasterToZscan[g_zscanToRaster[outPartIdxLT] + numPartInWidth - 1];
@@ -1829,10 +1837,10 @@ void TComDataCU::getInterMergeCandidates
         int refIdx;
         int lcuIdx = -1;
 
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxTmp] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
+        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxTmp] + m_pic->getUnitSize()) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
         {
         }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxTmp] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
+        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxTmp] + m_pic->getUnitSize()) >= m_slice->m_sps->picHeightInLumaSamples)
         {
         }
         else
@@ -2099,10 +2107,10 @@ int TComDataCU::fillMvpCand(uint32_t par
         //----  co-located RightBottom Temporal Predictor (H) ---//
         absPartIdx = g_zscanToRaster[partIdxRB];
         int lcuIdx = -1;
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdx] + UNIT_SIZE) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
+        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdx] + m_pic->getUnitSize()) >= m_slice->m_sps->picWidthInLumaSamples)  // image boundary check
         {
         }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdx] + UNIT_SIZE) >= m_slice->m_sps->picHeightInLumaSamples)
+        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdx] + m_pic->getUnitSize()) >= m_slice->m_sps->picHeightInLumaSamples)
         {
         }
         else
@@ -2334,7 +2342,7 @@ bool TComDataCU::xAddMVPCandOrder(MV& ou
  */
 bool TComDataCU::xGetColMVP(int picList, int cuAddr, int partUnitIdx, MV& outMV, int& outRefIdx)
 {
-    uint32_t absPartAddr = partUnitIdx & TMVP_UNIT_MASK;
+    uint32_t absPartAddr = partUnitIdx & m_unitMask;
 
     int colRefPicList;
     int colPOC, colRefPOC, curPOC, curRefPOC, scale;
@@ -2416,8 +2424,8 @@ void TComDataCU::xDeriveCenterIdx(uint32
 
     outPartIdxCenter = m_absIdxInLCU + partAddr; // partition origin.
     outPartIdxCenter = g_rasterToZscan[g_zscanToRaster[outPartIdxCenter]
-                                       + (partHeight >> (LOG2_UNIT_SIZE + 1)) * m_pic->getNumPartInCUSize()
-                                       + (partWidth  >> (LOG2_UNIT_SIZE + 1))];
+                                       + (partHeight >> (m_pic->getLog2UnitSize() + 1)) * m_pic->getNumPartInCUSize()
+                                       + (partWidth  >> (m_pic->getLog2UnitSize() + 1))];
 }
 
 ScanType TComDataCU::getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra)
@@ -2444,7 +2452,8 @@ ScanType TComDataCU::getCoefScanIdx(uint
         dirMode = getChromaIntraDir(absPartIdx);
         if (dirMode == DM_CHROMA_IDX)
         {
-            dirMode = getLumaIntraDir((m_chromaFormat == X265_CSP_I444) ? absPartIdx : absPartIdx & 0xFC);
+            uint32_t lumaLCUIdx = (m_chromaFormat == X265_CSP_I444) ? absPartIdx : absPartIdx & (~((1 << (2 * g_addCUDepth)) - 1));
+            dirMode = getLumaIntraDir(lumaLCUIdx);
             dirMode = (m_chromaFormat == X265_CSP_I422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
         }
     }
@@ -2481,7 +2490,7 @@ void TComDataCU::getTUEntropyCodingParam
 
 uint32_t TComDataCU::getSCUAddr()


More information about the x265-commits mailing list