<div dir="ltr">Thanks for this patch - on testing now.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 19, 2014 at 2:53 PM, Satoshi Nakagawa <span dir="ltr"><<a href="mailto:nakagawa424@oki.com" target="_blank">nakagawa424@oki.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>><br>
# Date 1400490890 -32400<br>
#      Mon May 19 18:14:50 2014 +0900<br>
# Node ID 862e454b039b1642f18e692f8def392bb636df0b<br>
# Parent  ba2a9f61ea06f0ac799d8c0247eec770065465bb<br>
cleanup bReusePred, unify absTUPartIdx to absPartIdx<br>
<br>
diff -r ba2a9f61ea06 -r 862e454b039b source/Lib/TLibCommon/TComRom.h<br>
--- a/source/Lib/TLibCommon/TComRom.h   Fri May 16 19:20:46 2014 +0900<br>
+++ b/source/Lib/TLibCommon/TComRom.h   Mon May 19 18:14:50 2014 +0900<br>
@@ -92,8 +92,8 @@<br>
 extern uint32_t g_maxCUDepth;<br>
 extern uint32_t g_addCUDepth;<br>
<br>
-#define MAX_TS_WIDTH  4<br>
-#define MAX_TS_HEIGHT 4<br>
+#define LOG2_MAX_TS_SIZE 2 // TODO: RExt<br>
+#define MAX_TS_SIZE (1 << LOG2_MAX_TS_SIZE)<br>
<br>
 extern const uint32_t g_puOffset[8];<br>
<br>
diff -r ba2a9f61ea06 -r 862e454b039b source/Lib/TLibEncoder/TEncSearch.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSearch.cpp     Fri May 16 19:20:46 2014 +0900<br>
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Mon May 19 18:14:50 2014 +0900<br>
@@ -132,9 +132,9 @@<br>
     m_qtTempTransformSkipFlag[1] = m_qtTempTransformSkipFlag[0] + numPartitions;<br>
     m_qtTempTransformSkipFlag[2] = m_qtTempTransformSkipFlag[0] + numPartitions * 2;<br>
<br>
-    CHECKED_MALLOC(m_qtTempTUCoeffY, coeff_t, MAX_TS_WIDTH * MAX_TS_HEIGHT * 3);<br>
-    m_qtTempTUCoeffCb = m_qtTempTUCoeffY + MAX_TS_WIDTH * MAX_TS_HEIGHT;<br>
-    m_qtTempTUCoeffCr = m_qtTempTUCoeffY + MAX_TS_WIDTH * MAX_TS_HEIGHT * 2;<br>
+    CHECKED_MALLOC(m_qtTempTUCoeffY, coeff_t, MAX_TS_SIZE * MAX_TS_SIZE * 3);<br>
+    m_qtTempTUCoeffCb = m_qtTempTUCoeffY + MAX_TS_SIZE * MAX_TS_SIZE;<br>
+    m_qtTempTUCoeffCr = m_qtTempTUCoeffY + MAX_TS_SIZE * MAX_TS_SIZE * 2;<br>
<br>
     return m_qtTempTransformSkipYuv.create(g_maxCUSize, g_maxCUSize, cfg->param->internalCsp);<br>
<br>
@@ -409,8 +409,7 @@<br>
                                      TComYuv*    fencYuv,<br>
                                      TComYuv*    predYuv,<br>
                                      ShortYuv*   resiYuv,<br>
-                                     uint32_t&   outDist,<br>
-                                     bool        bReusePred)<br>
+                                     uint32_t&   outDist)<br>
 {<br>
     uint32_t fullDepth    = cu->getDepth(0)  + trDepth;<br>
     uint32_t tuSize       = cu->getCUSize(0) >> trDepth;<br>
@@ -434,15 +433,6 @@<br>
     uint32_t reconIPredStride = cu->getPic()->getPicYuvRec()->getStride();<br>
     bool     useTransformSkip = cu->getTransformSkip(absPartIdx, TEXT_LUMA);<br>
<br>
-    if (!bReusePred)<br>
-    {<br>
-        //===== init availability pattern =====<br>
-        uint32_t lumaPredMode = cu->getLumaIntraDir(absPartIdx);<br>
-        TComPattern::initAdiPattern(cu, absPartIdx, trDepth, m_predBuf, m_refAbove, m_refLeft, m_refAboveFlt, m_refLeftFlt, lumaPredMode);<br>
-        //===== get prediction signal =====<br>
-        predIntraLumaAng(lumaPredMode, pred, stride, tuSize);<br>
-    }<br>
-<br>
     //===== get residual signal =====<br>
     X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");<br>
     X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");<br>
@@ -500,8 +490,7 @@<br>
                                        TComYuv*    predYuv,<br>
                                        ShortYuv*   resiYuv,<br>
                                        uint32_t&   outDist,<br>
-                                       uint32_t    chromaId,<br>
-                                       bool        bReusePred)<br>
+                                       uint32_t    chromaId)<br>
 {<br>
     uint32_t fullDepth   = cu->getDepth(0) + trDepth;<br>
     uint32_t trSizeLog2  = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> fullDepth] + 2;<br>
@@ -540,24 +529,6 @@<br>
     bool     useTransformSkipChroma = cu->getTransformSkip(absPartIdx, ttype);<br>
     int      part = partitionFromSizes(tuSize, tuSize);<br>
<br>
-    if (!bReusePred)<br>
-    {<br>
-        //===== init availability pattern =====<br>
-        TComPattern::initAdiPatternChroma(cu, absPartIdx, trDepth, m_predBuf, chromaId);<br>
-        pixel* chromaPred = TComPattern::getAdiChromaBuf(chromaId, tuSize, m_predBuf);<br>
-<br>
-        uint32_t chromaPredMode = cu->getChromaIntraDir(absPartIdx);<br>
-        //===== update chroma mode =====<br>
-        if (chromaPredMode == DM_CHROMA_IDX)<br>
-        {<br>
-            uint32_t lumaLCUIdx  = (chFmt == CHROMA_444) ? absPartIdx : absPartIdx & (~((1 << (2 * g_addCUDepth)) - 1));<br>
-            chromaPredMode = cu->getLumaIntraDir(lumaLCUIdx);<br>
-        }<br>
-        chromaPredMode = (chFmt == CHROMA_422) ? g_chroma422IntraAngleMappingTable[chromaPredMode] : chromaPredMode;<br>
-        //===== get prediction signal =====<br>
-        predIntraChromaAng(chromaPred, chromaPredMode, pred, stride, tuSize, chFmt);<br>
-    }<br>
-<br>
     //===== get residual signal =====<br>
     X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");<br>
     X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");<br>
@@ -669,21 +640,33 @@<br>
     uint64_t singleCost  = MAX_INT64;<br>
     uint32_t singleDistY = 0;<br>
     uint32_t singleCbfY  = 0;<br>
-    bool   checkTransformSkip  = cu->getSlice()->getPPS()->getUseTransformSkip();<br>
-    uint32_t widthTransformSkip  = cu->getCUSize(0) >> trDepth;<br>
-    uint32_t heightTransformSkip = cu->getCUSize(0) >> trDepth;<br>
     int    bestModeId    = 0;<br>
<br>
-    checkTransformSkip &= (widthTransformSkip == 4 && heightTransformSkip == 4);<br>
-    checkTransformSkip &= (!cu->getCUTransquantBypass(0));<br>
-    checkTransformSkip &= (!((cu->getQP(0) == 0) && (cu->getSlice()->getSPS()->getUseLossless())));<br>
-    if (m_cfg->param->bEnableTSkipFast)<br>
-    {<br>
-        checkTransformSkip &= (cu->getPartitionSize(absPartIdx) == SIZE_NxN);<br>
-    }<br>
-<br>
     if (bCheckFull)<br>
     {<br>
+        uint32_t tuSize = 1 << trSizeLog2;<br>
+<br>
+        bool checkTransformSkip = (cu->getSlice()->getPPS()->getUseTransformSkip() &&<br>
+                                   trSizeLog2 <= LOG2_MAX_TS_SIZE &&<br>
+                                   !cu->getCUTransquantBypass(0));<br>
+        if (checkTransformSkip)<br>
+        {<br>
+            checkTransformSkip &= (!((cu->getQP(0) == 0) && (cu->getSlice()->getSPS()->getUseLossless())));<br>
+            if (m_cfg->param->bEnableTSkipFast)<br>
+            {<br>
+                checkTransformSkip &= (cu->getPartitionSize(absPartIdx) == SIZE_NxN);<br>
+            }<br>
+        }<br>
+<br>
+        uint32_t stride       = fencYuv->getStride();<br>
+        pixel*   pred         = predYuv->getLumaAddr(absPartIdx);<br>
+<br>
+        //===== init availability pattern =====<br>
+        uint32_t lumaPredMode = cu->getLumaIntraDir(absPartIdx);<br>
+        TComPattern::initAdiPattern(cu, absPartIdx, trDepth, m_predBuf, m_refAbove, m_refLeft, m_refAboveFlt, m_refLeftFlt, lumaPredMode);<br>
+        //===== get prediction signal =====<br>
+        predIntraLumaAng(lumaPredMode, pred, stride, tuSize);<br>
+<br>
         if (checkTransformSkip == true)<br>
         {<br>
             //----- store original entropy coding status -----<br>
@@ -699,8 +682,7 @@<br>
                 singleDistYTmp = 0;<br>
                 cu->setTransformSkipSubParts(modeId, TEXT_LUMA, absPartIdx, fullDepth);<br>
                 //----- code luma block with given intra prediction mode and store Cbf-----<br>
-                bool bReusePred = modeId != firstCheckId;<br>
-                xIntraCodingLumaBlk(cu, trDepth, absPartIdx, fencYuv, predYuv, resiYuv, singleDistYTmp, bReusePred);<br>
+                xIntraCodingLumaBlk(cu, trDepth, absPartIdx, fencYuv, predYuv, resiYuv, singleDistYTmp);<br>
                 singleCbfYTmp = cu->getCbf(absPartIdx, TEXT_LUMA, trDepth);<br>
                 //----- determine rate and r-d cost -----<br>
                 if (modeId == 1 && singleCbfYTmp == 0)<br>
@@ -1199,13 +1181,14 @@<br>
     if (trMode == trDepth)<br>
     {<br>
         int chFmt = cu->getChromaFormat();<br>
-        bool checkTransformSkip = cu->getSlice()->getPPS()->getUseTransformSkip();<br>
         uint32_t trSizeLog2 = g_convertToBit[cu->getSlice()->getSPS()->getMaxCUSize() >> fullDepth] + 2;<br>
+        uint32_t trSizeCLog2 = trSizeLog2 - m_hChromaShift;<br>
         uint32_t actualTrDepth = trDepth;<br>
         if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))<br>
         {<br>
             X265_CHECK(trDepth > 0, "invalid trDepth\n");<br>
             actualTrDepth--;<br>
+            trSizeCLog2++;<br>
             uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + actualTrDepth) << 1);<br>
             bool bFirstQ = ((absPartIdx % qpdiv) == 0);<br>
             if (!bFirstQ)<br>
@@ -1215,9 +1198,12 @@<br>
         }<br>
<br>
         uint32_t tuSize = cu->getCUSize(0) >> (actualTrDepth + m_hChromaShift);<br>
+        uint32_t stride = fencYuv->getCStride();<br>
         const bool splitIntoSubTUs = (chFmt == CHROMA_422);<br>
<br>
-        checkTransformSkip &= (tuSize <= 4);<br>
+        bool checkTransformSkip = (cu->getSlice()->getPPS()->getUseTransformSkip() &&<br>
+                                   trSizeCLog2 <= LOG2_MAX_TS_SIZE &&<br>
+                                   !cu->getCUTransquantBypass(0));<br>
<br>
         if (m_cfg->param->bEnableTSkipFast)<br>
         {<br>
@@ -1242,6 +1228,24 @@<br>
<br>
             do<br>
             {<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
+                pixel*   pred        = (chromaId == 1) ? predYuv->getCbAddr(absPartIdxC) : predYuv->getCrAddr(absPartIdxC);<br>
+<br>
+                //===== init availability pattern =====<br>
+                TComPattern::initAdiPatternChroma(cu, absPartIdxC, actualTrDepth, m_predBuf, chromaId);<br>
+                pixel* chromaPred = TComPattern::getAdiChromaBuf(chromaId, tuSize, m_predBuf);<br>
+<br>
+                uint32_t chromaPredMode = cu->getChromaIntraDir(absPartIdxC);<br>
+                //===== update chroma mode =====<br>
+                if (chromaPredMode == DM_CHROMA_IDX)<br>
+                {<br>
+                    uint32_t lumaLCUIdx  = (chFmt == CHROMA_444) ? absPartIdxC : absPartIdxC & (~((1 << (2 * g_addCUDepth)) - 1));<br>
+                    chromaPredMode = cu->getLumaIntraDir(lumaLCUIdx);<br>
+                }<br>
+                chromaPredMode = (chFmt == CHROMA_422) ? g_chroma422IntraAngleMappingTable[chromaPredMode] : chromaPredMode;<br>
+                //===== get prediction signal =====<br>
+                predIntraChromaAng(chromaPred, chromaPredMode, pred, stride, tuSize, chFmt);<br>
+<br>
                 if (checkTransformSkip)<br>
                 {<br>
                     // use RDO to decide whether Cr/Cb takes TS<br>
@@ -1259,14 +1263,12 @@<br>
<br>
                     for (int chromaModeId = firstCheckId; chromaModeId < 2; chromaModeId++)<br>
                     {<br>
-                        cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                        cu->setTransformSkipPartRange(chromaModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                         singleDistCTmp = 0;<br>
-                        bool bReusePred = chromaModeId != firstCheckId;<br>
-<br>
-                        xIntraCodingChromaBlk(cu, trDepth, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, singleDistCTmp, (TextType)chromaId, bReusePred);<br>
-<br>
-                        singleCbfCTmp = cu->getCbf(tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, trDepth);<br>
+                        xIntraCodingChromaBlk(cu, trDepth, absPartIdxC, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, singleDistCTmp, chromaId);<br>
+<br>
+                        singleCbfCTmp = cu->getCbf(absPartIdxC, (TextType)chromaId, trDepth);<br>
<br>
                         if (chromaModeId == 1 && singleCbfCTmp == 0)<br>
                         {<br>
@@ -1275,7 +1277,7 @@<br>
                         }<br>
                         else<br>
                         {<br>
-                            uint32_t bitsTmp = xGetIntraBitsQTChroma(cu, trDepth, tuIterator.m_absPartIdxTURelCU, chromaId, splitIntoSubTUs);<br>
+                            uint32_t bitsTmp = xGetIntraBitsQTChroma(cu, trDepth, absPartIdxC, chromaId, splitIntoSubTUs);<br>
                             singleCostTmp = m_rdCost->calcRdCost(singleDistCTmp, bitsTmp);<br>
                         }<br>
<br>
@@ -1288,7 +1290,7 @@<br>
<br>
                             if (bestModeId == firstCheckId)<br>
                             {<br>
-                                xStoreIntraResultChromaQT(cu, trDepth, tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, splitIntoSubTUs);<br>
+                                xStoreIntraResultChromaQT(cu, trDepth, absPartIdxC, (TextType)chromaId, splitIntoSubTUs);<br>
                                 m_rdGoOnSbacCoder->store(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);<br>
                             }<br>
                         }<br>
@@ -1300,13 +1302,13 @@<br>
<br>
                     if (bestModeId == firstCheckId)<br>
                     {<br>
-                        xLoadIntraResultChromaQT(cu, trDepth, tuIterator.m_absPartIdxTURelCU, (TextType)chromaId, splitIntoSubTUs);<br>
-                        cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                        xLoadIntraResultChromaQT(cu, trDepth, absPartIdxC, (TextType)chromaId, splitIntoSubTUs);<br>
+                        cu->setCbfPartRange(singleCbfC << trDepth, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                         m_rdGoOnSbacCoder->load(m_rdSbacCoders[fullDepth][CI_TEMP_BEST]);<br>
                     }<br>
<br>
-                    cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                    cu->setTransformSkipPartRange(bestModeId, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                     outDist += singleDistC;<br>
<br>
@@ -1317,8 +1319,8 @@<br>
                 }<br>
                 else<br>
                 {<br>
-                    cu->setTransformSkipPartRange(0, (TextType)chromaId, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                    xIntraCodingChromaBlk(cu, trDepth, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, outDist, (TextType)chromaId);<br>
+                    cu->setTransformSkipPartRange(0, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                    xIntraCodingChromaBlk(cu, trDepth, absPartIdxC, tuIterator.m_absPartIdxStep, fencYuv, predYuv, resiYuv, outDist, chromaId);<br>
                 }<br>
             }<br>
             while (isNextSection(&tuIterator));<br>
@@ -1442,32 +1444,32 @@<br>
<br>
             do<br>
             {<br>
-                uint32_t absTUPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
-                cu->setTransformSkipPartRange(0, (TextType)chromaId, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
+                cu->setTransformSkipPartRange(0, (TextType)chromaId, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 TextType ttype          = (chromaId == 1) ? TEXT_CHROMA_U : TEXT_CHROMA_V;<br>
-                pixel*   fenc           = (chromaId == 1) ? fencYuv->getCbAddr(absTUPartIdxC) : fencYuv->getCrAddr(absTUPartIdxC);<br>
-                pixel*   pred           = (chromaId == 1) ? predYuv->getCbAddr(absTUPartIdxC) : predYuv->getCrAddr(absTUPartIdxC);<br>
-                int16_t* residual       = (chromaId == 1) ? resiYuv->getCbAddr(absTUPartIdxC) : resiYuv->getCrAddr(absTUPartIdxC);<br>
-                pixel*   recon          = (chromaId == 1) ? reconYuv->getCbAddr(absTUPartIdxC) : reconYuv->getCrAddr(absTUPartIdxC);<br>
+                pixel*   fenc           = (chromaId == 1) ? fencYuv->getCbAddr(absPartIdxC) : fencYuv->getCrAddr(absPartIdxC);<br>
+                pixel*   pred           = (chromaId == 1) ? predYuv->getCbAddr(absPartIdxC) : predYuv->getCrAddr(absPartIdxC);<br>
+                int16_t* residual       = (chromaId == 1) ? resiYuv->getCbAddr(absPartIdxC) : resiYuv->getCrAddr(absPartIdxC);<br>
+                pixel*   recon          = (chromaId == 1) ? reconYuv->getCbAddr(absPartIdxC) : reconYuv->getCrAddr(absPartIdxC);<br>
                 uint32_t numCoeffPerInc = (cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1)) >> (m_hChromaShift + m_vChromaShift);<br>


-                coeff_t*  coeff         = (chromaId == 1 ? cu->getCoeffCb() : cu->getCoeffCr()) + numCoeffPerInc * absTUPartIdxC;<br>
-                uint32_t zorder           = cu->getZorderIdxInCU() + absTUPartIdxC;<br>
+                coeff_t*  coeff         = (chromaId == 1 ? cu->getCoeffCb() : cu->getCoeffCr()) + numCoeffPerInc * absPartIdxC;<br>
+                uint32_t zorder           = cu->getZorderIdxInCU() + absPartIdxC;<br>
                 pixel*   reconIPred       = (chromaId == 1) ? cu->getPic()->getPicYuvRec()->getCbAddr(cu->getAddr(), zorder) : cu->getPic()->getPicYuvRec()->getCrAddr(cu->getAddr(), zorder);<br>
                 uint32_t reconIPredStride = cu->getPic()->getPicYuvRec()->getCStride();<br>
-                //bool     useTransformSkipChroma = cu->getTransformSkip(absTUPartIdxC, ttype);<br>
+                //bool     useTransformSkipChroma = cu->getTransformSkip(absPartIdxC, ttype);<br>
                 const bool useTransformSkipChroma = false;<br>
<br>
-                uint32_t chromaPredMode = cu->getChromaIntraDir(absTUPartIdxC);<br>
+                uint32_t chromaPredMode = cu->getChromaIntraDir(absPartIdxC);<br>
                 //===== update chroma mode =====<br>
                 if (chromaPredMode == DM_CHROMA_IDX)<br>
                 {<br>
-                    uint32_t lumaLCUIdx  = (chFmt == CHROMA_444) ? absTUPartIdxC : absTUPartIdxC & (~((1 << (2 * g_addCUDepth)) - 1));<br>
+                    uint32_t lumaLCUIdx  = (chFmt == CHROMA_444) ? absPartIdxC : absPartIdxC & (~((1 << (2 * g_addCUDepth)) - 1));<br>
                     chromaPredMode = cu->getLumaIntraDir(lumaLCUIdx);<br>
                 }<br>
                 chromaPredMode = (chFmt == CHROMA_422) ? g_chroma422IntraAngleMappingTable[chromaPredMode] : chromaPredMode;<br>
                 //===== init availability pattern =====<br>
-                TComPattern::initAdiPatternChroma(cu, absTUPartIdxC, actualTrDepth, m_predBuf, chromaId);<br>
+                TComPattern::initAdiPatternChroma(cu, absPartIdxC, actualTrDepth, m_predBuf, chromaId);<br>
                 pixel* chromaPred = TComPattern::getAdiChromaBuf(chromaId, tuSize, m_predBuf);<br>
<br>
                 //===== get prediction signal =====<br>
@@ -1497,17 +1499,17 @@<br>
<br>
                 m_trQuant->selectLambda(TEXT_CHROMA);<br>
<br>
-                absSum = m_trQuant->transformNxN(cu, residual, stride, coeff, tuSize, ttype, absTUPartIdxC, &lastPos, useTransformSkipChroma);<br>
+                absSum = m_trQuant->transformNxN(cu, residual, stride, coeff, tuSize, ttype, absPartIdxC, &lastPos, useTransformSkipChroma);<br>
<br>
                 //--- set coded block flag ---<br>
-                cu->setCbfPartRange((((absSum > 0) ? 1 : 0) << origTrDepth), ttype, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange((((absSum > 0) ? 1 : 0) << origTrDepth), ttype, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 //--- inverse transform ---<br>
                 if (absSum)<br>
                 {<br>
                     int scalingListType = 0 + ttype;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absTUPartIdxC), REG_DCT, residual, stride, coeff, tuSize, scalingListType, useTransformSkipChroma, lastPos);<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, residual, stride, coeff, tuSize, scalingListType, useTransformSkipChroma, lastPos);<br>
                 }<br>
                 else<br>
                 {<br>
@@ -2729,7 +2731,7 @@<br>
     m_rdGoOnSbacCoder->load(m_rdSbacCoders[cu->getDepth(0)][CI_CURR_BEST]);<br>
<br>
     uint32_t zeroDistortion = 0;<br>
-    xEstimateResidualQT(cu, 0, 0, outResiYuv, cu->getDepth(0), cost, bits, distortion, &zeroDistortion, curUseRDOQ);<br>
+    xEstimateResidualQT(cu, 0, outResiYuv, cu->getDepth(0), cost, bits, distortion, &zeroDistortion, curUseRDOQ);<br>
<br>
     m_entropyCoder->resetBits();<br>
     m_entropyCoder->encodeQtRootCbfZero(cu);<br>
@@ -2756,7 +2758,7 @@<br>
     }<br>
     else<br>
     {<br>
-        xSetResidualQTData(cu, 0, 0, NULL, cu->getDepth(0), false);<br>
+        xSetResidualQTData(cu, 0, NULL, cu->getDepth(0), false);<br>
     }<br>
<br>
     m_rdGoOnSbacCoder->load(m_rdSbacCoders[cu->getDepth(0)][CI_CURR_BEST]);<br>
@@ -2769,7 +2771,7 @@<br>
     {<br>
         if (cu->getQtRootCbf(0))<br>
         {<br>
-            xSetResidualQTData(cu, 0, 0, outBestResiYuv, cu->getDepth(0), true);<br>
+            xSetResidualQTData(cu, 0, outBestResiYuv, cu->getDepth(0), true);<br>
         }<br>
<br>
         bestBits = bits;<br>
@@ -2825,7 +2827,7 @@<br>
     }<br>
     if (cu->getPredictionMode(0) == MODE_INTER)<br>
     {<br>
-        residualTransformQuantInter(cu, 0, 0, resiYuv, cu->getDepth(0), true);<br>
+        residualTransformQuantInter(cu, 0, resiYuv, cu->getDepth(0), true);<br>
         uint32_t width  = cu->getCUSize(0);<br>
         if (cu->getQtRootCbf(0))<br>
         {<br>
@@ -2853,7 +2855,7 @@<br>
 #pragma warning(disable: 4701) // potentially uninitialized local variable<br>
 #endif<br>
<br>
-void TEncSearch::residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, ShortYuv* resiYuv, const uint32_t depth, bool curuseRDOQ)<br>
+void TEncSearch::residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, const uint32_t depth, bool curuseRDOQ)<br>
 {<br>
     X265_CHECK(cu->getDepth(0) == cu->getDepth(absPartIdx), "invalid depth\n");<br>
     const uint32_t trMode = depth - cu->getDepth(0);<br>
@@ -2906,14 +2908,14 @@<br>
         m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
         m_trQuant->selectLambda(TEXT_LUMA);<br>
<br>
-        absSumY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, coeffCurY,<br>
+        absSumY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,<br>
                                           trWidth, TEXT_LUMA, absPartIdx, &lastPosY, false, curuseRDOQ);<br>
<br>
         cu->setCbfSubParts(absSumY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
<br>
         if (absSumY)<br>
         {<br>
-            int16_t *curResiY = resiYuv->getLumaAddr(absTUPartIdx);<br>
+            int16_t *curResiY = resiYuv->getLumaAddr(absPartIdx);<br>
<br>
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
<br>
@@ -2923,7 +2925,7 @@<br>
         }<br>
         else<br>
         {<br>
-            int16_t *ptr =  resiYuv->getLumaAddr(absTUPartIdx);<br>
+            int16_t *ptr =  resiYuv->getLumaAddr(absPartIdx);<br>
             X265_CHECK(trWidth == trHeight, "square transform expected\n");<br>
             primitives.blockfill_s[(int)g_convertToBit[trWidth]](ptr, resiYuv->m_width, 0);<br>
         }<br>
@@ -2939,63 +2941,63 @@<br>
<br>
             do<br>
             {<br>
-                uint32_t absTUPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
-                uint32_t subTUBufferOffset    = widthC * heightC * tuIterator.m_section;<br>
-<br>
-                cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
-                cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
+                uint32_t subTUBufferOffset = widthC * heightC * tuIterator.m_section;<br>
+<br>
+                cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
<br>
                 m_trQuant->selectLambda(TEXT_CHROMA);<br>
<br>
-                absSumU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
-                                                  trWidthC, TEXT_CHROMA_U, absTUPartIdxC, &lastPosU, false, curuseRDOQ);<br>
+                absSumU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
+                                                  trWidthC, TEXT_CHROMA_U, absPartIdxC, &lastPosU, false, curuseRDOQ);<br>
<br>
                 curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
-                absSumV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absTUPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
-                                                  trWidthC, TEXT_CHROMA_V, absTUPartIdxC, &lastPosV, false, curuseRDOQ);<br>
-<br>
-                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                absSumV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
+                                                  trWidthC, TEXT_CHROMA_V, absPartIdxC, &lastPosV, false, curuseRDOQ);<br>
+<br>
+                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 if (absSumU)<br>
                 {<br>
-                    int16_t *pcResiCurrU = resiYuv->getCbAddr(absTUPartIdxC);<br>
+                    int16_t *pcResiCurrU = resiYuv->getCbAddr(absPartIdxC);<br>
<br>
                     curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
                     m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_U;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absTUPartIdxC), REG_DCT, pcResiCurrU, resiYuv->m_cwidth, coeffCurU + subTUBufferOffset, trWidthC, scalingListType, false, lastPosU);<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, pcResiCurrU, resiYuv->m_cwidth, coeffCurU + subTUBufferOffset, trWidthC, scalingListType, false, lastPosU);<br>
                 }<br>
                 else<br>
                 {<br>
-                    int16_t *ptr = resiYuv->getCbAddr(absTUPartIdxC);<br>
+                    int16_t *ptr = resiYuv->getCbAddr(absPartIdxC);<br>
                     X265_CHECK(trWidthC == trHeightC, "square chroma transform expected\n");<br>
                     primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
                 }<br>
                 if (absSumV)<br>
                 {<br>
-                    int16_t *curResiV = resiYuv->getCrAddr(absTUPartIdxC);<br>
+                    int16_t *curResiV = resiYuv->getCrAddr(absPartIdxC);<br>
                     curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
                     m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_V;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absTUPartIdxC), REG_DCT, curResiV, resiYuv->m_cwidth, coeffCurV + subTUBufferOffset, trWidthC, scalingListType, false, lastPosV);<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, curResiV, resiYuv->m_cwidth, coeffCurV + subTUBufferOffset, trWidthC, scalingListType, false, lastPosV);<br>
                 }<br>
                 else<br>
                 {<br>
-                    int16_t *ptr =  resiYuv->getCrAddr(absTUPartIdxC);<br>
+                    int16_t *ptr =  resiYuv->getCrAddr(absPartIdxC);<br>
                     X265_CHECK(trWidthC == trHeightC, "square chroma transform expected\n");<br>
                     primitives.blockfill_s[(int)g_convertToBit[trWidthC]](ptr, resiYuv->m_cwidth, 0);<br>
                 }<br>
-                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absTUPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSumU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSumV ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
             }<br>
             while (isNextSection(&tuIterator));<br>
<br>
@@ -3014,8 +3016,7 @@<br>
         const uint32_t qPartNumSubdiv = cu->getPic()->getNumPartInCU() >> ((depth + 1) << 1);<br>
         for (uint32_t i = 0; i < 4; ++i)<br>
         {<br>
-            uint32_t nsAddr = absPartIdx + i * qPartNumSubdiv;<br>
-            residualTransformQuantInter(cu, absPartIdx + i * qPartNumSubdiv, nsAddr, resiYuv, depth + 1, curuseRDOQ);<br>
+            residualTransformQuantInter(cu, absPartIdx + i * qPartNumSubdiv, resiYuv, depth + 1, curuseRDOQ);<br>
         }<br>
<br>
         uint32_t ycbf = 0;<br>
@@ -3041,7 +3042,6 @@<br>
<br>
 void TEncSearch::xEstimateResidualQT(TComDataCU*    cu,<br>
                                      uint32_t       absPartIdx,<br>
-                                     uint32_t       absTUPartIdx,<br>
                                      ShortYuv*      resiYuv,<br>
                                      const uint32_t depth,<br>
                                      uint64_t &     rdCost,<br>
@@ -3110,8 +3110,9 @@<br>
         coeff_t *coeffCurV = m_qtTempCoeffCr[qtlayer] + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));<br>
<br>
         cu->setTrIdxSubParts(depth - cu->getDepth(0), absPartIdx, depth);<br>
-        bool checkTransformSkipY  = cu->getSlice()->getPPS()->getUseTransformSkip() && (trWidth == 4) && (trHeight == 4) &&  (!cu->isLosslessCoded(0));<br>
-        bool checkTransformSkipUV = cu->getSlice()->getPPS()->getUseTransformSkip() && (trWidthC <= 4) && (!cu->isLosslessCoded(0));<br>
+        bool checkTransformSkip   = cu->getSlice()->getPPS()->getUseTransformSkip() && !cu->getCUTransquantBypass(0);<br>
+        bool checkTransformSkipY  = checkTransformSkip && trSizeLog2  <= LOG2_MAX_TS_SIZE;<br>
+        bool checkTransformSkipUV = checkTransformSkip && trSizeCLog2 <= LOG2_MAX_TS_SIZE;<br>
<br>
         cu->setTransformSkipSubParts(0, TEXT_LUMA, absPartIdx, depth);<br>
<br>
@@ -3123,7 +3124,7 @@<br>
         m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
         m_trQuant->selectLambda(TEXT_LUMA);<br>
<br>
-        absSum[TEXT_LUMA][0] = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, coeffCurY,<br>
+        absSum[TEXT_LUMA][0] = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,<br>
                                                        trWidth, TEXT_LUMA, absPartIdx, &lastPos[TEXT_LUMA][0], false, curuseRDOQ);<br>
<br>
         cu->setCbfSubParts(absSum[TEXT_LUMA][0] ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
@@ -3146,10 +3147,11 @@<br>
<br>
             do<br>
             {<br>
-                uint32_t subTUBufferOffset    = widthC * heightC * tuIterator.m_section;<br>
-<br>
-                cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
+                uint32_t subTUBufferOffset = widthC * heightC * tuIterator.m_section;<br>
+<br>
+                cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 if (m_cfg->bEnableRDOQ && curuseRDOQ)<br>
                 {<br>
@@ -3161,25 +3163,25 @@<br>
<br>
                 m_trQuant->selectLambda(TEXT_CHROMA);<br>
<br>
-                absSum[TEXT_CHROMA_U][tuIterator.m_section] = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
-                                                                                      widthC, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, &lastPos[TEXT_CHROMA_U][tuIterator.m_section], false, curuseRDOQ);<br>
+                absSum[TEXT_CHROMA_U][tuIterator.m_section] = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
+                                                                                      widthC, TEXT_CHROMA_U, absPartIdxC, &lastPos[TEXT_CHROMA_U][tuIterator.m_section], false, curuseRDOQ);<br>
                 //Cr transform<br>
                 curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
-                absSum[TEXT_CHROMA_V][tuIterator.m_section] = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
-                                                                                      widthC, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, &lastPos[TEXT_CHROMA_V][tuIterator.m_section], false, curuseRDOQ);<br>
-<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-<br>
-                m_entropyCoder->encodeQtCbf(cu, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_U, trMode, true);<br>
+                absSum[TEXT_CHROMA_V][tuIterator.m_section] = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
+                                                                                      widthC, TEXT_CHROMA_V, absPartIdxC, &lastPos[TEXT_CHROMA_V][tuIterator.m_section], false, curuseRDOQ);<br>
+<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+<br>
+                m_entropyCoder->encodeQtCbf(cu, absPartIdxC, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_U, trMode, true);<br>
                 if (absSum[TEXT_CHROMA_U][tuIterator.m_section])<br>
-                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurU + subTUBufferOffset, tuIterator.m_absPartIdxTURelCU, widthC, TEXT_CHROMA_U);<br>
+                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurU + subTUBufferOffset, absPartIdxC, widthC, TEXT_CHROMA_U);<br>
                 singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section] = m_entropyCoder->getNumberOfWrittenBits() - singleBitsPrev;<br>
<br>
-                m_entropyCoder->encodeQtCbf(cu, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_V, trMode, true);<br>
+                m_entropyCoder->encodeQtCbf(cu, absPartIdxC, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_V, trMode, true);<br>
                 if (absSum[TEXT_CHROMA_V][tuIterator.m_section])<br>
-                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurV + subTUBufferOffset, tuIterator.m_absPartIdxTURelCU, widthC, TEXT_CHROMA_V);<br>
+                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurV + subTUBufferOffset, absPartIdxC, widthC, TEXT_CHROMA_V);<br>
                 uint32_t newBits = m_entropyCoder->getNumberOfWrittenBits();<br>
                 singleBitsComp[TEXT_CHROMA_V][tuIterator.m_section] = newBits - (singleBitsPrev + singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section]);<br>
<br>
@@ -3198,7 +3200,7 @@<br>
         }<br>
<br>
         int partSize = partitionFromSizes(trWidth, trHeight);<br>
-        uint32_t distY = primitives.sse_sp[partSize](resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, (pixel*)TComRdCost::zeroPel, trWidth);<br>
+        uint32_t distY = primitives.sse_sp[partSize](resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, (pixel*)TComRdCost::zeroPel, trWidth);<br>
<br>
         if (outZeroDist)<br>
         {<br>
@@ -3206,7 +3208,7 @@<br>
         }<br>
         if (absSum[TEXT_LUMA][0])<br>
         {<br>
-            int16_t *curResiY = m_qtTempShortYuv[qtlayer].getLumaAddr(absTUPartIdx);<br>
+            int16_t *curResiY = m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx);<br>
<br>
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
<br>
@@ -3215,7 +3217,7 @@<br>
             X265_CHECK(m_qtTempShortYuv[qtlayer].m_width == MAX_CU_SIZE, "width not full CU\n");<br>
             m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiY, MAX_CU_SIZE,  coeffCurY, trWidth, scalingListType, false, lastPos[TEXT_LUMA][0]); //this is for inter mode only<br>
<br>
-            const uint32_t nonZeroDistY = primitives.sse_ss[partSize](resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, m_qtTempShortYuv[qtlayer].getLumaAddr(absTUPartIdx), MAX_CU_SIZE);<br>
+            const uint32_t nonZeroDistY = primitives.sse_ss[partSize](resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx), MAX_CU_SIZE);<br>
             if (cu->isLosslessCoded(0))<br>
             {<br>
                 distY = nonZeroDistY;<br>
@@ -3258,7 +3260,7 @@<br>
<br>
         if (!absSum[TEXT_LUMA][0])<br>
         {<br>
-            int16_t *ptr =  m_qtTempShortYuv[qtlayer].getLumaAddr(absTUPartIdx);<br>
+            int16_t *ptr =  m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx);<br>
             X265_CHECK(m_qtTempShortYuv[qtlayer].m_width == MAX_CU_SIZE, "width not full CU\n");<br>
             X265_CHECK(trWidth == trHeight, "not square block\n");<br>
             primitives.blockfill_s[(int)g_convertToBit[trWidth]](ptr, MAX_CU_SIZE, 0);<br>
@@ -3280,9 +3282,10 @@<br>
<br>
             do<br>
             {<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
                 uint32_t subTUBufferOffset = widthC * heightC * tuIterator.m_section;<br>
<br>
-                distU = m_rdCost->scaleChromaDistCb(primitives.sse_sp[partSizeC](resiYuv->getCbAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, (pixel*)TComRdCost::zeroPel, widthC));<br>
+                distU = m_rdCost->scaleChromaDistCb(primitives.sse_sp[partSizeC](resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, (pixel*)TComRdCost::zeroPel, widthC));<br>
<br>
                 if (outZeroDist)<br>
                 {<br>
@@ -3290,17 +3293,17 @@<br>
                 }<br>
                 if (absSum[TEXT_CHROMA_U][tuIterator.m_section])<br>
                 {<br>
-                    int16_t *pcResiCurrU = m_qtTempShortYuv[qtlayer].getCbAddr(tuIterator.m_absPartIdxTURelCU);<br>
+                    int16_t *pcResiCurrU = m_qtTempShortYuv[qtlayer].getCbAddr(absPartIdxC);<br>
<br>
                     int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
                     m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_U;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(tuIterator.m_absPartIdxTURelCU), REG_DCT, pcResiCurrU, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurU + subTUBufferOffset,<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, pcResiCurrU, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurU + subTUBufferOffset,<br>
                                                widthC, scalingListType, false, lastPos[TEXT_CHROMA_U][tuIterator.m_section]);<br>
-                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCbAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth,<br>
-                                                                 m_qtTempShortYuv[qtlayer].getCbAddr(tuIterator.m_absPartIdxTURelCU),<br>
+                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth,<br>
+                                                                 m_qtTempShortYuv[qtlayer].getCbAddr(absPartIdxC),<br>
                                                                  m_qtTempShortYuv[qtlayer].m_cwidth);<br>
                     const uint32_t nonZeroDistU = m_rdCost->scaleChromaDistCb(dist);<br>
<br>
@@ -3346,29 +3349,29 @@<br>
<br>
                 if (!absSum[TEXT_CHROMA_U][tuIterator.m_section])<br>
                 {<br>
-                    int16_t *ptr = m_qtTempShortYuv[qtlayer].getCbAddr(tuIterator.m_absPartIdxTURelCU);<br>
+                    int16_t *ptr = m_qtTempShortYuv[qtlayer].getCbAddr(absPartIdxC);<br>
                     const uint32_t stride = m_qtTempShortYuv[qtlayer].m_cwidth;<br>
                     X265_CHECK(trWidthC == trHeightC, "square chroma transform expected\n");<br>
                     primitives.blockfill_s[(int)g_convertToBit[widthC]](ptr, stride, 0);<br>
                 }<br>
<br>
-                distV = m_rdCost->scaleChromaDistCr(primitives.sse_sp[partSizeC](resiYuv->getCrAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, (pixel*)TComRdCost::zeroPel, widthC));<br>
+                distV = m_rdCost->scaleChromaDistCr(primitives.sse_sp[partSizeC](resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, (pixel*)TComRdCost::zeroPel, widthC));<br>
                 if (outZeroDist)<br>
                 {<br>
                     *outZeroDist += distV;<br>
                 }<br>
                 if (absSum[TEXT_CHROMA_V][tuIterator.m_section])<br>
                 {<br>
-                    int16_t *curResiV = m_qtTempShortYuv[qtlayer].getCrAddr(tuIterator.m_absPartIdxTURelCU);<br>
+                    int16_t *curResiV = m_qtTempShortYuv[qtlayer].getCrAddr(absPartIdxC);<br>
                     int curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
                     m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_V;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(tuIterator.m_absPartIdxTURelCU), REG_DCT, curResiV, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurV + subTUBufferOffset,<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, curResiV, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurV + subTUBufferOffset,<br>
                                                widthC, scalingListType, false, lastPos[TEXT_CHROMA_V][tuIterator.m_section]);<br>
-                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCrAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth,<br>
-                                                                 m_qtTempShortYuv[qtlayer].getCrAddr(tuIterator.m_absPartIdxTURelCU),<br>
+                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth,<br>
+                                                                 m_qtTempShortYuv[qtlayer].getCrAddr(absPartIdxC),<br>
                                                                  m_qtTempShortYuv[qtlayer].m_cwidth);<br>
                     const uint32_t nonZeroDistV = m_rdCost->scaleChromaDistCr(dist);<br>
<br>
@@ -3414,14 +3417,14 @@<br>
<br>
                 if (!absSum[TEXT_CHROMA_V][tuIterator.m_section])<br>
                 {<br>
-                    int16_t *ptr =  m_qtTempShortYuv[qtlayer].getCrAddr(tuIterator.m_absPartIdxTURelCU);<br>
+                    int16_t *ptr =  m_qtTempShortYuv[qtlayer].getCrAddr(absPartIdxC);<br>
                     const uint32_t stride = m_qtTempShortYuv[qtlayer].m_cwidth;<br>
                     X265_CHECK(trWidthC == trHeightC, "square chroma transform expected\n");<br>
                     primitives.blockfill_s[(int)g_convertToBit[widthC]](ptr, stride, 0);<br>
                 }<br>
<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
             }<br>
             while (isNextSection(&tuIterator));<br>
         }<br>
@@ -3432,7 +3435,7 @@<br>
             uint32_t nonZeroDistY = 0, absSumTransformSkipY;<br>
             uint64_t singleCostY = MAX_INT64;<br>
<br>
-            int16_t *curResiY = m_qtTempShortYuv[qtlayer].getLumaAddr(absTUPartIdx);<br>
+            int16_t *curResiY = m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx);<br>
             X265_CHECK(m_qtTempShortYuv[qtlayer].m_width == MAX_CU_SIZE, "width not full CU\n");<br>
<br>
             coeff_t bestCoeffY[32 * 32];<br>
@@ -3456,7 +3459,7 @@<br>
             m_trQuant->setQPforQuant(cu->getQP(0), TEXT_LUMA, QP_BD_OFFSET, 0, chFmt);<br>
<br>
             m_trQuant->selectLambda(TEXT_LUMA);<br>
-            absSumTransformSkipY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width, coeffCurY,<br>
+            absSumTransformSkipY = m_trQuant->transformNxN(cu, resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width, coeffCurY,<br>
                                                            trWidth, TEXT_LUMA, absPartIdx, &lastPosTransformSkip[TEXT_LUMA][0], true, curuseRDOQ);<br>
             cu->setCbfSubParts(absSumTransformSkipY ? setCbf : 0, TEXT_LUMA, absPartIdx, depth);<br>
<br>
@@ -3475,8 +3478,8 @@<br>
<br>
                 m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, curResiY, MAX_CU_SIZE,  coeffCurY, trWidth, scalingListType, true, lastPosTransformSkip[TEXT_LUMA][0]);<br>
<br>
-                nonZeroDistY = primitives.sse_ss[partSize](resiYuv->getLumaAddr(absTUPartIdx), resiYuv->m_width,<br>
-                                                           m_qtTempShortYuv[qtlayer].getLumaAddr(absTUPartIdx),<br>
+                nonZeroDistY = primitives.sse_ss[partSize](resiYuv->getLumaAddr(absPartIdx), resiYuv->m_width,<br>
+                                                           m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx),<br>
                                                            MAX_CU_SIZE);<br>
<br>
                 singleCostY = m_rdCost->calcRdCost(nonZeroDistY, skipSingleBitsY);<br>
@@ -3520,10 +3523,11 @@<br>
<br>
             do<br>
             {<br>
+                uint32_t absPartIdxC = tuIterator.m_absPartIdxTURelCU;<br>
                 uint32_t subTUBufferOffset = widthC * heightC * tuIterator.m_section;<br>
<br>
-                int16_t *curResiU = m_qtTempShortYuv[qtlayer].getCbAddr(tuIterator.m_absPartIdxTURelCU);<br>
-                int16_t *curResiV = m_qtTempShortYuv[qtlayer].getCrAddr(tuIterator.m_absPartIdxTURelCU);<br>
+                int16_t *curResiU = m_qtTempShortYuv[qtlayer].getCbAddr(absPartIdxC);<br>
+                int16_t *curResiV = m_qtTempShortYuv[qtlayer].getCrAddr(absPartIdxC);<br>
                 uint32_t stride = m_qtTempShortYuv[qtlayer].m_cwidth;<br>
<br>
                 coeff_t bestCoeffU[32 * 32], bestCoeffV[32 * 32];<br>
@@ -3537,8 +3541,8 @@<br>
                     memcpy(&bestResiV[i * widthC], curResiV + i * stride, sizeof(int16_t) * widthC);<br>
                 }<br>
<br>
-                cu->setTransformSkipPartRange(1, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setTransformSkipPartRange(1, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                cu->setTransformSkipPartRange(1, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setTransformSkipPartRange(1, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 if (m_cfg->bEnableRDOQTS)<br>
                 {<br>
@@ -3549,23 +3553,23 @@<br>
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
                 m_trQuant->selectLambda(TEXT_CHROMA);<br>
<br>
-                absSumTransformSkipU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
-                                                               widthC, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, &lastPosTransformSkip[TEXT_CHROMA_U][tuIterator.m_section], true, curuseRDOQ);<br>
+                absSumTransformSkipU = m_trQuant->transformNxN(cu, resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurU + subTUBufferOffset,<br>
+                                                               widthC, TEXT_CHROMA_U, absPartIdxC, &lastPosTransformSkip[TEXT_CHROMA_U][tuIterator.m_section], true, curuseRDOQ);<br>
                 curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
                 m_trQuant->setQPforQuant(cu->getQP(0), TEXT_CHROMA, cu->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset, chFmt);<br>
-                absSumTransformSkipV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
-                                                               widthC, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, &lastPosTransformSkip[TEXT_CHROMA_V][tuIterator.m_section], true, curuseRDOQ);<br>
-<br>
-                cu->setCbfPartRange(absSumTransformSkipU ? setCbf : 0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSumTransformSkipV ? setCbf : 0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                absSumTransformSkipV = m_trQuant->transformNxN(cu, resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth, coeffCurV + subTUBufferOffset,<br>
+                                                               widthC, TEXT_CHROMA_V, absPartIdxC, &lastPosTransformSkip[TEXT_CHROMA_V][tuIterator.m_section], true, curuseRDOQ);<br>
+<br>
+                cu->setCbfPartRange(absSumTransformSkipU ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSumTransformSkipV ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                 m_entropyCoder->resetBits();<br>
                 singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section] = 0;<br>
<br>
                 if (absSumTransformSkipU)<br>
                 {<br>
-                    m_entropyCoder->encodeQtCbf(cu, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_U, trMode, true);<br>
-                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurU + subTUBufferOffset, tuIterator.m_absPartIdxTURelCU, widthC, TEXT_CHROMA_U);<br>
+                    m_entropyCoder->encodeQtCbf(cu, absPartIdxC, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_U, trMode, true);<br>
+                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurU + subTUBufferOffset, absPartIdxC, widthC, TEXT_CHROMA_U);<br>
                     singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section] = m_entropyCoder->getNumberOfWrittenBits();<br>
<br>
                     curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCbQpOffset() + cu->getSlice()->getSliceQpDeltaCb();<br>
@@ -3573,10 +3577,10 @@<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_U;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(tuIterator.m_absPartIdxTURelCU), REG_DCT, curResiU, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurU + subTUBufferOffset,<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, curResiU, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurU + subTUBufferOffset,<br>
                                                widthC, scalingListType, true, lastPosTransformSkip[TEXT_CHROMA_U][tuIterator.m_section]);<br>
-                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCbAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth,<br>
-                                                                 m_qtTempShortYuv[qtlayer].getCbAddr(tuIterator.m_absPartIdxTURelCU),<br>
+                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCbAddr(absPartIdxC), resiYuv->m_cwidth,<br>
+                                                                 m_qtTempShortYuv[qtlayer].getCbAddr(absPartIdxC),<br>
                                                                  m_qtTempShortYuv[qtlayer].m_cwidth);<br>
                     nonZeroDistU = m_rdCost->scaleChromaDistCb(dist);<br>
                     singleCostU = m_rdCost->calcRdCost(nonZeroDistU, singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section]);<br>
@@ -3584,7 +3588,7 @@<br>
<br>
                 if (!absSumTransformSkipU || minCost[TEXT_CHROMA_U][tuIterator.m_section] < singleCostU)<br>
                 {<br>
-                    cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                    cu->setTransformSkipPartRange(0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                     memcpy(coeffCurU + subTUBufferOffset, bestCoeffU, sizeof(coeff_t) * numSamplesChroma);<br>
                     for (int i = 0; i < heightC; ++i)<br>
@@ -3601,8 +3605,8 @@<br>
<br>
                 if (absSumTransformSkipV)<br>
                 {<br>
-                    m_entropyCoder->encodeQtCbf(cu, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_V, trMode, true);<br>
-                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurV + subTUBufferOffset, tuIterator.m_absPartIdxTURelCU, widthC, TEXT_CHROMA_V);<br>
+                    m_entropyCoder->encodeQtCbf(cu, absPartIdxC, tuIterator.m_absPartIdxStep, widthC, heightC, TEXT_CHROMA_V, trMode, true);<br>
+                    m_entropyCoder->encodeCoeffNxN(cu, coeffCurV + subTUBufferOffset, absPartIdxC, widthC, TEXT_CHROMA_V);<br>
                     singleBitsComp[TEXT_CHROMA_V][tuIterator.m_section] = m_entropyCoder->getNumberOfWrittenBits() - singleBitsComp[TEXT_CHROMA_U][tuIterator.m_section];<br>
<br>
                     curChromaQpOffset = cu->getSlice()->getPPS()->getChromaCrQpOffset() + cu->getSlice()->getSliceQpDeltaCr();<br>
@@ -3610,10 +3614,10 @@<br>
<br>
                     int scalingListType = 3 + TEXT_CHROMA_V;<br>
                     X265_CHECK(scalingListType < 6, "scalingListType too large %d\n", scalingListType);<br>
-                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(tuIterator.m_absPartIdxTURelCU), REG_DCT, curResiV, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurV + subTUBufferOffset,<br>
+                    m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdxC), REG_DCT, curResiV, m_qtTempShortYuv[qtlayer].m_cwidth, coeffCurV + subTUBufferOffset,<br>
                                                widthC, scalingListType, true, lastPosTransformSkip[TEXT_CHROMA_V][tuIterator.m_section]);<br>
-                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCrAddr(tuIterator.m_absPartIdxTURelCU), resiYuv->m_cwidth,<br>
-                                                                 m_qtTempShortYuv[qtlayer].getCrAddr(tuIterator.m_absPartIdxTURelCU),<br>
+                    uint32_t dist = primitives.sse_ss[partSizeC](resiYuv->getCrAddr(absPartIdxC), resiYuv->m_cwidth,<br>
+                                                                 m_qtTempShortYuv[qtlayer].getCrAddr(absPartIdxC),<br>
                                                                  m_qtTempShortYuv[qtlayer].m_cwidth);<br>
                     nonZeroDistV = m_rdCost->scaleChromaDistCr(dist);<br>
                     singleCostV = m_rdCost->calcRdCost(nonZeroDistV, singleBitsComp[TEXT_CHROMA_V][tuIterator.m_section]);<br>
@@ -3621,7 +3625,7 @@<br>
<br>
                 if (!absSumTransformSkipV || minCost[TEXT_CHROMA_V][tuIterator.m_section] < singleCostV)<br>
                 {<br>
-                    cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                    cu->setTransformSkipPartRange(0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
<br>
                     memcpy(coeffCurV + subTUBufferOffset, bestCoeffV, sizeof(coeff_t) * numSamplesChroma);<br>
                     for (int i = 0; i < heightC; ++i)<br>
@@ -3636,8 +3640,8 @@<br>
                     bestTransformMode[TEXT_CHROMA_V][tuIterator.m_section] = 1;<br>
                 }<br>
<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
-                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, tuIterator.m_absPartIdxTURelCU, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_U][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_U, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
+                cu->setCbfPartRange(absSum[TEXT_CHROMA_V][tuIterator.m_section] ? setCbf : 0, TEXT_CHROMA_V, absPartIdxC, tuIterator.m_absPartIdxStep);<br>
             }<br>
             while (isNextSection(&tuIterator));<br>
         }<br>
@@ -3752,8 +3756,7 @@<br>
         const uint32_t qPartNumSubdiv = cu->getPic()->getNumPartInCU() >> ((depth + 1) << 1);<br>
         for (uint32_t i = 0; i < 4; ++i)<br>
         {<br>
-            uint32_t nsAddr = absPartIdx + i * qPartNumSubdiv;<br>
-            xEstimateResidualQT(cu, absPartIdx + i * qPartNumSubdiv, nsAddr, resiYuv, depth + 1, subDivCost, subdivBits, subdivDist, bCheckFull ? NULL : outZeroDist);<br>
+            xEstimateResidualQT(cu, absPartIdx + i * qPartNumSubdiv, resiYuv, depth + 1, subDivCost, subdivBits, subdivDist, bCheckFull ? NULL : outZeroDist);<br>
         }<br>
<br>
         uint32_t ycbf = 0;<br>
@@ -3977,7 +3980,7 @@<br>
     }<br>
 }<br>
<br>
-void TEncSearch::xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, ShortYuv* resiYuv, uint32_t depth, bool bSpatial)<br>
+void TEncSearch::xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth, bool bSpatial)<br>
 {<br>
     X265_CHECK(cu->getDepth(0) == cu->getDepth(absPartIdx), "depth not matching\n");<br>
     const uint32_t curTrMode = depth - cu->getDepth(0);<br>
@@ -4006,7 +4009,7 @@<br>
         {<br>
             uint32_t trWidth  = 1 << trSizeLog2;<br>
             uint32_t trHeight = 1 << trSizeLog2;<br>
-            m_qtTempShortYuv[qtlayer].copyPartToPartLuma(resiYuv, absTUPartIdx, trWidth, trHeight);<br>
+            m_qtTempShortYuv[qtlayer].copyPartToPartLuma(resiYuv, absPartIdx, trWidth, trHeight);<br>
<br>
             if (bCodeChroma)<br>
             {<br>
@@ -4040,8 +4043,7 @@<br>
         const uint32_t qPartNumSubdiv = cu->getPic()->getNumPartInCU() >> ((depth + 1) << 1);<br>
         for (uint32_t i = 0; i < 4; ++i)<br>
         {<br>
-            uint32_t nsAddr = absPartIdx + i * qPartNumSubdiv;<br>
-            xSetResidualQTData(cu, absPartIdx + i * qPartNumSubdiv, nsAddr, resiYuv, depth + 1, bSpatial);<br>
+            xSetResidualQTData(cu, absPartIdx + i * qPartNumSubdiv, resiYuv, depth + 1, bSpatial);<br>
         }<br>
     }<br>
 }<br>
diff -r ba2a9f61ea06 -r 862e454b039b source/Lib/TLibEncoder/TEncSearch.h<br>
--- a/source/Lib/TLibEncoder/TEncSearch.h       Fri May 16 19:20:46 2014 +0900<br>
+++ b/source/Lib/TLibEncoder/TEncSearch.h       Mon May 19 18:14:50 2014 +0900<br>
@@ -177,11 +177,11 @@<br>
<br>
     void generateCoeffRecon(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, ShortYuv* resiYuv, TComYuv* reconYuv, bool skipRes);<br>
<br>
-    void xEstimateResidualQT(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, ShortYuv* resiYuv, uint32_t depth,<br>
+    void xEstimateResidualQT(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth,<br>
                              uint64_t &rdCost, uint32_t &outBits, uint32_t &outDist, uint32_t *puiZeroDist, bool curUseRDOQ = true);<br>
-    void xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, ShortYuv* resiYuv, uint32_t depth, bool bSpatial);<br>
+    void xSetResidualQTData(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth, bool bSpatial);<br>
<br>
-    void residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, uint32_t absTUPartIdx, ShortYuv* resiYuv, uint32_t depth, bool curUseRDOQ = true);<br>
+    void residualTransformQuantInter(TComDataCU* cu, uint32_t absPartIdx, ShortYuv* resiYuv, uint32_t depth, bool curUseRDOQ = true);<br>
<br>
     // -------------------------------------------------------------------------------------------------------------------<br>
     // compute symbol bits<br>
@@ -206,10 +206,10 @@<br>
     uint32_t xGetIntraBitsQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t absPartIdxStep, bool bLuma, bool bChroma);<br>
     uint32_t xGetIntraBitsQTChroma(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t chromaId, const bool splitIntoSubTUs);<br>
     void xIntraCodingLumaBlk(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv, TComYuv* predYuv,<br>
-                             ShortYuv* resiYuv, uint32_t& outDist, bool bReusePred = false);<br>
+                             ShortYuv* resiYuv, uint32_t& outDist);<br>
<br>
     void xIntraCodingChromaBlk(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t absPartIdxStep, TComYuv* fencYuv, TComYuv* predYuv,<br>
-                               ShortYuv* resiYuv, uint32_t& outDist, uint32_t uiChromaId, bool bReusePred = false);<br>
+                               ShortYuv* resiYuv, uint32_t& outDist, uint32_t chromaId);<br>
<br>
     void xRecurIntraChromaCodingQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, TComYuv* fencYuv,<br>
                                    TComYuv* predYuv, ShortYuv* resiYuv, uint32_t& outDist);<br>
diff -r ba2a9f61ea06 -r 862e454b039b source/encoder/compress.cpp<br>
--- a/source/encoder/compress.cpp       Fri May 16 19:20:46 2014 +0900<br>
+++ b/source/encoder/compress.cpp       Mon May 19 18:14:50 2014 +0900<br>
@@ -892,7 +892,7 @@<br>
             primitives.chroma[m_param->internalCsp].sub_ps[part](dst, dststride, src1, src2, src1stride, src2stride);<br>
<br>
             //Residual encoding<br>
-            m_search->residualTransformQuantInter(cu, 0, 0, m_tmpResiYuv[depth], cu->getDepth(0), true);<br>
+            m_search->residualTransformQuantInter(cu, 0, m_tmpResiYuv[depth], cu->getDepth(0), true);<br>
             xCheckDQP(cu);<br>
<br>
             if (lcu->getMergeFlag(absPartIdx) && cu->getPartitionSize(0) == SIZE_2Nx2N && !cu->getQtRootCbf(0))<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div>