[x265-commits] [x265] ratecontrol: Fix initial I-slice QP for 10-bit CRF mode.

Deepthi Nandakumar deepthi at multicorewareinc.com
Mon Apr 14 21:06:56 CEST 2014


details:   http://hg.videolan.org/x265/rev/a622c4bfc688
branches:  
changeset: 6697:a622c4bfc688
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Sat Apr 12 19:18:15 2014 +0530
description:
ratecontrol: Fix initial I-slice QP for 10-bit CRF mode.
Subject: [x265] Modify TEncSearch structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/0454675dbaf7
branches:  
changeset: 6698:0454675dbaf7
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:19:58 2014 +0530
description:
Modify TEncSearch structure to support 422 color space format
Subject: [x265] Modify TEncSbac and TEncEntropy structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/aa0c458ede27
branches:  
changeset: 6699:aa0c458ede27
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:23:17 2014 +0530
description:
Modify TEncSbac and TEncEntropy structure to support 422 color space format
Subject: [x265] Modify TComYuv and TShortYuv structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/ff3892c00318
branches:  
changeset: 6700:ff3892c00318
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:26:18 2014 +0530
description:
Modify TComYuv and TShortYuv structure to support 422 color space format
Subject: [x265] Modify TComRom and TComPattern structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/abf05dab1844
branches:  
changeset: 6701:abf05dab1844
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:28:53 2014 +0530
description:
Modify TComRom and TComPattern structure to support 422 color space format
Subject: [x265] Modify TComLoopFilter structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/74ab24517d0e
branches:  
changeset: 6702:74ab24517d0e
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:30:43 2014 +0530
description:
Modify TComLoopFilter structure to support 422 color space format
Subject: [x265] Modify TComDataCU structure to support 422 color space format

details:   http://hg.videolan.org/x265/rev/3a9c1fc2b742
branches:  
changeset: 6703:3a9c1fc2b742
user:      ashok at multicorewareinc.com
date:      Sat Apr 12 18:34:20 2014 +0530
description:
Modify TComDataCU structure to support 422 color space format
Subject: [x265] x265: adding support for i422 in the help command

details:   http://hg.videolan.org/x265/rev/ae8f99512774
branches:  
changeset: 6704:ae8f99512774
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Mon Apr 14 16:38:08 2014 +0530
description:
x265: adding support for i422 in the help command
Subject: [x265] encoder: weightP not supported yet for 444 and 422.

details:   http://hg.videolan.org/x265/rev/6d4f0673c386
branches:  
changeset: 6705:6d4f0673c386
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Mon Apr 14 16:38:26 2014 +0530
description:
encoder: weightP not supported yet for 444 and 422.
Subject: [x265] encoder: nits

details:   http://hg.videolan.org/x265/rev/9f0f011294bd
branches:  
changeset: 6706:9f0f011294bd
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Mon Apr 14 16:44:14 2014 +0530
description:
encoder: nits
Subject: [x265] rest: update colorspace docs

details:   http://hg.videolan.org/x265/rev/b89d85f10bc4
branches:  
changeset: 6707:b89d85f10bc4
user:      Steve Borho <steve at borho.org>
date:      Mon Apr 14 13:16:52 2014 -0500
description:
rest: update colorspace docs
Subject: [x265] param: reintroduce range checks of internalCsp

details:   http://hg.videolan.org/x265/rev/e62e96cf506d
branches:  
changeset: 6708:e62e96cf506d
user:      Steve Borho <steve at borho.org>
date:      Mon Apr 14 13:17:17 2014 -0500
description:
param: reintroduce range checks of internalCsp
Subject: [x265] TComDataCU: white-space nits

details:   http://hg.videolan.org/x265/rev/488b81a7f1c6
branches:  
changeset: 6709:488b81a7f1c6
user:      Steve Borho <steve at borho.org>
date:      Mon Apr 14 13:17:37 2014 -0500
description:
TComDataCU: white-space nits
Subject: [x265] pixel: remove out-of-range chroma copy function assignments

details:   http://hg.videolan.org/x265/rev/08d64a70594e
branches:  
changeset: 6710:08d64a70594e
user:      Steve Borho <steve at borho.org>
date:      Mon Apr 14 13:18:18 2014 -0500
description:
pixel: remove out-of-range chroma copy function assignments

diffstat:

 doc/reST/cli.rst                         |     6 +-
 source/Lib/TLibCommon/TComDataCU.cpp     |    25 +-
 source/Lib/TLibCommon/TComDataCU.h       |     4 +-
 source/Lib/TLibCommon/TComLoopFilter.cpp |    32 +-
 source/Lib/TLibCommon/TComPattern.cpp    |   253 ++---
 source/Lib/TLibCommon/TComPattern.h      |     4 +-
 source/Lib/TLibCommon/TComRom.cpp        |     5 +-
 source/Lib/TLibCommon/TComRom.h          |     1 +
 source/Lib/TLibCommon/TComYuv.cpp        |     8 +-
 source/Lib/TLibCommon/TComYuv.h          |    27 +-
 source/Lib/TLibCommon/TypeDef.h          |     1 +
 source/Lib/TLibEncoder/TEncEntropy.cpp   |   140 ++-
 source/Lib/TLibEncoder/TEncEntropy.h     |    29 +-
 source/Lib/TLibEncoder/TEncSbac.cpp      |    63 +-
 source/Lib/TLibEncoder/TEncSbac.h        |     2 +-
 source/Lib/TLibEncoder/TEncSearch.cpp    |  1267 +++++++++++++++++------------
 source/Lib/TLibEncoder/TEncSearch.h      |    34 +-
 source/common/ipfilter.cpp               |    43 +
 source/common/param.cpp                  |     5 +-
 source/common/pixel.cpp                  |    46 +-
 source/common/shortyuv.cpp               |    11 +-
 source/common/shortyuv.h                 |    27 +-
 source/encoder/encoder.cpp               |     4 +-
 source/encoder/ratecontrol.cpp           |    12 +-
 source/x265.cpp                          |     8 +-
 25 files changed, 1250 insertions(+), 807 deletions(-)

diffs (truncated from 3452 to 300 lines):

diff -r 483e5077a6b7 -r 08d64a70594e doc/reST/cli.rst
--- a/doc/reST/cli.rst	Fri Apr 11 21:51:01 2014 -0500
+++ b/doc/reST/cli.rst	Mon Apr 14 13:18:18 2014 -0500
@@ -175,8 +175,10 @@ Input Options
 
 .. option:: --input-csp <integer|string>
 
-	YUV only: Source color space. Only i420 and i444 are supported at
-	this time.
+	YUV only: Source color space. Only i420, i422, and i444 are
+	supported at this time. The internal color space is always the
+	same as the source color space (libx265 does not support any color
+	space conversions).
 
 	0. i400
 	1. i420 **(default)**
diff -r 483e5077a6b7 -r 08d64a70594e source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Fri Apr 11 21:51:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Mon Apr 14 13:18:18 2014 -0500
@@ -510,7 +510,6 @@ void TComDataCU::initSubCU(TComDataCU* c
     m_cuAboveRight  = cu->getCUAboveRight();
 }
 
-
 void TComDataCU::copyToSubCU(TComDataCU* cu, uint32_t partUnitIdx, uint32_t depth)
 {
     assert(partUnitIdx < 4);
@@ -1353,6 +1352,11 @@ void TComDataCU::setCbfSubParts(uint32_t
     setSubPart<uint8_t>(uiCbf, m_cbf[ttype], absPartIdx, depth, partIdx);
 }
 
+void TComDataCU::setCbfPartRange (uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes)
+{
+    memset(m_cbf[ttype] + absPartIdx, cbf, sizeof(uint8_t) * coveredPartIdxes);
+}
+
 void TComDataCU::setDepthSubParts(uint32_t depth)
 {
     /*All 4x4 partitions in current CU have the CU depth saved*/
@@ -1568,6 +1572,11 @@ void TComDataCU::setTransformSkipSubPart
     memset(m_transformSkip[ttype] + absPartIdx, useTransformSkip, sizeof(uint8_t) * curPartNum);
 }
 
+void TComDataCU::setTransformSkipPartRange(uint32_t useTransformSkip, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes)
+{
+    memset(m_transformSkip[ttype] + absPartIdx, useTransformSkip, sizeof(uint8_t) * coveredPartIdxes);
+}
+
 uint8_t TComDataCU::getNumPartInter()
 {
     uint8_t numPart = 0;
@@ -1898,16 +1907,6 @@ void TComDataCU::deriveLeftRightTopIdxAd
     outPartIdxRT = g_rasterToZscan[g_zscanToRaster[outPartIdxLT] + numPartInWidth - 1];
 }
 
-void TComDataCU::deriveLeftBottomIdxAdi(uint32_t& outPartIdxLB, uint32_t partOffset, uint32_t partDepth)
-{
-    uint32_t absIdx;
-    uint32_t numPartInWidth = m_cuSize[0] >> (m_pic->getLog2UnitSize() + partDepth);
-
-    absIdx        = getZorderIdxInCU() + partOffset + (m_numPartitions >> (partDepth << 1)) - 1;
-    absIdx        = g_zscanToRaster[absIdx] - (numPartInWidth - 1);
-    outPartIdxLB    = g_rasterToZscan[absIdx];
-}
-
 bool TComDataCU::hasEqualMotion(uint32_t absPartIdx, TComDataCU* candCU, uint32_t candAbsPartIdx)
 {
     if (getInterDir(absPartIdx) != candCU->getInterDir(candAbsPartIdx))
@@ -2889,7 +2888,9 @@ uint32_t TComDataCU::getCoefScanIdx(uint
         dirMode  = getChromaIntraDir(absPartIdx);
         if (dirMode == DM_CHROMA_IDX)
         {
-            dirMode = getLumaIntraDir(absPartIdx);
+            uint32_t lumaLCUIdx  = (m_chromaFormat == CHROMA_444) ? absPartIdx : absPartIdx & (~((1<<(2*g_addCUDepth))-1));
+            dirMode = getLumaIntraDir(lumaLCUIdx );
+            dirMode = (m_chromaFormat == CHROMA_422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
         }
         // TODO: 4:2:2
     }
diff -r 483e5077a6b7 -r 08d64a70594e source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Fri Apr 11 21:51:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.h	Mon Apr 14 13:18:18 2014 -0500
@@ -303,6 +303,8 @@ public:
     void          setCbfSubParts(uint32_t cbfY, uint32_t cbfU, uint32_t cbfV, uint32_t absPartIdx, uint32_t depth);
     void          setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t depth);
     void          setCbfSubParts(uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t partIdx, uint32_t depth);
+    void          setCbfPartRange (uint32_t cbf, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes);
+    void          setTransformSkipPartRange(uint32_t useTransformSkip, TextType ttype, uint32_t absPartIdx, uint32_t coveredPartIdxes);
 
     // -------------------------------------------------------------------------------------------------------------------
     // member functions for coding tool information
@@ -408,9 +410,7 @@ public:
 
     void          deriveLeftRightTopIdx(uint32_t partIdx, uint32_t& partIdxLT, uint32_t& partIdxRT);
     void          deriveLeftBottomIdx(uint32_t partIdx, uint32_t& partIdxLB);
-
     void          deriveLeftRightTopIdxAdi(uint32_t& partIdxLT, uint32_t& partIdxRT, uint32_t partOffset, uint32_t partDepth);
-    void          deriveLeftBottomIdxAdi(uint32_t& partIdxLB, uint32_t partOffset, uint32_t partDepth);
 
     bool          hasEqualMotion(uint32_t absPartIdx, TComDataCU* candCU, uint32_t candAbsPartIdx);
     void          getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, TComMvField* mFieldNeighbours, uint8_t* interDirNeighbours, int& numValidMergeCand);
diff -r 483e5077a6b7 -r 08d64a70594e source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Fri Apr 11 21:51:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Mon Apr 14 13:18:18 2014 -0500
@@ -640,7 +640,8 @@ void TComLoopFilter::xEdgeFilterChroma(T
     int qp = 0;
     int qpP = 0;
     int qpQ = 0;
-    uint32_t  pelsInPartChroma = g_maxCUSize >> (g_maxCUDepth + cu->getHorzChromaShift());
+    uint32_t  pelsInPartChromaH = g_maxCUSize >> (g_maxCUDepth + cu->getHorzChromaShift());
+    uint32_t  pelsInPartChromaV = g_maxCUSize >> (g_maxCUDepth + cu->getVertChromaShift());
     int   offset, srcStep;
 
     const uint32_t lcuWidthInBaseUnits = cu->getPic()->getNumPartInCUSize();
@@ -658,9 +659,9 @@ void TComLoopFilter::xEdgeFilterChroma(T
     uint32_t edgeNumInLCUVert = g_zscanToRaster[absZOrderIdx] % lcuWidthInBaseUnits + edge;
     uint32_t edgeNumInLCUHor = g_zscanToRaster[absZOrderIdx] / lcuWidthInBaseUnits + edge;
 
-    if ((pelsInPartChroma < DEBLOCK_SMALLEST_BLOCK) &&
-        (((edgeNumInLCUVert % (DEBLOCK_SMALLEST_BLOCK / pelsInPartChroma)) && (dir == 0)) ||
-         ((edgeNumInLCUHor % (DEBLOCK_SMALLEST_BLOCK / pelsInPartChroma)) && dir)))
+    if ((pelsInPartChromaH < DEBLOCK_SMALLEST_BLOCK) && (pelsInPartChromaV < DEBLOCK_SMALLEST_BLOCK) && 
+        (((edgeNumInLCUVert % (DEBLOCK_SMALLEST_BLOCK / pelsInPartChromaH)) && (dir == 0)) ||
+         ((edgeNumInLCUHor % (DEBLOCK_SMALLEST_BLOCK / pelsInPartChromaV)) && dir)))
     {
         return;
     }
@@ -672,20 +673,23 @@ void TComLoopFilter::xEdgeFilterChroma(T
 
     pixel* tmpSrcCb = srcCb;
     pixel* tmpSrcCr = srcCr;
+    uint32_t loopLength;
 
     if (dir == EDGE_VER)
     {
-        offset   = 1;
-        srcStep  = stride;
-        tmpSrcCb += edge * pelsInPartChroma;
-        tmpSrcCr += edge * pelsInPartChroma;
+        offset     = 1;
+        srcStep    = stride;
+        tmpSrcCb   += edge * pelsInPartChromaH;
+        tmpSrcCr   += edge * pelsInPartChromaH;
+        loopLength = pelsInPartChromaV;
     }
     else // (dir == EDGE_HOR)
     {
-        offset   = stride;
-        srcStep  = 1;
-        tmpSrcCb += edge * stride * pelsInPartChroma;
-        tmpSrcCr += edge * stride * pelsInPartChroma;
+        offset     = stride;
+        srcStep    = 1;
+        tmpSrcCb   += edge * stride * pelsInPartChromaV;
+        tmpSrcCr   += edge * stride * pelsInPartChromaV;
+        loopLength = pelsInPartChromaH;
     }
 
     for (uint32_t idx = 0; idx < numParts; idx++)
@@ -730,9 +734,9 @@ void TComLoopFilter::xEdgeFilterChroma(T
                 int iIndexTC = Clip3(0, MAX_QP + DEFAULT_INTRA_TC_OFFSET, qp + DEFAULT_INTRA_TC_OFFSET * (bs - 1) + (tcOffsetDiv2 << 1));
                 int iTc =  sm_tcTable[iIndexTC] * iBitdepthScale;
 
-                for (uint32_t uiStep = 0; uiStep < pelsInPartChroma; uiStep++)
+                for (uint32_t uiStep = 0; uiStep < loopLength; uiStep++)
                 {
-                    xPelFilterChroma(piTmpSrcChroma + srcStep * (uiStep + idx * pelsInPartChroma), offset, iTc, bPartPNoFilter, bPartQNoFilter);
+                    xPelFilterChroma(piTmpSrcChroma + srcStep * (uiStep + idx * loopLength), offset, iTc, bPartPNoFilter, bPartQNoFilter);
                 }
             }
         }
diff -r 483e5077a6b7 -r 08d64a70594e source/Lib/TLibCommon/TComPattern.cpp
--- a/source/Lib/TLibCommon/TComPattern.cpp	Fri Apr 11 21:51:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPattern.cpp	Mon Apr 14 13:18:18 2014 -0500
@@ -57,42 +57,34 @@ void TComPattern::initAdiPattern(TComDat
     uint32_t cuHeight = cu->getCUSize(0) >> partDepth;
     uint32_t cuWidth2  = cuWidth << 1;
     uint32_t cuHeight2 = cuHeight << 1;
+
     uint32_t width;
     uint32_t height;
     int  picStride = cu->getPic()->getStride();
-    int  unitSize = 0;
-    int  numUnitsInCU = 0;
-    int  totalUnits = 0;
+
     bool bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
     int  numIntraNeighbor = 0;
 
     uint32_t partIdxLT, partIdxRT, partIdxLB;
 
     cu->deriveLeftRightTopIdxAdi(partIdxLT, partIdxRT, zOrderIdxInPart, partDepth);
-    cu->deriveLeftBottomIdxAdi(partIdxLB,              zOrderIdxInPart, partDepth);
 
-    unitSize      = g_maxCUSize >> g_maxCUDepth;
-    numUnitsInCU  = cuWidth / unitSize;
-    totalUnits    = (numUnitsInCU << 2) + 1;
+    int  partIdxStride   = cu->getPic()->getNumPartInCUSize();
+    int  baseUnitSize    = g_maxCUSize >> g_maxCUDepth;
+    int  unitWidth       =  baseUnitSize ;
+    int  unitHeight      = baseUnitSize ;
+    int  cuHeightInUnits = cuHeight / unitHeight;
+    int  cuWidthInUnits  = cuWidth / unitWidth;
+    int  iAboveUnits     = cuWidthInUnits  << 1;
+    int  leftUnits       = cuHeightInUnits << 1;
+    partIdxLB            = g_rasterToZscan[g_zscanToRaster[partIdxLT] + ((cuHeightInUnits - 1) * partIdxStride)];
 
-    if (!cu->getSlice()->getPPS()->getConstrainedIntraPred())
-    {
-        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
-        numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-        numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-        numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-        numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
-    }
-    else
-    {
-        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailableCIP(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
-        numIntraNeighbor += isAboveAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-        numIntraNeighbor += isAboveRightAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-        numIntraNeighbor += isLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-        numIntraNeighbor += isBelowLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
-    }
+    bNeighborFlags[leftUnits] = isAboveLeftAvailable(cu, partIdxLT);
+    numIntraNeighbor += (int)(bNeighborFlags[leftUnits]);
+    numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1));
+    numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, (bNeighborFlags + leftUnits + 1 + cuWidthInUnits));
+    numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits - 1));
+    numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, (bNeighborFlags + leftUnits   - 1 - cuHeightInUnits));
 
     width = cuWidth2 + 1;
     height = cuHeight2 + 1;
@@ -105,7 +97,8 @@ void TComPattern::initAdiPattern(TComDat
     roiOrigin = cu->getPic()->getPicYuvRec()->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + zOrderIdxInPart);
     adiTemp   = adiBuf;
 
-    fillReferenceSamples(roiOrigin, adiTemp, bNeighborFlags, numIntraNeighbor, unitSize, numUnitsInCU, totalUnits, cuWidth, cuHeight, width, height, picStride);
+    fillReferenceSamples(roiOrigin, adiTemp, bNeighborFlags, numIntraNeighbor, unitWidth, unitHeight, iAboveUnits, leftUnits,
+                         cuWidth, cuHeight, width, height, picStride);
 
     // generate filtered intra prediction samples
     // left and left above border + above and above right border + top left corner = length of 3. filter buffer
@@ -220,48 +213,37 @@ void TComPattern::initAdiPatternChroma(T
 {
     pixel*  roiOrigin;
     pixel*  adiTemp;
-    uint32_t  cuWidth  = cu->getCUSize(0) >> partDepth;
-    uint32_t  cuHeight = cu->getCUSize(0) >> partDepth;
+    uint32_t  cuWidth  = cu->getCUSize(0) >> (partDepth + cu->getHorzChromaShift());
+    uint32_t  cuHeight = cu->getCUSize(0) >> (partDepth + cu->getVertChromaShift());
+    cuHeight = (cuWidth != cuHeight) ? cuHeight >> 1 : cuHeight;
+
     uint32_t  width;
     uint32_t  height;
     int   picStride = cu->getPic()->getCStride();
 
-    int   unitSize = 0;
-    int   numUnitsInCU = 0;
-    int   totalUnits = 0;
     bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
     int   numIntraNeighbor = 0;
 
     uint32_t partIdxLT, partIdxRT, partIdxLB;
 
     cu->deriveLeftRightTopIdxAdi(partIdxLT, partIdxRT, zOrderIdxInPart, partDepth);
-    cu->deriveLeftBottomIdxAdi(partIdxLB,              zOrderIdxInPart, partDepth);
 
-    unitSize      = (g_maxCUSize >> g_maxCUDepth) >> cu->getHorzChromaShift(); // for chroma
-    numUnitsInCU  = (cuWidth / unitSize) >> cu->getHorzChromaShift();           // for chroma
-    totalUnits    = (numUnitsInCU << 2) + 1;
+    int  partIdxStride   = cu->getPic()->getNumPartInCUSize();
+    int  baseUnitSize    = g_maxCUSize >> g_maxCUDepth;
+    int  unitWidth       = baseUnitSize  >> cu->getHorzChromaShift();
+    int  unitHeight      = baseUnitSize  >> cu->getVertChromaShift();
+    int  cuHeightInUnits = cuHeight / unitHeight;
+    int  cuWidthInUnits  = cuWidth  / unitWidth;
+    int  aboveUnits      = cuWidthInUnits  << 1;
+    int  leftUnits       = cuHeightInUnits << 1;
+    partIdxLB            = g_rasterToZscan[g_zscanToRaster[partIdxLT] + ((cuHeightInUnits - 1) * partIdxStride)];
 
-    if (!cu->getSlice()->getPPS()->getConstrainedIntraPred())
-    {
-        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailable(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
-        numIntraNeighbor += isAboveAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-        numIntraNeighbor += isAboveRightAvailable(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-        numIntraNeighbor += isLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-        numIntraNeighbor += isBelowLeftAvailable(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
-    }
-    else
-    {
-        bNeighborFlags[numUnitsInCU * 2] = isAboveLeftAvailableCIP(cu, partIdxLT);
-        numIntraNeighbor += (int)(bNeighborFlags[numUnitsInCU * 2]);
-        numIntraNeighbor += isAboveAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 2) + 1);
-        numIntraNeighbor += isAboveRightAvailableCIP(cu, partIdxLT, partIdxRT, bNeighborFlags + (numUnitsInCU * 3) + 1);
-        numIntraNeighbor += isLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + (numUnitsInCU * 2) - 1);
-        numIntraNeighbor += isBelowLeftAvailableCIP(cu, partIdxLT, partIdxLB, bNeighborFlags + numUnitsInCU   - 1);
-    }


More information about the x265-commits mailing list