[x265] refine CUSize related

Satoshi Nakagawa nakagawa424 at oki.com
Thu Mar 27 10:21:51 CET 2014


# HG changeset patch
# User Satoshi Nakagawa <nakagawa424 at oki.com>
# Date 1395911972 -32400
#      Thu Mar 27 18:19:32 2014 +0900
# Node ID 65fb83d78276aef809747ea858a389232b388c80
# Parent  8e0c2d24fc45aecc17c3d8c131c1a0d8a67e342a
refine CUSize related

rename to clarify.
division to shift.

diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -102,7 +102,7 @@
 TComDataCU::~TComDataCU()
 {}
 
-bool TComDataCU::create(uint32_t numPartition, uint32_t width, uint32_t height, int unitSize, int csp)
+bool TComDataCU::create(uint32_t numPartition, uint32_t cuSize, int unitSize, int csp)
 {
     m_hChromaShift = CHROMA_H_SHIFT(csp);
     m_vChromaShift = CHROMA_V_SHIFT(csp);
@@ -111,7 +111,6 @@
     m_pic           = NULL;
     m_slice         = NULL;
     m_numPartitions = numPartition;
-    m_unitSize = unitSize;
 
     uint32_t tmp = 4 * AMVP_DECIMATION_FACTOR / unitSize;
     tmp = tmp * tmp;
@@ -148,14 +147,14 @@
     CHECKED_MALLOC(m_mvpIdx[0], uint8_t, numPartition * 2);
     m_mvpIdx[1] = m_mvpIdx[0] + numPartition;
 
-    CHECKED_MALLOC(m_trCoeffY, coeff_t, width * height);
-    CHECKED_MALLOC(m_trCoeffCb, coeff_t, (width >> m_hChromaShift) * (height >> m_vChromaShift));
-    CHECKED_MALLOC(m_trCoeffCr, coeff_t, (width >> m_hChromaShift) * (height >> m_vChromaShift));
+    CHECKED_MALLOC(m_trCoeffY, coeff_t, cuSize * cuSize);
+    CHECKED_MALLOC(m_trCoeffCb, coeff_t, cuSize * cuSize >> (m_hChromaShift + m_vChromaShift));
+    CHECKED_MALLOC(m_trCoeffCr, coeff_t, cuSize * cuSize >> (m_hChromaShift + m_vChromaShift));
 
     CHECKED_MALLOC(m_iPCMFlags, bool, numPartition);
-    CHECKED_MALLOC(m_iPCMSampleY, pixel, width * height);
-    CHECKED_MALLOC(m_iPCMSampleCb, pixel, (width >> m_hChromaShift) * (height >> m_vChromaShift));
-    CHECKED_MALLOC(m_iPCMSampleCr, pixel, (width >> m_hChromaShift) * (height >> m_vChromaShift));
+    CHECKED_MALLOC(m_iPCMSampleY, pixel, cuSize * cuSize);
+    CHECKED_MALLOC(m_iPCMSampleCb, pixel, cuSize * cuSize >> (m_hChromaShift + m_vChromaShift));
+    CHECKED_MALLOC(m_iPCMSampleCr, pixel, cuSize * cuSize >> (m_hChromaShift + m_vChromaShift));
 
     memset(m_partSizes, SIZE_NONE, numPartition * sizeof(*m_partSizes));
     return ok;
@@ -261,7 +260,7 @@
     }
 
     uint32_t y_tmp = g_maxCUSize * g_maxCUSize;
-    uint32_t c_tmp = (g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift);
+    uint32_t c_tmp = g_maxCUSize * g_maxCUSize >> (m_hChromaShift + m_vChromaShift);
     {
         m_cuMvField[0].clearMvField();
         m_cuMvField[1].clearMvField();
@@ -632,7 +631,7 @@
     memcpy(m_trCoeffY  + tmp2, cu->getCoeffY(),  sizeof(coeff_t) * tmp);
     memcpy(m_iPCMSampleY + tmp2, cu->getPCMSampleY(), sizeof(pixel) * tmp);
 
-    tmp  = (g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift) >> (depth << 1);
+    tmp  >>= m_hChromaShift + m_vChromaShift;
     tmp2 = partUnitIdx * tmp;
     memcpy(m_trCoeffCb + tmp2, cu->getCoeffCb(), sizeof(coeff_t) * tmp);
     memcpy(m_trCoeffCr + tmp2, cu->getCoeffCr(), sizeof(coeff_t) * tmp);
@@ -687,11 +686,11 @@
     memcpy(rpcCU->getIPCMFlag() + m_absIdxInLCU, m_iPCMFlags,         iSizeInBool);
 
     uint32_t tmp  = (g_maxCUSize * g_maxCUSize) >> (uhDepth << 1);
-    uint32_t tmp2 = m_absIdxInLCU * m_pic->getMinCUSize() * m_pic->getMinCUSize();
+    uint32_t tmp2 = m_absIdxInLCU << m_pic->getLog2UnitSize() * 2;
     memcpy(rpcCU->getCoeffY()     + tmp2, m_trCoeffY,    sizeof(coeff_t) * tmp);
     memcpy(rpcCU->getPCMSampleY() + tmp2, m_iPCMSampleY, sizeof(pixel) * tmp);
-    tmp  = ((g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift)) >> (uhDepth << 1);
-    tmp2 = m_absIdxInLCU * (m_pic->getMinCUSize() >> m_hChromaShift) * (m_pic->getMinCUSize() >> m_vChromaShift);
+    tmp  >>= m_hChromaShift + m_vChromaShift;
+    tmp2 >>= m_hChromaShift + m_vChromaShift;
     memcpy(rpcCU->getCoeffCb() + tmp2, m_trCoeffCb, sizeof(coeff_t) * tmp);
     memcpy(rpcCU->getCoeffCr() + tmp2, m_trCoeffCr, sizeof(coeff_t) * tmp);
     memcpy(rpcCU->getPCMSampleCb() + tmp2, m_iPCMSampleCb, sizeof(pixel) * tmp);
@@ -717,11 +716,11 @@
     memcpy(rpcCU->getCbf(TEXT_CHROMA_V) + m_absIdxInLCU, m_cbf[2], iSizeInUchar);
 
     uint32_t tmp  = (g_maxCUSize * g_maxCUSize) >> (depth << 1);
-    uint32_t tmp2 = m_absIdxInLCU * m_pic->getMinCUSize() * m_pic->getMinCUSize();
+    uint32_t tmp2 = m_absIdxInLCU << m_pic->getLog2UnitSize() * 2;
     memcpy(rpcCU->getCoeffY() + tmp2, m_trCoeffY, sizeof(coeff_t) * tmp);
 
-    tmp  = ((g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_hChromaShift)) >> (depth << 1);
-    tmp2 = m_absIdxInLCU * (m_pic->getMinCUSize() >> m_hChromaShift) * (m_pic->getMinCUSize() >> m_vChromaShift);
+    tmp  >>= m_hChromaShift + m_vChromaShift;
+    tmp2 >>= m_hChromaShift + m_vChromaShift;
     memcpy(rpcCU->getCoeffCb() + tmp2, m_trCoeffCb, sizeof(coeff_t) * tmp);
     memcpy(rpcCU->getCoeffCr() + tmp2, m_trCoeffCr, sizeof(coeff_t) * tmp);
 }
@@ -771,12 +770,12 @@
     memcpy(cu->getIPCMFlag() + partOffset, m_iPCMFlags, sizeInBool);
 
     uint32_t tmp  = (g_maxCUSize * g_maxCUSize) >> ((depth + partDepth) << 1);
-    uint32_t tmp2 = partOffset * m_pic->getMinCUSize() * m_pic->getMinCUSize();
+    uint32_t tmp2 = partOffset << m_pic->getLog2UnitSize() * 2;
     memcpy(cu->getCoeffY()  + tmp2, m_trCoeffY,  sizeof(coeff_t) * tmp);
     memcpy(cu->getPCMSampleY() + tmp2, m_iPCMSampleY, sizeof(pixel) * tmp);
 
-    tmp  = ((g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift)) >> ((depth + partDepth) << 1);
-    tmp2 = partOffset * (m_pic->getMinCUSize() >> m_hChromaShift) * (m_pic->getMinCUSize() >> m_vChromaShift);
+    tmp  >>= m_hChromaShift + m_vChromaShift;
+    tmp2 >>= m_hChromaShift + m_vChromaShift;
     memcpy(cu->getCoeffCb() + tmp2, m_trCoeffCb, sizeof(coeff_t) * tmp);
     memcpy(cu->getCoeffCr() + tmp2, m_trCoeffCr, sizeof(coeff_t) * tmp);
     memcpy(cu->getPCMSampleCb() + tmp2, m_iPCMSampleCb, sizeof(pixel) * tmp);
@@ -791,12 +790,12 @@
 {
     uint32_t absPartIdx       = g_zscanToRaster[curPartUnitIdx];
     uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU];
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if (!RasterAddress::isZeroCol(absPartIdx, numPartInCUWidth))
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if (!RasterAddress::isZeroCol(absPartIdx, numPartInCUSize))
     {
         lPartUnitIdx = g_rasterToZscan[absPartIdx - 1];
-        if (RasterAddress::isEqualCol(absPartIdx, absZorderCUIdx, numPartInCUWidth))
+        if (RasterAddress::isEqualCol(absPartIdx, absZorderCUIdx, numPartInCUSize))
         {
             return m_pic->getCU(getAddr());
         }
@@ -807,7 +806,7 @@
         }
     }
 
-    lPartUnitIdx = g_rasterToZscan[absPartIdx + numPartInCUWidth - 1];
+    lPartUnitIdx = g_rasterToZscan[absPartIdx + numPartInCUSize - 1];
 
     if ((bEnforceSliceRestriction && (m_cuLeft == NULL || m_cuLeft->getSlice() == NULL)) ||
         (bEnforceTileRestriction && (m_cuLeft == NULL || m_cuLeft->getSlice() == NULL)))
@@ -822,12 +821,12 @@
 {
     uint32_t absPartIdx       = g_zscanToRaster[curPartUnitIdx];
     uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU];
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUWidth))
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUSize))
     {
-        aPartUnitIdx = g_rasterToZscan[absPartIdx - numPartInCUWidth];
-        if (RasterAddress::isEqualRow(absPartIdx, absZorderCUIdx, numPartInCUWidth))
+        aPartUnitIdx = g_rasterToZscan[absPartIdx - numPartInCUSize];
+        if (RasterAddress::isEqualRow(absPartIdx, absZorderCUIdx, numPartInCUSize))
         {
             return m_pic->getCU(getAddr());
         }
@@ -843,7 +842,7 @@
         return NULL;
     }
 
-    aPartUnitIdx = g_rasterToZscan[absPartIdx + m_pic->getNumPartInCU() - numPartInCUWidth];
+    aPartUnitIdx = g_rasterToZscan[absPartIdx + m_pic->getNumPartInCU() - numPartInCUSize];
 
     if ((bEnforceSliceRestriction && (m_cuAbove == NULL || m_cuAbove->getSlice() == NULL)) ||
         (bEnforceTileRestriction && (m_cuAbove == NULL || m_cuAbove->getSlice() == NULL)))
@@ -857,14 +856,14 @@
 {
     uint32_t absPartIdx       = g_zscanToRaster[curPartUnitIdx];
     uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU];
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if (!RasterAddress::isZeroCol(absPartIdx, numPartInCUWidth))
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if (!RasterAddress::isZeroCol(absPartIdx, numPartInCUSize))
     {
-        if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUWidth))
+        if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUSize))
         {
-            alPartUnitIdx = g_rasterToZscan[absPartIdx - numPartInCUWidth - 1];
-            if (RasterAddress::isEqualRowOrCol(absPartIdx, absZorderCUIdx, numPartInCUWidth))
+            alPartUnitIdx = g_rasterToZscan[absPartIdx - numPartInCUSize - 1];
+            if (RasterAddress::isEqualRowOrCol(absPartIdx, absZorderCUIdx, numPartInCUSize))
             {
                 return m_pic->getCU(getAddr());
             }
@@ -874,7 +873,7 @@
                 return this;
             }
         }
-        alPartUnitIdx = g_rasterToZscan[absPartIdx + getPic()->getNumPartInCU() - numPartInCUWidth - 1];
+        alPartUnitIdx = g_rasterToZscan[absPartIdx + getPic()->getNumPartInCU() - numPartInCUSize - 1];
         if ((bEnforceSliceRestriction && (m_cuAbove == NULL || m_cuAbove->getSlice() == NULL)))
         {
             return NULL;
@@ -882,7 +881,7 @@
         return m_cuAbove;
     }
 
-    if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUWidth))
+    if (!RasterAddress::isZeroRow(absPartIdx, numPartInCUSize))
     {
         alPartUnitIdx = g_rasterToZscan[absPartIdx - 1];
         if ((bEnforceSliceRestriction && (m_cuLeft == NULL || m_cuLeft->getSlice() == NULL))
@@ -904,23 +903,23 @@
 TComDataCU* TComDataCU::getPUAboveRight(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx, bool bEnforceSliceRestriction)
 {
     uint32_t absPartIdxRT     = g_zscanToRaster[curPartUnitIdx];
-    uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU] + m_cuSize[0] / m_pic->getMinCUSize() - 1;
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())
+    uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU] + (m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1;
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())
     {
         arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUWidth - 1, numPartInCUWidth))
+    if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUSize - 1, numPartInCUSize))
     {
-        if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUWidth))
+        if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
         {
-            if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUWidth + 1])
+            if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUSize + 1])
             {
-                arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUWidth + 1];
-                if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUWidth))
+                arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUSize + 1];
+                if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUSize))
                 {
                     return m_pic->getCU(getAddr());
                 }
@@ -933,7 +932,7 @@
             arPartUnitIdx = MAX_UINT;
             return NULL;
         }
-        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUWidth + 1];
+        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + 1];
         if ((bEnforceSliceRestriction && (m_cuAbove == NULL || m_cuAbove->getSlice() == NULL)))
         {
             return NULL;
@@ -941,13 +940,13 @@
         return m_cuAbove;
     }
 
-    if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUWidth))
+    if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
     {
         arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUWidth];
+    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUSize];
     if ((bEnforceSliceRestriction && (m_cuAboveRight == NULL || m_cuAboveRight->getSlice() == NULL ||
                                       (m_cuAboveRight->getAddr()) > getAddr())))
     {
@@ -959,23 +958,23 @@
 TComDataCU* TComDataCU::getPUBelowLeft(uint32_t& blPartUnitIdx, uint32_t curPartUnitIdx, bool bEnforceSliceRestriction)
 {
     uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
-    uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + (m_cuSize[0] / m_pic->getMinCUSize() - 1) * m_pic->getNumPartInWidth();
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
+    uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1) * m_pic->getNumPartInCUSize();
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
     {
         blPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    if (RasterAddress::lessThanRow(absPartIdxLB, m_pic->getNumPartInHeight() - 1, numPartInCUWidth))
+    if (RasterAddress::lessThanRow(absPartIdxLB, numPartInCUSize - 1, numPartInCUSize))
     {
-        if (!RasterAddress::isZeroCol(absPartIdxLB, numPartInCUWidth))
+        if (!RasterAddress::isZeroCol(absPartIdxLB, numPartInCUSize))
         {
-            if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + numPartInCUWidth - 1])
+            if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + numPartInCUSize - 1])
             {
-                blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUWidth - 1];
-                if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUWidth))
+                blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUSize - 1];
+                if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUSize))
                 {
                     return m_pic->getCU(getAddr());
                 }
@@ -988,7 +987,7 @@
             blPartUnitIdx = MAX_UINT;
             return NULL;
         }
-        blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUWidth * 2 - 1];
+        blPartUnitIdx = g_rasterToZscan[absPartIdxLB + numPartInCUSize * 2 - 1];
         if ((bEnforceSliceRestriction && (m_cuLeft == NULL || m_cuLeft->getSlice() == NULL)))
         {
             return NULL;
@@ -1003,24 +1002,24 @@
 TComDataCU* TComDataCU::getPUBelowLeftAdi(uint32_t& blPartUnitIdx,  uint32_t curPartUnitIdx, uint32_t partUnitOffset)
 {
     uint32_t absPartIdxLB     = g_zscanToRaster[curPartUnitIdx];
-    uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((m_cuSize[0] / m_pic->getMinCUSize()) - 1) * m_pic->getNumPartInWidth();
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (m_pic->getPicSym()->getMinCUSize() * partUnitOffset)) >=
+    uint32_t absZorderCUIdxLB = g_zscanToRaster[m_absIdxInLCU] + ((m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1) * m_pic->getNumPartInCUSize();
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdxLB] + (partUnitOffset << m_pic->getPicSym()->getLog2UnitSize())) >=
         m_slice->getSPS()->getPicHeightInLumaSamples())
     {
         blPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    if (RasterAddress::lessThanRow(absPartIdxLB, m_pic->getNumPartInHeight() - partUnitOffset, numPartInCUWidth))
+    if (RasterAddress::lessThanRow(absPartIdxLB, numPartInCUSize - partUnitOffset, numPartInCUSize))
     {
-        if (!RasterAddress::isZeroCol(absPartIdxLB, numPartInCUWidth))
+        if (!RasterAddress::isZeroCol(absPartIdxLB, numPartInCUSize))
         {
-            if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUWidth - 1])
+            if (curPartUnitIdx > g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUSize - 1])
             {
-                blPartUnitIdx = g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUWidth - 1];
-                if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUWidth))
+                blPartUnitIdx = g_rasterToZscan[absPartIdxLB + partUnitOffset * numPartInCUSize - 1];
+                if (RasterAddress::isEqualRowOrCol(absPartIdxLB, absZorderCUIdxLB, numPartInCUSize))
                 {
                     return m_pic->getCU(getAddr());
                 }
@@ -1033,7 +1032,7 @@
             blPartUnitIdx = MAX_UINT;
             return NULL;
         }
-        blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (1 + partUnitOffset) * numPartInCUWidth - 1];
+        blPartUnitIdx = g_rasterToZscan[absPartIdxLB + (1 + partUnitOffset) * numPartInCUSize - 1];
         if (m_cuLeft == NULL || m_cuLeft->getSlice() == NULL)
         {
             return NULL;
@@ -1048,24 +1047,24 @@
 TComDataCU* TComDataCU::getPUAboveRightAdi(uint32_t& arPartUnitIdx, uint32_t curPartUnitIdx, uint32_t partUnitOffset)
 {
     uint32_t absPartIdxRT     = g_zscanToRaster[curPartUnitIdx];
-    uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU] + (m_cuSize[0] / m_pic->getMinCUSize()) - 1;
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-
-    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (m_pic->getPicSym()->getMinCUSize() * partUnitOffset)) >=
+    uint32_t absZorderCUIdx   = g_zscanToRaster[m_absIdxInLCU] + (m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1;
+    uint32_t numPartInCUSize  = m_pic->getNumPartInCUSize();
+
+    if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdxRT] + (partUnitOffset << m_pic->getPicSym()->getLog2UnitSize())) >=
         m_slice->getSPS()->getPicWidthInLumaSamples())
     {
         arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUWidth - partUnitOffset, numPartInCUWidth))
+    if (RasterAddress::lessThanCol(absPartIdxRT, numPartInCUSize - partUnitOffset, numPartInCUSize))
     {
-        if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUWidth))
+        if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
         {
-            if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUWidth + partUnitOffset])
+            if (curPartUnitIdx > g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset])
             {
-                arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUWidth + partUnitOffset];
-                if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUWidth))
+                arPartUnitIdx = g_rasterToZscan[absPartIdxRT - numPartInCUSize + partUnitOffset];
+                if (RasterAddress::isEqualRowOrCol(absPartIdxRT, absZorderCUIdx, numPartInCUSize))
                 {
                     return m_pic->getCU(getAddr());
                 }
@@ -1078,7 +1077,7 @@
             arPartUnitIdx = MAX_UINT;
             return NULL;
         }
-        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUWidth + partUnitOffset];
+        arPartUnitIdx = g_rasterToZscan[absPartIdxRT + m_pic->getNumPartInCU() - numPartInCUSize + partUnitOffset];
         if (m_cuAbove == NULL || m_cuAbove->getSlice() == NULL)
         {
             return NULL;
@@ -1086,13 +1085,13 @@
         return m_cuAbove;
     }
 
-    if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUWidth))
+    if (!RasterAddress::isZeroRow(absPartIdxRT, numPartInCUSize))
     {
         arPartUnitIdx = MAX_UINT;
         return NULL;
     }
 
-    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUWidth + partUnitOffset - 1];
+    arPartUnitIdx = g_rasterToZscan[m_pic->getNumPartInCU() - numPartInCUSize + partUnitOffset - 1];
     if ((m_cuAboveRight == NULL || m_cuAboveRight->getSlice() == NULL ||
          (m_cuAboveRight->getAddr()) > getAddr()))
     {
@@ -1108,13 +1107,13 @@
 */
 TComDataCU* TComDataCU::getQpMinCuLeft(uint32_t& lPartUnitIdx, uint32_t curAbsIdxInLCU)
 {
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
+    uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
     uint32_t absZorderQpMinCUIdx = (curAbsIdxInLCU >> ((g_maxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth()) << 1)) <<
         ((g_maxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth()) << 1);
     uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
 
     // check for left LCU boundary
-    if (RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUWidth))
+    if (RasterAddress::isZeroCol(absRorderQpMinCUIdx, numPartInCUSize))
     {
         return NULL;
     }
@@ -1133,19 +1132,19 @@
 */
 TComDataCU* TComDataCU::getQpMinCuAbove(uint32_t& aPartUnitIdx, uint32_t curAbsIdxInLCU)
 {
-    uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
+    uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
     uint32_t absZorderQpMinCUIdx = (curAbsIdxInLCU >> ((g_maxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth()) << 1)) <<
         ((g_maxCUDepth - getSlice()->getPPS()->getMaxCuDQPDepth()) << 1);
     uint32_t absRorderQpMinCUIdx = g_zscanToRaster[absZorderQpMinCUIdx];
 
     // check for top LCU boundary
-    if (RasterAddress::isZeroRow(absRorderQpMinCUIdx, numPartInCUWidth))
+    if (RasterAddress::isZeroRow(absRorderQpMinCUIdx, numPartInCUSize))
     {
         return NULL;
     }
 
     // get index of top-CU relative to top-left corner of current quantization group
-    aPartUnitIdx = g_rasterToZscan[absRorderQpMinCUIdx - numPartInCUWidth];
+    aPartUnitIdx = g_rasterToZscan[absRorderQpMinCUIdx - numPartInCUSize];
 
     // return pointer to current LCU
     return m_pic->getCU(getAddr());
@@ -1699,30 +1698,31 @@
 void TComDataCU::deriveLeftRightTopIdxGeneral(uint32_t absPartIdx, uint32_t partIdx, uint32_t& outPartIdxLT, uint32_t& outPartIdxRT)
 {
     outPartIdxLT = m_absIdxInLCU + absPartIdx;
+    uint32_t cuSize = m_cuSize[absPartIdx];
     uint32_t puWidth = 0;
 
     switch (m_partSizes[absPartIdx])
     {
-    case SIZE_2Nx2N: puWidth = m_cuSize[absPartIdx];
+    case SIZE_2Nx2N: puWidth = cuSize;
         break;
-    case SIZE_2NxN:  puWidth = m_cuSize[absPartIdx];
+    case SIZE_2NxN:  puWidth = cuSize;
         break;
-    case SIZE_Nx2N:  puWidth = m_cuSize[absPartIdx]  >> 1;
+    case SIZE_Nx2N:  puWidth = cuSize  >> 1;
         break;
-    case SIZE_NxN:   puWidth = m_cuSize[absPartIdx]  >> 1;
+    case SIZE_NxN:   puWidth = cuSize  >> 1;
         break;
-    case SIZE_2NxnU: puWidth = m_cuSize[absPartIdx];
+    case SIZE_2NxnU: puWidth = cuSize;
         break;
-    case SIZE_2NxnD: puWidth = m_cuSize[absPartIdx];
+    case SIZE_2NxnD: puWidth = cuSize;
         break;
     case SIZE_nLx2N:
         if (partIdx == 0)
         {
-            puWidth = m_cuSize[absPartIdx]  >> 2;
+            puWidth = cuSize  >> 2;
         }
         else if (partIdx == 1)
         {
-            puWidth = (m_cuSize[absPartIdx]  >> 1) + (m_cuSize[absPartIdx]  >> 2);
+            puWidth = (cuSize  >> 1) + (cuSize  >> 2);
         }
         else
         {
@@ -1732,11 +1732,11 @@
     case SIZE_nRx2N:
         if (partIdx == 0)
         {
-            puWidth = (m_cuSize[absPartIdx]  >> 1) + (m_cuSize[absPartIdx]  >> 2);
+            puWidth = (cuSize  >> 1) + (cuSize  >> 2);
         }
         else if (partIdx == 1)
         {
-            puWidth = m_cuSize[absPartIdx]  >> 2;
+            puWidth = cuSize  >> 2;
         }
         else
         {
@@ -1748,31 +1748,32 @@
         break;
     }
 
-    outPartIdxRT = g_rasterToZscan[g_zscanToRaster[outPartIdxLT] + puWidth / m_pic->getMinCUSize() - 1];
+    outPartIdxRT = g_rasterToZscan[g_zscanToRaster[outPartIdxLT] + (puWidth >> m_pic->getLog2UnitSize()) - 1];
 }
 
 void TComDataCU::deriveLeftBottomIdxGeneral(uint32_t absPartIdx, uint32_t partIdx, uint32_t& outPartIdxLB)
 {
+    uint32_t cuSize = m_cuSize[absPartIdx];
     uint32_t puHeight = 0;
 
     switch (m_partSizes[absPartIdx])
     {
-    case SIZE_2Nx2N: puHeight = m_cuSize[absPartIdx];
+    case SIZE_2Nx2N: puHeight = cuSize;
         break;
-    case SIZE_2NxN:  puHeight = m_cuSize[absPartIdx] >> 1;
+    case SIZE_2NxN:  puHeight = cuSize >> 1;
         break;
-    case SIZE_Nx2N:  puHeight = m_cuSize[absPartIdx];
+    case SIZE_Nx2N:  puHeight = cuSize;
         break;
-    case SIZE_NxN:   puHeight = m_cuSize[absPartIdx] >> 1;
+    case SIZE_NxN:   puHeight = cuSize >> 1;
         break;
     case SIZE_2NxnU:
         if (partIdx == 0)
         {
-            puHeight = m_cuSize[absPartIdx] >> 2;
+            puHeight = cuSize >> 2;
         }
         else if (partIdx == 1)
         {
-            puHeight = (m_cuSize[absPartIdx] >> 1) + (m_cuSize[absPartIdx] >> 2);
+            puHeight = (cuSize >> 1) + (cuSize >> 2);
         }
         else
         {
@@ -1782,33 +1783,33 @@
     case SIZE_2NxnD:
         if (partIdx == 0)
         {
-            puHeight = (m_cuSize[absPartIdx] >> 1) + (m_cuSize[absPartIdx] >> 2);
+            puHeight = (cuSize >> 1) + (cuSize >> 2);
         }
         else if (partIdx == 1)
         {
-            puHeight = m_cuSize[absPartIdx] >> 2;
+            puHeight = cuSize >> 2;
         }
         else
         {
             assert(0);
         }
         break;
-    case SIZE_nLx2N: puHeight = m_cuSize[absPartIdx];
+    case SIZE_nLx2N: puHeight = cuSize;
         break;
-    case SIZE_nRx2N: puHeight = m_cuSize[absPartIdx];
+    case SIZE_nRx2N: puHeight = cuSize;
         break;
     default:
         assert(0);
         break;
     }
 
-    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU + absPartIdx] + ((puHeight / m_pic->getMinCUSize()) - 1) * m_pic->getNumPartInWidth()];
+    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU + absPartIdx] + ((puHeight >> m_pic->getLog2UnitSize()) - 1) * m_pic->getNumPartInCUSize()];
 }
 
 void TComDataCU::deriveLeftRightTopIdx(uint32_t partIdx, uint32_t& ruiPartIdxLT, uint32_t& ruiPartIdxRT)
 {
     ruiPartIdxLT = m_absIdxInLCU;
-    ruiPartIdxRT = g_rasterToZscan[g_zscanToRaster[ruiPartIdxLT] + m_cuSize[0] / m_pic->getMinCUSize() - 1];
+    ruiPartIdxRT = g_rasterToZscan[g_zscanToRaster[ruiPartIdxLT] + (m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1];
 
     switch (m_partSizes[0])
     {
@@ -1849,7 +1850,7 @@
 
 void TComDataCU::deriveLeftBottomIdx(uint32_t partIdx, uint32_t& outPartIdxLB)
 {
-    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + (((m_cuSize[0] / m_pic->getMinCUSize()) >> 1) - 1) * m_pic->getNumPartInWidth()];
+    outPartIdxLB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + (((m_cuSize[0] >> m_pic->getLog2UnitSize()) >> 1) - 1) * m_pic->getNumPartInCUSize()];
 
     switch (m_partSizes[0])
     {
@@ -1890,8 +1891,8 @@
  */
 void TComDataCU::deriveRightBottomIdx(uint32_t partIdx, uint32_t& outPartIdxRB)
 {
-    outPartIdxRB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + (((m_cuSize[0] / m_pic->getMinCUSize()) >> 1) - 1) *
-                                   m_pic->getNumPartInWidth() +  m_cuSize[0] / m_pic->getMinCUSize() - 1];
+    outPartIdxRB = g_rasterToZscan[g_zscanToRaster[m_absIdxInLCU] + (((m_cuSize[0] >> m_pic->getLog2UnitSize()) >> 1) - 1) *
+                                   m_pic->getNumPartInCUSize() +  (m_cuSize[0] >> m_pic->getLog2UnitSize()) - 1];
 
     switch (m_partSizes[0])
     {
@@ -1927,7 +1928,7 @@
 
 void TComDataCU::deriveLeftRightTopIdxAdi(uint32_t& outPartIdxLT, uint32_t& outPartIdxRT, uint32_t partOffset, uint32_t partDepth)
 {
-    uint32_t numPartInWidth = (m_cuSize[0] / m_pic->getMinCUSize()) >> partDepth;
+    uint32_t numPartInWidth = m_cuSize[0] >> (m_pic->getLog2UnitSize() + partDepth);
 
     outPartIdxLT = m_absIdxInLCU + partOffset;
     outPartIdxRT = g_rasterToZscan[g_zscanToRaster[outPartIdxLT] + numPartInWidth - 1];
@@ -1936,12 +1937,10 @@
 void TComDataCU::deriveLeftBottomIdxAdi(uint32_t& outPartIdxLB, uint32_t partOffset, uint32_t partDepth)
 {
     uint32_t absIdx;
-    uint32_t minCUWidth, widthInMinCUs;
-
-    minCUWidth    = getPic()->getMinCUSize();
-    widthInMinCUs = (getCUSize(0) / minCUWidth) >> partDepth;
+    uint32_t numPartInWidth = m_cuSize[0] >> (m_pic->getLog2UnitSize() + partDepth);
+
     absIdx        = getZorderIdxInCU() + partOffset + (m_numPartitions >> (partDepth << 1)) - 1;
-    absIdx        = g_zscanToRaster[absIdx] - (widthInMinCUs - 1);
+    absIdx        = g_zscanToRaster[absIdx] - (numPartInWidth - 1);
     outPartIdxLB    = g_rasterToZscan[absIdx];
 }
 
@@ -2139,31 +2138,31 @@
         deriveRightBottomIdx(puIdx, partIdxRB);
 
         uint32_t uiAbsPartIdxTmp = g_zscanToRaster[partIdxRB];
-        uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
+        uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
 
         MV colmv;
         int refIdx;
         int lcuIdx = -1;
 
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[uiAbsPartIdxTmp] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())  // image boundary check
+        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[uiAbsPartIdxTmp] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())  // image boundary check
         {
         }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[uiAbsPartIdxTmp] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
+        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[uiAbsPartIdxTmp] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
         {
         }
         else
         {
-            if ((uiAbsPartIdxTmp % numPartInCUWidth < numPartInCUWidth - 1) &&        // is not at the last column of LCU
-                (uiAbsPartIdxTmp / numPartInCUWidth < m_pic->getNumPartInHeight() - 1)) // is not at the last row    of LCU
+            if ((uiAbsPartIdxTmp % numPartInCUSize < numPartInCUSize - 1) &&        // is not at the last column of LCU
+                (uiAbsPartIdxTmp / numPartInCUSize < numPartInCUSize - 1)) // is not at the last row    of LCU
             {
-                absPartAddr = g_rasterToZscan[uiAbsPartIdxTmp + numPartInCUWidth + 1];
+                absPartAddr = g_rasterToZscan[uiAbsPartIdxTmp + numPartInCUSize + 1];
                 lcuIdx = getAddr();
             }
-            else if (uiAbsPartIdxTmp % numPartInCUWidth < numPartInCUWidth - 1)       // is not at the last column of LCU But is last row of LCU
+            else if (uiAbsPartIdxTmp % numPartInCUSize < numPartInCUSize - 1)       // is not at the last column of LCU But is last row of LCU
             {
-                absPartAddr = g_rasterToZscan[(uiAbsPartIdxTmp + numPartInCUWidth + 1) % m_pic->getNumPartInCU()];
+                absPartAddr = g_rasterToZscan[(uiAbsPartIdxTmp + numPartInCUSize + 1) % m_pic->getNumPartInCU()];
             }
-            else if (uiAbsPartIdxTmp / numPartInCUWidth < m_pic->getNumPartInHeight() - 1) // is not at the last row of LCU But is last column of LCU
+            else if (uiAbsPartIdxTmp / numPartInCUSize < numPartInCUSize - 1) // is not at the last row of LCU But is last column of LCU
             {
                 absPartAddr = g_rasterToZscan[uiAbsPartIdxTmp + 1];
                 lcuIdx = getAddr() + 1;
@@ -2474,26 +2473,26 @@
         //----  co-located RightBottom Temporal Predictor (H) ---//
         absPartIdx = g_zscanToRaster[partIdxRB];
         int lcuIdx = -1;
-        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdx] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())  // image boundary check
+        if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[absPartIdx] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicWidthInLumaSamples())  // image boundary check
         {
         }
-        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdx] + m_pic->getMinCUSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
+        else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[absPartIdx] + m_pic->getUnitSize()) >= m_slice->getSPS()->getPicHeightInLumaSamples())
         {
         }
         else
         {
-            uint32_t numPartInCUWidth = m_pic->getNumPartInWidth();
-            if ((absPartIdx % numPartInCUWidth < numPartInCUWidth - 1) &&        // is not at the last column of LCU
-                (absPartIdx / numPartInCUWidth < m_pic->getNumPartInHeight() - 1)) // is not at the last row    of LCU
+            uint32_t numPartInCUSize = m_pic->getNumPartInCUSize();
+            if ((absPartIdx % numPartInCUSize < numPartInCUSize - 1) &&        // is not at the last column of LCU
+                (absPartIdx / numPartInCUSize < numPartInCUSize - 1)) // is not at the last row    of LCU
             {
-                absPartAddr = g_rasterToZscan[absPartIdx + numPartInCUWidth + 1];
+                absPartAddr = g_rasterToZscan[absPartIdx + numPartInCUSize + 1];
                 lcuIdx = getAddr();
             }
-            else if (absPartIdx % numPartInCUWidth < numPartInCUWidth - 1)       // is not at the last column of LCU But is last row of LCU
+            else if (absPartIdx % numPartInCUSize < numPartInCUSize - 1)       // is not at the last column of LCU But is last row of LCU
             {
-                absPartAddr = g_rasterToZscan[(absPartIdx + numPartInCUWidth + 1) % m_pic->getNumPartInCU()];
+                absPartAddr = g_rasterToZscan[(absPartIdx + numPartInCUSize + 1) % m_pic->getNumPartInCU()];
             }
-            else if (absPartIdx / numPartInCUWidth < m_pic->getNumPartInHeight() - 1) // is not at the last row of LCU But is last column of LCU
+            else if (absPartIdx / numPartInCUSize < numPartInCUSize - 1) // is not at the last row of LCU But is last column of LCU
             {
                 absPartAddr = g_rasterToZscan[absPartIdx + 1];
                 lcuIdx = getAddr() + 1;
@@ -2898,8 +2897,8 @@
 
     outPartIdxCenter = m_absIdxInLCU + partAddr; // partition origin.
     outPartIdxCenter = g_rasterToZscan[g_zscanToRaster[outPartIdxCenter]
-                                       + (partHeight / m_pic->getMinCUSize()) / 2 * m_pic->getNumPartInWidth()
-                                       + (partWidth / m_pic->getMinCUSize()) / 2];
+                                       + (partHeight >> m_pic->getLog2UnitSize()) / 2 * m_pic->getNumPartInCUSize()
+                                       + (partWidth >> m_pic->getLog2UnitSize()) / 2];
 }
 
 uint32_t TComDataCU::getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra)
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComDataCU.h	Thu Mar 27 18:19:32 2014 +0900
@@ -99,7 +99,6 @@
     int           m_chromaFormat;
     int           m_hChromaShift;
     int           m_vChromaShift;
-    int           m_unitSize;        ///< size of a "minimum partition"
     uint32_t      m_unitMask;        ///< mask for mapping index to CompressMV field
 
     // -------------------------------------------------------------------------------------------------------------------
@@ -179,7 +178,7 @@
     // create / destroy / initialize / copy
     // -------------------------------------------------------------------------------------------------------------------
 
-    bool          create(uint32_t numPartition, uint32_t width, uint32_t height, int unitSize, int csp);
+    bool          create(uint32_t numPartition, uint32_t cuSize, int unitSize, int csp);
     void          destroy();
 
     void          initCU(TComPic* pic, uint32_t cuAddr);
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -223,7 +223,7 @@
     uint32_t pelsInPart = g_maxCUSize >> g_maxCUDepth;
     uint32_t partIdxIncr = DEBLOCK_SMALLEST_BLOCK / pelsInPart ? DEBLOCK_SMALLEST_BLOCK / pelsInPart : 1;
 
-    uint32_t sizeInPU = pic->getNumPartInWidth() >> (depth);
+    uint32_t sizeInPU = pic->getNumPartInCUSize() >> (depth);
     const bool bAlwaysDoChroma = (cu->getChromaFormat() == CHROMA_444);
     for (uint32_t e = 0; e < sizeInPU; e += partIdxIncr)
     {
@@ -239,11 +239,11 @@
 {
     if (widthInBaseUnits == 0)
     {
-        widthInBaseUnits  = cu->getPic()->getNumPartInWidth() >> depth;
+        widthInBaseUnits  = cu->getPic()->getNumPartInCUSize() >> depth;
     }
     if (heightInBaseUnits == 0)
     {
-        heightInBaseUnits = cu->getPic()->getNumPartInHeight() >> depth;
+        heightInBaseUnits = cu->getPic()->getNumPartInCUSize() >> depth;
     }
     const uint32_t numElem = dir == 0 ? heightInBaseUnits : widthInBaseUnits;
     assert(numElem > 0);
@@ -288,8 +288,8 @@
 void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, uint32_t absZOrderIdx)
 {
     const uint32_t depth = cu->getDepth(absZOrderIdx);
-    const uint32_t widthInBaseUnits  = cu->getPic()->getNumPartInWidth() >> depth;
-    const uint32_t heightInBaseUnits = cu->getPic()->getNumPartInHeight() >> depth;
+    const uint32_t widthInBaseUnits  = cu->getPic()->getNumPartInCUSize() >> depth;
+    const uint32_t heightInBaseUnits = cu->getPic()->getNumPartInCUSize() >> depth;
     const uint32_t hWidthInBaseUnits  = widthInBaseUnits  >> 1;
     const uint32_t hHeightInBaseUnits = heightInBaseUnits >> 1;
     const uint32_t qWidthInBaseUnits  = widthInBaseUnits  >> 2;
@@ -529,7 +529,7 @@
     int qp = 0;
     int qpP = 0;
     int qpQ = 0;
-    uint32_t numParts = cu->getPic()->getNumPartInWidth() >> depth;
+    uint32_t numParts = cu->getPic()->getNumPartInCUSize() >> depth;
 
     uint32_t pelsInPart = g_maxCUSize >> g_maxCUDepth;
     uint32_t bsAbsIdx = 0, bs = 0;
@@ -643,7 +643,7 @@
     uint32_t  pelsInPartChroma = g_maxCUSize >> (g_maxCUDepth + cu->getHorzChromaShift());
     int   offset, srcStep;
 
-    const uint32_t lcuWidthInBaseUnits = cu->getPic()->getNumPartInWidth();
+    const uint32_t lcuWidthInBaseUnits = cu->getPic()->getNumPartInCUSize();
 
     bool  bPCMFilter = (cu->getSlice()->getSPS()->getUsePCM() && cu->getSlice()->getSPS()->getPCMFilterDisableFlag()) ? true : false;
     bool  bPartPNoFilter = false;
@@ -665,7 +665,7 @@
         return;
     }
 
-    uint32_t numParts = cu->getPic()->getNumPartInWidth() >> depth;
+    uint32_t numParts = cu->getPic()->getNumPartInCUSize() >> depth;
 
     uint32_t bsAbsIdx;
     uint8_t bs;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComLoopFilter.h
--- a/source/Lib/TLibCommon/TComLoopFilter.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComLoopFilter.h	Thu Mar 27 18:19:32 2014 +0900
@@ -88,7 +88,7 @@
     uint32_t xCalcBsIdx(TComDataCU* cu, uint32_t absZOrderIdx, int dir, int edgeIdx, int baseUnitIdx)
     {
         TComPic* const pic = cu->getPic();
-        const uint32_t lcuWidthInBaseUnits = pic->getNumPartInWidth();
+        const uint32_t lcuWidthInBaseUnits = pic->getNumPartInCUSize();
 
         if (dir == 0)
         {
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPattern.cpp
--- a/source/Lib/TLibCommon/TComPattern.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPattern.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -476,7 +476,7 @@
 {
     const uint32_t rasterPartBegin = g_zscanToRaster[partIdxLT];
     const uint32_t rasterPartEnd = g_zscanToRaster[partIdxLB] + 1;
-    const uint32_t idxStep = cu->getPic()->getNumPartInWidth();
+    const uint32_t idxStep = cu->getPic()->getNumPartInCUSize();
     bool *validFlagPtr = bValidFlags;
     int numIntra = 0;
 
@@ -556,7 +556,7 @@
 
 int TComPattern::isBelowLeftAvailable(TComDataCU* cu, uint32_t partIdxLT, uint32_t partIdxLB, bool *bValidFlags)
 {
-    const uint32_t numUnitsInPU = (g_zscanToRaster[partIdxLB] - g_zscanToRaster[partIdxLT]) / cu->getPic()->getNumPartInWidth() + 1;
+    const uint32_t numUnitsInPU = (g_zscanToRaster[partIdxLB] - g_zscanToRaster[partIdxLT]) / cu->getPic()->getNumPartInCUSize() + 1;
     bool *validFlagPtr = bValidFlags;
     int numIntra = 0;
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -104,8 +104,8 @@
 
     bool ok = true;
     ok &= m_picSym->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUSize, g_maxCUDepth);
-    ok &= m_origPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUSize, g_maxCUSize, g_maxCUDepth);
-    ok &= m_reconPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUSize, g_maxCUSize, g_maxCUDepth);
+    ok &= m_origPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUSize, g_maxCUDepth);
+    ok &= m_reconPicYuv->create(cfg->param->sourceWidth, cfg->param->sourceHeight, cfg->param->internalCsp, g_maxCUSize,g_maxCUDepth);
     ok &= m_lowres.create(m_origPicYuv, cfg->param->bframes, !!cfg->param->rc.aqMode);
 
     bool isVbv = cfg->param->rc.vbvBufferSize > 0 && cfg->param->rc.vbvMaxBitrate > 0;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.h	Thu Mar 27 18:19:32 2014 +0900
@@ -148,23 +148,19 @@
 
     TComPicYuv*   getPicYuvRec()          { return m_reconPicYuv; }
 
-    uint32_t      getNumCUsInFrame()      { return m_picSym->getNumberOfCUsInFrame(); }
+    uint32_t      getNumCUsInFrame() const { return m_picSym->getNumberOfCUsInFrame(); }
 
-    uint32_t      getNumPartInWidth()     { return m_picSym->getNumPartInWidth(); }
+    uint32_t      getNumPartInCUSize() const { return m_picSym->getNumPartInCUSize(); }
 
-    uint32_t      getNumPartInHeight()    { return m_picSym->getNumPartInHeight(); }
+    uint32_t      getNumPartInCU() const  { return m_picSym->getNumPartition(); }
 
-    uint32_t      getNumPartInCU()        { return m_picSym->getNumPartition(); }
+    uint32_t      getFrameWidthInCU() const { return m_picSym->getFrameWidthInCU(); }
 
-    uint32_t      getFrameWidthInCU()     { return m_picSym->getFrameWidthInCU(); }
+    uint32_t      getFrameHeightInCU() const { return m_picSym->getFrameHeightInCU(); }
 
-    uint32_t      getFrameHeightInCU()    { return m_picSym->getFrameHeightInCU(); }
+    uint32_t      getUnitSize() const     { return m_picSym->getUnitSize(); }
 
-    uint32_t      getMinCUSize()          { return m_picSym->getMinCUSize(); }
-
-    uint32_t      getParPelX(uint8_t partIdx) { return getParPelX(partIdx); }
-
-    uint32_t      getParPelY(uint8_t partIdx) { return getParPelX(partIdx); }
+    uint32_t      getLog2UnitSize() const   { return m_picSym->getLog2UnitSize(); }
 
     int           getStride()             { return m_reconPicYuv->getStride(); }
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPicSym.cpp
--- a/source/Lib/TLibCommon/TComPicSym.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicSym.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -51,11 +51,11 @@
     : m_widthInCU(0)
     , m_heightInCU(0)
     , m_maxCUSize(0)
-    , m_minCUSize(0)
+    , m_unitSize(0)
+    , m_log2UnitSize(0)
     , m_totalDepth(0)
     , m_numPartitions(0)
-    , m_numPartInWidth(0)
-    , m_numPartInHeight(0)
+    , m_numPartInCUSize(0)
     , m_numCUsInFrame(0)
     , m_slice(NULL)
     , m_cuData(NULL)
@@ -71,13 +71,13 @@
 
     m_maxCUSize       = maxCUSize;
 
-    m_minCUSize       = maxCUSize  >> m_totalDepth;
+    m_unitSize        = maxCUSize  >> m_totalDepth;
+    m_log2UnitSize    = g_convertToBit[m_unitSize] + 2;
 
-    m_numPartInWidth  = m_maxCUSize / m_minCUSize;
-    m_numPartInHeight = m_maxCUSize / m_minCUSize;
+    m_numPartInCUSize = m_maxCUSize >> m_log2UnitSize;
 
-    m_widthInCU       = (picWidth % m_maxCUSize) ? picWidth / m_maxCUSize  + 1 : picWidth / m_maxCUSize;
-    m_heightInCU      = (picHeight % m_maxCUSize) ? picHeight / m_maxCUSize + 1 : picHeight / m_maxCUSize;
+    m_widthInCU       = (picWidth  + m_maxCUSize - 1) / m_maxCUSize;
+    m_heightInCU      = (picHeight + m_maxCUSize - 1) / m_maxCUSize;
 
     m_numCUsInFrame   = m_widthInCU * m_heightInCU;
 
@@ -91,7 +91,7 @@
         m_cuData[i] = new TComDataCU;
         if (!m_cuData[i])
             return false;
-        if (!m_cuData[i]->create(m_numPartitions, m_maxCUSize, m_maxCUSize, m_maxCUSize >> m_totalDepth, picCsp))
+        if (!m_cuData[i]->create(m_numPartitions, m_maxCUSize, m_unitSize, picCsp))
             return false;
     }
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPicSym.h
--- a/source/Lib/TLibCommon/TComPicSym.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicSym.h	Thu Mar 27 18:19:32 2014 +0900
@@ -65,12 +65,12 @@
     uint32_t      m_heightInCU;
 
     uint32_t      m_maxCUSize;
-    uint32_t      m_minCUSize;
+    uint32_t      m_unitSize;
+    uint32_t      m_log2UnitSize;
 
     uint8_t       m_totalDepth;
     uint32_t      m_numPartitions;
-    uint32_t      m_numPartInWidth;
-    uint32_t      m_numPartInHeight;
+    uint32_t      m_numPartInCUSize;
     uint32_t      m_numCUsInFrame;
 
     TComSlice*    m_slice;
@@ -87,21 +87,21 @@
 
     TComSlice*  getSlice()                { return m_slice; }
 
-    uint32_t    getFrameWidthInCU()       { return m_widthInCU; }
+    uint32_t    getFrameWidthInCU() const { return m_widthInCU; }
 
-    uint32_t    getFrameHeightInCU()      { return m_heightInCU; }
+    uint32_t    getFrameHeightInCU() const { return m_heightInCU; }
 
-    uint32_t    getMinCUSize()            { return m_minCUSize; }
+    uint32_t    getUnitSize() const       { return m_unitSize; }
 
-    uint32_t    getNumberOfCUsInFrame()   { return m_numCUsInFrame; }
+    uint32_t    getLog2UnitSize() const   { return m_log2UnitSize; }
+
+    uint32_t    getNumberOfCUsInFrame() const { return m_numCUsInFrame; }
 
     TComDataCU*&  getCU(uint32_t cuAddr)  { return m_cuData[cuAddr]; }
 
-    uint32_t    getNumPartition()         { return m_numPartitions; }
+    uint32_t    getNumPartition() const   { return m_numPartitions; }
 
-    uint32_t    getNumPartInWidth()       { return m_numPartInWidth; }
-
-    uint32_t    getNumPartInHeight()      { return m_numPartInHeight; }
+    uint32_t    getNumPartInCUSize() const { return m_numPartInCUSize; }
 
     void allocSaoParam(TComSampleAdaptiveOffset *sao);
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPicYuv.cpp
--- a/source/Lib/TLibCommon/TComPicYuv.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -64,7 +64,7 @@
 {
 }
 
-bool TComPicYuv::create(int picWidth, int picHeight, int picCsp, uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxCUDepth)
+bool TComPicYuv::create(int picWidth, int picHeight, int picCsp, uint32_t maxCUSize, uint32_t maxCUDepth)
 {
     m_picWidth  = picWidth;
     m_picHeight = picHeight;
@@ -73,11 +73,10 @@
     m_picCsp = picCsp;
 
     // --> After config finished!
-    m_cuWidth  = maxCUWidth;
-    m_cuHeight = maxCUHeight;
+    m_cuSize = maxCUSize;
 
-    m_numCuInWidth = (m_picWidth + m_cuWidth - 1)  / m_cuWidth;
-    m_numCuInHeight = (m_picHeight + m_cuHeight - 1) / m_cuHeight;
+    m_numCuInWidth = (m_picWidth + m_cuSize - 1)  / m_cuSize;
+    m_numCuInHeight = (m_picHeight + m_cuSize - 1) / m_cuSize;
 
     m_lumaMarginX = g_maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment
     m_lumaMarginY = g_maxCUSize + 16; // margin for 8-tap filter and infinite padding
@@ -104,8 +103,8 @@
     {
         for (int cuCol = 0; cuCol < m_numCuInWidth; cuCol++)
         {
-            m_cuOffsetY[cuRow * m_numCuInWidth + cuCol] = getStride() * cuRow * m_cuHeight + cuCol * m_cuWidth;
-            m_cuOffsetC[cuRow * m_numCuInWidth + cuCol] = getCStride() * cuRow * (m_cuHeight >> m_vChromaShift) + cuCol * (m_cuWidth >> m_hChromaShift);
+            m_cuOffsetY[cuRow * m_numCuInWidth + cuCol] = getStride() * cuRow * m_cuSize + cuCol * m_cuSize;
+            m_cuOffsetC[cuRow * m_numCuInWidth + cuCol] = getCStride() * cuRow * (m_cuSize >> m_vChromaShift) + cuCol * (m_cuSize >> m_hChromaShift);
         }
     }
 
@@ -115,8 +114,8 @@
     {
         for (int buCol = 0; buCol < (1 << maxCUDepth); buCol++)
         {
-            m_buOffsetY[(buRow << maxCUDepth) + buCol] = getStride() * buRow * (maxCUHeight >> maxCUDepth) + buCol * (maxCUWidth  >> maxCUDepth);
-            m_buOffsetC[(buRow << maxCUDepth) + buCol] = getCStride() * buRow * ((maxCUHeight >> m_vChromaShift) >> maxCUDepth) + buCol * ((maxCUWidth >> m_hChromaShift) >> maxCUDepth);
+            m_buOffsetY[(buRow << maxCUDepth) + buCol] = getStride() * buRow * (maxCUSize >> maxCUDepth) + buCol * (maxCUSize  >> maxCUDepth);
+            m_buOffsetC[(buRow << maxCUDepth) + buCol] = getCStride() * buRow * (maxCUSize >> maxCUDepth >> m_vChromaShift) + buCol * (maxCUSize >> maxCUDepth >> m_hChromaShift);
         }
     }
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComPicYuv.h
--- a/source/Lib/TLibCommon/TComPicYuv.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicYuv.h	Thu Mar 27 18:19:32 2014 +0900
@@ -81,8 +81,7 @@
     int   m_hChromaShift;
     int   m_vChromaShift;
 
-    int   m_cuWidth;           ///< Width of Coding Unit (CU)
-    int   m_cuHeight;          ///< Height of Coding Unit (CU)
+    int   m_cuSize;            ///< Width/Height of Coding Unit (CU)
     int32_t*  m_cuOffsetY;
     int32_t*  m_cuOffsetC;
     int32_t*  m_buOffsetY;
@@ -105,7 +104,7 @@
     //  Memory management
     // ------------------------------------------------------------------------------------------------
 
-    bool  create(int picWidth, int picHeight, int csp, uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxCUDepth);
+    bool  create(int picWidth, int picHeight, int csp, uint32_t maxCUSize, uint32_t maxCUDepth);
     void  destroy();
 
     // ------------------------------------------------------------------------------------------------
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -254,50 +254,46 @@
     }
 }
 
-void initRasterToZscan(uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxDepth)
+void initRasterToZscan(uint32_t maxCUSize, uint32_t maxDepth)
 {
-    uint32_t  minWidth  = maxCUWidth  >> (maxDepth - 1);
-    uint32_t  minHeight = maxCUHeight >> (maxDepth - 1);
+    uint32_t  unitSize = maxCUSize  >> (maxDepth - 1);
 
-    uint32_t  numPartInWidth  = (uint32_t)maxCUWidth  / minWidth;
-    uint32_t  numPartInHeight = (uint32_t)maxCUHeight / minHeight;
+    uint32_t  numPartInCUSize  = (uint32_t)maxCUSize / unitSize;
 
-    for (uint32_t i = 0; i < numPartInWidth * numPartInHeight; i++)
+    for (uint32_t i = 0; i < numPartInCUSize * numPartInCUSize; i++)
     {
         g_rasterToZscan[g_zscanToRaster[i]] = i;
     }
 }
 
-void initRasterToPelXY(uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxDepth)
+void initRasterToPelXY(uint32_t maxCUSize, uint32_t maxDepth)
 {
     uint32_t i;
 
     uint32_t* tempX = &g_rasterToPelX[0];
     uint32_t* tempY = &g_rasterToPelY[0];
 
-    uint32_t  minWidth  = maxCUWidth  >> (maxDepth - 1);
-    uint32_t  minHeight = maxCUHeight >> (maxDepth - 1);
+    uint32_t  unitSize  = maxCUSize >> (maxDepth - 1);
 
-    uint32_t  numPartInWidth  = maxCUWidth  / minWidth;
-    uint32_t  numPartInHeight = maxCUHeight / minHeight;
+    uint32_t  numPartInCUSize = maxCUSize / unitSize;
 
     tempX[0] = 0;
     tempX++;
-    for (i = 1; i < numPartInWidth; i++)
+    for (i = 1; i < numPartInCUSize; i++)
     {
-        tempX[0] = tempX[-1] + minWidth;
+        tempX[0] = tempX[-1] + unitSize;
         tempX++;
     }
 
-    for (i = 1; i < numPartInHeight; i++)
+    for (i = 1; i < numPartInCUSize; i++)
     {
-        memcpy(tempX, tempX - numPartInWidth, sizeof(uint32_t) * numPartInWidth);
-        tempX += numPartInWidth;
+        memcpy(tempX, tempX - numPartInCUSize, sizeof(uint32_t) * numPartInCUSize);
+        tempX += numPartInCUSize;
     }
 
-    for (i = 1; i < numPartInWidth * numPartInHeight; i++)
+    for (i = 1; i < numPartInCUSize * numPartInCUSize; i++)
     {
-        tempY[i] = (i / numPartInWidth) * minWidth;
+        tempY[i] = (i / numPartInCUSize) * unitSize;
     }
 }
 
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.h	Thu Mar 27 18:19:32 2014 +0900
@@ -78,13 +78,13 @@
 extern uint32_t g_rasterToZscan[MAX_NUM_SPU_W * MAX_NUM_SPU_W];
 extern uint16_t*  g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_DEPTH];
 void initZscanToRaster(int maxDepth, int depth, uint32_t startVal, uint32_t*& curIdx);
-void initRasterToZscan(uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxCUDepth);
+void initRasterToZscan(uint32_t maxCUSize, uint32_t maxCUDepth);
 
 // conversion of partition index to picture pel position
 extern uint32_t g_rasterToPelX[MAX_NUM_SPU_W * MAX_NUM_SPU_W];
 extern uint32_t g_rasterToPelY[MAX_NUM_SPU_W * MAX_NUM_SPU_W];
 
-void initRasterToPelXY(uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxCUDepth);
+void initRasterToPelXY(uint32_t maxCUSize, uint32_t maxCUDepth);
 
 // global variable (LCU width/height, max. CU depth)
 extern uint32_t g_maxCUSize;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp
--- a/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -1368,9 +1368,9 @@
     uint32_t height;
     uint32_t pcmLeftShiftBit;
     uint32_t x, y;
-    uint32_t minCoeffSize = cu->getPic()->getMinCUSize() * cu->getPic()->getMinCUSize();
-    uint32_t lumaOffset   = minCoeffSize * absZOrderIdx;
+    uint32_t lumaOffset   = absZOrderIdx << cu->getPic()->getLog2UnitSize() * 2;
     uint32_t chromaOffset = lumaOffset >> 2;
+    //uint32_t chromaOffset = lumaOffset >> (m_hChromaShift + m_vChromaShift);
 
     if (ttText == TEXT_LUMA)
     {
@@ -1402,8 +1402,10 @@
         }
 
         stride = pcPicYuvRec->getCStride();
-        width  = ((g_maxCUSize >> depth) / 2);
-        height = ((g_maxCUSize >> depth) / 2);
+        //width  = ((g_maxCUSize >> depth) >> m_hChromaShift);
+        //height = ((g_maxCUSize >> depth) >> m_vhChromaShift);
+        width  = ((g_maxCUSize >> depth) >> 1);
+        height = ((g_maxCUSize >> depth) >> 1);
         if (cu->isLosslessCoded(absZOrderIdx) && !cu->getIPCMFlag(absZOrderIdx))
         {
             pcmLeftShiftBit = 0;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -123,68 +123,68 @@
 
     m_origYuv = new TComYuv*[m_totalDepth - 1];
 
+    int unitSize = maxWidth >> (m_totalDepth - 1);
     int csp = m_param->internalCsp;
 
     bool ok = true;
     for (int i = 0; i < m_totalDepth - 1; i++)
     {
         uint32_t numPartitions = 1 << ((m_totalDepth - i - 1) << 1);
-        uint32_t width  = maxWidth  >> i;
-        uint32_t height = maxWidth >> i;
+        uint32_t cuSize = maxWidth >> i;
 
         m_bestCU[i] = new TComDataCU;
-        ok &= m_bestCU[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_bestCU[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_tempCU[i] = new TComDataCU;
-        ok &= m_tempCU[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_tempCU[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_interCU_2Nx2N[i] = new TComDataCU;
-        ok &= m_interCU_2Nx2N[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_interCU_2Nx2N[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_interCU_2NxN[i] = new TComDataCU;
-        ok &= m_interCU_2NxN[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_interCU_2NxN[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_interCU_Nx2N[i] = new TComDataCU;
-        ok &= m_interCU_Nx2N[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_interCU_Nx2N[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_intraInInterCU[i] = new TComDataCU;
-        ok &= m_intraInInterCU[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_intraInInterCU[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_mergeCU[i] = new TComDataCU;
-        ok &= m_mergeCU[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_mergeCU[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_bestMergeCU[i] = new TComDataCU;
-        ok &= m_bestMergeCU[i]->create(numPartitions, width, height, maxWidth >> (m_totalDepth - 1), csp);
+        ok &= m_bestMergeCU[i]->create(numPartitions, cuSize, unitSize, csp);
 
         m_bestPredYuv[i] = new TComYuv;
-        ok &= m_bestPredYuv[i]->create(width, height, csp);
+        ok &= m_bestPredYuv[i]->create(cuSize, cuSize, csp);
 
         m_bestResiYuv[i] = new ShortYuv;
-        ok &= m_bestResiYuv[i]->create(width, height, csp);
+        ok &= m_bestResiYuv[i]->create(cuSize, cuSize, csp);
 
         m_bestRecoYuv[i] = new TComYuv;
-        ok &= m_bestRecoYuv[i]->create(width, height, csp);
+        ok &= m_bestRecoYuv[i]->create(cuSize, cuSize, csp);
 
         m_tmpPredYuv[i] = new TComYuv;
-        ok &= m_tmpPredYuv[i]->create(width, height, csp);
+        ok &= m_tmpPredYuv[i]->create(cuSize, cuSize, csp);
 
         for (int j = 0; j < MAX_PRED_TYPES; j++)
         {
             m_modePredYuv[j][i] = new TComYuv;
-            ok &= m_modePredYuv[j][i]->create(width, height, csp);
+            ok &= m_modePredYuv[j][i]->create(cuSize, cuSize, csp);
         }
 
         m_tmpResiYuv[i] = new ShortYuv;
-        ok &= m_tmpResiYuv[i]->create(width, height, csp);
+        ok &= m_tmpResiYuv[i]->create(cuSize, cuSize, csp);
 
         m_tmpRecoYuv[i] = new TComYuv;
-        ok &= m_tmpRecoYuv[i]->create(width, height, csp);
+        ok &= m_tmpRecoYuv[i]->create(cuSize, cuSize, csp);
 
         m_bestMergeRecoYuv[i] = new TComYuv;
-        ok &= m_bestMergeRecoYuv[i]->create(width, height, csp);
+        ok &= m_bestMergeRecoYuv[i]->create(cuSize, cuSize, csp);
 
         m_origYuv[i] = new TComYuv;
-        ok &= m_origYuv[i]->create(width, height, csp);
+        ok &= m_origYuv[i]->create(cuSize, cuSize, csp);
     }
 
     m_bEncodeDQP = false;
@@ -1554,10 +1554,10 @@
     if (!bSliceEnd && (rpelx < slice->getSPS()->getPicWidthInLumaSamples()) && (bpely < slice->getSPS()->getPicHeightInLumaSamples()))
     {
         uint32_t absPartIdxInRaster = g_zscanToRaster[absPartIdx];
-        uint32_t srcBlkWidth = outPic->getNumPartInWidth() >> (srcDepth);
-        uint32_t blkWidth    = outPic->getNumPartInWidth() >> (depth);
-        uint32_t partIdxX = ((absPartIdxInRaster % outPic->getNumPartInWidth()) % srcBlkWidth) / blkWidth;
-        uint32_t partIdxY = ((absPartIdxInRaster / outPic->getNumPartInWidth()) % srcBlkWidth) / blkWidth;
+        uint32_t srcBlkWidth = outPic->getNumPartInCUSize() >> (srcDepth);
+        uint32_t blkWidth    = outPic->getNumPartInCUSize() >> (depth);
+        uint32_t partIdxX = ((absPartIdxInRaster % outPic->getNumPartInCUSize()) % srcBlkWidth) / blkWidth;
+        uint32_t partIdxY = ((absPartIdxInRaster / outPic->getNumPartInCUSize()) % srcBlkWidth) / blkWidth;
         uint32_t partIdx = partIdxY * (srcBlkWidth / blkWidth) + partIdxX;
         m_bestRecoYuv[srcDepth]->copyToPicYuv(outPic->getPicYuvRec(), cuAddr, absPartIdx, depth - srcDepth, partIdx);
     }
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibEncoder/TEncEntropy.cpp
--- a/source/Lib/TLibEncoder/TEncEntropy.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncEntropy.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -592,8 +592,7 @@
  */
 void TEncEntropy::encodeCoeff(TComDataCU* cu, uint32_t absPartIdx, uint32_t depth, uint32_t width, uint32_t height, bool& bCodeDQP)
 {
-    uint32_t minCoeffSize = cu->getPic()->getMinCUSize() * cu->getPic()->getMinCUSize();
-    uint32_t lumaOffset   = minCoeffSize * absPartIdx;
+    uint32_t lumaOffset   = absPartIdx << cu->getPic()->getLog2UnitSize() * 2;
     uint32_t chromaOffset = lumaOffset >> (cu->getHorzChromaShift() + cu->getVertChromaShift());
 
     if (cu->isIntra(absPartIdx))
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -1872,9 +1872,9 @@
     {
         m_binIf->encodePCMAlignBits();
 
-        uint32_t minCoeffSize = cu->getPic()->getMinCUSize() * cu->getPic()->getMinCUSize();
-        uint32_t lumaOffset   = minCoeffSize * absPartIdx;
+        uint32_t lumaOffset   = absPartIdx << cu->getPic()->getLog2UnitSize() * 2;
         uint32_t chromaOffset = lumaOffset >> 2;
+        //uint32_t chromaOffset = lumaOffset >> (m_hChromaShift + m_vChromaShift);
         uint32_t width;
         uint32_t height;
         uint32_t sampleBits;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -126,8 +126,8 @@
     for (uint32_t i = 0; i < numLayersToAllocate; ++i)
     {
         m_qtTempCoeffY[i]  = X265_MALLOC(coeff_t, g_maxCUSize * g_maxCUSize);
-        m_qtTempCoeffCb[i] = X265_MALLOC(coeff_t, (g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift));
-        m_qtTempCoeffCr[i] = X265_MALLOC(coeff_t, (g_maxCUSize >> m_hChromaShift) * (g_maxCUSize >> m_vChromaShift));
+        m_qtTempCoeffCb[i] = X265_MALLOC(coeff_t, g_maxCUSize * g_maxCUSize >> (m_hChromaShift + m_vChromaShift));
+        m_qtTempCoeffCr[i] = X265_MALLOC(coeff_t, g_maxCUSize * g_maxCUSize >> (m_hChromaShift + m_vChromaShift));
         m_qtTempShortYuv[i].create(MAX_CU_SIZE, MAX_CU_SIZE, cfg->param->internalCsp);
     }
 
@@ -255,7 +255,7 @@
     int cspy = chroma ? m_vChromaShift : 0;
     uint32_t width = cu->getCUSize(0) >> (trDepth + cspx);
     uint32_t height = cu->getCUSize(0) >> (trDepth + cspy);
-    uint32_t coeffOffset = (cu->getPic()->getMinCUSize() >> cspx) * (cu->getPic()->getMinCUSize() >> cspy) * absPartIdx;
+    uint32_t coeffOffset = absPartIdx << (cu->getPic()->getLog2UnitSize() * 2 - (cspx + cspy));
     uint32_t qtLayer = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - trSizeLog2;
     coeff_t* coeff = 0;
     switch (ttype)
@@ -1308,10 +1308,10 @@
         uint32_t numCoeffC = (cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize()) >> (fullDepth << 1);
         if (!bChromaSame)
         {
-            numCoeffC = ((cu->getSlice()->getSPS()->getMaxCUSize() >> m_hChromaShift) * (cu->getSlice()->getSPS()->getMaxCUSize() >> m_vChromaShift)) >> (fullDepth << 1);
+            numCoeffC = ((cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (m_hChromaShift + m_vChromaShift)) >> (fullDepth << 1));
         }
 
-        uint32_t numCoeffIncC = ((cu->getSlice()->getSPS()->getMaxCUSize() >> m_hChromaShift) * (cu->getSlice()->getSPS()->getMaxCUSize() >> m_vChromaShift)) >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1);
+        uint32_t numCoeffIncC = (cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (m_hChromaShift + m_vChromaShift)) >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1);
 
         coeff_t* coeffSrcU = m_qtTempCoeffCb[qtlayer] + (numCoeffIncC * absPartIdx);
         coeff_t* coeffSrcV = m_qtTempCoeffCr[qtlayer] + (numCoeffIncC * absPartIdx);
@@ -2031,9 +2031,8 @@
     uint64_t cost;
 
     uint32_t absPartIdx = 0;
-    uint32_t minCoeffSize = cu->getPic()->getMinCUSize() * cu->getPic()->getMinCUSize();
-    uint32_t lumaOffset   = minCoeffSize * absPartIdx;
-    uint32_t chromaOffset = lumaOffset >> 2;
+    uint32_t lumaOffset   = absPartIdx << cu->getPic()->getLog2UnitSize() * 2;
+    uint32_t chromaOffset = lumaOffset >> (m_hChromaShift + m_vChromaShift);
 
     // Luminance
     pixel*   fenc = fencYuv->getLumaAddr();
@@ -3597,7 +3596,7 @@
     bool mCodeAll = true;
     int width  = 1 << trSizeLog2;
     int height = 1 << trSizeLog2;
-    const uint32_t numPels = (width >> cu->getHorzChromaShift()) * (height >> cu->getHorzChromaShift());
+    const uint32_t numPels = width * height >> (cu->getHorzChromaShift() + cu->getHorzChromaShift());
     if (numPels < (MIN_TU_SIZE * MIN_TU_SIZE))
     {
         mCodeAll = false;
diff -r 8e0c2d24fc45 -r 65fb83d78276 source/common/param.cpp
--- a/source/common/param.cpp	Wed Mar 26 22:39:01 2014 -0500
+++ b/source/common/param.cpp	Thu Mar 27 18:19:32 2014 +0900
@@ -1039,10 +1039,10 @@
         // initialize partition order
         uint32_t* tmp = &g_zscanToRaster[0];
         initZscanToRaster(g_maxCUDepth + 1, 1, 0, tmp);
-        initRasterToZscan(g_maxCUSize, g_maxCUSize, g_maxCUDepth + 1);
+        initRasterToZscan(g_maxCUSize, g_maxCUDepth + 1);
 
         // initialize conversion matrix from partition index to pel
-        initRasterToPelXY(g_maxCUSize, g_maxCUSize, g_maxCUDepth + 1);
+        initRasterToPelXY(g_maxCUSize, g_maxCUDepth + 1);
     }
     return 0;
 }


More information about the x265-devel mailing list