Index: branches/HTM-14.0-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-14.0-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 1187)
@@ -539,12 +539,16 @@
     Int iSpace = max(1, ENC_CFG_CONSOUT_SPACE - (Int) description.length() ); 
     
-    for ( Int i = 0; i < iSpace; i++ ) 
+    for ( Int i = 0; i < iSpace; i++ )
+    {
       description.append( " " ); 
+    }
       
     description.append( ":" ); 
     printf( "%s", description.c_str() ); 
 
-    for(Int i=0;i<rpcVector.size();i++)                
+    for(Int i=0;i<rpcVector.size();i++)
+    {
       xPrintVectorElem( rpcVector[i] );
+    }
 
     printf("\n");
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/ContextTables.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/ContextTables.h	(revision 1187)
@@ -51,6 +51,8 @@
 #define NUM_SPLIT_FLAG_CTX            3       ///< number of context models for split flag
 #define NUM_SKIP_FLAG_CTX             3       ///< number of context models for skip flag
+#if H_3D
 #define NUM_DIS_FLAG_CTX              1
 #define NUM_DIS_TYPE_CTX              1       
+#endif
 #define NUM_MERGE_FLAG_EXT_CTX        1       ///< number of context models for merge flag of merge extended
 #define NUM_MERGE_IDX_EXT_CTX         1       ///< number of context models for merge index of merge extended
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1187)
@@ -153,5 +153,4 @@
   m_pbDBBPFlag         = NULL;
 #endif
-
 }
 
@@ -957,6 +956,4 @@
       m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
 #endif
-
-
 #if H_3D_DIM
       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -1095,5 +1092,4 @@
   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
 #endif
-
 #if H_3D_ARP
   m_puhARPW             = pcCU->getARPW()             + uiPart;
@@ -1102,6 +1098,4 @@
   m_pbICFlag            = pcCU->getICFlag()           + uiPart;
 #endif
-
-
   m_puhLumaIntraDir     = pcCU->getLumaIntraDir()     + uiPart;
   m_puhChromaIntraDir   = pcCU->getChromaIntraDir()   + uiPart;
@@ -1242,15 +1236,11 @@
 #endif
 #if H_3D_SPIVMP
-  m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()               + uiAbsPartIdx;
-#endif
-
+  m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
+#endif
   m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
-  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
-  
+  m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;  
 #if H_3D_ARP
   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
-#endif
-
-    
+#endif    
 #if H_3D_DBBP
   m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
@@ -1300,5 +1290,4 @@
   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
   memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
-
 #endif
 #if H_3D_SPIVMP
@@ -1316,7 +1305,4 @@
   memcpy( m_puhCbf[1] + uiOffset, pcCU->getCbf(TEXT_CHROMA_U), iSizeInUchar );
   memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar );
-
-
-
 #if H_3D_DIM
   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -1415,6 +1401,4 @@
   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
 #endif
-
-
   memcpy( rpcCU->getPartitionSize()  + m_uiAbsIdxInLCU, m_pePartSize, sizeof( *m_pePartSize ) * m_uiNumPartition );
   memcpy( rpcCU->getPredictionMode() + m_uiAbsIdxInLCU, m_pePredMode, sizeof( *m_pePredMode ) * m_uiNumPartition );
@@ -1548,6 +1532,4 @@
   memcpy( rpcCU->getCbf(TEXT_CHROMA_U) + uiPartOffset, m_puhCbf[1], iSizeInUchar );
   memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar );
-
-
 #if H_3D_DIM
   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
@@ -2284,6 +2266,5 @@
   {
     return NULL;
-  }
-  
+  }  
 #if H_3D_FCO
   TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
@@ -3850,5 +3831,5 @@
 #endif
 #if H_3D_ARP
-  Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false;
+  Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
 #endif
 #if H_3D_DBBP
@@ -3883,6 +3864,5 @@
     m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
 #if H_3D_VSP
-    , 
-      (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
+    , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
 #if H_3D_IC
       && !bICFlag
@@ -3907,6 +3887,5 @@
     m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
 #if H_3D_VSP
-    ,
-      false
+    , false
 #endif
       , false
@@ -3935,6 +3914,5 @@
     m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
 #if H_3D_VSP
-    ,
-      false
+    , false
 #endif
       , false
@@ -3949,6 +3927,5 @@
     m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
 #if H_3D_VSP
-    ,
-      false
+    , false
 #endif
       , false
@@ -3977,9 +3954,5 @@
     TComPic * pcTexPic = m_pcSlice->getTexturePic();
 #if H_3D_FCO
-#if H_3D_FCO
     if (pcTexPic && pcTexPic->getReconMark())
-#else
-    if (pcTexturePic->getReconMark())
-#endif
     {
 #endif    
@@ -4016,5 +3989,5 @@
       Int         iTexPosX, iTexPosY;
       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
-      
+
       Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
       Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
@@ -4023,6 +3996,6 @@
       if(iWidth == iPUWidth && iHeight == iPUHeight)
       {
-          iCenterPosX = iCurrPosX + (iWidth >> 1);
-          iCenterPosY = iCurrPosY + (iHeight >> 1);
+        iCenterPosX = iCurrPosX + (iWidth >> 1);
+        iCenterPosY = iCurrPosY + (iHeight >> 1);
       }
 
@@ -4060,8 +4033,8 @@
       if ( bSPIVMPFlag == true )
       {   
-          iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
-          tmpDir = iInterDirSaved;
-          tmpMV[0] = cMvFieldSaved[0];
-          tmpMV[1] = cMvFieldSaved[1];
+        iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
+        tmpDir = iInterDirSaved;
+        tmpMV[0] = cMvFieldSaved[0];
+        tmpMV[1] = cMvFieldSaved[1];
       }
 
@@ -4205,14 +4178,14 @@
     if (!bRemoveSpa)
     {
-      Bool SPIVMPFlag = false;
+      Bool spiMvpFlag = false;
       if(!m_pcSlice->getIsDepth())
       {
-        SPIVMPFlag = true;
+        spiMvpFlag = true;
       }
 #if H_3D_DBBP
-      SPIVMPFlag &= !bDBBPFlag;
-#endif
-
-      m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, SPIVMPFlag);
+      spiMvpFlag &= !bDBBPFlag;
+#endif
+
+      m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, spiMvpFlag);
 
       if ( mrgCandIdx == iCount )
@@ -5319,5 +5292,5 @@
 
 #if H_MV
-Void TComDataCU::checkMV_V (TComMv&  rcMv,  RefPicList eRefPicList, int iRefIdx )
+Void TComDataCU::checkMvVertRest (TComMv&  rcMv,  RefPicList eRefPicList, int iRefIdx )
 {
   if ( getSlice()->getSPS()->getInterViewMvVertConstraintFlag() )
@@ -5685,5 +5658,7 @@
     iScale = 4096;
     if ( iCurrRefViewId != iCurrViewId && iColViewId != iColRefViewId )
+    {
       iScale = xGetDistScaleFactor( iCurrViewId, iCurrRefViewId, iColViewId, iColRefViewId );
+    }
     if ( bMRG && iScale != 4096 && m_pcSlice->getIvMvScalingFlag( ) ) 
     {
@@ -5862,8 +5837,8 @@
 }
 #endif
+
 #if H_3D_IV_MERGE
 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
 {
-
   assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
 
@@ -5871,12 +5846,12 @@
   if ( getSlice()->getDefaultRefViewIdxAvailableFlag() )
   {
-      Int iViewIdx = getSlice()->getDefaultRefViewIdx();
-      pDisp->m_aVIdxCan = iViewIdx;
-      Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
-
-      cMv.setHor(iDisp);
-      cMv.setVer(0);
-      pDisp->m_acNBDV = cMv;
-      pDisp->m_aVIdxCan = iViewIdx;
+    Int iViewIdx = getSlice()->getDefaultRefViewIdx();
+    pDisp->m_aVIdxCan = iViewIdx;
+    Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
+
+    cMv.setHor(iDisp);
+    cMv.setVer(0);
+    pDisp->m_acNBDV = cMv;
+    pDisp->m_aVIdxCan = iViewIdx;
   }
 }
@@ -6037,6 +6012,7 @@
 #endif
         if (picDepth && bDepthRefine)
+        {
           estimateDVFromDM(iTargetViewIdx, uiPartIdx, picDepth, uiPartAddr, &cColMv );
-
+        }
         pDInfo->m_acDoNBDV  = cColMv;
 #endif //H_3D_NBDV_REF
@@ -6121,28 +6097,28 @@
   if (getSlice()->getDefaultRefViewIdxAvailableFlag())
   {
-      pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
+    pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
 
 #if H_3D_NBDV_REF
-          TComPic* picDepth = NULL;
+    TComPic* picDepth = NULL;
 #if H_3D_FCO_VSP_DONBDV_E0163
-          picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
-      if ( picDepth->getPicYuvRec() != NULL )  
-      {
-          defaultDV.setZero();
-      }
-      else // Go back with virtual depth
-      {
-          picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
-      }
-
-      assert(picDepth != NULL);
+    picDepth  = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
+    if ( picDepth->getPicYuvRec() != NULL )  
+    {
+      defaultDV.setZero();
+    }
+    else // Go back with virtual depth
+    {
+      picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
+    }
+
+    assert(picDepth != NULL);
 #else
-          picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
-#endif
-      if (picDepth && bDepthRefine)
-      {
-          estimateDVFromDM(getSlice()->getDefaultRefViewIdx(), uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view
-      }
-      pDInfo->m_acDoNBDV = defaultDV;
+    picDepth = getSlice()->getIvPic( true, getSlice()->getDefaultRefViewIdx());
+#endif
+    if (picDepth && bDepthRefine)
+    {
+      estimateDVFromDM(getSlice()->getDefaultRefViewIdx(), uiPartIdx, picDepth, uiPartAddr, &defaultDV ); // from base view
+    }
+    pDInfo->m_acDoNBDV = defaultDV;
 #endif
   }
@@ -6236,6 +6212,7 @@
 
           if (picDepth && bDepthRefine)
+          {
             estimateDVFromDM(refViewIdx, uiPartIdx, picDepth, uiPartAddr, &cMvPred );
-
+          }
           pNbDvInfo->m_acDoNBDV = cMvPred;
 #endif
@@ -6657,6 +6634,6 @@
                 {
                   RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
-                  Bool bLoop_stop = false;
-                  for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop)
+                  Bool bLoopStop = false;
+                  for(Int iLoop = 0; iLoop < 2 && !bLoopStop; ++iLoop)
                   {
                     RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
@@ -6684,5 +6661,5 @@
                             }
 
-                            bLoop_stop = true;
+                            bLoopStop = true;
 
                             pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
@@ -6916,5 +6893,8 @@
 {
   UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
-  for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; }
+  for( UInt ui = 0; ui < uiCurrPartNumb; ui++ )
+  { 
+    m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; 
+  }
 }
 #endif
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 1187)
@@ -72,5 +72,5 @@
   PartSize    eVirtualPartSize;
   UInt        uiVirtualPartIndex;
-} DBBPTmpData;
+} DbbpTmpData;
 #endif
 
@@ -173,10 +173,8 @@
 #endif
 #if H_3D_VSP
-  Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not
-                                      ///< 0: non-VSP; 1: VSP
+  Char*         m_piVSPFlag;          ///< array of VSP flags to indicate whehter a block uses VSP or not  ///< 0: non-VSP; 1: VSP
 #endif
 #if H_3D_SPIVMP
-  Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP
-                                      ///< 0: non-SPIVMP; 1: SPIVMP
+  Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP ///< 0: non-SPIVMP; 1: SPIVMP
 #endif
 #if H_3D_ARP
@@ -194,10 +192,10 @@
   Bool*         m_pbSDCFlag;
   Pel*          m_apSegmentDCOffset[2];
-  Pel          m_apDmmPredictor[2];
+  Pel           m_apDmmPredictor[2];
 #endif
 #endif
 #if H_3D_DBBP
   Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
-  DBBPTmpData   m_sDBBPTmpData;
+  DbbpTmpData   m_sDBBPTmpData;
 #endif
 #if H_3D
@@ -247,6 +245,5 @@
   Bool          xGetColMVP( RefPicList eRefPicList, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int& riRefIdx 
 #if H_3D_TMVP
-  ,
-  Bool bMRG = true
+  ,  Bool bMRG = true
 #endif
   );
@@ -368,5 +365,5 @@
   Void          setDBBPFlag           ( UInt uiIdx, Bool b )    { m_pbDBBPFlag[uiIdx] = b;           }
   Void          setDBBPFlagSubParts   ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
-  DBBPTmpData*  getDBBPTmpData        () { return &m_sDBBPTmpData; }
+  DbbpTmpData*  getDBBPTmpData        () { return &m_sDBBPTmpData; }
 #endif
   
@@ -596,5 +593,5 @@
   Void          clipMv                ( TComMv&     rcMv     );
 #if H_MV
-  Void          checkMV_V (TComMv&  rcMv,  RefPicList eRefPicList, int iRefIdx );
+  Void          checkMvVertRest (TComMv&  rcMv,  RefPicList eRefPicList, int iRefIdx );
 #endif
   Void          getMvPredLeft         ( TComMv&     rcMvPred )   { rcMvPred = m_cMvFieldA.getMv(); }
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1187)
@@ -353,5 +353,5 @@
 {
   assert(frac >= 0 && frac < 4);
-  
+
   if ( frac == 0 )
   {
@@ -368,5 +368,5 @@
     {
 #endif
-    filterHor<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
+      filterHor<NTAPS_LUMA>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
 #if H_3D_ARP
     }
@@ -436,5 +436,5 @@
 {
   assert(frac >= 0 && frac < 8);
-  
+
   if ( frac == 0 )
   {
@@ -451,5 +451,5 @@
     {
 #endif
-    filterHor<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac]);
+      filterHor<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac]);
 #if H_3D_ARP
     }
@@ -478,5 +478,5 @@
 {
   assert(frac >= 0 && frac < 8);
-  
+
   if ( frac == 0 )
   {
@@ -493,5 +493,5 @@
     {
 #endif
-    filterVer<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);
+      filterVer<NTAPS_CHROMA>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac]);
 #if H_3D_ARP
     }
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1187)
@@ -335,7 +335,5 @@
   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
   Int iEndPelX = iStartPelX + iWidth;
-  Int iEndPelY = iStartPelY + iHeight;
-
-  Int iCurrRaster, uiPartAddr;
+  Int iEndPelY = iStartPelY + iHeight;  
 
   for (Int i=iStartPelY; i<iEndPelY; i+=pcCU->getPic()->getMinCUHeight())
@@ -343,6 +341,6 @@
     for (Int j=iStartPelX; j < iEndPelX; j += pcCU->getPic()->getMinCUWidth())
     {
-      iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
-      uiPartAddr = g_auiRasterToZscan[iCurrRaster];
+      Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
+      Int uiPartAddr = g_auiRasterToZscan[iCurrRaster];
       uiPartAddr -= pcCU->getZorderIdxInCU();  
 
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 1187)
@@ -415,29 +415,28 @@
 #endif
 
-  TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
-
-  for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
-  {
-    for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
-    {
-      Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
-      Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
-      m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
-      Int iCurrRefDir = iTextRefDir;
-      for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
-      {
-        if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
-          pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
-        {  
-          m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
+    TComSlice* pcTextSlice = pcTextPic->getSlice(0); // currently only support single slice
+
+    for( Int iTextRefDir = 0; (iTextRefDir < (pcTextSlice->isInterB()? 2:1) ) && !pcTextSlice->isIntra(); iTextRefDir ++ )
+    {
+      for( Int iTextRefIdx =0; iTextRefIdx<pcTextSlice->getNumRefIdx(( RefPicList )iTextRefDir ); iTextRefIdx++)
+      {
+        Int iTextRefPOC    = pcTextSlice->getRefPOC( ( RefPicList )iTextRefDir, iTextRefIdx);
+        Int iTextRefViewId = pcTextSlice->getRefPic( ( RefPicList )iTextRefDir, iTextRefIdx)->getViewIndex();
+        m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = -1;
+        Int iCurrRefDir = iTextRefDir;
+        for( Int iCurrRefIdx =0; ( iCurrRefIdx<pcCurrSlice->getNumRefIdx(( RefPicList )iCurrRefDir ) ) && ( m_aiTexToDepRef[iTextRefDir][iTextRefIdx] < 0 ) ; iCurrRefIdx++)
+        {
+          if( pcCurrSlice->getRefPOC( ( RefPicList )iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
+            pcCurrSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId )
+          {  
+            m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
+          }
         }
       }
-    }
-
-  }
+
+    }
 #if H_3D_FCO
   }
 #endif
-
 }
 
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1187)
@@ -54,5 +54,7 @@
   m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
   if (m_pDepthBlock == NULL)
+  {
       printf("ERROR: UKTGHU, No memory allocated.\n");
+  }
 #endif
 }
@@ -62,5 +64,7 @@
 #if H_3D_VSP
   if (m_pDepthBlock != NULL)
-      free(m_pDepthBlock);
+  {
+    free(m_pDepthBlock);
+  }
   m_cYuvDepthOnVsp.destroy();
 #endif
@@ -513,5 +517,9 @@
 
 #if H_3D_DIM_DMM
-  if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; }
+  if( dimType == DMM4_IDX && dmm4Segmentation == NULL )
+  { 
+    dmmSegmentation->destroy(); 
+    delete dmmSegmentation; 
+  }
 #endif
 }
@@ -635,5 +643,5 @@
   // segmentation of texture block --> mask IDs
   Pel*  pDepthBlockStart      = pDepthPels;
-  
+
   // first compute average of depth block for thresholding
   Int iSumDepth = 0;
@@ -648,38 +656,41 @@
   Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2);
   Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2);
+  
   UInt t=0;
 
   for (Int y=0; y<uiSize; y+=iSubSample)
-   {
+  {
     for (Int x=0; x<uiSize; x+=iSubSample)
-   {
-if (iBlkX+x>iPictureWidth)
-{
-    Int depthPel = pDepthPels[t];
-    iSumDepth += depthPel;
-} 
-else
-{
-    Int depthPel = pDepthPels[x];
-    t=x;
-    iSumDepth += depthPel;
-}
-   }
-    
+    {
+      if (iBlkX+x>iPictureWidth)
+      {
+        Int depthPel = pDepthPels[t];
+        iSumDepth += depthPel;
+      } 
+      else
+      {
+        Int depthPel = pDepthPels[x];
+        t=x;
+        iSumDepth += depthPel;
+      }
+    }
+
     // next row
     if (!(iBlkY+y+4>iPictureHeight))
-    pDepthPels += uiDepthStride*iSubSample;
-  }
-  
+    {
+      pDepthPels += uiDepthStride*iSubSample;
+    }
+  }
+
   Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample];  // respect sub-sampling factor
   Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiSize*uiSize);
-  
+
   // start again for segmentation
   pDepthPels = pDepthBlockStart;
-  
+
   // start mapping process
   Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option
   PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN};
-  
+
   UInt uiHalfSize = uiSize>>1;
   for (Int y=0; y<uiSize; y+=iSubSample)
@@ -688,19 +699,19 @@
     {
       Int depthPel = 0;
-if (iBlkX+x>iPictureWidth)
-{
-    depthPel = pDepthPels[t];
-}
-else
-{ 
-    depthPel = pDepthPels[x];
-     t=x;
-}
-      
+      if (iBlkX+x>iPictureWidth)
+      {
+        depthPel = pDepthPels[t];
+      }
+      else
+      { 
+        depthPel = pDepthPels[x];
+        t=x;
+      }
+
       // decide which segment this pixel belongs to
       Int ucSegment = (Int)(depthPel>iMean);
-      
+
       // Matched Filter to find optimal (conventional) partitioning
-      
+
       // SIZE_Nx2N
       if(x<uiHalfSize)  // left
@@ -712,5 +723,5 @@
         matchedPartSum[0][1-ucSegment]++;
       }
-      
+
       // SIZE_2NxN
       if(y<uiHalfSize)  // top
@@ -723,12 +734,14 @@
       }
     }
-    
+
     // next row
     if (!(iBlkY+y+4>iPictureHeight))
-    pDepthPels += uiDepthStride*iSubSample;
-  }
-  
+    {
+      pDepthPels += uiDepthStride*iSubSample;
+    }
+  }
+
   PartSize matchedPartSize = SIZE_NONE;
-  
+
   Int iMaxMatchSum = 0;
   for(Int p=0; p<2; p++)  // loop over partition
@@ -743,7 +756,7 @@
     }
   }
-  
+
   AOF( matchedPartSize != SIZE_NONE );
-  
+
   return matchedPartSize;
 }
@@ -761,5 +774,5 @@
   uiMaxDepth = pDepthPels[ 0 ];
   iSumDepth  = pDepthPels[ 0 ];
-  UInt t=0;
+  
   Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth();
   Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight();  
@@ -835,4 +848,5 @@
 
   // generate mask
+  UInt t=0;
   UInt uiSumPix[2] = {0,0};
   for (Int y=0; y<uiHeight; y++)
@@ -952,5 +966,9 @@
   }
 
-  if ( tmpTar    ) { xFree(tmpTar);             tmpTar        = NULL; }
+  if ( tmpTar    ) 
+  { 
+    xFree(tmpTar);             
+    tmpTar        = NULL; 
+  }
   
   // now combine chroma
@@ -1055,6 +1073,14 @@
   }
 
-  if ( tmpTarU    ) { xFree(tmpTarU);             tmpTarU        = NULL; }
-  if ( tmpTarV    ) { xFree(tmpTarV);             tmpTarV        = NULL; }
+  if( tmpTarU )
+  {
+    xFree(tmpTarU);
+    tmpTarU        = NULL;
+  }
+  if ( tmpTarV    ) 
+  {
+    xFree(tmpTarV);
+    tmpTarV        = NULL; 
+  }
 }
 #endif
@@ -1243,5 +1269,5 @@
   pcCU->clipMv(cMv);
 #if H_MV
-  pcCU->checkMV_V(cMv, eRefPicList, iRefIdx );
+  pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
 #endif
 #if H_3D_ARP
@@ -2367,6 +2393,12 @@
     for( UInt k = 0; k < (patternStride * patternStride); k++ )
     {
-      if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; }
-      else                          { ptrDst[k] = valDC1; }
+      if( true == biSegPattern[k] )
+      { 
+        ptrDst[k] = valDC2; 
+      }
+      else                          
+      { 
+        ptrDst[k] = valDC1; 
+      }
     }
   }
@@ -2378,6 +2410,12 @@
       for( UInt uiX = 0; uiX < patternStride; uiX++ )
       {
-        if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; }
-        else                            { piTemp[uiX] = valDC1; }
+        if( true == biSegPattern[uiX] ) 
+        { 
+          piTemp[uiX] = valDC2; 
+        }
+        else                            
+        { 
+          piTemp[uiX] = valDC1; 
+        }
       }
       piTemp       += dstStride;
@@ -2449,9 +2487,11 @@
   Int iSumPix[2];
   memset(iSumPix, 0, sizeof(Int)*2);
+
   for( Int i = 0; i < uiNumSegments; i++ )
   {
-    rpSegMeans[i] = 0;
-  }
-  if (orgDC == false)
+    rpSegMeans[i] = 0;  
+  }
+
+  if ( !orgDC )
   {
     Pel* pLeftTop = pOrig;
@@ -2473,4 +2513,5 @@
     subSamplePix = 1;
   }
+
   for (Int y=0; y<uiSize; y+=subSamplePix)
   {
@@ -2492,7 +2533,11 @@
   {
     if( iSumPix[ucSeg] > 0 )
+    {
       rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
+    }
     else
+    {
       rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
+    }
   }
 }
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComPrediction.h	(revision 1187)
@@ -121,7 +121,5 @@
   Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
 #endif
-
-  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
-  
+  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );  
   Void xGetLLSPrediction ( TComPattern* pcPattern, Int* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0 );
 #if H_3D_IC
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1187)
@@ -2862,12 +2862,9 @@
 UInt TComRdCost::getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y )
 {
-  Double dD;
-  Int iTemp;
-
-  dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
+  Double  dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
 
   Double dDepthWeight = ( pOrg[x] >=  ( (1<<(g_bitDepthY - 3)) + (1<<(g_bitDepthY - 2)) ) ? 4 : pOrg[x] > ((1<<g_bitDepthY) >> 4) ? (Float)(pOrg[x] - ((1<<g_bitDepthY) >> 4))/(Float)((1<<g_bitDepthY) >> 3) + 1 : 1.0 );
   Double dTemp = ( 0.5 * fabs(dD) * dDepthWeight * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
-  iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
+  Int iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
 
   return (UInt) ( (iTemp*iTemp)>>1 );
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 1187)
@@ -104,10 +104,16 @@
   if( !g_dmmWedgeLists.empty() ) 
   {
-    for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); }
+    for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ )
+    { 
+      g_dmmWedgeLists[ui].clear(); 
+    }
     g_dmmWedgeLists.clear();
   }
   if( !g_dmmWedgeRefLists.empty() )
   {
-    for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) { g_dmmWedgeRefLists[ui].clear(); }
+    for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) 
+    { 
+      g_dmmWedgeRefLists[ui].clear(); 
+    }
     g_dmmWedgeRefLists.clear();
   }
@@ -115,5 +121,8 @@
   if( !g_dmmWedgeNodeLists.empty() )
   {
-    for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); }
+    for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ )
+    { 
+      g_dmmWedgeNodeLists[ui].clear(); 
+    }
     g_dmmWedgeNodeLists.clear();
   }
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 1187)
@@ -290,11 +290,11 @@
 
 #if H_MV_ENC_DEC_TRAC
-#define DTRACE_CU(x,y)             
-#define DTRACE_PU(x,y)             
-#define DTRACE_TU(x,y)             
-
-#define DTRACE_CU_S(x)             
-#define DTRACE_PU_S(x)             
-#define DTRACE_TU_S(x)             
+#define DTRACE_CU(x,y) ;             
+#define DTRACE_PU(x,y) ;            
+#define DTRACE_TU(x,y) ;            
+
+#define DTRACE_CU_S(x) ;            
+#define DTRACE_PU_S(x) ;            
+#define DTRACE_TU_S(x) ;            
 
 #endif
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 1187)
@@ -2721,4 +2721,65 @@
 }
 
+#if H_3D
+Void TComVPS::initViewCompLayer()
+{
+  assert( m_viewCompLayerId.size() == 0 && m_viewCompLayerPresentFlag.size() == 0  );
+  for( Int i = 0; i < getNumViews(); i++ )
+  {
+    m_viewCompLayerId         .push_back( std::vector<Int>(0)  );
+    m_viewCompLayerPresentFlag.push_back( std::vector<Bool>(0) );      
+
+    for( Int depFlag = 0; depFlag  <=  1; depFlag++ )
+    {
+      Int iViewOIdx = getViewOIdxList( i );
+      Int layerId = -1;
+      for( Int j = 0; j  <=  getMaxLayersMinus1(); j++ ) 
+      {
+        Int jNuhLId = getLayerIdInNuh( j );
+        if( getVpsDepthFlag( jNuhLId ) == ( (Bool) depFlag )  &&  getViewOrderIdx( jNuhLId )  ==  iViewOIdx  
+          &&  getDependencyId( jNuhLId )  ==  0  &&  getAuxId( jNuhLId )  ==  0 )
+        {
+          layerId = jNuhLId;
+        }
+      }
+      m_viewCompLayerPresentFlag[ i ].push_back( layerId  !=  -1 );
+      m_viewCompLayerId         [ i ].push_back( layerId );        
+    }
+  }
+}
+
+Int TComVPS::getVoiInVps(Int viewOIdx)
+{
+  for ( Int i = 0; i < m_viewOIdxList.size(); i++ )
+  {
+    if  ( m_viewOIdxList[ i ] == viewOIdx )
+    {
+      return i; 
+    }
+  }
+  assert( 0 );   
+  return -1;
+}
+
+Void TComVPS::deriveCpPresentFlag()
+{
+  for( Int nInVps = 0; nInVps < getNumViews(); nInVps++  )
+  {
+    for( Int mInVps = 0; mInVps < getNumViews(); mInVps++ )
+    {
+      m_cpPresentFlag[nInVps][mInVps] = 0; 
+    }
+  }
+
+  for( Int n = 1; n < getNumViews(); n++ )
+  {
+    Int iInVps = getVoiInVps(  getViewOIdxList( n ) );      
+    for( Int m = 0; m < getNumCp( iInVps ); m++ )
+    {
+      m_cpPresentFlag[ iInVps ][ getVoiInVps( getCpRefVoi( iInVps, m ) ) ] = 1;
+    }
+  }
+}
+#endif
 
 #endif // H_MV
@@ -3824,5 +3885,7 @@
 }
 #endif
+
 #if H_3D_IC
+// This is an encoder only function and should be moved to TEncSlice or TEncSearch!!
 Void TComSlice::xSetApplyIC(Bool bUseLowLatencyICEnc)
 {
@@ -3888,78 +3951,75 @@
   }
   else
-  {
-  Int iMaxPelValue = ( 1 << g_bitDepthY ); 
-  Int *aiRefOrgHist;
-  Int *aiCurrHist;
-  aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue );
-  aiCurrHist   = (Int *) xMalloc( Int,iMaxPelValue );
-  memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) );
-  memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) );
-  // Reference Idx Number
-  Int iNumRefIdx = getNumRefIdx( REF_PIC_LIST_0 );
-  TComPic* pcCurrPic = NULL;
-  TComPic* pcRefPic = NULL;
-  TComPicYuv* pcCurrPicYuv = NULL;
-  TComPicYuv* pcRefPicYuvOrg = NULL;
-  pcCurrPic = getPic();
-  pcCurrPicYuv = pcCurrPic->getPicYuvOrg();
-  Int iWidth = pcCurrPicYuv->getWidth();
-  Int iHeight = pcCurrPicYuv->getHeight();
-
-
-  // Get InterView Reference picture
-  // !!!!! Assume only one Interview Reference Picture in L0
-  for ( Int i = 0; i < iNumRefIdx; i++ )
-  {
-    pcRefPic = getRefPic( REF_PIC_LIST_0, i );
-    if ( pcRefPic != NULL )
-    {
-      if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
-      {
-        pcRefPicYuvOrg = pcRefPic->getPicYuvOrg();
-      }
-    }
-  }
-
-  if ( pcRefPicYuvOrg != NULL )
-  {
-    Pel* pCurrY = pcCurrPicYuv ->getLumaAddr();
-    Pel* pRefOrgY = pcRefPicYuvOrg  ->getLumaAddr();
-    Int iCurrStride = pcCurrPicYuv->getStride();
-    Int iRefStride = pcRefPicYuvOrg->getStride();
-    Int iSumOrgSAD = 0;
-    Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05;
-
-    // Histogram building - luminance
-    for ( Int y = 0; y < iHeight; y++ )
-    {
-      for ( Int x = 0; x < iWidth; x++ )
-      {
-        aiCurrHist[pCurrY[x]]++;
-        aiRefOrgHist[pRefOrgY[x]]++;
-      }
-      pCurrY += iCurrStride;
-      pRefOrgY += iRefStride;
-    }
-    // Histogram SAD
-    for ( Int i = 0; i < iMaxPelValue; i++ )
-    {
-      iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] );
-    }
-    // Setting
-    if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) )
-    {
-      m_bApplyIC = true;
-    }
-    else
-    {
-      m_bApplyIC = false;
-    }
-  }
-
-  xFree( aiCurrHist   );
-  xFree( aiRefOrgHist );
-  aiCurrHist = NULL;
-  aiRefOrgHist = NULL;
+  {        
+    TComPic*    pcCurrPic = getPic();
+    TComPicYuv* pcCurrPicYuv = pcCurrPic->getPicYuvOrg();
+    
+    // Get InterView Reference picture
+    // !!!!! Assume only one Interview Reference Picture in L0
+    // GT: Is this assumption correct?
+
+    TComPicYuv* pcRefPicYuvOrg = NULL;
+    for ( Int i = 0; i < getNumRefIdx( REF_PIC_LIST_0 ); i++ )
+    {
+      TComPic* pcRefPic = getRefPic( REF_PIC_LIST_0, i );
+      if ( pcRefPic != NULL )
+      {
+        if ( pcCurrPic->getViewIndex() != pcRefPic->getViewIndex() )
+        {
+          pcRefPicYuvOrg = pcRefPic->getPicYuvOrg();
+        }
+      }
+    }
+
+    if ( pcRefPicYuvOrg != NULL )
+    {
+      // Histogram building - luminance
+      Int iMaxPelValue = ( 1 << g_bitDepthY ); 
+      Int *aiRefOrgHist = (Int *) xMalloc( Int,iMaxPelValue );
+      Int *aiCurrHist   = (Int *) xMalloc( Int,iMaxPelValue );
+      memset( aiRefOrgHist, 0, iMaxPelValue*sizeof(Int) );
+      memset( aiCurrHist, 0, iMaxPelValue*sizeof(Int) );
+
+      Int iWidth   = pcCurrPicYuv->getWidth();
+      Int iHeight  = pcCurrPicYuv->getHeight();
+
+      Pel* pCurrY   = pcCurrPicYuv ->getLumaAddr();
+      Pel* pRefOrgY = pcRefPicYuvOrg  ->getLumaAddr();
+      Int iCurrStride = pcCurrPicYuv->getStride();
+      Int iRefStride = pcRefPicYuvOrg->getStride();
+
+      for ( Int y = 0; y < iHeight; y++ )
+      {
+        for ( Int x = 0; x < iWidth; x++ )
+        {
+          aiCurrHist[pCurrY[x]]++;
+          aiRefOrgHist[pRefOrgY[x]]++;
+        }
+        pCurrY += iCurrStride;
+        pRefOrgY += iRefStride;
+      }
+
+      // Histogram SAD
+      Int iSumOrgSAD = 0;
+      for ( Int i = 0; i < iMaxPelValue; i++ )
+      {
+        iSumOrgSAD += abs( aiCurrHist[i] - aiRefOrgHist[i] );
+      }
+
+      // Setting
+      Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05;
+
+      if ( iSumOrgSAD > Int( dThresholdOrgSAD * iWidth * iHeight ) )
+      {
+        m_bApplyIC = true;
+      }
+      else
+      {
+        m_bApplyIC = false;
+      }
+
+      xFree( aiCurrHist   );
+      xFree( aiRefOrgHist );
+    }
   }//if(bUseLowLatencyICEnc)
 }
@@ -4136,4 +4196,86 @@
 #endif
 }
+
+Void TComSlice::deriveInCmpPredAndCpAvailFlag()
+{
+  Int numCurCmpLIds = getIsDepth() ? 1 : getNumActiveRefLayerPics(); 
+  std::vector<Int> curCmpLIds;
+  if ( getIsDepth() )
+  {
+    curCmpLIds.push_back( getLayerId() );
+  }
+  else
+  {
+    for (Int i = 0; i < numCurCmpLIds; i++)
+    {
+      curCmpLIds.push_back( getRefPicLayerId( i ) );
+    }
+  }
+
+  m_cpAvailableFlag = true;
+  m_inCmpRefViewIdcs.clear();
+  Bool allRefCmpLayersAvailFlag = true;
+
+  for( Int i = 0; i <= numCurCmpLIds - 1; i++ )
+  {      
+    m_inCmpRefViewIdcs.push_back( getVPS()->getViewOrderIdx( curCmpLIds[ i ] ));
+    if( !getVPS()->getCpPresentFlag( getVPS()->getVoiInVps( getViewIndex() ),  getVPS()->getVoiInVps( m_inCmpRefViewIdcs[ i ] ) ) )
+    {
+      m_cpAvailableFlag = false;
+    }
+    Bool refCmpCurLIdAvailFlag = false;
+    if( getVPS()->getViewCompLayerPresentFlag( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) )
+    {
+      Int j = getVPS()->getLayerIdInVps( getVPS()->getViewCompLayerId( m_inCmpRefViewIdcs[ i ],  !getIsDepth() ) );
+      if  ( getVPS()->getDirectDependencyFlag( getVPS()->getLayerIdInVps( getLayerId() ) ,  j ) &&
+        getVPS()->getSubLayersVpsMaxMinus1( j ) >= getTemporalId()   &&
+        ( getTemporalId() == 0 || getVPS()->getMaxTidIlRefPicsPlus1( j , getVPS()->getLayerIdInVps( getLayerId() ) ) > getTemporalId() )        
+        )
+      {
+        refCmpCurLIdAvailFlag = true;
+      }
+    }
+    if( !refCmpCurLIdAvailFlag )
+    {
+      allRefCmpLayersAvailFlag = false;
+    }
+  }
+
+  if( !allRefCmpLayersAvailFlag )
+  {
+    m_inCmpPredAvailFlag = false;
+  }  
+  else 
+  {
+    TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension();
+    if( !getIsDepth() )
+    {
+      m_inCmpPredAvailFlag = sps3dExt->getViewSynthesisPredFlag( getIsDepth() ) || 
+        sps3dExt->getDepthBasedBlkPartFlag( getIsDepth() ) || 
+        sps3dExt->getDepthRefinementFlag  ( getIsDepth() );                            
+    }
+    else
+    {
+      m_inCmpPredAvailFlag = sps3dExt->getIntraContourFlag( getIsDepth() ) || 
+        sps3dExt->getQtPredFlag( getIsDepth() ) || 
+        sps3dExt->getMpiFlag( getIsDepth() );                                  
+    }
+  }
+}
+
+Void TComSlice::checkInCompPredRefLayers()
+{
+  if ( getInCompPredFlag() )
+  {
+    for (Int i = 0; i < getNumCurCmpLIds(); i++ )
+    {
+      assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL );       
+      //  It is a requirement of bitstream conformance that there 
+      //  is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture, 
+      //  and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ].
+    }
+  }
+}
+
 #endif
 
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 1187)
@@ -912,4 +912,5 @@
   Int         xGetDimBitOffset( Int j );
   Void        xSetRefLayerFlags( Int currLayerId );
+
   // VPS EXTENSION 2 SYNTAX ELEMENTS
 #if H_3D
@@ -1011,5 +1012,6 @@
   Void    setVpsNonVuiExtensionLength( Int  val )                          { m_vpsNonVuiExtensionLength = val; } 
   Int     getVpsNonVuiExtensionLength(  )                                  { return m_vpsNonVuiExtensionLength; } 
-
+  
+  // VPS Extension
   Void    setSplittingFlag( Bool val )                                     { m_splittingFlag = val;  }
   Bool    getSplittingFlag()                                               { return m_splittingFlag; }
@@ -1154,47 +1156,9 @@
   Void    initNumViews();
 #if H_3D
-  Void   initViewCompLayer( )
-  { 
-    assert( m_viewCompLayerId.size() == 0 && m_viewCompLayerPresentFlag.size() == 0  );
-    for( Int i = 0; i < getNumViews(); i++ )
-    {
-      m_viewCompLayerId         .push_back( std::vector<Int>(0)  );
-      m_viewCompLayerPresentFlag.push_back( std::vector<Bool>(0) );      
-
-      for( Int depFlag = 0; depFlag  <=  1; depFlag++ )
-      {
-        Int iViewOIdx = getViewOIdxList( i );
-        Int layerId = -1;
-        for( Int j = 0; j  <=  getMaxLayersMinus1(); j++ ) 
-        {
-          Int jNuhLId = getLayerIdInNuh( j );
-          if( getVpsDepthFlag( jNuhLId ) == ( (Bool) depFlag )  &&  getViewOrderIdx( jNuhLId )  ==  iViewOIdx  
-            &&  getDependencyId( jNuhLId )  ==  0  &&  getAuxId( jNuhLId )  ==  0 )
-          {
-            layerId = jNuhLId;
-          }
-        }
-        m_viewCompLayerPresentFlag[ i ].push_back( layerId  !=  -1 );
-        m_viewCompLayerId         [ i ].push_back( layerId );        
-      }
-    }
-  };
-
-
+  Void   initViewCompLayer( );
   Int     getViewOIdxList( Int i )                                         { return m_viewOIdxList[i]; }
   std::vector<Int> getViewOIdxList( )                                               { return m_viewOIdxList; }
 
-  Int     getVoiInVps( Int viewOIdx )                                      
-  {    
-    for ( Int i = 0; i < m_viewOIdxList.size(); i++ )
-    {
-      if  ( m_viewOIdxList[ i ] == viewOIdx )
-      {
-        return i; 
-      }
-    }
-    assert( 0 );   
-    return -1; 
-  };
+  Int     getVoiInVps( Int viewOIdx );;
 
   Bool    getViewCompLayerPresentFlag (Int i, Bool d ) { return  m_viewCompLayerPresentFlag[ getVoiInVps(i) ][d]; }
@@ -1349,23 +1313,5 @@
 
 // Derived
-  Void deriveCpPresentFlag( )
-  {
-    for( Int nInVps = 0; nInVps < getNumViews(); nInVps++  )
-    {
-      for( Int mInVps = 0; mInVps < getNumViews(); mInVps++ )
-      {
-        m_cpPresentFlag[nInVps][mInVps] = 0; 
-      }
-    }
-
-   for( Int n = 1; n < getNumViews(); n++ )
-   {
-      Int iInVps = getVoiInVps(  getViewOIdxList( n ) );      
-      for( Int m = 0; m < getNumCp( iInVps ); m++ )
-      {
-         m_cpPresentFlag[ iInVps ][ getVoiInVps( getCpRefVoi( iInVps, m ) ) ] = 1;
-      }
-    }
-  }
+  Void deriveCpPresentFlag( );
 
   Void setCpPresentFlag( Int i, Int m, Bool flag ) { m_cpPresentFlag[i][m] = flag; } 
@@ -2480,6 +2426,6 @@
   Bool      m_bApplyDIS;
 #if H_3D_IC
-  Int *m_aICEnableCandidate;
-  Int *m_aICEnableNum;
+  Int*      m_aICEnableCandidate;
+  Int*      m_aICEnableNum;
 #endif
   Int       m_iDefaultRefViewIdx;
@@ -2930,86 +2876,7 @@
 #if H_3D
   // 3D-HEVC tool parameters
-  Void deriveInCmpPredAndCpAvailFlag()
-  { 
-    Int numCurCmpLIds = getIsDepth() ? 1 : getNumActiveRefLayerPics(); 
-    std::vector<Int> curCmpLIds;
-    if ( getIsDepth() )
-    {
-      curCmpLIds.push_back( getLayerId() );
-    }
-    else
-    {
-      for (Int i = 0; i < numCurCmpLIds; i++)
-      {
-        curCmpLIds.push_back( getRefPicLayerId( i ) );
-      }
-    }
-
-    m_cpAvailableFlag = true;
-    m_inCmpRefViewIdcs.clear();
-    Bool allRefCmpLayersAvailFlag = true;
-
-    for( Int i = 0; i <= numCurCmpLIds - 1; i++ )
-    {      
-      m_inCmpRefViewIdcs.push_back( getVPS()->getViewOrderIdx( curCmpLIds[ i ] ));
-      if( !getVPS()->getCpPresentFlag( getVPS()->getVoiInVps( getViewIndex() ),  getVPS()->getVoiInVps( m_inCmpRefViewIdcs[ i ] ) ) )
-      {
-        m_cpAvailableFlag = false;
-      }
-      Bool refCmpCurLIdAvailFlag = false;
-      if( getVPS()->getViewCompLayerPresentFlag( m_inCmpRefViewIdcs[ i ], !getIsDepth() ) )
-      {
-        Int j = getVPS()->getLayerIdInVps( getVPS()->getViewCompLayerId( m_inCmpRefViewIdcs[ i ],  !getIsDepth() ) );
-        if  ( getVPS()->getDirectDependencyFlag( getVPS()->getLayerIdInVps( getLayerId() ) ,  j ) &&
-          getVPS()->getSubLayersVpsMaxMinus1( j ) >= getTemporalId()   &&
-          ( getTemporalId() == 0 || getVPS()->getMaxTidIlRefPicsPlus1( j , getVPS()->getLayerIdInVps( getLayerId() ) ) > getTemporalId() )        
-          )
-        {
-          refCmpCurLIdAvailFlag = true;
-        }
-      }
-      if( !refCmpCurLIdAvailFlag )
-      {
-        allRefCmpLayersAvailFlag = false;
-      }
-    }
-
-    if( !allRefCmpLayersAvailFlag )
-    {
-      m_inCmpPredAvailFlag = false;
-    }  
-    else 
-    {
-      TComSps3dExtension* sps3dExt = getSPS()->getSps3dExtension();
-      if( !getIsDepth() )
-      {
-        m_inCmpPredAvailFlag = sps3dExt->getViewSynthesisPredFlag( getIsDepth() ) || 
-          sps3dExt->getDepthBasedBlkPartFlag( getIsDepth() ) || 
-          sps3dExt->getDepthRefinementFlag  ( getIsDepth() );                            
-      }
-      else
-      {
-        m_inCmpPredAvailFlag = sps3dExt->getIntraContourFlag( getIsDepth() ) || 
-          sps3dExt->getQtPredFlag( getIsDepth() ) || 
-          sps3dExt->getMpiFlag( getIsDepth() );                                  
-      }
-    }  
-  };
-
-
+  Void deriveInCmpPredAndCpAvailFlag();
   Void init3dToolParameters();   
-  Void checkInCompPredRefLayers()
-  {
-    if ( getInCompPredFlag() )
-    {
-      for (Int i = 0; i < getNumCurCmpLIds(); i++ )
-      {
-        assert( getIvPic(!getIsDepth(), getInCmpRefViewIdcs( i ) ) != NULL );       
-        //  It is a requirement of bitstream conformance that there 
-        //  is a picture in the DPB with PicOrderCntVal equal to the PicOrderCntVal of the current picture, 
-        //  and a nuh_layer_id value equal to ViewCompLayerId[ inCmpRefViewIdcs[ i ] ][ !DepthFlag ].
-      }
-    }
-  };
+  Void checkInCompPredRefLayers();;
 
   Bool getIvMvPredFlag           ( ) { return m_ivMvPredFlag           ; };
Index: branches/HTM-14.0-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 1187)
@@ -306,4 +306,5 @@
 #define H_3D_DISABLE_CHROMA                    1 
 #define H_3D_OUTPUT_ACTIVE_TOOLS               0
+#define H_3D_REN_MAX_DEV_OUT                   0
 #endif
 
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1187)
@@ -2397,11 +2397,10 @@
       if( rpcSlice->getSPS()->getChromaFormatIdc() != 0 )
       {
-      READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
-    }
+        READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
+      }
       else
       {
         rpcSlice->setSaoEnabledFlagChroma( false );
       }
-      
 #else
       READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1187)
@@ -593,5 +593,5 @@
   UInt uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
   UInt uiBPelY   = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1;
-  
+
   UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
   TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
@@ -601,5 +601,5 @@
     bBoundary = true;
   }
-  
+
   if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary )
   {
@@ -611,5 +611,5 @@
       uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ];
       uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
-      
+
       Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
       if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
@@ -617,5 +617,5 @@
         xDecompressCU(pcCU, uiIdx, uiNextDepth );
       }
-      
+
       uiIdx += uiQNumParts;
     }
@@ -625,17 +625,17 @@
   // Residual reconstruction
   m_ppcYuvResi[uiDepth]->clear();
-  
+
   m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
 
   switch( m_ppcCU[uiDepth]->getPredictionMode(0) )
   {
-    case MODE_INTER:
+  case MODE_INTER:
 #if H_3D_DBBP
-      if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
-      {
-        xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
-      }
-      else
-      {
+    if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
+    {
+      xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
+    }
+    else
+    {
 #endif
 #if H_3D_INTER_SDC
@@ -647,31 +647,31 @@
       {
 #endif
-      xReconInter( m_ppcCU[uiDepth], uiDepth );
+        xReconInter( m_ppcCU[uiDepth], uiDepth );
 #if H_3D_INTER_SDC
       }
 #endif
 #if H_3D_DBBP
-      }
-#endif
-      break;
-    case MODE_INTRA:
+    }
+#endif
+    break;
+  case MODE_INTRA:
 #if H_3D
-      if( m_ppcCU[uiDepth]->getDISFlag(0) )
-      {
-        xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
-      }
+    if( m_ppcCU[uiDepth]->getDISFlag(0) )
+    {
+      xReconDIS( m_ppcCU[uiDepth], 0, uiDepth );
+    }
 #if H_3D_DIM_SDC
-      else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
-      {
-        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
-      }
-#endif
-      else
+    else if( m_ppcCU[uiDepth]->getSDCFlag(0) )
+    {
+      xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
+    }
+#endif
+    else
 #endif
       xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
-      break;
-    default:
-      assert(0);
-      break;
+    break;
+  default:
+    assert(0);
+    break;
   }
   if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
@@ -679,5 +679,5 @@
     xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
   }
-  
+
   xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth );
 }
@@ -847,5 +847,5 @@
   AOF(bValidMask);
   
-  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
   TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
   
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1187)
@@ -220,9 +220,7 @@
 #endif
 #if H_3D_SPIVMP
-  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
-  TComMvField*  pcMvFieldSP;
-  UChar* puhInterDirSP;
-  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
-  puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
+  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];     
+  TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
+  UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
 #endif
   for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
@@ -489,10 +487,4 @@
         }
       }
-#if H_3D_ARP
-      decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
-#endif
-#if H_3D_IC
-      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
-#endif
     }
     if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
@@ -735,15 +727,15 @@
       if (pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 )      
       {
-      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
-      {
-        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
-      }
-      if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
-      {
-        m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
-      }
-    }
-    else
-    {
+        if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
+        {
+          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth );
+        }
+        if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) )
+        {
+          m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth );
+        }
+      }
+      else
+      {
         if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) )
         {
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1187)
@@ -446,11 +446,11 @@
   UInt uiSymbol;
 
-    m_pcTDecBinIf->decodeBinTrm(uiSymbol);
+  m_pcTDecBinIf->decodeBinTrm(uiSymbol);
 
 #if H_MV_ENC_DEC_TRAC
-      DTRACE_CU("pcm_flag", uiSymbol)
-#endif
-    if (uiSymbol)
-    {
+  DTRACE_CU("pcm_flag", uiSymbol)
+#endif
+  if (uiSymbol)
+  {
     Bool bIpcmFlag = true;
 
@@ -485,46 +485,42 @@
       piPCMSample += uiWidth;
     }
-
-
 #if H_3D_DISABLE_CHROMA
     if( pcCU->getSlice()->getSPS()->getChromaFormatIdc() != 0 )
     {    
 #endif
-    piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;
-    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
-    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
-    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
-
-    for(uiY = 0; uiY < uiHeight; uiY++)
-    {
-      for(uiX = 0; uiX < uiWidth; uiX++)
-      {
-        UInt uiSample;
-        m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
-        piPCMSample[uiX] = uiSample;
-      }
-      piPCMSample += uiWidth;
-    }
-
-    piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;
-    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
-    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
-    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
-
-    for(uiY = 0; uiY < uiHeight; uiY++)
-    {
-      for(uiX = 0; uiX < uiWidth; uiX++)
-      {
-        UInt uiSample;
-        m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
-        piPCMSample[uiX] = uiSample;
-      }
-      piPCMSample += uiWidth;
-    }
+      piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;
+      uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
+      uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
+      uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
+
+      for(uiY = 0; uiY < uiHeight; uiY++)
+      {
+        for(uiX = 0; uiX < uiWidth; uiX++)
+        {
+          UInt uiSample;
+          m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
+          piPCMSample[uiX] = uiSample;
+        }
+        piPCMSample += uiWidth;
+      }
+
+      piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;
+      uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
+      uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
+      uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
+
+      for(uiY = 0; uiY < uiHeight; uiY++)
+      {
+        for(uiX = 0; uiX < uiWidth; uiX++)
+        {
+          UInt uiSample;
+          m_pcTDecBinIf->xReadPCMCode(uiSampleBits, uiSample);
+          piPCMSample[uiX] = uiSample;
+        }
+        piPCMSample += uiWidth;
+      }
 #if H_3D_DISABLE_CHROMA
     }
 #endif
-
-
     m_pcTDecBinIf->start();
   }
@@ -707,6 +703,4 @@
 #if H_3D_QTLPC
   Bool bParseSplitFlag    = true;
-
-  
   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
   TComPic *pcTexture      = pcCU->getSlice()->getTexturePic();
@@ -745,5 +739,5 @@
 #endif
   pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx );
-  
+
   return;
 }
@@ -762,5 +756,5 @@
 #if H_3D_QTLPC
   Bool bParsePartSize    = true;
-  
+
   Bool    bLimQtPredFlag = pcCU->getPic()->getSlice(0)->getQtPredFlag();
   TComPic *pcTexture     = pcCU->getSlice()->getTexturePic();
@@ -794,5 +788,5 @@
 #endif
 
-  
+
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
@@ -801,5 +795,5 @@
     {
 #endif
-     uiSymbol = 1;
+      uiSymbol = 1;
       if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
       {
@@ -834,40 +828,40 @@
       {
 #endif
-      UInt uiMaxNumBits = 2;
-      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
-      {
-        uiMaxNumBits ++;
-      }
-      for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
-      {
-        m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
-        if ( uiSymbol )
-        {
-          break;
-        }
-        uiMode++;
-      }
-      eMode = (PartSize) uiMode;
-      if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
-      {
-        if (eMode == SIZE_2NxN)
-        {
-        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-          if (uiSymbol == 0)
+        UInt uiMaxNumBits = 2;
+        if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
+        {
+          uiMaxNumBits ++;
+        }
+        for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
+        {
+          m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
+          if ( uiSymbol )
           {
-            m_pcTDecBinIf->decodeBinEP(uiSymbol);
-            eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
+            break;
           }
-        }
-        else if (eMode == SIZE_Nx2N)
-        {
-        m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-          if (uiSymbol == 0)
+          uiMode++;
+        }
+        eMode = (PartSize) uiMode;
+        if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+        {
+          if (eMode == SIZE_2NxN)
           {
-            m_pcTDecBinIf->decodeBinEP(uiSymbol);
-            eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
+            m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+            if (uiSymbol == 0)
+            {
+              m_pcTDecBinIf->decodeBinEP(uiSymbol);
+              eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
+            }
           }
-        }
-      }
+          else if (eMode == SIZE_Nx2N)
+          {
+            m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+            if (uiSymbol == 0)
+            {
+              m_pcTDecBinIf->decodeBinEP(uiSymbol);
+              eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
+            }
+          }
+        }
 #if H_3D_QTLPC
       }
@@ -995,8 +989,8 @@
     {
 #endif
-    m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
-    mpmPred[j] = symbol;
+      m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
+      mpmPred[j] = symbol;
 #if H_MV_ENC_DEC_TRAC          
-    DTRACE_CU("prev_intra_luma_pred_flag", symbol)
+      DTRACE_CU("prev_intra_luma_pred_flag", symbol)
 #endif
 #if H_3D_DIM
@@ -1010,45 +1004,45 @@
     {
 #endif
-    Int preds[3] = {-1, -1, -1};
-    Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds);  
-    if (mpmPred[j])
-    {
-      m_pcTDecBinIf->decodeBinEP( symbol );
-      if (symbol)
+      Int preds[3] = {-1, -1, -1};
+      Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds);  
+      if (mpmPred[j])
       {
         m_pcTDecBinIf->decodeBinEP( symbol );
-        symbol++;
-      }
+        if (symbol)
+        {
+          m_pcTDecBinIf->decodeBinEP( symbol );
+          symbol++;
+        }
 #if H_MV_ENC_DEC_TRAC          
-      DTRACE_CU("mpm_idx", symbol)
-#endif
-      intraPredMode = preds[symbol];
-    }
-    else
-    {
-      m_pcTDecBinIf->decodeBinsEP( symbol, 5 );
-      intraPredMode = symbol;
+        DTRACE_CU("mpm_idx", symbol)
+#endif
+          intraPredMode = preds[symbol];
+      }
+      else
+      {
+        m_pcTDecBinIf->decodeBinsEP( symbol, 5 );
+        intraPredMode = symbol;
 #if H_MV_ENC_DEC_TRAC          
-      DTRACE_CU("rem_intra_luma_pred_mode", symbol)
+        DTRACE_CU("rem_intra_luma_pred_mode", symbol)
 #endif        
-      //postponed sorting of MPMs (only in remaining branch)
-      if (preds[0] > preds[1])
-      { 
-        std::swap(preds[0], preds[1]); 
-      }
-      if (preds[0] > preds[2])
-      {
-        std::swap(preds[0], preds[2]);
-      }
-      if (preds[1] > preds[2])
-      {
-        std::swap(preds[1], preds[2]);
-      }
-      for ( Int i = 0; i < predNum; i++ )
-      {
-        intraPredMode += ( intraPredMode >= preds[i] );
-      }
-    }
-    pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth );
+          //postponed sorting of MPMs (only in remaining branch)
+          if (preds[0] > preds[1])
+          { 
+            std::swap(preds[0], preds[1]); 
+          }
+          if (preds[0] > preds[2])
+          {
+            std::swap(preds[0], preds[2]);
+          }
+          if (preds[1] > preds[2])
+          {
+            std::swap(preds[1], preds[2]);
+          }
+          for ( Int i = 0; i < predNum; i++ )
+          {
+            intraPredMode += ( intraPredMode >= preds[i] );
+          }
+      }
+      pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth );
 #if H_3D_DIM
     }
@@ -1068,5 +1062,5 @@
     DTRACE_CU("intra_chroma_pred_mode", uiSymbol )
 #endif        
-    uiSymbol = DM_CHROMA_IDX;
+      uiSymbol = DM_CHROMA_IDX;
   } 
   else 
@@ -1078,5 +1072,5 @@
       DTRACE_CU("intra_chroma_pred_mode", uiIPredMode )
 #endif        
-      UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ];
+        UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ];
       pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir );
       uiSymbol = uiAllowedChromaDir[ uiIPredMode ];
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1187)
@@ -290,6 +290,4 @@
     }
   }  
-
-
 }
 
@@ -349,4 +347,5 @@
 }
 #endif
+
 TDecTop::TDecTop()
 {
@@ -1197,5 +1196,7 @@
 #if  H_3D_TMVP
     if(pcSlice->getLayerId())
+    {
       pcSlice->generateAlterRefforTMVP();
+    }
 #endif
   }
@@ -1650,5 +1651,4 @@
 }
 
-#if H_MV
 Void TDecTop::xCeckNoClrasOutput()
 {
@@ -1684,4 +1684,28 @@
   return allRefLayersInitilizedFlag;
 }
+
+#if H_3D
+Void TDecTop::setProfileIdc()
+{
+  if (m_targetOptLayerSetIdx != -1 )
+  {    
+    TComVPS* vps = getPrefetchedVPS(); 
+    Int lsIdx = vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
+    Int lIdx = -1; 
+    for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
+    {
+      if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
+      {
+        lIdx = j; 
+        break; 
+      }        
+    }
+    assert( lIdx != -1 ); 
+
+    Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOptLayerSetIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
+    assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 ); 
+    m_profileIdc = profileIdc;   
+  };
+}
 #endif
 #endif
Index: branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 1187)
@@ -301,26 +301,5 @@
   Void                    setCamParsCollector( CamParsCollector* pcCamParsCollector ) { m_pcCamParsCollector = pcCamParsCollector; }
 
-  Void                    setProfileIdc()
-  {        
-    if (m_targetOptLayerSetIdx != -1 )
-    {    
-      TComVPS* vps = getPrefetchedVPS(); 
-      Int lsIdx = vps->olsIdxToLsIdx( m_targetOptLayerSetIdx );
-      Int lIdx = -1; 
-      for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ); j++ )
-      {
-        if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() )
-        {
-          lIdx = j; 
-          break; 
-        }        
-      }
-      assert( lIdx != -1 ); 
-
-      Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOptLayerSetIdx, lIdx ) )->getGeneralPTL()->getProfileIdc();
-      assert( profileIdc == 1 || profileIdc == 6 || profileIdc == 8 ); 
-      m_profileIdc = profileIdc;   
-    };
-  }
+  Void                    setProfileIdc();
   Bool                    decProcAnnexI()           { assert( m_profileIdc != -1 ); return ( m_profileIdc == 8); }    
 #endif
Index: branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1187)
@@ -541,5 +541,5 @@
         TComDataCU* pcTextureCU = pcTexture->getCU( rpcBestCU->getAddr() ); //Corresponding texture LCU
         UInt uiCUIdx            = rpcBestCU->getZorderIdxInCU();
-        assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitionned than the texture.
+        assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth); //Depth cannot be more partitioned than the texture.
         if (pcTextureCU->getDepth(uiCUIdx) > uiDepth || pcTextureCU->getPartitionSize(uiCUIdx) == SIZE_NxN) //Texture was split.
         {
@@ -556,7 +556,11 @@
           {
             if(pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxN || pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnU|| pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnD)
+            {
               bTry2NxN  = true;
+            }
             else
+            {
               bTryNx2N  = true;
+            }
           }
         }
@@ -592,10 +596,13 @@
 #endif 
 #if H_3D_NBDV_REF
-          if( rpcTempCU->getSlice()->getDepthRefinementFlag() )
-            rpcTempCU->getDisMvpCandNBDV(&DvInfo, true);
-          else
+            if( rpcTempCU->getSlice()->getDepthRefinementFlag() )
+            {
+              rpcTempCU->getDisMvpCandNBDV(&DvInfo, true);
+            }
+            else
 #endif 
-            rpcTempCU->getDisMvpCandNBDV(&DvInfo);
-
+            {
+              rpcTempCU->getDisMvpCandNBDV(&DvInfo);
+            }
 #if H_3D_IV_MERGE
           }
@@ -624,36 +631,36 @@
           Bool bICFlag = uiICId ? true : false;
 #endif
-        // 2Nx2N
-        if(m_pcEncCfg->getUseEarlySkipDetection())
-        {
+          // 2Nx2N
+          if(m_pcEncCfg->getUseEarlySkipDetection())
+          {
+#if H_3D_IC
+            rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
+#endif
+#if  H_3D_FAST_TEXTURE_ENCODING
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
+#else
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
+            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
+#endif
+#if H_3D_VSP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#endif
+          }
+          // SKIP
 #if H_3D_IC
           rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
 #endif
+          xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
 #if  H_3D_FAST_TEXTURE_ENCODING
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );//by Competition for inter_2Nx2N
-#else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
-          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
-#endif
+          bFMD = bIVFMerge && rpcBestCU->isSkipped(0);
+#endif
+          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
 #if H_3D_VSP
           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
-        }
-        // SKIP
-#if H_3D_IC
-        rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
-#endif
-        xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N
-#if  H_3D_FAST_TEXTURE_ENCODING
-        bFMD = bIVFMerge && rpcBestCU->isSkipped(0);
-#endif
-        rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-        rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
-#endif
-
-        if(!m_pcEncCfg->getUseEarlySkipDetection())
-        {
-          // 2Nx2N, NxN
+
+          if(!m_pcEncCfg->getUseEarlySkipDetection())
+          {
+            // 2Nx2N, NxN
 #if H_3D_IC
             rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth);
@@ -662,27 +669,26 @@
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD );  rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
 #else
-          xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
-          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
+            xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
+            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
 #endif
 #if H_3D_VSP
             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
-          
+
 #if H_3D_DBBP
-          if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
-          {
-            xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false );
-            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );
+            if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
+            {
+              xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false );
+              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );
 #if H_3D_VSP
-            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
-#endif
-          }
-#endif
-          
+              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#endif
+            }
+#endif
             if(m_pcEncCfg->getUseCbfFastMode())
             {
               doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0;
             }
-        }
+          }
 #if H_3D_IC
         }
@@ -1771,5 +1777,5 @@
   Bool bICFlag = rpcTempCU->getICFlag( 0 );
 #endif
-#if H_3D_VSO // M1  //nececcary here?
+#if H_3D_VSO // M1  //necessary here?
   if( m_pcRdCost->getUseRenModel() )
   {
@@ -1896,14 +1902,14 @@
     {      
 #if H_3D_IC
-        if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() )
+      if( rpcTempCU->getSlice()->getApplyIC() && rpcTempCU->getSlice()->getIcSkipParseFlag() )
+      {
+        if( bICFlag && uiMergeCand == 0 ) 
         {
-          if( bICFlag && uiMergeCand == 0 ) 
-          {
-            continue;
-          }
+          continue;
         }
-#endif
-        if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
-        {
+      }
+#endif
+      if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1))
+      {
         if( !(bestIsSkip && uiNoResidual == 0) )
         {
@@ -1944,67 +1950,67 @@
 #if H_3D_VSP
           {
-          if ( vspFlag[uiMergeCand] )
-          {
-            UInt partAddr;
-            Int vspSize;
-            Int width, height;
-            rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
-            if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
+            if ( vspFlag[uiMergeCand] )
             {
-              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
-              rpcTempCU->setVSPFlag( partAddr, vspSize );
+              UInt partAddr;
+              Int vspSize;
+              Int width, height;
+              rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
+              if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
+              {
+                rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
+                rpcTempCU->setVSPFlag( partAddr, vspSize );
+              }
+              else
+              {
+                rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+              }
+              if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
+              {
+                rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
+                rpcTempCU->setVSPFlag( partAddr, vspSize );
+              }
+              else
+              {
+                rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+              }
+              rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
             }
             else
             {
+#endif
+              rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
               rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+#if H_3D_VSP
             }
-            if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
-            {
-              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
-              rpcTempCU->setVSPFlag( partAddr, vspSize );
-            }
-            else
-            {
-              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-            }
-            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
           }
-          else
+#endif
+          // do MC
+          m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
+          // estimate residual and encode everything
+#if H_3D_VSO //M2
+          if( m_pcRdCost->getUseRenModel() )
+          { //Reset
+            UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
+            UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
+            Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
+            UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
+            m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+          }
+#endif
+          m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
+            m_ppcOrigYuv    [uhDepth],
+            m_ppcPredYuvTemp[uhDepth],
+            m_ppcResiYuvTemp[uhDepth],
+            m_ppcResiYuvBest[uhDepth],
+            m_ppcRecoYuvTemp[uhDepth],
+            (uiNoResidual? true:false));
+
+
+          if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 )
           {
-#endif
-            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
-            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-#if H_3D_VSP
+            // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
+            mergeCandBuffer[uiMergeCand] = 1;
           }
-        }
-#endif
-       // do MC
-       m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
-       // estimate residual and encode everything
-#if H_3D_VSO //M2
-       if( m_pcRdCost->getUseRenModel() )
-       { //Reset
-         UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
-         UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
-         Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
-         UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
-         m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-       }
-#endif
-       m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
-         m_ppcOrigYuv    [uhDepth],
-         m_ppcPredYuvTemp[uhDepth],
-         m_ppcResiYuvTemp[uhDepth],
-         m_ppcResiYuvBest[uhDepth],
-         m_ppcRecoYuvTemp[uhDepth],
-         (uiNoResidual? true:false));
-
-
-          if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 )
-         {
-            // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
-           mergeCandBuffer[uiMergeCand] = 1;
-         }
 
           rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
@@ -2094,53 +2100,53 @@
           rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
 
-      if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
+          if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
+          {
+#if H_3D_INTER_SDC
+            if( rpcTempCU->getSlice()->getInterSdcFlag() )
+            {
+              bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
+            }
+            else
+            {
+#endif
+              bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
+#if H_3D_INTER_SDC
+            }
+#endif
+          }
+        }
+      }
+    }
+
+    if(uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection())
+    {
+      if(rpcBestCU->getQtRootCbf( 0 ) == 0)
       {
-#if H_3D_INTER_SDC
-        if( rpcTempCU->getSlice()->getInterSdcFlag() )
+        if( rpcBestCU->getMergeFlag( 0 ))
         {
-          bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
+          *earlyDetectionSkipMode = true;
         }
         else
         {
-#endif
-        bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
-#if H_3D_INTER_SDC
-        }
-#endif
-      }
-    }
-   }
-  }
-
-  if(uiNoResidual == 0 && m_pcEncCfg->getUseEarlySkipDetection())
-  {
-    if(rpcBestCU->getQtRootCbf( 0 ) == 0)
-    {
-      if( rpcBestCU->getMergeFlag( 0 ))
-      {
-        *earlyDetectionSkipMode = true;
-      }
-      else
-      {
-        Int absoulte_MV=0;
-        for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
-        {
-          if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
+          Int absoulte_MV=0;
+          for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
           {
-            TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
-            Int iHor = pcCUMvField->getMvd( 0 ).getAbsHor();
-            Int iVer = pcCUMvField->getMvd( 0 ).getAbsVer();
-            absoulte_MV+=iHor+iVer;
+            if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 )
+            {
+              TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
+              Int iHor = pcCUMvField->getMvd( 0 ).getAbsHor();
+              Int iVer = pcCUMvField->getMvd( 0 ).getAbsVer();
+              absoulte_MV+=iHor+iVer;
+            }
+          }
+
+          if(absoulte_MV == 0)
+          {
+            *earlyDetectionSkipMode = true;
           }
         }
-
-        if(absoulte_MV == 0)
-        {
-          *earlyDetectionSkipMode = true;
-        }
       }
     }
   }
- }
 #if H_3D_SPIVMP
  delete[] pcMvFieldSP;
@@ -2163,5 +2169,4 @@
 #endif
 {
-
 #if H_3D
   const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
@@ -2171,149 +2176,20 @@
   {
 #endif
-  UChar uhDepth = rpcTempCU->getDepth( 0 );
+    UChar uhDepth = rpcTempCU->getDepth( 0 );
 #if H_3D_ARP
-  Bool bFirstTime = true;
-  Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
-  if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) )
-  {
-    nARPWMax = 0;
-  }
-
-  for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ )
-  {
-    if( !bFirstTime && rpcTempCU->getSlice()->getIvResPredFlag() )
-    {
-      rpcTempCU->initEstData( rpcTempCU->getDepth(0), rpcTempCU->getQP(0),bTransquantBypassFlag );      
-    }
-#endif
-#if H_3D_VSO // M3
-  if( m_pcRdCost->getUseRenModel() )
-  {
-    UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
-    UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
-    Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
-    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
-    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
-  }
-#endif
-
-  rpcTempCU->setDepthSubParts( uhDepth, 0 );
-  
-  rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
-#if H_3D
-  rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
-#endif
-  rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
-  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
-
-#if H_3D_ARP
-  rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-#endif
-
-#if H_3D_ARP
-  if( bFirstTime == false && nARPWMax )
-  {
-    rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
-    rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-
-    m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
-  }
-  else
-  {
-    bFirstTime = false;
-#endif
-#if AMP_MRG
-  rpcTempCU->setMergeAMP (true);
-#if  H_3D_FAST_TEXTURE_ENCODING
-  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG );
-#else
-  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
-#endif
-#else  
-  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
-#endif
-#if H_3D_ARP
-   if( nARPWMax )
-   {
-     m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
-   }
-  }
-#endif
-
-#if AMP_MRG
-  if ( !rpcTempCU->getMergeAMP() )
-  {
-#if H_3D_ARP
-    if( nARPWMax )
-    {
-      continue;
-    }
-    else
-#endif
-    return;
-  }
-#endif
-
-#if KWU_RC_MADPRED_E0227
-  if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
-  {
-    UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
-      m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
-      rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
-    m_temporalSAD = (Int)SAD;
-  }
-#endif
-  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
-#if H_3D_VSP // possible bug fix
-  if( rpcTempCU->getQtRootCbf(0)==0 )
-  {
-    rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
-  }
-#endif
-#if H_3D_VSO // M4
-  if( m_pcRdCost->getUseLambdaScaleVSO() )
-    rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-  else
-#endif
-  rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-#if H_3D_INTER_SDC
-  TComDataCU *rpcTempCUPre = rpcTempCU;
-#endif
-  xCheckDQP( rpcTempCU );
-  xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
-#if H_3D_INTER_SDC
-  if( rpcTempCU->getSlice()->getInterSdcFlag() && ePartSize == SIZE_2Nx2N)
-  {
-    Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
-    for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
-    {
-      if( uiOffest > 3)
+    Bool bFirstTime = true;
+    Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
+    if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) )
+    {
+      nARPWMax = 0;
+    }
+
+    for( Int nARPW = 0; nARPW <= nARPWMax; nARPW++ )
+    {
+      if( !bFirstTime && rpcTempCU->getSlice()->getIvResPredFlag() )
       {
-        if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
-        {
-          continue;
-        }
-        if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
-        {
-          continue;
-        }
-        if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
-        {
-          continue;
-        }
+        rpcTempCU->initEstData( rpcTempCU->getDepth(0), rpcTempCU->getQP(0),bTransquantBypassFlag );      
       }
-
-      if( rpcTempCU != rpcTempCUPre )
-      {
-        Int orgQP = rpcBestCU->getQP( 0 );
-        rpcTempCU->initEstData( uhDepth, orgQP ,bTransquantBypassFlag );      
-        rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
-      }
-      rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
-#if H_3D
-      rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
-#endif
-      rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
-      rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
+#endif
 #if H_3D_VSO // M3
       if( m_pcRdCost->getUseRenModel() )
@@ -2327,33 +2203,160 @@
 #endif
 
-      Int iSdcOffset = 0;
-      if(uiOffest % 2 == 0)
+      rpcTempCU->setDepthSubParts( uhDepth, 0 );
+
+      rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
+#if H_3D
+      rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
+#endif
+      rpcTempCU->setPartSizeSubParts  ( ePartSize,  0, uhDepth );
+      rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
+#if H_3D_ARP
+      rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#endif
+#if H_3D_ARP
+      if( bFirstTime == false && nARPWMax )
       {
-        iSdcOffset = uiOffest >> 1;
+        rpcTempCU->copyPartFrom( m_ppcWeightedTempCU[uhDepth] , 0 , uhDepth );
+        rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+
+        m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
       }
       else
       {
-        iSdcOffset = -1 * (uiOffest >> 1);
+        bFirstTime = false;
+#endif
+#if AMP_MRG
+        rpcTempCU->setMergeAMP (true);
+#if  H_3D_FAST_TEXTURE_ENCODING
+        m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG );
+#else
+        m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
+#endif
+#else  
+        m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
+#endif
+#if H_3D_ARP
+        if( nARPWMax )
+        {
+          m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
+        }
       }
-      m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
-        m_ppcOrigYuv[uhDepth],
-        ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
-        m_ppcResiYuvTemp[uhDepth],
-        m_ppcRecoYuvTemp[uhDepth],
-        iSdcOffset,
-        uhDepth );
-      if (uiOffest <= 3 )
+#endif
+
+#if AMP_MRG
+      if ( !rpcTempCU->getMergeAMP() )
       {
-        dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
+#if H_3D_ARP
+        if( nARPWMax )
+        {
+          continue;
+        }
+        else
+#endif
+          return;
       }
-
+#endif
+
+#if KWU_RC_MADPRED_E0227
+      if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
+      {
+        UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
+          m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
+          rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
+        m_temporalSAD = (Int)SAD;
+      }
+#endif
+      m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
+#if H_3D_VSP // possible bug fix
+      if( rpcTempCU->getQtRootCbf(0)==0 )
+      {
+        rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
+      }
+#endif
+#if H_3D_VSO // M4
+      if( m_pcRdCost->getUseLambdaScaleVSO() )
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCostVSO( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+      else
+#endif
+        rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
+#if H_3D_INTER_SDC
+      TComDataCU *rpcTempCUPre = rpcTempCU;
+#endif
       xCheckDQP( rpcTempCU );
       xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
-    }
-
-  }
+#if H_3D_INTER_SDC
+      if( rpcTempCU->getSlice()->getInterSdcFlag() && ePartSize == SIZE_2Nx2N)
+      {
+        Double dOffsetCost[3] = {MAX_DOUBLE,MAX_DOUBLE,MAX_DOUBLE};
+        for( Int uiOffest = 1 ; uiOffest <= 5 ; uiOffest++ )
+        {
+          if( uiOffest > 3)
+          {
+            if ( dOffsetCost[0] < (0.9*dOffsetCost[1]) && dOffsetCost[0] < (0.9*dOffsetCost[2]) )
+            {
+              continue;
+            }
+            if ( dOffsetCost[1] < dOffsetCost[0] && dOffsetCost[0] < dOffsetCost[2] &&  uiOffest == 5)
+            {
+              continue;
+            }
+            if ( dOffsetCost[0] < dOffsetCost[1] && dOffsetCost[2] < dOffsetCost[0] &&  uiOffest == 4)
+            {
+              continue;
+            }
+          }
+
+          if( rpcTempCU != rpcTempCUPre )
+          {
+            Int orgQP = rpcBestCU->getQP( 0 );
+            rpcTempCU->initEstData( uhDepth, orgQP ,bTransquantBypassFlag );      
+            rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
+          }
+          rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
+#if H_3D
+          rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
+#endif
+          rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
+          rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
+#if H_3D_VSO // M3
+          if( m_pcRdCost->getUseRenModel() )
+          {
+            UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
+            UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
+            Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
+            UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
+            m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+          }
+#endif
+
+          Int iSdcOffset = 0;
+          if(uiOffest % 2 == 0)
+          {
+            iSdcOffset = uiOffest >> 1;
+          }
+          else
+          {
+            iSdcOffset = -1 * (uiOffest >> 1);
+          }
+          m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
+            m_ppcOrigYuv[uhDepth],
+            ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
+            m_ppcResiYuvTemp[uhDepth],
+            m_ppcRecoYuvTemp[uhDepth],
+            iSdcOffset,
+            uhDepth );
+          if (uiOffest <= 3 )
+          {
+            dOffsetCost [uiOffest -1] = rpcTempCU->getTotalCost();
+          }
+
+          xCheckDQP( rpcTempCU );
+          xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+        }
+
+      }
 #endif
 #if H_3D_ARP
-  }
+    }
 #endif
 #if  H_3D_FAST_TEXTURE_ENCODING
@@ -2548,5 +2551,5 @@
   // find optimal motion/disparity vector for each segment
   DisInfo originalDvInfo = rpcTempCU->getDvInfo(0);
-  DBBPTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData();
+  DbbpTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData();
   TComYuv* apPredYuv[2] = { m_ppcRecoYuvTemp[uhDepth], m_ppcPredYuvTemp[uhDepth] };
   
@@ -2629,4 +2632,5 @@
 }
 #endif
+
 #if H_3D_DIM
 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize, Bool bOnlyIVP )
@@ -2670,5 +2674,5 @@
   if( !rpcTempCU->getSDCFlag( 0 ) )
 #endif
-  m_pcPredSearch  ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC );
+    m_pcPredSearch  ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC );
   
   m_pcEntropyCoder->resetBits();
@@ -2683,22 +2687,20 @@
   {
 #endif
-  m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
-  m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
-  m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0,          true );
-  m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
+    m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
+    m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
+    m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0,          true );
+    m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
 #if H_3D_DIM_SDC
-  m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
-#endif
-
-  // Encode Coefficients
-  Bool bCodeDQP = getdQPFlag();
+    m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
+#endif
+
+    // Encode Coefficients
+    Bool bCodeDQP = getdQPFlag();
 #if H_3D_DISABLE_CHROMA
-  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP, true );
-#else
-  m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
-#endif
-
-
-  setdQPFlag( bCodeDQP );
+    m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP, true );
+#else
+    m_pcEntropyCoder->encodeCoeff( rpcTempCU, 0, uiDepth, rpcTempCU->getWidth (0), rpcTempCU->getHeight(0), bCodeDQP );
+#endif
+    setdQPFlag( bCodeDQP );
 #if H_3D
   }
@@ -2707,5 +2709,5 @@
   
   rpcTempCU->getTotalBits() = m_pcEntropyCoder->getNumberOfWrittenBits();
-    rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
+  rpcTempCU->getTotalBins() = ((TEncBinCABAC *)((TEncSbac*)m_pcEntropyCoder->m_pcEntropyCoderIf)->getEncBinIf())->getBinsCoded();
 #if H_3D_VSO // M6
   if( m_pcRdCost->getUseLambdaScaleVSO())  
Index: branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1187)
@@ -561,5 +561,5 @@
 #endif
 #endif
-    encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD );
+      encodeIntraDirModeChroma( pcCU, uiAbsPartIdx, bRD );
   }
   else                                                                // if it is Inter mode, encode motion vector and reference index
Index: branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1187)
@@ -255,11 +255,11 @@
       curCost += m_CUTransquantBypassFlagSCModel.calcCost( curSliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
 #if H_3D_DIM
-    if( m_pcSlice->getIntraSdcWedgeFlag() || m_pcSlice->getIntraContourFlag() )
-    {
-      curCost += m_cDepthIntraModeSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE );
-      curCost += m_cDdcFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_FLAG );
-      curCost += m_cDdcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
-      curCost += m_cAngleFlagSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG );  
-    }
+      if( m_pcSlice->getIntraSdcWedgeFlag() || m_pcSlice->getIntraContourFlag() )
+      {
+        curCost += m_cDepthIntraModeSCModel.calcCost    ( curSliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE );
+        curCost += m_cDdcFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_FLAG );
+        curCost += m_cDdcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
+        curCost += m_cAngleFlagSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG );  
+      }
 #endif
       if (curCost < bestCost)
@@ -626,5 +626,5 @@
   Bool bDepthMapDetect   = (pcTexture != NULL);
   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
- 
+
   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
 
@@ -664,5 +664,5 @@
     return;
   }
-  
+
 #if H_MV_ENC_DEC_TRAC          
   DTRACE_CU("part_mode", eSize )
@@ -672,70 +672,70 @@
     {
 #endif
-  switch(eSize)
-  {
-    case SIZE_2Nx2N:
-    {
-      m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
-      break;
-    }
-    case SIZE_2NxN:
-    case SIZE_2NxnU:
-    case SIZE_2NxnD:
-    {
-      m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
-      m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
-      if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
-      {
-        if (eSize == SIZE_2NxN)
-        {
-          m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-        }
-        else
-        {
-          m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-          m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
-        }
-      }
-      break;
-    }
-    case SIZE_Nx2N:
-    case SIZE_nLx2N:
-    case SIZE_nRx2N:
-    {
-      m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
-      m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
-      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) )
-      {
-        m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 2) );
-      }
-      if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
-      {
-        if (eSize == SIZE_Nx2N)
-        {
-          m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-        }
-        else
-        {
-          m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
-          m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
-        }
-      }
-      break;
-    }
-    case SIZE_NxN:
-    {
-      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) )
-      {
-        m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
-        m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
-        m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) );
-      }
-      break;
-    }
-    default:
-    {
-      assert(0);
-    }
-  }
+      switch(eSize)
+      {
+      case SIZE_2Nx2N:
+        {
+          m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          break;
+        }
+      case SIZE_2NxN:
+      case SIZE_2NxnU:
+      case SIZE_2NxnD:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+          {
+            if (eSize == SIZE_2NxN)
+            {
+              m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+            }
+            else
+            {
+              m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+              m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
+            }
+          }
+          break;
+        }
+      case SIZE_Nx2N:
+      case SIZE_nLx2N:
+      case SIZE_nRx2N:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) )
+          {
+            m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 2) );
+          }
+          if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+          {
+            if (eSize == SIZE_Nx2N)
+            {
+              m_pcBinIf->encodeBin(1, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+            }
+            else
+            {
+              m_pcBinIf->encodeBin(0, m_cCUPartSizeSCModel.get( 0, 0, 3 ));
+              m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
+            }
+          }
+          break;
+        }
+      case SIZE_NxN:
+        {
+          if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getWidth(uiAbsPartIdx) == 8 && pcCU->getHeight(uiAbsPartIdx) == 8 ) )
+          {
+            m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+            m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+            m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 2) );
+          }
+          break;
+        }
+      default:
+        {
+          assert(0);
+        }
+      }
 #if H_3D_QTLPC
     }
@@ -1089,38 +1089,38 @@
     {
 #endif
-    if(predIdx[j] != -1)
-    {
-      m_pcBinIf->encodeBinEP( predIdx[j] ? 1 : 0 );
-      if (predIdx[j])
-      {
-        m_pcBinIf->encodeBinEP( predIdx[j]-1 );
-      }
+      if(predIdx[j] != -1)
+      {
+        m_pcBinIf->encodeBinEP( predIdx[j] ? 1 : 0 );
+        if (predIdx[j])
+        {
+          m_pcBinIf->encodeBinEP( predIdx[j]-1 );
+        }
 #if H_MV_ENC_DEC_TRAC
-      DTRACE_CU("mpm_idx", predIdx[j] ); 
-#endif
-    }
-    else
-    {
-      if (preds[j][0] > preds[j][1])
-      { 
-        std::swap(preds[j][0], preds[j][1]); 
-      }
-      if (preds[j][0] > preds[j][2])
-      {
-        std::swap(preds[j][0], preds[j][2]);
-      }
-      if (preds[j][1] > preds[j][2])
-      {
-        std::swap(preds[j][1], preds[j][2]);
-      }
-      for(Int i = (predNum[j] - 1); i >= 0; i--)
-      {
-        dir[j] = dir[j] > preds[j][i] ? dir[j] - 1 : dir[j];
-      }
-      m_pcBinIf->encodeBinsEP( dir[j], 5 );
+        DTRACE_CU("mpm_idx", predIdx[j] ); 
+#endif
+      }
+      else
+      {
+        if (preds[j][0] > preds[j][1])
+        { 
+          std::swap(preds[j][0], preds[j][1]); 
+        }
+        if (preds[j][0] > preds[j][2])
+        {
+          std::swap(preds[j][0], preds[j][2]);
+        }
+        if (preds[j][1] > preds[j][2])
+        {
+          std::swap(preds[j][1], preds[j][2]);
+        }
+        for(Int i = (predNum[j] - 1); i >= 0; i--)
+        {
+          dir[j] = dir[j] > preds[j][i] ? dir[j] - 1 : dir[j];
+        }
+        m_pcBinIf->encodeBinsEP( dir[j], 5 );
 #if H_MV_ENC_DEC_TRAC
-      DTRACE_CU("rem_intra_luma_pred_mode", dir[j] ); 
-#endif
-    }
+        DTRACE_CU("rem_intra_luma_pred_mode", dir[j] ); 
+#endif
+      }
 #if H_3D_DIM
     }
@@ -1467,35 +1467,35 @@
     {    
 #endif
-    piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;
-    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
-    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
-    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
-
-    for(uiY = 0; uiY < uiHeight; uiY++)
-    {
-      for(uiX = 0; uiX < uiWidth; uiX++)
-      {
-        UInt uiSample = piPCMSample[uiX];
-
-        m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits);
-      }
-      piPCMSample += uiWidth;
-    }
-
-    piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;
-    uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
-    uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
-    uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
-
-    for(uiY = 0; uiY < uiHeight; uiY++)
-    {
-      for(uiX = 0; uiX < uiWidth; uiX++)
-      {
-        UInt uiSample = piPCMSample[uiX];
-
-        m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits);
-      }
-      piPCMSample += uiWidth;
-    }
+      piPCMSample = pcCU->getPCMSampleCb() + uiChromaOffset;
+      uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
+      uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
+      uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
+
+      for(uiY = 0; uiY < uiHeight; uiY++)
+      {
+        for(uiX = 0; uiX < uiWidth; uiX++)
+        {
+          UInt uiSample = piPCMSample[uiX];
+
+          m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits);
+        }
+        piPCMSample += uiWidth;
+      }
+
+      piPCMSample = pcCU->getPCMSampleCr() + uiChromaOffset;
+      uiWidth = pcCU->getWidth(uiAbsPartIdx)/2;
+      uiHeight = pcCU->getHeight(uiAbsPartIdx)/2;
+      uiSampleBits = pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
+
+      for(uiY = 0; uiY < uiHeight; uiY++)
+      {
+        for(uiX = 0; uiX < uiWidth; uiX++)
+        {
+          UInt uiSample = piPCMSample[uiX];
+
+          m_pcBinIf->xWritePCMCode(uiSample, uiSampleBits);
+        }
+        piPCMSample += uiWidth;
+      }
 #if H_3D_DISABLE_CHROMA
     }
Index: branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1186)
+++ branches/HTM-14.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1187)
@@ -976,5 +976,5 @@
           {
             m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiPart * uiQNumParts );
-#if H_3D_SDC
+#if H_3D_DIM_SDC
           }
           m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
@@ -2211,5 +2211,5 @@
   // encode pred direction + DC residual data
   m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
-#if H_3D_SDC
+#if H_3D_DIM_SDC
   m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
 #endif
@@ -3016,5 +3016,5 @@
     pcCU->getPattern()->initPattern   ( pcCU, uiInitTrDepth, uiPartOffset );
     pcCU->getPattern()->initAdiPattern( pcCU, uiPartOffset, uiInitTrDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
-    
+
     //===== determine set of modes to be tested (using prediction signal only) =====
     Int numModesAvailable     = 35; //total number of Intra modes
@@ -3024,5 +3024,5 @@
     UInt uiRdModeList[FAST_UDI_MAX_RDMODE_NUM];
     Int numModesForFullRD = g_aucIntraModeNumFast[ uiWidthBit ];
-    
+
 #if H_3D_DIM
     if( bOnlyIVP )
@@ -3033,99 +3033,99 @@
     {
 #endif
-    Bool doFastSearch = (numModesForFullRD != numModesAvailable);
-    if (doFastSearch)
-    {
-      assert(numModesForFullRD < numModesAvailable);
-
-      for( Int i=0; i < numModesForFullRD; i++ ) 
-      {
-        CandCostList[ i ] = MAX_DOUBLE;
-      }
-      CandNum = 0;
-      
-      for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
-      {
-        UInt uiMode = modeIdx;
-
-        predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
+      Bool doFastSearch = (numModesForFullRD != numModesAvailable);
+      if (doFastSearch)
+      {
+        assert(numModesForFullRD < numModesAvailable);
+
+        for( Int i=0; i < numModesForFullRD; i++ ) 
+        {
+          CandCostList[ i ] = MAX_DOUBLE;
+        }
+        CandNum = 0;
+
+        for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
+        {
+          UInt uiMode = modeIdx;
+
+          predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
 #if H_3D_VSO // M34
-        Dist uiSad; 
-        if ( m_pcRdCost->getUseVSO() )
-        {
-          if ( m_pcRdCost->getUseEstimatedVSD() )
-          {          
-            uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true ) );
+          Dist uiSad; 
+          if ( m_pcRdCost->getUseVSO() )
+          {
+            if ( m_pcRdCost->getUseEstimatedVSD() )
+            {          
+              uiSad = (Dist) ( m_pcRdCost->getDistPartVSD( pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true ) );
+            }
+            else
+            {    
+              uiSad = m_pcRdCost->getDistPartVSO(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true );
+            }
           }
           else
-          {    
-            uiSad = m_pcRdCost->getDistPartVSO(pcCU, uiPartOffset, piPred, uiStride, piOrg, uiStride, uiWidth, uiHeight, true );
+          {
+            uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
           }
-        }
-        else
-        {
-          uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
-        }
 #else        
-        // use hadamard transform here
-        UInt uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
-#endif
-        
-        UInt   iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth );
+          // use hadamard transform here
+          UInt uiSad = m_pcRdCost->calcHAD(g_bitDepthY, piOrg, uiStride, piPred, uiStride, uiWidth, uiHeight );
+#endif
+
+          UInt   iModeBits = xModeBitsIntra( pcCU, uiMode, uiPU, uiPartOffset, uiDepth, uiInitTrDepth );
 #if H_3D_VSO // M35
-        Double dLambda;
-        if ( m_pcRdCost->getUseLambdaScaleVSO() )
-        {
-          dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
-        }
-        else        
-        {
-          dLambda = m_pcRdCost->getSqrtLambda();        
-        }
-
-        Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
+          Double dLambda;
+          if ( m_pcRdCost->getUseLambdaScaleVSO() )
+          {
+            dLambda = m_pcRdCost->getUseRenModel() ? m_pcRdCost->getLambdaVSO() : m_pcRdCost->getSqrtLambdaVSO();
+          }
+          else        
+          {
+            dLambda = m_pcRdCost->getSqrtLambda();        
+          }
+
+          Double cost      = (Double)uiSad + (Double)iModeBits * dLambda;
 #else
-        Double cost      = (Double)uiSad + (Double)iModeBits * m_pcRdCost->getSqrtLambda();
-#endif
-        
-        CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
-      }
-    
+          Double cost      = (Double)uiSad + (Double)iModeBits * m_pcRdCost->getSqrtLambda();
+#endif
+
+          CandNum += xUpdateCandList( uiMode, cost, numModesForFullRD, uiRdModeList, CandCostList );
+        }
+
 #if FAST_UDI_USE_MPM
-      Int uiPreds[3] = {-1, -1, -1};
-      Int iMode = -1;
-      Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode );
-      if( iMode >= 0 )
-      {
-        numCand = iMode;
-      }
-      
-      for( Int j=0; j < numCand; j++)
-
-      {
-        Bool mostProbableModeIncluded = false;
-        Int mostProbableMode = uiPreds[j];
-        
+        Int uiPreds[3] = {-1, -1, -1};
+        Int iMode = -1;
+        Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode );
+        if( iMode >= 0 )
+        {
+          numCand = iMode;
+        }
+
+        for( Int j=0; j < numCand; j++)
+
+        {
+          Bool mostProbableModeIncluded = false;
+          Int mostProbableMode = uiPreds[j];
+
+          for( Int i=0; i < numModesForFullRD; i++)
+          {
+            mostProbableModeIncluded |= (mostProbableMode == uiRdModeList[i]);
+          }
+          if (!mostProbableModeIncluded)
+          {
+            uiRdModeList[numModesForFullRD++] = mostProbableMode;
+          }
+        }
+#endif // FAST_UDI_USE_MPM
+      }
+      else
+      {
         for( Int i=0; i < numModesForFullRD; i++)
         {
-          mostProbableModeIncluded |= (mostProbableMode == uiRdModeList[i]);
-        }
-        if (!mostProbableModeIncluded)
-        {
-          uiRdModeList[numModesForFullRD++] = mostProbableMode;
-        }
-      }
-#endif // FAST_UDI_USE_MPM
-    }
-    else
-    {
-      for( Int i=0; i < numModesForFullRD; i++)
-      {
-        uiRdModeList[i] = i;
-      }
-    }
+          uiRdModeList[i] = i;
+        }
+      }
 #if H_3D_DIM
     }
 #endif
-    
+
 #if H_3D_DIM
     //===== determine set of depth intra modes to be tested =====
@@ -3148,39 +3148,39 @@
       {
 #if H_3D_FAST_DEPTH_INTRA
-      Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
-      Int  varThreshold = (Int)( threshold * threshold - 8 );
-      UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
+        Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
+        Int  varThreshold = (Int)( threshold * threshold - 8 );
+        UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
 #endif
 
 #if H_3D_DIM_DMM
-      if( ( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() )  || pcCU->getSlice()->getIntraContourFlag() )
+        if( ( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() )  || pcCU->getSlice()->getIntraContourFlag() )
 #if H_3D_FAST_DEPTH_INTRA
-         && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold)
-#endif
-        )
-      {
-        UInt uiStart, uiEnd;
-        if( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) &&  pcCU->getSlice()->getIntraContourFlag() )
-        {
-          uiStart = 0;
-          uiEnd   = 2;
-        }
-        else if( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
-        {
-          uiStart = 0;
-          uiEnd   = 1;
-        }
-        else if( pcCU->getSlice()->getIntraContourFlag() )
-        {
-          uiStart = 1;
-          uiEnd   = 2;
-        }
-        else
-        {
-          uiStart = 0;
-          uiEnd   = 0;
-        }
-        for( UInt dmmType = uiStart; dmmType < uiEnd; dmmType++ )
-        {
+          && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold)
+#endif
+          )
+        {
+          UInt uiStart, uiEnd;
+          if( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) &&  pcCU->getSlice()->getIntraContourFlag() )
+          {
+            uiStart = 0;
+            uiEnd   = 2;
+          }
+          else if( ( m_pcEncCfg->getUseDMM() &&  pcCU->getSlice()->getIntraSdcWedgeFlag() ) )
+          {
+            uiStart = 0;
+            uiEnd   = 1;
+          }
+          else if( pcCU->getSlice()->getIntraContourFlag() )
+          {
+            uiStart = 1;
+            uiEnd   = 2;
+          }
+          else
+          {
+            uiStart = 0;
+            uiEnd   = 0;
+          }
+          for( UInt dmmType = uiStart; dmmType < uiEnd; dmmType++ )
+          {
 #if H_3D_FCO
             TComPic* picTexture  = pcCU->getSlice()->getIvPic(false, pcCU->getSlice()->getViewIndex() );
@@ -3191,47 +3191,47 @@
 #endif
             {
-                continue;
+              continue;
             }
 #endif
-          UInt uiTabIdx = 0;
-          TComWedgelet* biSegmentation = NULL;
-          Pel deltaDC1 = 0; Pel deltaDC2 = 0;
-          switch( dmmType )
-          {
-          case( DMM1_IDX ):
+            UInt uiTabIdx = 0;
+            TComWedgelet* biSegmentation = NULL;
+            Pel deltaDC1 = 0; Pel deltaDC2 = 0;
+            switch( dmmType )
             {
-              xSearchDmm1Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx );
-              pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType,  uiPartOffset, uiDepth + uiInitTrDepth );
-              biSegmentation = pcCU->isDMM1UpscaleMode( uiWidth ) ? 
+            case( DMM1_IDX ):
+              {
+                xSearchDmm1Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx );
+                pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType,  uiPartOffset, uiDepth + uiInitTrDepth );
+                biSegmentation = pcCU->isDMM1UpscaleMode( uiWidth ) ? 
                   &(g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])][uiTabIdx]) : &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
-            } break;
-
-          case( DMM4_IDX ):
+              } break;
+
+            case( DMM4_IDX ):
+              {
+                {
+                  biSegmentation = new TComWedgelet( uiWidth, uiHeight );
+                  xPredContourFromTex( pcCU, uiPartOffset, uiWidth, uiHeight, biSegmentation );
+                }
+              } break;
+            default: assert(0);
+            }
+
+            if( biSegmentation )
             {
+              if( dmmType == DMM1_IDX && pcCU->isDMM1UpscaleMode( uiWidth ) ){
+                xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getScaledPattern(uiWidth), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
+              } 
+              else
               {
-                biSegmentation = new TComWedgelet( uiWidth, uiHeight );
-                xPredContourFromTex( pcCU, uiPartOffset, uiWidth, uiHeight, biSegmentation );
+                xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getPattern(), biSegmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 );
               }
-            } break;
-          default: assert(0);
+              pcCU->setDimDeltaDC( dmmType, 0, uiPartOffset, deltaDC1 );
+              pcCU->setDimDeltaDC( dmmType, 1, uiPartOffset, deltaDC2 );
+
+              uiRdModeList[ numModesForFullRD++ ] = (dmmType  +DIM_OFFSET);
+              if( DMM4_IDX == dmmType ) { biSegmentation->destroy(); delete biSegmentation; }
+            }
           }
-
-          if( biSegmentation )
-          {
-            if( dmmType == DMM1_IDX && pcCU->isDMM1UpscaleMode( uiWidth ) ){
-                xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getScaledPattern(uiWidth), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
-            } 
-            else
-            {
-                xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, biSegmentation->getPattern(), biSegmentation->getStride(), uiWidth, uiHeight, deltaDC1, deltaDC2 );
-            }
-            pcCU->setDimDeltaDC( dmmType, 0, uiPartOffset, deltaDC1 );
-            pcCU->setDimDeltaDC( dmmType, 1, uiPartOffset, deltaDC2 );
-
-            uiRdModeList[ numModesForFullRD++ ] = (dmmType  +DIM_OFFSET);
-            if( DMM4_IDX == dmmType ) { biSegmentation->destroy(); delete biSegmentation; }
-          }
-        }
-      }
+        }
 #if H_3D_DIM
       }
@@ -3245,5 +3245,5 @@
     Double dSecondBestPUCost = MAX_DOUBLE;
 #endif
-    
+
     UInt    uiBestPUMode  = 0;
 #if H_3D_FAST_INTRA_SDC
@@ -3279,32 +3279,32 @@
       // set luma prediction mode
 #if !H_3D_FAST_INTRA_SDC
-     UInt uiOrgMode = uiRdModeList[uiMode];  
-#endif
-      
+      UInt uiOrgMode = uiRdModeList[uiMode];  
+#endif
+
 #if H_3D_FAST_INTRA_SDC
       UInt uiOrgMode;
       if (uiMode < numModesForFullRD)
       {   
-         uiOrgMode = uiRdModeList[uiMode];
+        uiOrgMode = uiRdModeList[uiMode];
       }
       else
       {
-           uiOrgMode = uiRdModeList[uiMode - numModesForFullRD];
-
-           if (uiBestPUModeConv <= 1 )
-           {
-           if (uiOrgMode > 1 && varCU < 1) continue;          
-           }
-           else
-           {
-              if (uiOrgMode != uiBestPUModeConv && uiOrgMode != uiSecondBestPUModeConv && uiOrgMode != uiThirdBestPUModeConv 
-                  && uiOrgMode > 1 && uiOrgMode < NUM_INTRA_MODE && varCU < 4) 
-              continue;
-           }
-       }
+        uiOrgMode = uiRdModeList[uiMode - numModesForFullRD];
+
+        if (uiBestPUModeConv <= 1 )
+        {
+          if (uiOrgMode > 1 && varCU < 1) continue;          
+        }
+        else
+        {
+          if (uiOrgMode != uiBestPUModeConv && uiOrgMode != uiSecondBestPUModeConv && uiOrgMode != uiThirdBestPUModeConv 
+            && uiOrgMode > 1 && uiOrgMode < NUM_INTRA_MODE && varCU < 4) 
+            continue;
+        }
+      }
 #endif
 
       pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
-      
+
 #if H_3D_DIM_SDC
 #if H_3D_FAST_INTRA_SDC
@@ -3313,5 +3313,5 @@
       Bool bTestSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getSDCAvailable(uiPartOffset) );
 #endif
-      
+
       for( UInt uiSDC=0; uiSDC<=(bTestSDC?1:0); uiSDC++ )
       {
@@ -3352,133 +3352,133 @@
           }
 #endif
-      
+
 #if H_3D_DIM_ENC || H_3D_DIM_SDC
-      Bool bTestZeroResi = false;
+          Bool bTestZeroResi = false;
 #if H_3D_DIM_ENC
-      bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP();
+          bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP();
 #endif
 #if H_3D_DIM_SDC
-      bTestZeroResi |= pcCU->getSDCFlag(uiPartOffset);
-#endif
-      if( uiSDC != 0 && iSDCDeltaResi != 0 )
-      {
-        bTestZeroResi = false;
-      }
-#endif
-      
+          bTestZeroResi |= pcCU->getSDCFlag(uiPartOffset);
+#endif
+          if( uiSDC != 0 && iSDCDeltaResi != 0 )
+          {
+            bTestZeroResi = false;
+          }
+#endif
+
 #if H_3D_DIM_ENC || H_3D_DIM_SDC      
-      for( UInt testZeroResi = 0; testZeroResi <= (bTestZeroResi ? 1 : 0) ; testZeroResi++ )
-      {
-#endif
-        // set context models
-        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
-
-        // determine residual for partition
+          for( UInt testZeroResi = 0; testZeroResi <= (bTestZeroResi ? 1 : 0) ; testZeroResi++ )
+          {
+#endif
+            // set context models
+            m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
+
+            // determine residual for partition
 #if H_3D_VSO
-        Dist   uiPUDistY = 0;
+            Dist   uiPUDistY = 0;
 #else
-        UInt   uiPUDistY = 0;
-#endif
-        UInt   uiPUDistC = 0;
-        Double dPUCost   = 0.0;
+            UInt   uiPUDistY = 0;
+#endif
+            UInt   uiPUDistC = 0;
+            Double dPUCost   = 0.0;
 #if H_3D_VSO // M36
-        if( m_pcRdCost->getUseRenModel() )
-        {
-          m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
-        }
+            if( m_pcRdCost->getUseRenModel() )
+            {
+              m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
+            }
 #endif
 #if H_3D_DIM_SDC
-        if( pcCU->getSDCFlag(uiPartOffset) )
-        {
-          pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
-          pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
-
-          // start encoding with SDC
-          xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( testZeroResi != 0 ), iSDCDeltaResi );
-          if ( testZeroResi == 0 && iOffset <= 3 )
-          {
-            dOffsetCost [iOffset -1] = dPUCost;
-          }
-        }
-        else
-        {
+            if( pcCU->getSDCFlag(uiPartOffset) )
+            {
+              pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
+              pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
+
+              // start encoding with SDC
+              xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( testZeroResi != 0 ), iSDCDeltaResi );
+              if ( testZeroResi == 0 && iOffset <= 3 )
+              {
+                dOffsetCost [iOffset -1] = dPUCost;
+              }
+            }
+            else
+            {
 #endif
 #if HHI_RQT_INTRA_SPEEDUP
 #if H_3D_DIM_ENC
-          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, (testZeroResi != 0) );
+              xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost, (testZeroResi != 0) );
 #if H_3D_FAST_INTRA_SDC    
-      if( dPUCost < dBestPUCostConv )
-      {
-        uiThirdBestPUModeConv = uiSecondBestPUModeConv;
-        uiSecondBestPUModeConv = uiBestPUModeConv;
-        uiBestPUModeConv  = uiOrgMode;
-        dBestPUCostConv   = dPUCost;
-      }
+              if( dPUCost < dBestPUCostConv )
+              {
+                uiThirdBestPUModeConv = uiSecondBestPUModeConv;
+                uiSecondBestPUModeConv = uiBestPUModeConv;
+                uiBestPUModeConv  = uiOrgMode;
+                dBestPUCostConv   = dPUCost;
+              }
 #endif
 #else
-          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
+              xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, true, dPUCost );
 #endif
 #else
 #if H_3D_DIM_ENC
-          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost, (testZeroResi != 0) );
+              xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost, (testZeroResi != 0) );
 #else
-          xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
+              xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
 #endif
 #endif
 #if H_3D_DIM_SDC
-        }
-#endif
-
-        // check r-d cost
-        if( dPUCost < dBestPUCost )
-        {
+            }
+#endif
+
+            // check r-d cost
+            if( dPUCost < dBestPUCost )
+            {
 #if HHI_RQT_INTRA_SPEEDUP_MOD
-          uiSecondBestMode  = uiBestPUMode;
-          dSecondBestPUCost = dBestPUCost;
-#endif
-          uiBestPUMode  = uiOrgMode;
-          uiBestPUDistY = uiPUDistY;
-          uiBestPUDistC = uiPUDistC;
-          dBestPUCost   = dPUCost;
+              uiSecondBestMode  = uiBestPUMode;
+              dSecondBestPUCost = dBestPUCost;
+#endif
+              uiBestPUMode  = uiOrgMode;
+              uiBestPUDistY = uiPUDistY;
+              uiBestPUDistC = uiPUDistC;
+              dBestPUCost   = dPUCost;
 
 #if H_3D_DIM_SDC
-          if( pcCU->getSDCFlag(uiPartOffset) )
-          {
-            bBestUseSDC = true;
-
-            // copy reconstruction
-            pcPredYuv->copyPartToPartYuv(pcRecoYuv, uiPartOffset, uiWidth, uiHeight);
-
-            // copy DC values
-            apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset);
-            apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset);
+              if( pcCU->getSDCFlag(uiPartOffset) )
+              {
+                bBestUseSDC = true;
+
+                // copy reconstruction
+                pcPredYuv->copyPartToPartYuv(pcRecoYuv, uiPartOffset, uiWidth, uiHeight);
+
+                // copy DC values
+                apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset);
+                apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset);
+              }
+              else
+              {
+                bBestUseSDC = false;
+#endif
+                xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
+
+                UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
+                ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempTransformSkipFlag[0], pcCU->getTransformSkip(TEXT_LUMA)     + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempTransformSkipFlag[1], pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+                ::memcpy( m_puhQTTempTransformSkipFlag[2], pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+#if H_3D_DIM_SDC
+              }
+#endif
+            }
+#if HHI_RQT_INTRA_SPEEDUP_MOD
+            else if( dPUCost < dSecondBestPUCost )
+            {
+              uiSecondBestMode  = uiOrgMode;
+              dSecondBestPUCost = dPUCost;
+            }
+#endif
+#if H_3D_DIM_ENC || H_3D_DIM_SDC
           }
-          else
-          {
-            bBestUseSDC = false;
-#endif
-            xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
-
-            UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
-            ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempTransformSkipFlag[0], pcCU->getTransformSkip(TEXT_LUMA)     + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempTransformSkipFlag[1], pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-            ::memcpy( m_puhQTTempTransformSkipFlag[2], pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-#if H_3D_DIM_SDC
-          }
-#endif
-        }
-#if HHI_RQT_INTRA_SPEEDUP_MOD
-        else if( dPUCost < dSecondBestPUCost )
-        {
-          uiSecondBestMode  = uiOrgMode;
-          dSecondBestPUCost = dPUCost;
-        }
-#endif
-#if H_3D_DIM_ENC || H_3D_DIM_SDC
-      }
         } // SDC residual loop
 #endif
@@ -3487,5 +3487,5 @@
 #endif
     } // Mode loop
-    
+
 #if HHI_RQT_INTRA_SPEEDUP
 #if HHI_RQT_INTRA_SPEEDUP_MOD
@@ -3502,13 +3502,13 @@
       UInt uiOrgMode = uiBestPUMode;
 #endif
-      
+
       pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
 #if H_3D_DIM_SDC
       pcCU->setSDCFlagSubParts(false, uiPartOffset, uiDepth + uiInitTrDepth);
 #endif
-      
+
       // set context models
-        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
-      
+      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
+
       // determine residual for partition
 #if H_3D_VSO
@@ -3527,5 +3527,5 @@
 #endif
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost );
-      
+
       // check r-d cost
       if( dPUCost < dBestPUCost )
@@ -3538,7 +3538,7 @@
         bBestUseSDC   = false;
 #endif
-        
+
         xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
-        
+
         UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
         ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
@@ -3552,9 +3552,9 @@
     } // Mode loop
 #endif
-    
+
     //--- update overall distortion ---
     uiOverallDistY += uiBestPUDistY;
     uiOverallDistC += uiBestPUDistC;
-    
+
 #if H_3D_DIM_SDC
     if( bBestUseSDC )
@@ -3562,5 +3562,5 @@
       pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
       pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
-      
+
       //=== copy best DC segment values back to CU ====
       pcCU->setSDCSegmentDCOffset(apBestDCOffsets[0], 0, uiPartOffset);
@@ -3570,13 +3570,13 @@
     {
 #endif
-        //--- update transform index and cbf ---
-    UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
-    ::memcpy( pcCU->getTransformIdx()       + uiPartOffset, m_puhQTTempTrIdx,  uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, m_puhQTTempCbf[0], uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, m_puhQTTempCbf[1], uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, m_puhQTTempCbf[2], uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getTransformSkip(TEXT_LUMA)     + uiPartOffset, m_puhQTTempTransformSkipFlag[0], uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhQTTempTransformSkipFlag[1], uiQPartNum * sizeof( UChar ) );
-    ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhQTTempTransformSkipFlag[2], uiQPartNum * sizeof( UChar ) );
+      //--- update transform index and cbf ---
+      UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
+      ::memcpy( pcCU->getTransformIdx()       + uiPartOffset, m_puhQTTempTrIdx,  uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, m_puhQTTempCbf[0], uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, m_puhQTTempCbf[1], uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, m_puhQTTempCbf[2], uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getTransformSkip(TEXT_LUMA)     + uiPartOffset, m_puhQTTempTransformSkipFlag[0], uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_U) + uiPartOffset, m_puhQTTempTransformSkipFlag[1], uiQPartNum * sizeof( UChar ) );
+      ::memcpy( pcCU->getTransformSkip(TEXT_CHROMA_V) + uiPartOffset, m_puhQTTempTransformSkipFlag[2], uiQPartNum * sizeof( UChar ) );
 #if H_3D_DIM_SDC
     }
@@ -3594,5 +3594,5 @@
         bChromaSame  = true;
       }
-      
+
       UInt    uiCompWidth   = pcCU->getWidth ( 0 ) >> uiInitTrDepth;
       UInt    uiCompHeight  = pcCU->getHeight( 0 ) >> uiInitTrDepth;
@@ -3646,5 +3646,5 @@
       }
     }
-    
+
     //=== update PU data ====
     pcCU->setLumaIntraDirSubParts     ( uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth );
@@ -3974,5 +3974,5 @@
   
 #if H_3D_DBBP
-  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+  DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
   if( pcCU->getDBBPFlag(0) )
   {
@@ -4964,5 +4964,5 @@
   {
 #if H_3D_DBBP
-    DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+    DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
     if( pcCU->getDBBPFlag(0) )
     {
@@ -5326,5 +5326,5 @@
   
 #if H_MV
-  Bool bMv_VRng_Restricted = false;
+  Bool motVecVertRngRestricted = false;
   if( m_pcEncCfg->getUseDisparitySearchRangeRestriction()
        &&
@@ -5332,8 +5332,8 @@
     )
   {
-      bMv_VRng_Restricted = true;
-  }
-  if ( bBi )  xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB, bMv_VRng_Restricted, m_pcEncCfg->getVerticalDisparitySearchRange() );
-  else        xSetSearchRange   ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, bMv_VRng_Restricted, m_pcEncCfg->getVerticalDisparitySearchRange() );
+      motVecVertRngRestricted = true;
+  }
+  if ( bBi )  xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB, motVecVertRngRestricted, m_pcEncCfg->getVerticalDisparitySearchRange() );
+  else        xSetSearchRange   ( pcCU, cMvPred, iSrchRng, cMvSrchRngLT, cMvSrchRngRB, motVecVertRngRestricted, m_pcEncCfg->getVerticalDisparitySearchRange() );
 #else
   if ( bBi )  xSetSearchRange   ( pcCU, rcMv   , iSrchRng, cMvSrchRngLT, cMvSrchRngRB );
@@ -5523,5 +5523,5 @@
   if( ! pcCU->getSlice()->getIsDepth() )
 #endif
-  rcMv >>= 2;
+    rcMv >>= 2;
   // init TZSearchStruct
   IntTZSearchStruct cStruct;
