Index: /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1465)
@@ -139,5 +139,4 @@
 
 static const Int AMVP_MAX_NUM_CANDS =                               2; ///< AMVP: advanced motion vector prediction - max number of final candidates
-static const Int AMVP_MAX_NUM_CANDS_MEM =                           3; ///< AMVP: advanced motion vector prediction - max number of candidates
 static const Int AMVP_DECIMATION_FACTOR =                           4;
 static const Int MRG_MAX_NUM_CANDS =                                5; ///< MERGE
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1465)
@@ -407,5 +407,5 @@
 }
 
-Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx)
+Bool TComDataCU::isLastSubCUOfCtu(const UInt absPartIdx) const
 {
   const TComSPS &sps=*(getSlice()->getSPS());
@@ -1036,8 +1036,8 @@
 // --------------------------------------------------------------------------------------------------------------------
 
-TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
-                                   UInt uiCurrPartUnitIdx,
-                                   Bool bEnforceSliceRestriction,
-                                   Bool bEnforceTileRestriction )
+const TComDataCU* TComDataCU::getPULeft( UInt& uiLPartUnitIdx,
+                                         UInt uiCurrPartUnitIdx,
+                                         Bool bEnforceSliceRestriction,
+                                         Bool bEnforceTileRestriction ) const
 {
   UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
@@ -1068,9 +1068,9 @@
 
 
-TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
-                                    UInt uiCurrPartUnitIdx,
-                                    Bool bEnforceSliceRestriction,
-                                    Bool planarAtCtuBoundary,
-                                    Bool bEnforceTileRestriction )
+const TComDataCU* TComDataCU::getPUAbove( UInt& uiAPartUnitIdx,
+                                          UInt uiCurrPartUnitIdx,
+                                          Bool bEnforceSliceRestriction,
+                                          Bool planarAtCtuBoundary,
+                                          Bool bEnforceTileRestriction ) const
 {
   UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
@@ -1106,5 +1106,5 @@
 }
 
-TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction )
+const TComDataCU* TComDataCU::getPUAboveLeft( UInt& uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction ) const
 {
   UInt uiAbsPartIdx       = g_auiZscanToRaster[uiCurrPartUnitIdx];
@@ -1153,5 +1153,5 @@
 }
 
-TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
+const TComDataCU* TComDataCU::getPUBelowLeft(UInt& uiBLPartUnitIdx,  UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
 {
   UInt uiAbsPartIdxLB     = g_auiZscanToRaster[uiCurrPartUnitIdx];
@@ -1201,5 +1201,5 @@
 }
 
-TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction)
+const TComDataCU* TComDataCU::getPUAboveRight(UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset, Bool bEnforceSliceRestriction) const
 {
   UInt uiAbsPartIdxRT     = g_auiZscanToRaster[uiCurrPartUnitIdx];
@@ -1265,5 +1265,5 @@
 *\returns TComDataCU*   point of TComDataCU of left QpMinCu
 */
-TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu )
+const TComDataCU* TComDataCU::getQpMinCuLeft( UInt& uiLPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
 {
   const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
@@ -1292,5 +1292,5 @@
 *\returns TComDataCU*   point of TComDataCU of above QpMinCu
 */
-TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu )
+const TComDataCU* TComDataCU::getQpMinCuAbove( UInt& uiAPartUnitIdx, UInt uiCurrAbsIdxInCtu ) const
 {
   const UInt numPartInCtuWidth = m_pcPic->getNumPartInCtuWidth();
@@ -1320,14 +1320,14 @@
 *\returns SChar   reference QP value
 */
-SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu )
+SChar TComDataCU::getRefQP( UInt uiCurrAbsIdxInCtu ) const
 {
   UInt lPartIdx = MAX_UINT;
   UInt aPartIdx = MAX_UINT;
-  TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
-  TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
+  const TComDataCU* cULeft  = getQpMinCuLeft ( lPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
+  const TComDataCU* cUAbove = getQpMinCuAbove( aPartIdx, m_absZIdxInCtu + uiCurrAbsIdxInCtu );
   return (((cULeft? cULeft->getQP( lPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + (cUAbove? cUAbove->getQP( aPartIdx ): getLastCodedQP( uiCurrAbsIdxInCtu )) + 1) >> 1);
 }
 
-Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx )
+Int TComDataCU::getLastValidPartIdx( Int iAbsPartIdx ) const
 {
   Int iLastValidPartIdx = iAbsPartIdx-1;
@@ -1341,5 +1341,5 @@
 }
 
-SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx )
+SChar TComDataCU::getLastCodedQP( UInt uiAbsPartIdx ) const
 {
   UInt uiQUPartIdxMask = ~((1<<((getSlice()->getSPS()->getMaxTotalCUDepth() - getSlice()->getPPS()->getMaxCuDQPDepth())<<1))-1);
@@ -1381,5 +1381,5 @@
  * \returns true if the CU is coded in lossless coding mode; false if otherwise
  */
-Bool TComDataCU::isLosslessCoded(UInt absPartIdx)
+Bool TComDataCU::isLosslessCoded(UInt absPartIdx) const
 {
   return (getSlice()->getPPS()->getTransquantBypassEnableFlag() && getCUTransquantBypass (absPartIdx));
@@ -1393,5 +1393,5 @@
 *\param   [out] uiModeList pointer to chroma intra modes array
 */
-Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] )
+Void TComDataCU::getAllowedChromaDir( UInt uiAbsPartIdx, UInt uiModeList[NUM_CHROMA_MODE] ) const
 {
   uiModeList[0] = PLANAR_IDX;
@@ -1421,7 +1421,6 @@
 *\returns Number of MPM
 */
-Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode  )
-{
-  TComDataCU* pcCULeft, *pcCUAbove;
+Void TComDataCU::getIntraDirPredictor( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode ) const
+{
   UInt        LeftPartIdx  = MAX_UINT;
   UInt        AbovePartIdx = MAX_UINT;
@@ -1433,5 +1432,5 @@
   const ChromaFormat chForm = getPic()->getChromaFormat();
   // Get intra direction of left PU
-  pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
+  const TComDataCU *pcCULeft = getPULeft( LeftPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
 
   if (isChroma(compID))
@@ -1442,5 +1441,5 @@
 
   // Get intra direction of above PU
-  pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
+  const TComDataCU *pcCUAbove = getPUAbove( AbovePartIdx, m_absZIdxInCtu + uiAbsPartIdx, true, true );
 
   if (isChroma(compID))
@@ -1507,9 +1506,9 @@
 }
 
-UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth )
-{
-  TComDataCU* pcTempCU;
-  UInt        uiTempPartIdx;
-  UInt        uiCtx;
+UInt TComDataCU::getCtxSplitFlag( UInt uiAbsPartIdx, UInt uiDepth ) const
+{
+  const TComDataCU* pcTempCU;
+  UInt              uiTempPartIdx;
+  UInt              uiCtx;
   // Get left split flag
   pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
@@ -1523,5 +1522,5 @@
 }
 
-UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType )
+UInt TComDataCU::getCtxQtCbf( TComTU &rTu, const ChannelType chType ) const
 {
   const UInt transformDepth = rTu.GetTransformDepthRel();
@@ -1538,5 +1537,5 @@
 }
 
-UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx )
+UInt TComDataCU::getQuadtreeTULog2MinSizeInCU( UInt absPartIdx ) const
 {
   UInt log2CbSize = g_aucConvertToBit[getWidth( absPartIdx )] + 2;
@@ -1565,9 +1564,9 @@
 }
 
-UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx )
-{
-  TComDataCU* pcTempCU;
-  UInt        uiTempPartIdx;
-  UInt        uiCtx = 0;
+UInt TComDataCU::getCtxSkipFlag( UInt uiAbsPartIdx ) const
+{
+  const TComDataCU* pcTempCU;
+  UInt              uiTempPartIdx;
+  UInt              uiCtx = 0;
 
   // Get BCBP of left PU
@@ -1582,5 +1581,5 @@
 }
 
-UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
+UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx ) const
 {
   return getDepth( uiAbsPartIdx );
@@ -1588,5 +1587,5 @@
 
 
-UChar TComDataCU::getQtRootCbf( UInt uiIdx )
+UChar TComDataCU::getQtRootCbf( UInt uiIdx ) const
 {
   const UInt numberValidComponents = getPic()->getNumberValidComponents();
@@ -1644,5 +1643,5 @@
 }
 
-Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth)
+Bool TComDataCU::isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth) const
 {
   UInt uiPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
@@ -1892,5 +1891,5 @@
 }
 
-UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx)
+UChar TComDataCU::getNumPartitions(const UInt uiAbsPartIdx) const
 {
   UChar iNumPart = 0;
@@ -1913,5 +1912,5 @@
 
 // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
-Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight )
+Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const
 {
   switch ( m_pePartSize[0] )
@@ -1953,6 +1952,6 @@
 }
 
-
-Void TComDataCU::getMvField ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
+// static member function
+Void TComDataCU::getMvField ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField )
 {
   if ( pcCU == NULL )  // OUT OF BOUNDARY
@@ -1963,9 +1962,9 @@
   }
 
-  TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
+  const TComCUMvField*  pcCUMvField = pcCU->getCUMvField( eRefPicList );
   rcMvField.setMvField( pcCUMvField->getMv( uiAbsPartIdx ), pcCUMvField->getRefIdx( uiAbsPartIdx ) );
 }
 
-Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
+Void TComDataCU::deriveLeftRightTopIdxGeneral ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
 {
   ruiPartIdxLT = m_absZIdxInCtu + uiAbsPartIdx;
@@ -2016,5 +2015,5 @@
 }
 
-Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB )
+Void TComDataCU::deriveLeftBottomIdxGeneral( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const
 {
   UInt uiPUHeight = 0;
@@ -2063,5 +2062,5 @@
 }
 
-Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT )
+Void TComDataCU::deriveLeftRightTopIdx ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const
 {
   ruiPartIdxLT = m_absZIdxInCtu;
@@ -2103,5 +2102,5 @@
 }
 
-Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB )
+Void TComDataCU::deriveLeftBottomIdx( UInt  uiPartIdx,      UInt&      ruiPartIdxLB ) const
 {
   ruiPartIdxLB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth()];
@@ -2143,5 +2142,5 @@
  * \param [out] ruiPartIdxRB  partition index of neighbouring bottom right block
  */
-Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB )
+Void TComDataCU::deriveRightBottomIdx( UInt uiPartIdx, UInt &ruiPartIdxRB ) const
 {
   ruiPartIdxRB      = g_auiRasterToZscan [g_auiZscanToRaster[ m_absZIdxInCtu ] + ( ((m_puhHeight[0] / m_pcPic->getMinCUHeight())>>1) - 1)*m_pcPic->getNumPartInCtuWidth() +  m_puhWidth[0] / m_pcPic->getMinCUWidth() - 1];
@@ -2179,5 +2178,5 @@
 }
 
-Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx )
+Bool TComDataCU::hasEqualMotion( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const
 {
   if ( getInterDir( uiAbsPartIdx ) != pcCandCU->getInterDir( uiCandAbsPartIdx ) )
@@ -2202,5 +2201,5 @@
 
 //! Construct a list of merging candidates
-Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
+Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx ) const
 {
   UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
@@ -2226,6 +2225,5 @@
   //left
   UInt uiLeftPartIdx = 0;
-  TComDataCU* pcCULeft = 0;
-  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
+  const TComDataCU *pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
 
   Bool isAvailableA1 = pcCULeft &&
@@ -2240,8 +2238,8 @@
     puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
     // get Mv from Left
-    pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     if ( getSlice()->isInterB() )
     {
-      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      TComDataCU::getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
     if ( mrgCandIdx == iCount )
@@ -2259,6 +2257,5 @@
   // above
   UInt uiAbovePartIdx = 0;
-  TComDataCU* pcCUAbove = 0;
-  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+  const TComDataCU *pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
 
   Bool isAvailableB1 = pcCUAbove &&
@@ -2273,8 +2270,8 @@
     puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
     // get Mv from Left
-    pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     if ( getSlice()->isInterB() )
     {
-      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      TComDataCU::getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
     if ( mrgCandIdx == iCount )
@@ -2292,6 +2289,5 @@
   // above right
   UInt uiAboveRightPartIdx = 0;
-  TComDataCU* pcCUAboveRight = 0;
-  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+  const TComDataCU *pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
 
   Bool isAvailableB0 = pcCUAboveRight &&
@@ -2305,8 +2301,8 @@
     puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
     // get Mv from Left
-    pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     if ( getSlice()->isInterB() )
     {
-      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      TComDataCU::getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
     if ( mrgCandIdx == iCount )
@@ -2324,6 +2320,5 @@
   //left bottom
   UInt uiLeftBottomPartIdx = 0;
-  TComDataCU* pcCULeftBottom = 0;
-  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+  const TComDataCU *pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
 
   Bool isAvailableA0 = pcCULeftBottom &&
@@ -2337,8 +2332,8 @@
     puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
     // get Mv from Left
-    pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
     if ( getSlice()->isInterB() )
     {
-      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      TComDataCU::getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
     if ( mrgCandIdx == iCount )
@@ -2358,6 +2353,5 @@
   {
     UInt uiAboveLeftPartIdx = 0;
-    TComDataCU* pcCUAboveLeft = 0;
-    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+    const TComDataCU *pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
 
     Bool isAvailableB2 = pcCUAboveLeft &&
@@ -2372,8 +2366,8 @@
       puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
       // get Mv from Left
-      pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+      TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
       if ( getSlice()->isInterB() )
       {
-        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+        TComDataCU::getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
       }
       if ( mrgCandIdx == iCount )
@@ -2560,5 +2554,5 @@
  * \param xP, yP   location of the upper-left corner pixel of the current PU
  */
-Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP)
+Bool TComDataCU::isDiffMER(Int xN, Int yN, Int xP, Int yP) const
 {
 
@@ -2580,5 +2574,5 @@
  * \param nPSW, nPSH    size of the current PU
  */
-Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH)
+Void TComDataCU::getPartPosition( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH) const
 {
   UInt col = m_uiCUPelX;
@@ -2641,5 +2635,5 @@
 }
 
-/** Constructs a list of candidates for AMVP
+/** Constructs a list of candidates for AMVP (See specification, section "Derivation process for motion vector predictor candidates")
  * \param uiPartIdx
  * \param uiPartAddr
@@ -2648,11 +2642,8 @@
  * \param pInfo
  */
-Void TComDataCU::fillMvpCand ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo )
-{
-  TComMv cMvPred;
-  Bool bAddedSmvp = false;
-
+Void TComDataCU::fillMvpCand ( const UInt partIdx, const UInt partAddr, const RefPicList eRefPicList, const Int refIdx, AMVPInfo* pInfo ) const
+{
   pInfo->iN = 0;
-  if (iRefIdx < 0)
+  if (refIdx < 0)
   {
     return;
@@ -2660,63 +2651,61 @@
 
   //-- Get Spatial MV
-  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
-  const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
-  const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
-  Bool bAdded = false;
-
-  deriveLeftRightTopIdx( uiPartIdx, uiPartIdxLT, uiPartIdxRT );
-  deriveLeftBottomIdx( uiPartIdx, uiPartIdxLB );
-
-  TComDataCU* tmpCU = NULL;
-  UInt idx;
-  tmpCU = getPUBelowLeft(idx, uiPartIdxLB);
-  bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
-
-  if (!bAddedSmvp)
-  {
-    tmpCU = getPULeft(idx, uiPartIdxLB);
-    bAddedSmvp = (tmpCU != NULL) && (tmpCU->isInter(idx));
+  UInt partIdxLT, partIdxRT, partIdxLB;
+  deriveLeftRightTopIdx( partIdx, partIdxLT, partIdxRT );
+  deriveLeftBottomIdx( partIdx, partIdxLB );
+
+  Bool isScaledFlagLX = false; /// variable name from specification; true when the PUs below left or left are available (availableA0 || availableA1).
+  {
+    UInt idx;
+    const TComDataCU* tmpCU = getPUBelowLeft(idx, partIdxLB);
+    isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
+    if (!isScaledFlagLX)
+    {
+      tmpCU = getPULeft(idx, partIdxLB);
+      isScaledFlagLX = (tmpCU != NULL) && (tmpCU->isInter(idx));
+    }
   }
 
   // Left predictor search
-  bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
-  if (!bAdded)
-  {
-    bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
-  }
-
-  if(!bAdded)
-  {
-    bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_BELOW_LEFT);
+  if (isScaledFlagLX)
+  {
+    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
     if (!bAdded)
     {
-      xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLB, MD_LEFT );
+      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
+      if(!bAdded)
+      {
+        bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_BELOW_LEFT);
+        if (!bAdded)
+        {
+          xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLB, MD_LEFT );
+        }
+      }
     }
   }
 
   // Above predictor search
-  bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
-
-  if (!bAdded)
-  {
-    bAdded = xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
-  }
-
-  if(!bAdded)
-  {
-    xAddMVPCand( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
-  }
-
-  if(!bAddedSmvp)
-  {
-    bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE_RIGHT);
+  {
+    Bool bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
     if (!bAdded)
     {
-      bAdded = xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxRT, MD_ABOVE);
-    }
-
-    if(!bAdded)
-    {
-      xAddMVPCandOrder( pInfo, eRefPicList, iRefIdx, uiPartIdxLT, MD_ABOVE_LEFT);
+      bAdded = xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
+      if(!bAdded)
+      {
+        xAddMVPCandUnscaled( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
+      }
+    }
+  }
+
+  if(!isScaledFlagLX)
+  {
+    Bool bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE_RIGHT);
+    if (!bAdded)
+    {
+      bAdded = xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxRT, MD_ABOVE);
+      if(!bAdded)
+      {
+        xAddMVPCandWithScaling( *pInfo, eRefPicList, refIdx, partIdxLT, MD_ABOVE_LEFT);
+      }
     }
   }
@@ -2730,49 +2719,50 @@
   }
 
-  if ( getSlice()->getEnableTMVPFlag() )
+  if (pInfo->iN < AMVP_MAX_NUM_CANDS && getSlice()->getEnableTMVPFlag() )
   {
     // Get Temporal Motion Predictor
-    Int iRefIdx_Col = iRefIdx;
+    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
+    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
+    const Int refIdx_Col = refIdx;
     TComMv cColMv;
-    UInt uiPartIdxRB;
-    UInt uiAbsPartIdx;
-    UInt uiAbsPartAddr;
-
-    deriveRightBottomIdx( uiPartIdx, uiPartIdxRB );
-    uiAbsPartAddr = m_absZIdxInCtu + uiPartAddr;
+    UInt partIdxRB;
+    UInt absPartIdx;
+
+    deriveRightBottomIdx( partIdx, partIdxRB );
+    UInt absPartAddr = m_absZIdxInCtu + partAddr;
 
     //----  co-located RightBottom Temporal Predictor (H) ---//
-    uiAbsPartIdx = g_auiZscanToRaster[uiPartIdxRB];
+    absPartIdx = g_auiZscanToRaster[partIdxRB];
     Int ctuRsAddr = -1;
 
 #if SVC_EXTENSION
-    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getPicWidthInLumaSamples())   // image boundary check
-       && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getPicHeightInLumaSamples() ) )    
+    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getPicWidthInLumaSamples())   // image boundary check
+       && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getPicHeightInLumaSamples() ) )    
 #else
-    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
-       && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
+    if (  ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[absPartIdx] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
+       && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[absPartIdx] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
 #endif    
     {
-      if ( ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
-           ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + numPartInCtuWidth + 1 ];
+      if ( ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&  // is not at the last column of CTU
+           ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) )  // is not at the last row    of CTU
+      {
+        absPartAddr = g_auiRasterToZscan[ absPartIdx + numPartInCtuWidth + 1 ];
         ctuRsAddr = getCtuRsAddr();
       }
-      else if ( uiAbsPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
-      }
-      else if ( uiAbsPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdx + 1 ];
+      else if ( absPartIdx % numPartInCtuWidth < numPartInCtuWidth - 1 )  // is not at the last column of CTU But is last row of CTU
+      {
+        absPartAddr = g_auiRasterToZscan[ (absPartIdx + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
+      }
+      else if ( absPartIdx / numPartInCtuWidth < numPartInCtuHeight - 1 ) // is not at the last row of CTU But is last column of CTU
+      {
+        absPartAddr = g_auiRasterToZscan[ absPartIdx + 1 ];
         ctuRsAddr = getCtuRsAddr() + 1;
       }
       else //is the right bottom corner of CTU
       {
-        uiAbsPartAddr = 0;
-      }
-    }
-    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx_Col ) )
+        absPartAddr = 0;
+      }
+    }
+    if ( ctuRsAddr >= 0 && xGetColMVP( eRefPicList, ctuRsAddr, absPartAddr, cColMv, refIdx_Col ) )
     {
       pInfo->m_acMvCand[pInfo->iN++] = cColMv;
@@ -2781,6 +2771,6 @@
     {
       UInt uiPartIdxCenter;
-      xDeriveCenterIdx( uiPartIdx, uiPartIdxCenter );
-      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx_Col ))
+      xDeriveCenterIdx( partIdx, uiPartIdxCenter );
+      if (xGetColMVP( eRefPicList, getCtuRsAddr(), uiPartIdxCenter,  cColMv, refIdx_Col ))
       {
         pInfo->m_acMvCand[pInfo->iN++] = cColMv;
@@ -2788,9 +2778,4 @@
     }
     //----  co-located RightBottom Temporal Predictor  ---//
-  }
-
-  if (pInfo->iN > AMVP_MAX_NUM_CANDS)
-  {
-    pInfo->iN = AMVP_MAX_NUM_CANDS;
   }
 
@@ -2804,5 +2789,5 @@
 
 
-Bool TComDataCU::isBipredRestriction(UInt puIdx)
+Bool TComDataCU::isBipredRestriction(UInt puIdx) const
 {
   Int width = 0;
@@ -2830,5 +2815,5 @@
 #endif
   Int iHorMin = (      -(Int)sps.getMaxCUWidth() - iOffset - (Int)m_uiCUPelX + 1 ) << iMvShift;
-  
+
 #if SVC_EXTENSION
   Int iVerMax = ( m_pcSlice->getPicHeightInLumaSamples() + iOffset - (Int)m_uiCUPelY - 1 ) << iMvShift;
@@ -2843,5 +2828,5 @@
 
 
-UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx)
+UInt TComDataCU::getIntraSizeIdx(UInt uiAbsPartIdx) const
 {
   UInt uiShift = ( m_pePartSize[uiAbsPartIdx]==SIZE_NxN ? 1 : 0 );
@@ -2880,5 +2865,5 @@
  * \returns true if the current the block is skipped
  */
-Bool TComDataCU::isSkipped( UInt uiPartIdx )
+Bool TComDataCU::isSkipped( UInt uiPartIdx ) const
 {
   return ( getSkipFlag( uiPartIdx ) );
@@ -2889,33 +2874,33 @@
 // ====================================================================================================================
 
-Bool TComDataCU::xAddMVPCand( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
-{
-  TComDataCU* pcTmpCU = NULL;
-  UInt uiIdx;
+Bool TComDataCU::xAddMVPCandUnscaled( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
+{
+  const TComDataCU* neibCU = NULL;
+  UInt neibPUPartIdx;
   switch( eDir )
   {
     case MD_LEFT:
     {
-      pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
     case MD_ABOVE:
     {
-      pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
     case MD_ABOVE_RIGHT:
     {
-      pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
     case MD_BELOW_LEFT:
     {
-      pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
     case MD_ABOVE_LEFT:
     {
-      pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
@@ -2926,42 +2911,24 @@
   }
 
-  if ( pcTmpCU == NULL )
+  if ( neibCU == NULL )
   {
     return false;
   }
 
-  if ( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0 && m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC() == pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ))
-  {
-    TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-
-    pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
-    return true;
-  }
-
-  RefPicList eRefPicList2nd = REF_PIC_LIST_0;
-  if(       eRefPicList == REF_PIC_LIST_0 )
-  {
-    eRefPicList2nd = REF_PIC_LIST_1;
-  }
-  else if ( eRefPicList == REF_PIC_LIST_1)
-  {
-    eRefPicList2nd = REF_PIC_LIST_0;
-  }
-
-
-  Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
-  Int iNeibRefPOC;
-
-
-  if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0 )
-  {
-    iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
-    if( iNeibRefPOC == iCurrRefPOC ) // Same Reference Frame But Diff List//
-    {
-      TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
-      pInfo->m_acMvCand[ pInfo->iN++] = cMvPred;
+  const Int        currRefPOC     = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
+  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
+
+  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
+  {
+    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
+    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
+
+    if ( neibRefIdx >= 0 && currRefPOC == neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx ))
+    {
+      info.m_acMvCand[info.iN++] = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
       return true;
     }
   }
+
   return false;
 }
@@ -2975,33 +2942,33 @@
  * \returns Bool
  */
-Bool TComDataCU::xAddMVPCandOrder( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir )
-{
-  TComDataCU* pcTmpCU = NULL;
-  UInt uiIdx;
+Bool TComDataCU::xAddMVPCandWithScaling( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const
+{
+  const TComDataCU* neibCU = NULL;
+  UInt neibPUPartIdx;
   switch( eDir )
   {
   case MD_LEFT:
     {
-      pcTmpCU = getPULeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPULeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
   case MD_ABOVE:
     {
-      pcTmpCU = getPUAbove(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAbove(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
   case MD_ABOVE_RIGHT:
     {
-      pcTmpCU = getPUAboveRight(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAboveRight(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
   case MD_BELOW_LEFT:
     {
-      pcTmpCU = getPUBelowLeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPUBelowLeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
   case MD_ABOVE_LEFT:
     {
-      pcTmpCU = getPUAboveLeft(uiIdx, uiPartUnitIdx);
+      neibCU = getPUAboveLeft(neibPUPartIdx, uiPartUnitIdx);
       break;
     }
@@ -3012,44 +2979,29 @@
   }
 
-  if ( pcTmpCU == NULL )
+  if ( neibCU == NULL )
   {
     return false;
   }
 
-  RefPicList eRefPicList2nd = REF_PIC_LIST_0;
-  if(       eRefPicList == REF_PIC_LIST_0 )
-  {
-    eRefPicList2nd = REF_PIC_LIST_1;
-  }
-  else if ( eRefPicList == REF_PIC_LIST_1)
-  {
-    eRefPicList2nd = REF_PIC_LIST_0;
-  }
-
-  Int iCurrPOC = m_pcSlice->getPOC();
-  Int iCurrRefPOC = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
-  Int iNeibPOC = iCurrPOC;
-  Int iNeibRefPOC;
-  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
-  Bool bIsNeibRefLongTerm = false;
-
-  //---------------  V1 (END) ------------------//
-  if( pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) >= 0)
-  {
-    iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) );
-    TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-    TComMv rcMv;
-
-    bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList, pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) )->getIsLongTerm();
-    if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
-    {
-      if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
-      {
-        rcMv = cMvPred;
-      }
-      else
-      {
-        Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
-        if ( iScale == 4096 )
+  const RefPicList eRefPicList2nd = (eRefPicList == REF_PIC_LIST_0) ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
+
+  const Int  currPOC            = m_pcSlice->getPOC();
+  const Int  currRefPOC         = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getPOC();
+  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic( eRefPicList, iRefIdx)->getIsLongTerm();
+  const Int  neibPOC            = currPOC;
+
+  for(Int predictorSource=0; predictorSource<2; predictorSource++) // examine the indicated reference picture list, then if not available, examine the other list.
+  {
+    const RefPicList eRefPicListIndex = (predictorSource==0) ? eRefPicList : eRefPicList2nd;
+    const Int        neibRefIdx       = neibCU->getCUMvField(eRefPicListIndex)->getRefIdx(neibPUPartIdx);
+    if( neibRefIdx >= 0)
+    {
+      const Bool bIsNeibRefLongTerm = neibCU->getSlice()->getRefPic( eRefPicListIndex, neibRefIdx )->getIsLongTerm();
+
+      if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
+      {
+        const TComMv &cMvPred = neibCU->getCUMvField(eRefPicListIndex)->getMv(neibPUPartIdx);
+        TComMv rcMv;
+        if ( bIsCurrRefLongTerm /* || bIsNeibRefLongTerm*/ )
         {
           rcMv = cMvPred;
@@ -3057,78 +3009,48 @@
         else
         {
-          rcMv = cMvPred.scaleMv( iScale );
+          const Int neibRefPOC = neibCU->getSlice()->getRefPOC( eRefPicListIndex, neibRefIdx );
+          const Int scale      = xGetDistScaleFactor( currPOC, currRefPOC, neibPOC, neibRefPOC );
+          if ( scale == 4096 )
+          {
+            rcMv = cMvPred;
+          }
+          else
+          {
+            rcMv = cMvPred.scaleMv( scale );
+          }
         }
-      }
-
-      pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
-      return true;
-    }
-  }
-  //---------------------- V2(END) --------------------//
-  if( pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) >= 0)
-  {
-    iNeibRefPOC = pcTmpCU->getSlice()->getRefPOC( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) );
-    TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList2nd)->getMv(uiIdx);
-    TComMv rcMv;
-
-    bIsNeibRefLongTerm = pcTmpCU->getSlice()->getRefPic( eRefPicList2nd, pcTmpCU->getCUMvField(eRefPicList2nd)->getRefIdx(uiIdx) )->getIsLongTerm();
-    if ( bIsCurrRefLongTerm == bIsNeibRefLongTerm )
-    {
-      if ( bIsCurrRefLongTerm || bIsNeibRefLongTerm )
-      {
-        rcMv = cMvPred;
-      }
-      else
-      {
-        Int iScale = xGetDistScaleFactor( iCurrPOC, iCurrRefPOC, iNeibPOC, iNeibRefPOC );
-        if ( iScale == 4096 )
-        {
-          rcMv = cMvPred;
-        }
-        else
-        {
-          rcMv = cMvPred.scaleMv( iScale );
-        }
-      }
-
-      pInfo->m_acMvCand[ pInfo->iN++] = rcMv;
-      return true;
-    }
-  }
-  //---------------------- V3(END) --------------------//
+
+        info.m_acMvCand[info.iN++] = rcMv;
+        return true;
+      }
+    }
+  }
   return false;
 }
 
-Bool TComDataCU::xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx )
-{
-  UInt uiAbsPartAddr = uiPartUnitIdx;
-
-  RefPicList  eColRefPicList;
-  Int iColPOC, iColRefPOC, iCurrPOC, iCurrRefPOC, iScale;
-  TComMv cColMv;
+Bool TComDataCU::xGetColMVP( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const
+{
+  const UInt absPartAddr = partUnitIdx;
 
   // use coldir.
-  TComPic *pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
-  TComDataCU *pColCtu = pColPic->getCtu( ctuRsAddr );
-  if(pColCtu->getPic()==0||pColCtu->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES)
+  const TComPic    * const pColPic = getSlice()->getRefPic( RefPicList(getSlice()->isInterB() ? 1-getSlice()->getColFromL0Flag() : 0), getSlice()->getColRefIdx());
+  const TComDataCU * const pColCtu = pColPic->getCtu( ctuRsAddr );
+  if(pColCtu->getPic()==0 || pColCtu->getPartitionSize(partUnitIdx)==NUMBER_OF_PART_SIZES)
   {
     return false;
   }
-  iCurrPOC = m_pcSlice->getPOC();
-  iColPOC = pColCtu->getSlice()->getPOC();
-
-  if (!pColCtu->isInter(uiAbsPartAddr))
+
+  if (!pColCtu->isInter(absPartAddr))
   {
     return false;
   }
 
-  eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
-
-  Int iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
+  RefPicList eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(getSlice()->getColFromL0Flag());
+  Int iColRefIdx            = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
 
   if (iColRefIdx < 0 )
   {
     eColRefPicList = RefPicList(1 - eColRefPicList);
-    iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(uiAbsPartAddr);
+    iColRefIdx = pColCtu->getCUMvField(RefPicList(eColRefPicList))->getRefIdx(absPartAddr);
 
     if (iColRefIdx < 0 )
@@ -3138,19 +3060,15 @@
   }
 
+  const Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, refIdx)->getIsLongTerm();
+  const Bool bIsColRefLongTerm  = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
+
+  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
+  {
+    return false;
+  }
+
   // Scale the vector.
-  iColRefPOC = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
-  cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(uiAbsPartAddr);
-
-  iCurrRefPOC = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getPOC();
-
-  Bool bIsCurrRefLongTerm = m_pcSlice->getRefPic(eRefPicList, riRefIdx)->getIsLongTerm();
-  Bool bIsColRefLongTerm = pColCtu->getSlice()->getIsUsedAsLongTerm(eColRefPicList, iColRefIdx);
-
-  if ( bIsCurrRefLongTerm != bIsColRefLongTerm )
-  {
-    return false;
-  }
-
-  if ( bIsCurrRefLongTerm || bIsColRefLongTerm )
+  const TComMv &cColMv = pColCtu->getCUMvField(eColRefPicList)->getMv(absPartAddr);
+  if ( bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/ )
   {
     rcMv = cColMv;
@@ -3158,6 +3076,10 @@
   else
   {
-    iScale = xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iColPOC, iColRefPOC);
-    if ( iScale == 4096 )
+    const Int currPOC    = m_pcSlice->getPOC();
+    const Int colPOC     = pColCtu->getSlice()->getPOC();
+    const Int colRefPOC  = pColCtu->getSlice()->getRefPOC(eColRefPicList, iColRefIdx);
+    const Int currRefPOC = m_pcSlice->getRefPic(eRefPicList, refIdx)->getPOC();
+    const Int scale      = xGetDistScaleFactor(currPOC, currRefPOC, colPOC, colRefPOC);
+    if ( scale == 4096 )
     {
       rcMv = cColMv;
@@ -3165,5 +3087,5 @@
     else
     {
-      rcMv = cColMv.scaleMv( iScale );
+      rcMv = cColMv.scaleMv( scale );
     }
   }
@@ -3172,4 +3094,5 @@
 }
 
+// Static member
 Int TComDataCU::xGetDistScaleFactor(Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC)
 {
@@ -3191,5 +3114,5 @@
 }
 
-Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter )
+Void TComDataCU::xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const
 {
   UInt uiPartAddr;
@@ -3486,5 +3409,5 @@
 
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1)
+Bool TComDataCU::isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1) const
 {
   Bool checkILR = false;
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1465)
@@ -70,6 +70,6 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  TComPic*      m_pcPic;              ///< picture class pointer
-  TComSlice*    m_pcSlice;            ///< slice header pointer
+  TComPic*      m_pcPic;                                ///< picture class pointer
+  TComSlice*    m_pcSlice;                              ///< slice header pointer
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -77,16 +77,16 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  UInt          m_ctuRsAddr;          ///< CTU (also known as LCU) address in a slice (Raster-scan address, as opposed to tile-scan/encoding order).
-  UInt          m_absZIdxInCtu;       ///< absolute address in a CTU. It's Z scan order
-  UInt          m_uiCUPelX;           ///< CU position in a pixel (X)
-  UInt          m_uiCUPelY;           ///< CU position in a pixel (Y)
-  UInt          m_uiNumPartition;     ///< total number of minimum partitions in a CU
-  UChar*        m_puhWidth;           ///< array of widths
-  UChar*        m_puhHeight;          ///< array of heights
-  UChar*        m_puhDepth;           ///< array of depths
-  Int           m_unitSize;           ///< size of a "minimum partition"
+  UInt          m_ctuRsAddr;                            ///< CTU (also known as LCU) address in a slice (Raster-scan address, as opposed to tile-scan/encoding order).
+  UInt          m_absZIdxInCtu;                         ///< absolute address in a CTU. It's Z scan order
+  UInt          m_uiCUPelX;                             ///< CU position in a pixel (X)
+  UInt          m_uiCUPelY;                             ///< CU position in a pixel (Y)
+  UInt          m_uiNumPartition;                       ///< total number of minimum partitions in a CU
+  UChar*        m_puhWidth;                             ///< array of widths
+  UChar*        m_puhHeight;                            ///< array of heights
+  UChar*        m_puhDepth;                             ///< array of depths
+  Int           m_unitSize;                             ///< size of a "minimum partition"
 
 #if SVC_EXTENSION
-  UInt          m_layerId;          ///< layer id
+  UInt          m_layerId;                              ///< layer id
 #if FAST_INTRA_SHVC
   UChar         m_reducedSetIntraModes[NUM_INTRA_MODE-1];
@@ -98,23 +98,23 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Bool*          m_skipFlag;           ///< array of skip flags
-  SChar*         m_pePartSize;         ///< array of partition sizes
-  SChar*         m_pePredMode;         ///< array of prediction modes
-  SChar*         m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha values
-  Bool*          m_CUTransquantBypass;   ///< array of cu_transquant_bypass flags
-  SChar*         m_phQP;               ///< array of QP values
-  UChar*         m_ChromaQpAdj;        ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
-  UInt           m_codedChromaQpAdj;
-  UChar*         m_puhTrIdx;           ///< array of transform indices
-  UChar*         m_puhTransformSkip[MAX_NUM_COMPONENT];///< array of transform skipping flags
-  UChar*         m_puhCbf[MAX_NUM_COMPONENT];          ///< array of coded block flags (CBF)
-  TComCUMvField  m_acCUMvField[NUM_REF_PIC_LIST_01];    ///< array of motion vectors.
-  TCoeff*        m_pcTrCoeff[MAX_NUM_COMPONENT];       ///< array of transform coefficient buffers (0->Y, 1->Cb, 2->Cr)
+  Bool*         m_skipFlag;                             ///< array of skip flags
+  SChar*        m_pePartSize;                           ///< array of partition sizes
+  SChar*        m_pePredMode;                           ///< array of prediction modes
+  SChar*        m_crossComponentPredictionAlpha[MAX_NUM_COMPONENT]; ///< array of cross-component prediction alpha values
+  Bool*         m_CUTransquantBypass;                   ///< array of cu_transquant_bypass flags
+  SChar*        m_phQP;                                 ///< array of QP values
+  UChar*        m_ChromaQpAdj;                          ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
+  UInt          m_codedChromaQpAdj;
+  UChar*        m_puhTrIdx;                             ///< array of transform indices
+  UChar*        m_puhTransformSkip[MAX_NUM_COMPONENT];  ///< array of transform skipping flags
+  UChar*        m_puhCbf[MAX_NUM_COMPONENT];            ///< array of coded block flags (CBF)
+  TComCUMvField m_acCUMvField[NUM_REF_PIC_LIST_01];     ///< array of motion vectors.
+  TCoeff*       m_pcTrCoeff[MAX_NUM_COMPONENT];         ///< array of transform coefficient buffers (0->Y, 1->Cb, 2->Cr)
 #if ADAPTIVE_QP_SELECTION
-  TCoeff*        m_pcArlCoeff[MAX_NUM_COMPONENT];  // ARL coefficient buffer (0->Y, 1->Cb, 2->Cr)
-  Bool           m_ArlCoeffIsAliasedAllocation;  ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
-#endif
-
-  Pel*           m_pcIPCMSample[MAX_NUM_COMPONENT];    ///< PCM sample buffer (0->Y, 1->Cb, 2->Cr)
+  TCoeff*       m_pcArlCoeff[MAX_NUM_COMPONENT];        ///< ARL coefficient buffer (0->Y, 1->Cb, 2->Cr)
+  Bool          m_ArlCoeffIsAliasedAllocation;          ///< ARL coefficient buffer is an alias of the global buffer and must not be free()'d
+#endif
+
+  Pel*          m_pcIPCMSample[MAX_NUM_COMPONENT];      ///< PCM sample buffer (0->Y, 1->Cb, 2->Cr)
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -122,13 +122,13 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  TComDataCU*   m_pCtuAboveLeft;      ///< pointer of above-left CTU.
-  TComDataCU*   m_pCtuAboveRight;     ///< pointer of above-right CTU.
-  TComDataCU*   m_pCtuAbove;          ///< pointer of above CTU.
-  TComDataCU*   m_pCtuLeft;           ///< pointer of left CTU
+  TComDataCU*   m_pCtuAboveLeft;                        ///< pointer of above-left CTU.
+  TComDataCU*   m_pCtuAboveRight;                       ///< pointer of above-right CTU.
+  TComDataCU*   m_pCtuAbove;                            ///< pointer of above CTU.
+  TComDataCU*   m_pCtuLeft;                             ///< pointer of left CTU
   TComDataCU*   m_apcCUColocated[NUM_REF_PIC_LIST_01];  ///< pointer of temporally colocated CU's for both directions
-  TComMvField   m_cMvFieldA;          ///< motion vector of position A
-  TComMvField   m_cMvFieldB;          ///< motion vector of position B
-  TComMvField   m_cMvFieldC;          ///< motion vector of position C
-  TComMv        m_cMvPred;            ///< motion vector predictor
+  TComMvField   m_cMvFieldA;                            ///< motion vector of position A
+  TComMvField   m_cMvFieldB;                            ///< motion vector of position B
+  TComMvField   m_cMvFieldC;                            ///< motion vector of position C
+  TComMv        m_cMvPred;                              ///< motion vector predictor
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -136,14 +136,14 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Bool*         m_pbMergeFlag;        ///< array of merge flags
-  UChar*        m_puhMergeIndex;      ///< array of merge candidate indices
+  Bool*         m_pbMergeFlag;                          ///< array of merge flags
+  UChar*        m_puhMergeIndex;                        ///< array of merge candidate indices
 #if AMP_MRG
   Bool          m_bIsMergeAMP;
 #endif
-  UChar*        m_puhIntraDir[MAX_NUM_CHANNEL_TYPE]; // 0-> Luma, 1-> Chroma
-  UChar*        m_puhInterDir;        ///< array of inter directions
+  UChar*        m_puhIntraDir[MAX_NUM_CHANNEL_TYPE];
+  UChar*        m_puhInterDir;                          ///< array of inter directions
   SChar*        m_apiMVPIdx[NUM_REF_PIC_LIST_01];       ///< array of motion vector predictor candidates
   SChar*        m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
-  Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
+  Bool*         m_pbIPCMFlag;                           ///< array of intra_pcm flags
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -151,9 +151,9 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Bool          m_bDecSubCu;          ///< indicates decoder-mode
-  Double        m_dTotalCost;         ///< sum of partition RD costs
-  Distortion    m_uiTotalDistortion;  ///< sum of partition distortion
-  UInt          m_uiTotalBits;        ///< sum of partition bits
-  UInt          m_uiTotalBins;        ///< sum of partition bins
+  Bool          m_bDecSubCu;                            ///< indicates decoder-mode
+  Double        m_dTotalCost;                           ///< sum of partition RD costs
+  Distortion    m_uiTotalDistortion;                    ///< sum of partition distortion
+  UInt          m_uiTotalBits;                          ///< sum of partition bits
+  UInt          m_uiTotalBins;                          ///< sum of partition bins
   SChar         m_codedQP;
   UChar*        m_explicitRdpcmMode[MAX_NUM_COMPONENT]; ///< Stores the explicit RDPCM mode for all TUs belonging to this CU
@@ -161,19 +161,19 @@
 protected:
 
-  /// add possible motion vector predictor candidates
-  Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
-  Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
-
-  Void          deriveRightBottomIdx        ( UInt uiPartIdx, UInt& ruiPartIdxRB );
-  Bool          xGetColMVP( RefPicList eRefPicList, Int ctuRsAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx );
+  /// adds a single possible motion vector predictor candidate
+  Bool          xAddMVPCandUnscaled           ( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const;
+  Bool          xAddMVPCandWithScaling        ( AMVPInfo &info, const RefPicList eRefPicList, const Int iRefIdx, const UInt uiPartUnitIdx, const MVP_DIR eDir ) const;
+
+  Void          deriveRightBottomIdx          ( UInt uiPartIdx, UInt& ruiPartIdxRB ) const;
+  Bool          xGetColMVP                    ( const RefPicList eRefPicList, const Int ctuRsAddr, const Int partUnitIdx, TComMv& rcMv, const Int refIdx ) const;
 
   /// compute scaling factor from POC difference
-  Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
-
-  Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
+  static Int    xGetDistScaleFactor           ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
+
+  Void          xDeriveCenterIdx              ( UInt uiPartIdx, UInt& ruiPartIdxCenter ) const;
 
 public:
-  TComDataCU();
-  virtual ~TComDataCU();
+                TComDataCU();
+  virtual       ~TComDataCU();
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -181,21 +181,21 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Void          create                ( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
+  Void          create                        ( ChromaFormat chromaFormatIDC, UInt uiNumPartition, UInt uiWidth, UInt uiHeight, Bool bDecSubCu, Int unitSize
 #if ADAPTIVE_QP_SELECTION
-    , TCoeff *pParentARLBuffer = 0
-#endif
-    );
-  Void          destroy               ();
-
-  Void          initCtu               ( TComPic* pcPic, UInt ctuRsAddr );
-  Void          initEstData           ( const UInt uiDepth, const Int qp, const Bool bTransquantBypass );
-  Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
-  Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
-
-  Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx );
-  Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList );
-  Void          copyPartFrom          ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
-
-  Void          copyToPic             ( UChar uiDepth );
+                                                , TCoeff *pParentARLBuffer = 0
+#endif
+                                              );
+  Void          destroy                       ( );
+
+  Void          initCtu                       ( TComPic* pcPic, UInt ctuRsAddr );
+  Void          initEstData                   ( const UInt uiDepth, const Int qp, const Bool bTransquantBypass );
+  Void          initSubCU                     ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
+  Void          setOutsideCUPart              ( UInt uiAbsPartIdx, UInt uiDepth );
+
+  Void          copySubCU                     ( TComDataCU* pcCU, UInt uiPartUnitIdx );
+  Void          copyInterPredInfoFrom         ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList );
+  Void          copyPartFrom                  ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth );
+
+  Void          copyToPic                     ( UChar uiDepth );
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -203,19 +203,19 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  TComPic*        getPic              ()                        { return m_pcPic;           }
-  const TComPic*  getPic              () const                  { return m_pcPic;           }
-  TComSlice*       getSlice           ()                        { return m_pcSlice;         }
-  const TComSlice* getSlice           () const                  { return m_pcSlice;         }
-  UInt&         getCtuRsAddr          ()                        { return m_ctuRsAddr;       }
-  UInt          getCtuRsAddr          () const                  { return m_ctuRsAddr;       }
-  UInt          getZorderIdxInCtu     () const                  { return m_absZIdxInCtu;    }
-  UInt          getCUPelX             () const                  { return m_uiCUPelX;        }
-  UInt          getCUPelY             () const                  { return m_uiCUPelY;        }
-
-  UChar*        getDepth              ()                        { return m_puhDepth;        }
-  UChar         getDepth              ( UInt uiIdx ) const      { return m_puhDepth[uiIdx]; }
-  Void          setDepth              ( UInt uiIdx, UChar  uh ) { m_puhDepth[uiIdx] = uh;   }
-
-  Void          setDepthSubParts      ( UInt uiDepth, UInt uiAbsPartIdx );
+  TComPic*         getPic                     ( )                                                          { return m_pcPic;                            }
+  const TComPic*   getPic                     ( ) const                                                    { return m_pcPic;                            }
+  TComSlice*       getSlice                   ( )                                                          { return m_pcSlice;                          }
+  const TComSlice* getSlice                   ( ) const                                                    { return m_pcSlice;                          }
+  UInt&         getCtuRsAddr                  ( )                                                          { return m_ctuRsAddr;                        }
+  UInt          getCtuRsAddr                  ( ) const                                                    { return m_ctuRsAddr;                        }
+  UInt          getZorderIdxInCtu             ( ) const                                                    { return m_absZIdxInCtu;                     }
+  UInt          getCUPelX                     ( ) const                                                    { return m_uiCUPelX;                         }
+  UInt          getCUPelY                     ( ) const                                                    { return m_uiCUPelY;                         }
+
+  UChar*        getDepth                      ( )                                                          { return m_puhDepth;                         }
+  UChar         getDepth                      ( UInt uiIdx ) const                                         { return m_puhDepth[uiIdx];                  }
+  Void          setDepth                      ( UInt uiIdx, UChar uh )                                     { m_puhDepth[uiIdx] = uh;                    }
+
+  Void          setDepthSubParts              ( UInt uiDepth, UInt uiAbsPartIdx );
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -223,97 +223,98 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  SChar*        getPartitionSize      ()                        { return m_pePartSize;        }
-  PartSize      getPartitionSize      ( UInt uiIdx )            { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
-  Void          setPartitionSize      ( UInt uiIdx, PartSize uh){ m_pePartSize[uiIdx] = uh;   }
-  Void          setPartSizeSubParts   ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
-  Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
-
-  Bool*         getSkipFlag            ()                        { return m_skipFlag;          }
-  Bool          getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
-  Void          setSkipFlag           ( UInt idx, Bool skip)     { m_skipFlag[idx] = skip;   }
-  Void          setSkipFlagSubParts   ( Bool skip, UInt absPartIdx, UInt depth );
-
-  SChar*        getPredictionMode     ()                        { return m_pePredMode;        }
-  PredMode      getPredictionMode     ( UInt uiIdx )            { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
-  Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
-  Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
-
-  SChar*        getCrossComponentPredictionAlpha( ComponentID compID )             { return m_crossComponentPredictionAlpha[compID];         }
-  SChar         getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID ) { return m_crossComponentPredictionAlpha[compID][uiIdx];  }
-
-  Bool*         getCUTransquantBypass ()                        { return m_CUTransquantBypass;        }
-  Bool          getCUTransquantBypass( UInt uiIdx )             { return m_CUTransquantBypass[uiIdx]; }
-
-  UChar*        getWidth              ()                        { return m_puhWidth;          }
-  UChar         getWidth              ( UInt uiIdx )            { return m_puhWidth[uiIdx];   }
-  Void          setWidth              ( UInt uiIdx, UChar  uh ) { m_puhWidth[uiIdx] = uh;     }
-
-  UChar*        getHeight             ()                        { return m_puhHeight;         }
-  UChar         getHeight             ( UInt uiIdx )            { return m_puhHeight[uiIdx];  }
-  Void          setHeight             ( UInt uiIdx, UChar  uh ) { m_puhHeight[uiIdx] = uh;    }
-
-  Void          setSizeSubParts       ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
-
-  SChar*        getQP                 ()                        { return m_phQP;              }
-  SChar         getQP                 ( UInt uiIdx ) const      { return m_phQP[uiIdx];       }
-  Void          setQP                 ( UInt uiIdx, SChar value){ m_phQP[uiIdx] =  value;     }
-  Void          setQPSubParts         ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
-  Int           getLastValidPartIdx   ( Int iAbsPartIdx );
-  SChar         getLastCodedQP        ( UInt uiAbsPartIdx );
-  Void          setQPSubCUs           ( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
-  Void          setCodedQP            ( SChar qp )              { m_codedQP = qp;             }
-  SChar         getCodedQP            ()                        { return m_codedQP;           }
-
-  UChar*        getChromaQpAdj        ()                        { return m_ChromaQpAdj;       } ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
-  UChar         getChromaQpAdj        (Int idx)           const { return m_ChromaQpAdj[idx];  } ///< When value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
-  Void          setChromaQpAdj        (Int idx, UChar val)      { m_ChromaQpAdj[idx] = val;   } ///< When val = 0,   cu_chroma_qp_offset_flag=0; when val>0,   indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=val-1
-  Void          setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth );
-  Void          setCodedChromaQpAdj   ( SChar qp )              { m_codedChromaQpAdj = qp;    }
-  SChar         getCodedChromaQpAdj   ()                        { return m_codedChromaQpAdj;  }
-
-  Bool          isLosslessCoded       ( UInt absPartIdx );
-
-  UChar*        getTransformIdx       ()                        { return m_puhTrIdx;          }
-  UChar         getTransformIdx       ( UInt uiIdx )            { return m_puhTrIdx[uiIdx];   }
-  Void          setTrIdxSubParts      ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
-
-  UChar*        getTransformSkip      ( ComponentID compID )    { return m_puhTransformSkip[compID];}
-  UChar         getTransformSkip      ( UInt uiIdx, ComponentID compID)    { return m_puhTransformSkip[compID][uiIdx];}
-  Void          setTransformSkipSubParts  ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth);
-  Void          setTransformSkipSubParts  ( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth );
-
-  UChar*        getExplicitRdpcmMode      ( ComponentID component ) { return m_explicitRdpcmMode[component]; }
-  UChar         getExplicitRdpcmMode      ( ComponentID component, UInt partIdx ) {return m_explicitRdpcmMode[component][partIdx]; }
+  SChar*        getPartitionSize              ( )                                                          { return m_pePartSize;                       }
+  PartSize      getPartitionSize              ( UInt uiIdx ) const                                         { return static_cast<PartSize>( m_pePartSize[uiIdx] ); }
+  Void          setPartitionSize              ( UInt uiIdx, PartSize uh )                                  { m_pePartSize[uiIdx] = uh;                  }
+  Void          setPartSizeSubParts           ( PartSize eMode, UInt uiAbsPartIdx, UInt uiDepth );
+  Void          setCUTransquantBypassSubParts ( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
+
+  Bool*         getSkipFlag                   ( )                                                          { return m_skipFlag;                         }
+  Bool          getSkipFlag                   ( UInt idx ) const                                           { return m_skipFlag[idx];                    }
+  Void          setSkipFlag                   ( UInt idx, Bool skip )                                      { m_skipFlag[idx] = skip;                    }
+  Void          setSkipFlagSubParts           ( Bool skip, UInt absPartIdx, UInt depth );
+
+  SChar*        getPredictionMode             ( )                                                          { return m_pePredMode;                       }
+  PredMode      getPredictionMode             ( UInt uiIdx ) const                                         { return static_cast<PredMode>( m_pePredMode[uiIdx] ); }
+  Void          setPredictionMode             ( UInt uiIdx, PredMode uh )                                  { m_pePredMode[uiIdx] = uh;                  }
+  Void          setPredModeSubParts           ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
+
+  SChar*        getCrossComponentPredictionAlpha( ComponentID compID )                                     { return m_crossComponentPredictionAlpha[compID];        }
+  SChar         getCrossComponentPredictionAlpha( UInt uiIdx, ComponentID compID )                         { return m_crossComponentPredictionAlpha[compID][uiIdx]; }
+
+  Bool*         getCUTransquantBypass         ( )                                                          { return m_CUTransquantBypass;               }
+  Bool          getCUTransquantBypass         ( UInt uiIdx ) const                                         { return m_CUTransquantBypass[uiIdx];        }
+
+  UChar*        getWidth                      ( )                                                          { return m_puhWidth;                         }
+  UChar         getWidth                      ( UInt uiIdx ) const                                         { return m_puhWidth[uiIdx];                  }
+  Void          setWidth                      ( UInt uiIdx, UChar  uh )                                    { m_puhWidth[uiIdx] = uh;                    }
+
+  UChar*        getHeight                     ( )                                                          { return m_puhHeight;                        }
+  UChar         getHeight                     ( UInt uiIdx ) const                                         { return m_puhHeight[uiIdx];                 }
+  Void          setHeight                     ( UInt uiIdx, UChar  uh )                                    { m_puhHeight[uiIdx] = uh;                   }
+
+  Void          setSizeSubParts               ( UInt uiWidth, UInt uiHeight, UInt uiAbsPartIdx, UInt uiDepth );
+
+  SChar*        getQP                         ( )                                                          { return m_phQP;                             }
+  SChar         getQP                         ( UInt uiIdx ) const                                         { return m_phQP[uiIdx];                      }
+  Void          setQP                         ( UInt uiIdx, SChar value )                                  { m_phQP[uiIdx] =  value;                    }
+  Void          setQPSubParts                 ( Int qp,   UInt uiAbsPartIdx, UInt uiDepth );
+  Int           getLastValidPartIdx           ( Int iAbsPartIdx ) const;
+  SChar         getLastCodedQP                ( UInt uiAbsPartIdx ) const;
+  Void          setQPSubCUs                   ( Int qp, UInt absPartIdx, UInt depth, Bool &foundNonZeroCbf );
+  Void          setCodedQP                    ( SChar qp )                                                 { m_codedQP = qp;                            }
+  SChar         getCodedQP                    ( ) const                                                    { return m_codedQP;                          }
+
+  UChar*        getChromaQpAdj                ( )                                                          { return m_ChromaQpAdj;                      } ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
+  UChar         getChromaQpAdj                ( Int idx ) const                                            { return m_ChromaQpAdj[idx];                 } ///< When value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
+  Void          setChromaQpAdj                ( Int idx, UChar val )                                       { m_ChromaQpAdj[idx] = val;                  } ///< When val = 0,   cu_chroma_qp_offset_flag=0; when val>0,   indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=val-1
+  Void          setChromaQpAdjSubParts        ( UChar val, Int absPartIdx, Int depth );
+  Void          setCodedChromaQpAdj           ( SChar qp )                                                 { m_codedChromaQpAdj = qp;                   }
+  SChar         getCodedChromaQpAdj           ( ) const                                                    { return m_codedChromaQpAdj;                 }
+
+  Bool          isLosslessCoded               ( UInt absPartIdx ) const;
+
+  UChar*        getTransformIdx               ( )                                                          { return m_puhTrIdx;                         }
+  UChar         getTransformIdx               ( UInt uiIdx ) const                                         { return m_puhTrIdx[uiIdx];                  }
+  Void          setTrIdxSubParts              ( UInt uiTrIdx, UInt uiAbsPartIdx, UInt uiDepth );
+
+  UChar*        getTransformSkip              ( ComponentID compID )                                       { return m_puhTransformSkip[compID];         }
+  UChar         getTransformSkip              ( UInt uiIdx, ComponentID compID ) const                     { return m_puhTransformSkip[compID][uiIdx];  }
+  Void          setTransformSkipSubParts      ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth );
+  Void          setTransformSkipSubParts      ( const UInt useTransformSkip[MAX_NUM_COMPONENT], UInt uiAbsPartIdx, UInt uiDepth );
+
+  UChar*        getExplicitRdpcmMode          ( ComponentID component )                                    { return m_explicitRdpcmMode[component];     }
+  UChar         getExplicitRdpcmMode          ( ComponentID component, UInt partIdx ) const                { return m_explicitRdpcmMode[component][partIdx]; }
   Void          setExplicitRdpcmModePartRange ( UInt rdpcmMode, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
 
-  Bool          isRDPCMEnabled         ( UInt uiAbsPartIdx )  { return getSlice()->getSPS()->getSpsRangeExtension().getRdpcmEnabledFlag(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); }
-
-  Void          setCrossComponentPredictionAlphaPartRange    ( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
-  Void          setTransformSkipPartRange                    ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
-
-  UInt          getQuadtreeTULog2MinSizeInCU( UInt uiIdx );
-
-  TComCUMvField* getCUMvField         ( RefPicList e )          { return  &m_acCUMvField[e];  }
-
-  TCoeff*       getCoeff              (ComponentID component)   { return m_pcTrCoeff[component]; }
+  Bool          isRDPCMEnabled                ( UInt uiAbsPartIdx ) const                                  { return getSlice()->getSPS()->getSpsRangeExtension().getRdpcmEnabledFlag(isIntra(uiAbsPartIdx) ? RDPCM_SIGNAL_IMPLICIT : RDPCM_SIGNAL_EXPLICIT); }
+
+  Void          setCrossComponentPredictionAlphaPartRange ( SChar alphaValue, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
+  Void          setTransformSkipPartRange     ( UInt useTransformSkip, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
+
+  UInt          getQuadtreeTULog2MinSizeInCU  ( UInt uiIdx ) const;
+
+        TComCUMvField* getCUMvField           ( RefPicList e )                                             { return &m_acCUMvField[e];                  }
+  const TComCUMvField* getCUMvField           ( RefPicList e ) const                                       { return &m_acCUMvField[e];                  }
+
+  TCoeff*       getCoeff                      ( ComponentID component )                                    { return m_pcTrCoeff[component];             }
 
 #if ADAPTIVE_QP_SELECTION
-  TCoeff*       getArlCoeff           ( ComponentID component ) { return m_pcArlCoeff[component]; }
-#endif
-  Pel*          getPCMSample          ( ComponentID component ) { return m_pcIPCMSample[component]; }
-
-  UChar         getCbf    ( UInt uiIdx, ComponentID eType )                  { return m_puhCbf[eType][uiIdx];  }
-  UChar*        getCbf    ( ComponentID eType )                              { return m_puhCbf[eType];         }
-  UChar         getCbf    ( UInt uiIdx, ComponentID eType, UInt uiTrDepth )  { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
-  Void          setCbf    ( UInt uiIdx, ComponentID eType, UChar uh )        { m_puhCbf[eType][uiIdx] = uh;    }
-  Void          clearCbf  ( UInt uiIdx, ComponentID eType, UInt uiNumParts );
-  UChar         getQtRootCbf          ( UInt uiIdx );
-
-  Void          setCbfSubParts        ( const UInt uiCbf[MAX_NUM_COMPONENT],  UInt uiAbsPartIdx, UInt uiDepth           );
-  Void          setCbfSubParts        ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth                    );
-  Void          setCbfSubParts        ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth    );
-
-  Void          setCbfPartRange       ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes      );
-  Void          bitwiseOrCbfPartRange ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes      );
+  TCoeff*       getArlCoeff                   ( ComponentID component )                                    { return m_pcArlCoeff[component];            }
+#endif
+  Pel*          getPCMSample                  ( ComponentID component )                                    { return m_pcIPCMSample[component];          }
+
+  UChar         getCbf                        ( UInt uiIdx, ComponentID eType ) const                      { return m_puhCbf[eType][uiIdx];             }
+  UChar*        getCbf                        ( ComponentID eType )                                        { return m_puhCbf[eType];                    }
+  UChar         getCbf                        ( UInt uiIdx, ComponentID eType, UInt uiTrDepth ) const      { return ( ( getCbf( uiIdx, eType ) >> uiTrDepth ) & 0x1 ); }
+  Void          setCbf                        ( UInt uiIdx, ComponentID eType, UChar uh )                  { m_puhCbf[eType][uiIdx] = uh;               }
+  Void          clearCbf                      ( UInt uiIdx, ComponentID eType, UInt uiNumParts );
+  UChar         getQtRootCbf                  ( UInt uiIdx ) const;
+
+  Void          setCbfSubParts                ( const UInt uiCbf[MAX_NUM_COMPONENT],  UInt uiAbsPartIdx, UInt uiDepth );
+  Void          setCbfSubParts                ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiDepth );
+  Void          setCbfSubParts                ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  Void          setCbfPartRange               ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
+  Void          bitwiseOrCbfPartRange         ( UInt uiCbf, ComponentID compID, UInt uiAbsPartIdx, UInt uiCoveredPartIdxes );
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -321,37 +322,37 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Bool*         getMergeFlag          ()                        { return m_pbMergeFlag;               }
-  Bool          getMergeFlag          ( UInt uiIdx )            { return m_pbMergeFlag[uiIdx];        }
-  Void          setMergeFlag          ( UInt uiIdx, Bool b )    { m_pbMergeFlag[uiIdx] = b;           }
-  Void          setMergeFlagSubParts  ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-
-  UChar*        getMergeIndex         ()                        { return m_puhMergeIndex;                         }
-  UChar         getMergeIndex         ( UInt uiIdx )            { return m_puhMergeIndex[uiIdx];                  }
-  Void          setMergeIndex         ( UInt uiIdx, UInt uiMergeIndex ) { m_puhMergeIndex[uiIdx] = uiMergeIndex;  }
-  Void          setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  Bool*         getMergeFlag                  ( )                                                          { return m_pbMergeFlag;                      }
+  Bool          getMergeFlag                  ( UInt uiIdx ) const                                         { return m_pbMergeFlag[uiIdx];               }
+  Void          setMergeFlag                  ( UInt uiIdx, Bool b )                                       { m_pbMergeFlag[uiIdx] = b;                  }
+  Void          setMergeFlagSubParts          ( Bool bMergeFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  UChar*        getMergeIndex                 ( )                                                          { return m_puhMergeIndex;                    }
+  UChar         getMergeIndex                 ( UInt uiIdx ) const                                         { return m_puhMergeIndex[uiIdx];             }
+  Void          setMergeIndex                 ( UInt uiIdx, UInt uiMergeIndex )                            { m_puhMergeIndex[uiIdx] = uiMergeIndex;     }
+  Void          setMergeIndexSubParts         ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
   template <typename T>
-  Void          setSubPart            ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
+  Void          setSubPart                    ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
 
 #if AMP_MRG
-  Void          setMergeAMP( Bool b )      { m_bIsMergeAMP = b; }
-  Bool          getMergeAMP( )             { return m_bIsMergeAMP; }
-#endif
-
-  UChar*        getIntraDir         ( const ChannelType channelType )                   const { return m_puhIntraDir[channelType];         }
-  UChar         getIntraDir         ( const ChannelType channelType, const UInt uiIdx ) const { return m_puhIntraDir[channelType][uiIdx];  }
-
-  Void          setIntraDirSubParts ( const ChannelType channelType,
-                                      const UInt uiDir,
-                                      const UInt uiAbsPartIdx,
-                                      const UInt uiDepth );
-
-  UChar*        getInterDir           ()                        { return m_puhInterDir;               }
-  UChar         getInterDir           ( UInt uiIdx )            { return m_puhInterDir[uiIdx];        }
-  Void          setInterDir           ( UInt uiIdx, UChar  uh ) { m_puhInterDir[uiIdx] = uh;          }
-  Void          setInterDirSubParts   ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-  Bool*         getIPCMFlag           ()                        { return m_pbIPCMFlag;               }
-  Bool          getIPCMFlag           (UInt uiIdx )             { return m_pbIPCMFlag[uiIdx];        }
-  Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
-  Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
+  Void          setMergeAMP                   ( Bool b )                                                   { m_bIsMergeAMP = b;                         }
+  Bool          getMergeAMP                   ( ) const                                                    { return m_bIsMergeAMP;                      }
+#endif
+
+  UChar*        getIntraDir                   ( const ChannelType channelType )                   const    { return m_puhIntraDir[channelType];         }
+  UChar         getIntraDir                   ( const ChannelType channelType, const UInt uiIdx ) const    { return m_puhIntraDir[channelType][uiIdx];  }
+
+  Void          setIntraDirSubParts           ( const ChannelType channelType,
+                                                const UInt uiDir,
+                                                const UInt uiAbsPartIdx,
+                                                const UInt uiDepth );
+
+  UChar*        getInterDir                   ( )                                                          { return m_puhInterDir;                      }
+  UChar         getInterDir                   ( UInt uiIdx ) const                                         { return m_puhInterDir[uiIdx];               }
+  Void          setInterDir                   ( UInt uiIdx, UChar  uh )                                    { m_puhInterDir[uiIdx] = uh;                 }
+  Void          setInterDirSubParts           ( UInt uiDir,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  Bool*         getIPCMFlag                   ( )                                                          { return m_pbIPCMFlag;                       }
+  Bool          getIPCMFlag                   ( UInt uiIdx ) const                                         { return m_pbIPCMFlag[uiIdx];                }
+  Void          setIPCMFlag                   ( UInt uiIdx, Bool b )                                       { m_pbIPCMFlag[uiIdx] = b;                   }
+  Void          setIPCMFlagSubParts           ( Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth );
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -359,7 +360,7 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Void          getPartIndexAndSize   ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ); // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
-  UChar         getNumPartitions      ( const UInt uiAbsPartIdx = 0 );
-  Bool          isFirstAbsZorderIdxInDepth (UInt uiAbsPartIdx, UInt uiDepth);
+  Void          getPartIndexAndSize           ( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight ) const; // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
+  UChar         getNumPartitions              ( const UInt uiAbsPartIdx = 0 ) const;
+  Bool          isFirstAbsZorderIdxInDepth    ( UInt uiAbsPartIdx, UInt uiDepth ) const;
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -367,27 +368,27 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Void          getMvField            ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
-
-  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
-  Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
-  Void          getPartPosition       ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH);
-
-  Void          setMVPIdx             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)  { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx;  }
-  Int           getMVPIdx             ( RefPicList eRefPicList, UInt uiIdx)               { return m_apiMVPIdx[eRefPicList][uiIdx];     }
-  SChar*        getMVPIdx             ( RefPicList eRefPicList )                          { return m_apiMVPIdx[eRefPicList];            }
-
-  Void          setMVPNum             ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum ) { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum;  }
-  Int           getMVPNum             ( RefPicList eRefPicList, UInt uiIdx )              { return m_apiMVPNum[eRefPicList][uiIdx];     }
-  SChar*        getMVPNum             ( RefPicList eRefPicList )                          { return m_apiMVPNum[eRefPicList];            }
-
-  Void          setMVPIdxSubParts     ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-  Void          setMVPNumSubParts     ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-
-  Void          clipMv                ( TComMv&     rcMv     ) const;
-  Void          getMvPredLeft         ( TComMv&     rcMvPred ) const  { rcMvPred = m_cMvFieldA.getMv(); }
-  Void          getMvPredAbove        ( TComMv&     rcMvPred ) const  { rcMvPred = m_cMvFieldB.getMv(); }
-  Void          getMvPredAboveRight   ( TComMv&     rcMvPred ) const  { rcMvPred = m_cMvFieldC.getMv(); }
-
-  Void          compressMV            ();
+  static Void   getMvField                    ( const TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList, TComMvField& rcMvField );
+
+  Void          fillMvpCand                   ( const UInt uiPartIdx, const UInt uiPartAddr, const RefPicList eRefPicList, const Int iRefIdx, AMVPInfo* pInfo ) const;
+  Bool          isDiffMER                     ( Int xN, Int yN, Int xP, Int yP ) const;
+  Void          getPartPosition               ( UInt partIdx, Int& xP, Int& yP, Int& nPSW, Int& nPSH ) const;
+
+  Void          setMVPIdx                     ( RefPicList eRefPicList, UInt uiIdx, Int iMVPIdx)           { m_apiMVPIdx[eRefPicList][uiIdx] = iMVPIdx; }
+  Int           getMVPIdx                     ( RefPicList eRefPicList, UInt uiIdx) const                  { return m_apiMVPIdx[eRefPicList][uiIdx];    }
+  SChar*        getMVPIdx                     ( RefPicList eRefPicList )                                   { return m_apiMVPIdx[eRefPicList];           }
+
+  Void          setMVPNum                     ( RefPicList eRefPicList, UInt uiIdx, Int iMVPNum )          { m_apiMVPNum[eRefPicList][uiIdx] = iMVPNum; }
+  Int           getMVPNum                     ( RefPicList eRefPicList, UInt uiIdx ) const                 { return m_apiMVPNum[eRefPicList][uiIdx];    }
+  SChar*        getMVPNum                     ( RefPicList eRefPicList )                                   { return m_apiMVPNum[eRefPicList];           }
+
+  Void          setMVPIdxSubParts             ( Int iMVPIdx, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  Void          setMVPNumSubParts             ( Int iMVPNum, RefPicList eRefPicList, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  Void          clipMv                        ( TComMv&     rcMv     ) const;
+  Void          getMvPredLeft                 ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldA.getMv();            }
+  Void          getMvPredAbove                ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldB.getMv();            }
+  Void          getMvPredAboveRight           ( TComMv&     rcMvPred ) const                               { rcMvPred = m_cMvFieldC.getMv();            }
+
+  Void          compressMV                    ();
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -395,44 +396,47 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  TComDataCU*   getCtuLeft                  () { return m_pCtuLeft;       }
-  TComDataCU*   getCtuAbove                 () { return m_pCtuAbove;      }
-  TComDataCU*   getCtuAboveLeft             () { return m_pCtuAboveLeft;  }
-  TComDataCU*   getCtuAboveRight            () { return m_pCtuAboveRight; }
-  TComDataCU*   getCUColocated              ( RefPicList eRefPicList ) { return m_apcCUColocated[eRefPicList]; }
-  Bool          CUIsFromSameSlice           ( const TComDataCU *pCU /* Can be NULL */) const { return ( pCU!=NULL && pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() ); }
-  Bool          CUIsFromSameTile            ( const TComDataCU *pCU /* Can be NULL */) const;
-  Bool          CUIsFromSameSliceAndTile    ( const TComDataCU *pCU /* Can be NULL */) const;
-  Bool          CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */) const;
-  Bool          isLastSubCUOfCtu(const UInt absPartIdx);
-
-
-  TComDataCU*   getPULeft                   ( UInt&  uiLPartUnitIdx,
-                                              UInt uiCurrPartUnitIdx,
-                                              Bool bEnforceSliceRestriction=true,
-                                              Bool bEnforceTileRestriction=true );
-  TComDataCU*   getPUAbove                  ( UInt&  uiAPartUnitIdx,
-                                              UInt uiCurrPartUnitIdx,
-                                              Bool bEnforceSliceRestriction=true,
-                                              Bool planarAtCTUBoundary = false,
-                                              Bool bEnforceTileRestriction=true );
-  TComDataCU*   getPUAboveLeft              ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true );
-
-  TComDataCU*   getQpMinCuLeft              ( UInt&  uiLPartUnitIdx , UInt uiCurrAbsIdxInCtu );
-  TComDataCU*   getQpMinCuAbove             ( UInt&  uiAPartUnitIdx , UInt uiCurrAbsIdxInCtu );
-  SChar         getRefQP                    ( UInt   uiCurrAbsIdxInCtu                       );
+  TComDataCU*   getCtuLeft                    ( )                                                          { return m_pCtuLeft;                         }
+  TComDataCU*   getCtuAbove                   ( )                                                          { return m_pCtuAbove;                        }
+  TComDataCU*   getCtuAboveLeft               ( )                                                          { return m_pCtuAboveLeft;                    }
+  TComDataCU*   getCtuAboveRight              ( )                                                          { return m_pCtuAboveRight;                   }
+  TComDataCU*   getCUColocated                ( RefPicList eRefPicList )                                   { return m_apcCUColocated[eRefPicList];      }
+  Bool          CUIsFromSameSlice             ( const TComDataCU *pCU /* Can be NULL */ ) const            { return ( pCU!=NULL && pCU->getSlice()->getSliceCurStartCtuTsAddr() == getSlice()->getSliceCurStartCtuTsAddr() ); }
+  Bool          CUIsFromSameTile              ( const TComDataCU *pCU /* Can be NULL */ ) const;
+  Bool          CUIsFromSameSliceAndTile      ( const TComDataCU *pCU /* Can be NULL */ ) const;
+  Bool          CUIsFromSameSliceTileAndWavefrontRow( const TComDataCU *pCU /* Can be NULL */ ) const;
+  Bool          isLastSubCUOfCtu              ( const UInt absPartIdx ) const;
+
+
+  const TComDataCU*   getPULeft               ( UInt& uiLPartUnitIdx,
+                                                UInt  uiCurrPartUnitIdx,
+                                                Bool  bEnforceSliceRestriction=true,
+                                                Bool  bEnforceTileRestriction=true ) const;
+
+  const TComDataCU*   getPUAbove              ( UInt& uiAPartUnitIdx,
+                                                UInt  uiCurrPartUnitIdx,
+                                                Bool  bEnforceSliceRestriction=true,
+                                                Bool  planarAtCTUBoundary = false,
+                                                Bool  bEnforceTileRestriction=true ) const;
+
+  const TComDataCU*   getPUAboveLeft          ( UInt&  uiALPartUnitIdx, UInt uiCurrPartUnitIdx, Bool bEnforceSliceRestriction=true ) const;
+
+  const TComDataCU*   getQpMinCuLeft          ( UInt&  uiLPartUnitIdx,  UInt uiCurrAbsIdxInCtu ) const;
+  const TComDataCU*   getQpMinCuAbove         ( UInt&  uiAPartUnitIdx,  UInt uiCurrAbsIdxInCtu ) const;
 
   /// returns CU and part index of the PU above the top row of the current uiCurrPartUnitIdx of the CU, at a horizontal offset (to the right) of uiPartUnitOffset (in parts)
-  TComDataCU*   getPUAboveRight             ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
+  const TComDataCU*   getPUAboveRight         ( UInt&  uiARPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ) const;
   /// returns CU and part index of the PU left of the lefthand column of the current uiCurrPartUnitIdx of the CU, at a vertical offset (below) of uiPartUnitOffset (in parts)
-  TComDataCU*   getPUBelowLeft              ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true );
-
-  Void          deriveLeftRightTopIdx       ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
-  Void          deriveLeftBottomIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLB );
-
-  Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
-  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
-
-  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
-  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB );
+  const TComDataCU*   getPUBelowLeft          ( UInt&  uiBLPartUnitIdx, UInt uiCurrPartUnitIdx, UInt uiPartUnitOffset = 1, Bool bEnforceSliceRestriction=true ) const;
+
+  SChar         getRefQP                      ( UInt uiCurrAbsIdxInCtu ) const;
+
+  Void          deriveLeftRightTopIdx         ( UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const;
+  Void          deriveLeftBottomIdx           ( UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
+
+  Bool          hasEqualMotion                ( UInt uiAbsPartIdx, const TComDataCU* pcCandCU, UInt uiCandAbsPartIdx ) const;
+  Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 ) const;
+
+  Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT ) const;
+  Void          deriveLeftBottomIdxGeneral    ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLB ) const;
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -440,8 +444,8 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  Bool          isIntra            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTRA;                                              }
-  Bool          isInter            ( UInt uiPartIdx )  const { return m_pePredMode[ uiPartIdx ] == MODE_INTER;                                              }
-  Bool          isSkipped          ( UInt uiPartIdx );                                                     ///< returns true, if the partiton is skipped
-  Bool          isBipredRestriction( UInt puIdx );
+  Bool          isIntra                       ( UInt uiPartIdx ) const                                     { return m_pePredMode[ uiPartIdx ] == MODE_INTRA; }
+  Bool          isInter                       ( UInt uiPartIdx ) const                                     { return m_pePredMode[ uiPartIdx ] == MODE_INTER; }
+  Bool          isSkipped                     ( UInt uiPartIdx ) const; ///< returns true, if the partiton is skipped
+  Bool          isBipredRestriction           ( UInt puIdx     ) const;
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -449,8 +453,8 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  UInt          getIntraSizeIdx                 ( UInt uiAbsPartIdx                                       );
-
-  Void          getAllowedChromaDir             ( UInt uiAbsPartIdx, UInt* uiModeList );
-  Void          getIntraDirPredictor            ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL );
+  UInt          getIntraSizeIdx               ( UInt uiAbsPartIdx ) const;
+
+  Void          getAllowedChromaDir           ( UInt uiAbsPartIdx, UInt* uiModeList ) const;
+  Void          getIntraDirPredictor          ( UInt uiAbsPartIdx, Int uiIntraDirPred[NUM_MOST_PROBABLE_MODES], const ComponentID compID, Int* piMode = NULL ) const;
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -458,41 +462,41 @@
   // -------------------------------------------------------------------------------------------------------------------
 
-  UInt          getCtxSplitFlag                 ( UInt   uiAbsPartIdx, UInt uiDepth                   );
-  UInt          getCtxQtCbf                     ( TComTU &rTu, const ChannelType chType );
-
-  UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
-  UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
-
-  UInt&         getTotalBins            ()                            { return m_uiTotalBins;                              }
+  UInt          getCtxSplitFlag               ( UInt   uiAbsPartIdx, UInt uiDepth     ) const;
+  UInt          getCtxQtCbf                   ( TComTU &rTu, const ChannelType chType ) const;
+
+  UInt          getCtxSkipFlag                ( UInt   uiAbsPartIdx ) const;
+  UInt          getCtxInterDir                ( UInt   uiAbsPartIdx ) const;
+
+  UInt&         getTotalBins                  ( )                                                          { return m_uiTotalBins;       }
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for RD cost storage
   // -------------------------------------------------------------------------------------------------------------------
 
-  Double&       getTotalCost()                  { return m_dTotalCost;        }
-  Distortion&   getTotalDistortion()            { return m_uiTotalDistortion; }
-  UInt&         getTotalBits()                  { return m_uiTotalBits;       }
-  UInt&         getTotalNumPart()               { return m_uiNumPartition;    }
-
-  UInt          getCoefScanIdx(const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) const ;
+  Double&       getTotalCost                  ( )                                                          { return m_dTotalCost;        }
+  Distortion&   getTotalDistortion            ( )                                                          { return m_uiTotalDistortion; }
+  UInt&         getTotalBits                  ( )                                                          { return m_uiTotalBits;       }
+  UInt&         getTotalNumPart               ( )                                                          { return m_uiNumPartition;    }
+
+  UInt          getCoefScanIdx                ( const UInt uiAbsPartIdx, const UInt uiWidth, const UInt uiHeight, const ComponentID compID ) const ;
 
 #if SVC_EXTENSION
-  Void          setLayerId (UInt layerId)       { m_layerId = layerId; }
-  UInt          getLayerId ()                   { return m_layerId; }
-  UInt          getLayerIdx ()                  { return m_pcSlice->getVPS()->getLayerIdxInVps(m_layerId); }
+  Void          setLayerId                    ( UInt layerId )                                             { m_layerId = layerId;        }
+  UInt          getLayerId                    ( ) const                                                    { return m_layerId;           }
+  UInt          getLayerIdx                   ( ) const                                                    { return m_pcSlice->getVPS()->getLayerIdxInVps(m_layerId); }
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-  Bool          isInterLayerReference(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
+  Bool          isInterLayerReference         ( UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1 ) const;
 #endif
 #if FAST_INTRA_SHVC
-  Int           reduceSetOfIntraModes(  UInt   uiAbsPartIdx, Int* uiIntraDirPred, Int** posScalingFactor, Int &fullSetOfModes );
+  Int           reduceSetOfIntraModes         ( UInt   uiAbsPartIdx, Int* uiIntraDirPred, Int** posScalingFactor, Int &fullSetOfModes );
 #endif
 #if REF_IDX_ME_ZEROMV
-  Bool          xCheckZeroMVILRMerge(UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
-  Bool          xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
-#endif
-  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping = false );
-  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping = false );
-  Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase, Int** mvScalingFactor );
+  Bool          xCheckZeroMVILRMerge          ( UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1);
+  Bool          xCheckZeroMVILRMvdL1Zero      ( Int iRefList, Int iRefIdx, Int MvpIdx);
+#endif
+  TComDataCU*   getBaseColCU                  ( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping = false );
+  TComDataCU*   getBaseColCU                  ( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int** posScalingFactor, Bool motionMapping = false );
+  Void          scaleBaseMV                   ( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase, Int** mvScalingFactor );
 #if FAST_INTRA_SHVC
-  UChar         getReducedSetIntraModes(UChar idx)     { assert( idx < NUM_INTRA_MODE-1 ); return m_reducedSetIntraModes[idx]; }
+  UChar         getReducedSetIntraModes       ( UChar idx ) const                                         { assert( idx < NUM_INTRA_MODE-1 ); return m_reducedSetIntraModes[idx]; }
 #endif
 #endif
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComLoopFilter.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComLoopFilter.cpp	(revision 1465)
@@ -369,5 +369,4 @@
   UInt uiY           = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsZorderIdx ] ];
 
-  TComDataCU* pcTempCU;
   UInt        uiTempPartIdx;
 
@@ -384,5 +383,5 @@
   if ( m_stLFCUParam.bLeftEdge )
   {
-    pcTempCU = pcCU->getPULeft( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);
+    const TComDataCU* pcTempCU = pcCU->getPULeft( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), !m_bLFCrossTileBoundary);
 
     if ( pcTempCU != NULL )
@@ -406,5 +405,5 @@
   if ( m_stLFCUParam.bTopEdge )
   {
-    pcTempCU = pcCU->getPUAbove( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);
+    const TComDataCU* pcTempCU = pcCU->getPUAbove( uiTempPartIdx, uiAbsZorderIdx, !pcCU->getSlice()->getLFCrossSliceBoundaryFlag(), false, !m_bLFCrossTileBoundary);
 
     if ( pcTempCU != NULL )
@@ -429,5 +428,5 @@
 
   UInt uiPartP;
-  TComDataCU* pcCUP;
+  const TComDataCU* pcCUP;
   UInt uiBs = 0;
 
@@ -463,13 +462,12 @@
       {
         Int iRefIdx;
-        TComPic *piRefP0, *piRefP1, *piRefQ0, *piRefQ1;
         iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartP);
-        piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
+        const TComPic *piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
         iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartP);
-        piRefP1 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_1, iRefIdx);
+        const TComPic *piRefP1 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_1, iRefIdx);
         iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartQ);
-        piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
+        const TComPic *piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
         iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartQ);
-        piRefQ1 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx);
+        const TComPic *piRefQ1 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx);
 
         TComMv pcMvP0 = pcCUP->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartP);
@@ -534,9 +532,8 @@
       {
         Int iRefIdx;
-        TComPic *piRefP0, *piRefQ0;
         iRefIdx = pcCUP->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartP);
-        piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
+        const TComPic *piRefP0 = (iRefIdx < 0) ? NULL : pcCUP->getSlice()->getRefPic(REF_PIC_LIST_0, iRefIdx);
         iRefIdx = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartQ);
-        piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
+        const TComPic *piRefQ0 = (iRefIdx < 0) ? NULL : pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx);
         TComMv pcMvP0 = pcCUP->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartP);
         TComMv pcMvQ0 = pcCUQ->getCUMvField(REF_PIC_LIST_0)->getMv(uiPartQ);
@@ -593,5 +590,5 @@
   UInt  uiPartPIdx = 0;
   UInt  uiPartQIdx = 0;
-  TComDataCU* pcCUP = pcCU;
+  const TComDataCU* pcCUP = pcCU;
   TComDataCU* pcCUQ = pcCU;
   Int  betaOffsetDiv2 = pcCUQ->getSlice()->getDeblockingFilterBetaOffsetDiv2();
@@ -776,5 +773,5 @@
       UInt  uiPartQIdx = uiBsAbsIdx;
       // Derive neighboring PU index
-      TComDataCU* pcCUP;
+      const TComDataCU* pcCUP;
       UInt  uiPartPIdx;
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1465)
@@ -54,5 +54,5 @@
 typedef struct _AMVPInfo
 {
-  TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS_MEM ];  ///< array of motion vector predictor candidates
+  TComMv m_acMvCand[ AMVP_MAX_NUM_CANDS ];  ///< array of motion vector predictor candidates
   Int    iN;                                ///< number of motion vector predictor candidates
 } AMVPInfo;
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp	(revision 1465)
@@ -66,9 +66,9 @@
 
 /// constrained intra prediction
-Bool  isAboveLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT );
-Int   isAboveAvailable      ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
-Int   isLeftAvailable       ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
-Int   isAboveRightAvailable ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
-Int   isBelowLeftAvailable  ( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
+Bool  isAboveLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT );
+Int   isAboveAvailable      ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
+Int   isLeftAvailable       ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
+Int   isAboveRightAvailable ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool* bValidFlags );
+Int   isBelowLeftAvailable  ( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool* bValidFlags );
 
 
@@ -570,9 +570,9 @@
 }
 
-Bool isAboveLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT )
+Bool isAboveLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT )
 {
   Bool bAboveLeftFlag;
   UInt uiPartAboveLeft;
-  TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
+  const TComDataCU* pcCUAboveLeft = pcCU->getPUAboveLeft( uiPartAboveLeft, uiPartIdxLT );
   if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
   {
@@ -586,5 +586,5 @@
 }
 
-Int isAboveAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
+Int isAboveAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
 {
   const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
@@ -597,5 +597,5 @@
   {
     UInt uiPartAbove;
-    TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
+    const TComDataCU* pcCUAbove = pcCU->getPUAbove( uiPartAbove, g_auiRasterToZscan[uiRasterPart] );
     if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     {
@@ -627,5 +627,5 @@
 }
 
-Int isLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
+Int isLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
 {
   const UInt uiRasterPartBegin = g_auiZscanToRaster[uiPartIdxLT];
@@ -638,5 +638,5 @@
   {
     UInt uiPartLeft;
-    TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
+    const TComDataCU* pcCULeft = pcCU->getPULeft( uiPartLeft, g_auiRasterToZscan[uiRasterPart] );
     if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     {
@@ -669,5 +669,5 @@
 }
 
-Int isAboveRightAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
+Int isAboveRightAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxRT, Bool *bValidFlags )
 {
   const UInt uiNumUnitsInPU = g_auiZscanToRaster[uiPartIdxRT] - g_auiZscanToRaster[uiPartIdxLT] + 1;
@@ -678,5 +678,5 @@
   {
     UInt uiPartAboveRight;
-    TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
+    const TComDataCU* pcCUAboveRight = pcCU->getPUAboveRight( uiPartAboveRight, uiPartIdxRT, uiOffset );
     if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     {
@@ -709,5 +709,5 @@
 }
 
-Int isBelowLeftAvailable( TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
+Int isBelowLeftAvailable( const TComDataCU* pcCU, UInt uiPartIdxLT, UInt uiPartIdxLB, Bool *bValidFlags )
 {
   const UInt uiNumUnitsInPU = (g_auiZscanToRaster[uiPartIdxLB] - g_auiZscanToRaster[uiPartIdxLT]) / pcCU->getPic()->getNumPartInCtuWidth() + 1;
@@ -718,5 +718,5 @@
   {
     UInt uiPartBelowLeft;
-    TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
+    const TComDataCU* pcCUBelowLeft = pcCU->getPUBelowLeft( uiPartBelowLeft, uiPartIdxLB, uiOffset );
     if(pcCU->getSlice()->getPPS()->getConstrainedIntraPred())
     {
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h	(revision 1465)
@@ -84,4 +84,5 @@
 
   SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
+
 #if SVC_EXTENSION
   UInt                  m_layerId;              //  Layer ID
@@ -119,4 +120,5 @@
 
   TComPicSym*   getPicSym()           { return  &m_picSym;    }
+  const TComPicSym* getPicSym() const { return  &m_picSym;    }
   TComSlice*    getSlice(Int i)       { return  m_picSym.getSlice(i);  }
   Int           getPOC() const        { return  m_picSym.getSlice(m_uiCurrSliceIdx)->getPOC();  }
@@ -192,12 +194,12 @@
 #if SVC_EXTENSION
   Void          setLayerId(UInt layerId)                                    { m_layerId = layerId;                                       }
-  UInt          getLayerId()                                                { return m_layerId;                                          }
-  UInt          getLayerIdx()                                               { return getSlice(0)->getVPS()->getLayerIdxInVps(m_layerId); }
-  Bool          isSpatialEnhLayer(UInt refLayerIdc)                         { return m_bSpatialEnhLayer[refLayerIdc];                    }
+  UInt          getLayerId() const                                          { return m_layerId;                                          }
+  UInt          getLayerIdx() const                                         { return m_picSym.getSlice(0)->getVPS()->getLayerIdxInVps(m_layerId);     }
+  Bool          isSpatialEnhLayer(UInt refLayerIdc) const                   { return m_bSpatialEnhLayer[refLayerIdc];                    }
   Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b)           { m_bSpatialEnhLayer[refLayerIdc] = b;                       }
   Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p)       { m_pcFullPelBaseRec[refLayerIdc] = p;                       }
-  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)                      { return  m_pcFullPelBaseRec[refLayerIdc];                   }
-  Bool          isILR( UInt currLayerId )                                   { return ( m_bIsLongTerm && m_layerId < currLayerId );       }
-  Bool          equalPictureSizeAndOffsetFlag(UInt refLayerIdc)             { return m_equalPictureSizeAndOffsetFlag[refLayerIdc];       }
+  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc) const                { return  m_pcFullPelBaseRec[refLayerIdc];                   }
+  Bool          isILR( UInt currLayerId ) const                             { return ( m_bIsLongTerm && m_layerId < currLayerId );       }
+  Bool          equalPictureSizeAndOffsetFlag(UInt refLayerIdc) const       { return m_equalPictureSizeAndOffsetFlag[refLayerIdc];       }
   Void          setEqualPictureSizeAndOffsetFlag(UInt refLayerIdc, Bool b)  { m_equalPictureSizeAndOffsetFlag[refLayerIdc] = b;          }
   Void          copyUpsampledMvField(UInt refLayerIdc, Int** mvScalingFactor, Int** posScalingFactor);
@@ -215,7 +217,7 @@
 #if CGS_3D_ASYMLUT
   Void          setFrameBit( Int n )                                        { m_nFrameBit = n;     }
-  Int           getFrameBit()                                               { return m_nFrameBit;  }
-#endif
-  Bool          isCurrAu()                                                  { return m_currAuFlag; }
+  Int           getFrameBit() const                                         { return m_nFrameBit;  }
+#endif
+  Bool          isCurrAu() const                                            { return m_currAuFlag; }
   Void          setCurrAuFlag(Bool x)                                       { m_currAuFlag = x;    }
 #endif //SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1465)
@@ -464,5 +464,4 @@
   } u;
 };
-
 
 class Window
@@ -2203,5 +2202,6 @@
   TComPic*                    getPic()                                               { return m_pcPic;                                               }
   TComPic*                    getRefPic( RefPicList e, Int iRefIdx)                  { return m_apcRefPicList[e][iRefIdx];                           }
-  Int                         getRefPOC( RefPicList e, Int iRefIdx)                  { return m_aiRefPOCList[e][iRefIdx];                            }
+  const TComPic*              getRefPic( RefPicList e, Int iRefIdx) const            { return m_apcRefPicList[e][iRefIdx];                           }
+  Int                         getRefPOC( RefPicList e, Int iRefIdx) const            { return m_aiRefPOCList[e][iRefIdx];                            }
   Int                         getDepth() const                                       { return m_iDepth;                                              }
   Bool                        getColFromL0Flag() const                               { return m_colFromL0Flag;                                       }
@@ -2385,5 +2385,5 @@
 
   Void                        setEnableTMVPFlag( Bool   b )                          { m_enableTMVPFlag = b;                                         }
-  Bool                        getEnableTMVPFlag()                                    { return m_enableTMVPFlag;                                      }
+  Bool                        getEnableTMVPFlag() const                              { return m_enableTMVPFlag;                                      }
 
   Void                        setEncCABACTableIdx( SliceType idx )                   { m_encCABACTableIdx = idx;                                     }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1464)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1465)
@@ -3529,6 +3529,6 @@
       // save ME result.
       uiMEInterDir = pcCU->getInterDir( uiPartAddr );
-      pcCU->getMvField( pcCU, uiPartAddr, REF_PIC_LIST_0, cMEMvField[0] );
-      pcCU->getMvField( pcCU, uiPartAddr, REF_PIC_LIST_1, cMEMvField[1] );
+      TComDataCU::getMvField( pcCU, uiPartAddr, REF_PIC_LIST_0, cMEMvField[0] );
+      TComDataCU::getMvField( pcCU, uiPartAddr, REF_PIC_LIST_1, cMEMvField[1] );
 
       // find Merge result
