Index: branches/HTM-14.1-update-dev2/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 1274)
@@ -2287,5 +2287,5 @@
 
   dimBitOffset[ 0 ] = 0; 
-  for (Int j = 1; j <= ((Int) m_dimIds.size() - m_splittingFlag ? 1 : 0); j++ )
+  for (Int j = 1; j <= (((Int) m_dimIds.size() - m_splittingFlag) ? 1 : 0); j++ )
   {
     dimBitOffset[ j ] = dimBitOffset[ j - 1 ] + m_dimensionIdLen[ j - 1]; 
Index: branches/HTM-14.1-update-dev2/source/App/TAppRenderer/TAppRendererCfg.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/App/TAppRenderer/TAppRendererCfg.cpp	(revision 1274)
@@ -306,11 +306,11 @@
 
   Int iNumNonNULL;
-  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchDepthInputFileList[iNumNonNULL]; iNumNonNULL++);  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
-  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchVideoInputFileList[iNumNonNULL]; iNumNonNULL++);  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
+  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchDepthInputFileList[iNumNonNULL]; iNumNonNULL++) {};  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
+  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfInputViews)  && m_pchVideoInputFileList[iNumNonNULL]; iNumNonNULL++) {};  xConfirmPara( iNumNonNULL < m_iNumberOfInputViews,  "Number of DepthInputFiles  must be greater than or equal to number of BaseViewNumbers" );
 
 
   if ( !m_bSweep )
   {
-  for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfOutputViews) && m_pchSynthOutputFileList[iNumNonNULL]; iNumNonNULL++); xConfirmPara( iNumNonNULL < m_iNumberOfOutputViews, "Number of SynthOutputFiles must be greater than or equal to number of SynthViewNumbers" );
+    for (iNumNonNULL = 0; (iNumNonNULL < m_iNumberOfOutputViews) && m_pchSynthOutputFileList[iNumNonNULL]; iNumNonNULL++) {}; xConfirmPara( iNumNonNULL < m_iNumberOfOutputViews, "Number of SynthOutputFiles must be greater than or equal to number of SynthViewNumbers" );
   }
   else
Index: branches/HTM-14.1-update-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TAppCommon/TAppComCamPara.cpp	(revision 1274)
@@ -1373,7 +1373,7 @@
   Int  iSourceViewNum = m_aiBaseViews[ iViewIdx ];
   Double dBaseLine = 0.0;
-  Double dFL1, dCS1, dCP1, dZN1, dZF1; 
-  Bool bInterpolated;
-  double dPos[3];
+  Double dFL1 = 1.0, dCS1 = 1.0, dCP1 = 1.0, dZN1 = 1.0, dZF1 = 1.0;
+  Bool bInterpolated = false;
+  double dPos[3] = {0.0, 0.0, 0.0};
 
   if( m_iNumberOfBaseViews == 3 )
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/CommonDef.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/CommonDef.h	(revision 1274)
@@ -363,5 +363,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_MLC  || NH_3D_ARP
 #define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/ContextTables.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/ContextTables.h	(revision 1274)
@@ -162,5 +162,5 @@
 #define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
 
-#if H_3D_ARP
+#if NH_3D_ARP
 #define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
 #endif
@@ -188,5 +188,5 @@
 #define NUM_SDC_FLAG_CTX              1      ///< number of context 
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
 #define DBBP_NUM_FLAG_CTX                 1
 #endif
@@ -542,5 +542,5 @@
 //! \}
 
-#if H_3D_ARP
+#if NH_3D_ARP
 static const UChar 
 INIT_ARPW[3][NUM_ARPW_CTX] = 
@@ -629,5 +629,5 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
 {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComCodingStatistics.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1274)
@@ -81,4 +81,10 @@
   STATS__CABAC_BITS__ESCAPE_BITS,
 
+#if NH_3D_DBBP
+  STATS__CABAC_BITS__DBBP_FLAG,
+#endif
+#if NH_3D_ARP
+  STATS__CABAC_BITS__ARP_FLAG,
+#endif
   STATS__CABAC_BITS__SAO,
   STATS__CABAC_TRM_BITS,
@@ -134,4 +140,7 @@
     "CABAC_BITS__SIGN_BIT",
     "CABAC_BITS__ESCAPE_BITS",
+#if NH_3D_DBBP
+    "CABAC_BITS__DBBP_FLAG",
+#endif
     "CABAC_BITS__SAO",
     "CABAC_TRM_BITS",
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1274)
@@ -125,14 +125,14 @@
   m_bDecSubCu          = false;
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
   m_pDvInfo              = NULL;
 #endif
-#if H_3D_VSP
+#if NH_3D_VSP
   m_piVSPFlag            = NULL;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag         = NULL;
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW              = NULL;
 #endif
@@ -142,5 +142,5 @@
 #if H_3D_INTER_SDC
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_pbDBBPFlag         = NULL;
 #endif
@@ -185,8 +185,8 @@
     m_pbMergeFlag        = (Bool*  )xMalloc(Bool,   uiNumPartition);
     m_puhMergeIndex      = (UChar* )xMalloc(UChar,  uiNumPartition);
-#if H_3D_VSP
+#if NH_3D_VSP
     m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
 #endif
@@ -208,5 +208,5 @@
     }
 
-#if H_3D_NBDV 
+#if NH_3D_NBDV 
     m_pDvInfo            = (DisInfo* )xMalloc(DisInfo,  uiNumPartition);
 #endif
@@ -249,6 +249,6 @@
     }
 
-#if H_3D_ARP
-    m_puhARPW            = new UChar[ uiNumPartition];
+#if NH_3D_ARP
+    m_puhARPW            = (UChar*  )xMalloc(UChar,   uiNumPartition);
 #endif
 #if NH_3D_IC
@@ -273,5 +273,5 @@
 #endif
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
     m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
 #endif
@@ -372,8 +372,12 @@
     }
 
-#if H_3D_VSP
-    if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
-#endif
-#if H_3D_SPIVMP
+#if NH_3D_VSP
+    if ( m_piVSPFlag )
+    {
+      xFree(m_piVSPFlag);
+      m_piVSPFlag = NULL;
+    }
+#endif
+#if NH_3D_SPIVMP
     if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
 #endif
@@ -463,11 +467,11 @@
       m_acCUMvField[rpl].destroy();
     }
-#if H_3D_NBDV 
+#if NH_3D_NBDV 
     if ( m_pDvInfo            ) { xFree(m_pDvInfo);             m_pDvInfo           = NULL; }
 #endif
 
 
-#if H_3D_ARP
-    if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
+#if NH_3D_ARP
+    if ( m_puhARPW            ) { xFree(m_puhARPW);             m_puhARPW           = NULL; }
 #endif
 #if NH_3D_IC
@@ -493,5 +497,5 @@
 #endif    
 #endif    
-#if H_3D_DBBP
+#if NH_3D_DBBP
     if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
 #endif
@@ -598,11 +602,7 @@
   memset( m_puhHeight         , maxCUHeight,                m_uiNumPartition * sizeof( *m_puhHeight ) );
 
-#if H_3D_ARP
-    m_puhARPW   [ui] = pcFrom->getARPW( ui );
-#endif
 #if NH_3D_IC
   memset( m_pbICFlag          , false,                      m_uiNumPartition * sizeof( *m_pbICFlag ) );
 #endif
-
   for(UInt i=0; i<NUM_REF_PIC_LIST_01; i++)
   {
@@ -623,15 +623,15 @@
   memset( m_puhMergeIndex     , 0,                        m_uiNumPartition * sizeof( *m_puhMergeIndex ) );
 
-#if H_3D_VSP
-    m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
-#endif
-#if H_3D_SPIVMP
-    m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
+#if NH_3D_VSP
+  memset( m_piVSPFlag         , 0,                        m_uiNumPartition * sizeof( *m_piVSPFlag ) );
+#endif
+#if NH_3D_SPIVMP
+  memset( m_pbSPIVMPFlag      , 0,                     m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );   
 #endif
 #if H_3D_DIM_SDC
     m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
 #endif
-#if H_3D_DBBP
-    m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
+#if NH_3D_DBBP
+  memset( m_pbDBBPFlag , false, m_uiNumPartition * sizeof( *m_pbDBBPFlag ));
 #endif
 #if H_3D
@@ -639,10 +639,4 @@
     memset( m_uiDISType         + firstElement,     0,                    numElements * sizeof( *m_uiDISType) );
 #endif
-#if H_3D_VSP
-    memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
-#endif
-#if H_3D_SPIVMP
-    memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
-#endif
 
   for (UInt ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
@@ -651,6 +645,6 @@
   }
 
-#if H_3D_ARP
-    memset( m_puhARPW           + firstElement, 0,                        numElements * sizeof( UChar )         );
+#if NH_3D_ARP
+  memset( m_puhARPW      ,      0,        m_uiNumPartition * sizeof( *m_puhARPW )         );
 #endif
 
@@ -674,7 +668,4 @@
     m_apDmmPredictor[0] = 0;
     m_apDmmPredictor[1] = 0;
-#endif
-#if H_3D_DBBP
-    memset( m_pbDBBPFlag        + firstElement, false,                    numElements * sizeof( *m_pbDBBPFlag ) );
 #endif
 
@@ -791,9 +782,9 @@
     m_pbMergeFlag[ui]   = 0;
     m_puhMergeIndex[ui] = 0;
-#if H_3D_VSP
-      m_piVSPFlag[ui] = 0;
-#endif
-#if H_3D_SPIVMP
-      m_pbSPIVMPFlag[ui] = 0;
+#if NH_3D_VSP
+    m_piVSPFlag[ui]     = 0;
+#endif
+#if NH_3D_SPIVMP
+    m_pbSPIVMPFlag[ui] = 0;
 #endif
 
@@ -808,5 +799,5 @@
       m_puhCbf[comp][ui] = 0;
     }
-#if H_3D_ARP
+#if NH_3D_ARP
       m_puhARPW[ui] = 0;
 #endif
@@ -836,5 +827,5 @@
       m_apDmmPredictor[1] = 0;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
       m_pbDBBPFlag[ui] = false;
 #endif
@@ -892,8 +883,8 @@
   memset( m_pbMergeFlag,        0, iSizeInBool  );
   memset( m_puhMergeIndex,      0, iSizeInUchar );
-#if H_3D_VSP
+#if NH_3D_VSP
   memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
 #endif
@@ -914,7 +905,4 @@
     memset( m_explicitRdpcmMode[comp],             NUMBER_OF_RDPCM_MODES, iSizeInUchar );
   }
-#if H_3D_ARP
-  memset( m_puhARPW,            0, iSizeInUchar  );
-#endif
 
   memset( m_puhDepth,     uiDepth, iSizeInUchar );
@@ -922,4 +910,7 @@
   memset( m_puhHeight,         uhHeight, iSizeInUchar );
   memset( m_pbIPCMFlag,        0, iSizeInBool  );
+#if NH_3D_ARP
+  memset( m_puhARPW,           0, iSizeInUchar  );
+#endif
 #if NH_3D_IC
   memset( m_pbICFlag,          0, iSizeInBool  );
@@ -945,6 +936,6 @@
   m_apDmmPredictor[1] = 0;
 #endif
-#if H_3D_DBBP
-  memset( m_pbDBBPFlag,         0, iSizeInBool  );
+#if NH_3D_DBBP
+  memset( m_pbDBBPFlag,         0, sizeof(Bool) * m_uiNumPartition  );
 #endif
 
@@ -972,12 +963,12 @@
       m_uiDISType[ui]   = pcCU->getDISType(uiPartOffset+ui);
 #endif
-#if H_3D_VSP
-      m_piVSPFlag[ui]=pcCU->m_piVSPFlag[uiPartOffset+ui];
-      m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
-#endif
-#if H_3D_SPIVMP
-      m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
-#endif
-#if H_3D_ARP
+#if NH_3D_VSP
+    m_piVSPFlag[ui] = pcCU->m_piVSPFlag[uiPartOffset+ui];
+    m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
+#endif
+#if NH_3D_SPIVMP
+    m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
+#endif
+#if NH_3D_ARP
       m_puhARPW           [ui] = pcCU->getARPW( uiPartOffset+ui );
 #endif
@@ -1003,5 +994,5 @@
 #endif
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
       m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
 #endif
@@ -1074,5 +1065,5 @@
   m_pePredMode=pcCU->getPredictionMode()  + uiPart;
   m_CUTransquantBypass  = pcCU->getCUTransquantBypass()+uiPart;
-#if H_3D_NBDV
+#if NH_3D_NBDV
   m_pDvInfo             = pcCU->getDvInfo()           + uiPart;
 #endif
@@ -1080,11 +1071,11 @@
   m_pbMergeFlag         = pcCU->getMergeFlag()        + uiPart;
   m_puhMergeIndex       = pcCU->getMergeIndex()       + uiPart;
-#if H_3D_VSP
+#if NH_3D_VSP
   m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW             = pcCU->getARPW()             + uiPart;
 #endif
@@ -1126,5 +1117,5 @@
 #endif  
 #endif  
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
 #endif
@@ -1173,5 +1164,5 @@
 }
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
 Void TComDataCU::copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx)
 {
@@ -1182,5 +1173,5 @@
 // Copy inter prediction info from the biggest CU
 Void TComDataCU::copyInterPredInfoFrom    ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList 
-#if H_3D_NBDV
+#if NH_3D_NBDV
   , Bool bNBDV
 #endif
@@ -1213,5 +1204,5 @@
 
   m_pePartSize         = pcCU->getPartitionSize ()        + uiAbsPartIdx;
-#if H_3D_NBDV
+#if NH_3D_NBDV
   if(bNBDV == true)
   {
@@ -1234,9 +1225,9 @@
   m_pbMergeFlag        = pcCU->getMergeFlag()             + uiAbsPartIdx;
   m_puhMergeIndex      = pcCU->getMergeIndex()            + uiAbsPartIdx;
-#if H_3D_VSP
+#if NH_3D_VSP
   m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
 #endif
@@ -1244,13 +1235,13 @@
   m_apiMVPIdx[eRefPicList] = pcCU->getMVPIdx(eRefPicList) + uiAbsPartIdx;
   m_apiMVPNum[eRefPicList] = pcCU->getMVPNum(eRefPicList) + uiAbsPartIdx;
-#if H_3D_ARP
+#if NH_3D_ARP
   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
 #endif    
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
 #endif
 
   m_acCUMvField[ eRefPicList ].linkToWithOffset( pcCU->getCUMvField(eRefPicList), uiAbsPartIdx );
-#if H_3D_NBDV
+#if NH_3D_NBDV
   }
 #endif
@@ -1292,9 +1283,9 @@
   memcpy( m_pbMergeFlag         + uiOffset, pcCU->getMergeFlag(),         iSizeInBool  );
   memcpy( m_puhMergeIndex       + uiOffset, pcCU->getMergeIndex(),        iSizeInUchar );
-#if H_3D_VSP
+#if NH_3D_VSP
   memcpy( m_piVSPFlag           + uiOffset, pcCU->getVSPFlag(),           sizeof( Char ) * uiNumPartition );
   memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP  || NH_3D_DBBP
   memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
 #endif
@@ -1333,6 +1324,9 @@
 #endif
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
+#endif
+#if NH_3D_ARP
+  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
 #endif
 
@@ -1376,7 +1370,4 @@
   }
 
-#if H_3D_ARP
-  memcpy( m_puhARPW             + uiOffset, pcCU->getARPW(),              iSizeInUchar );
-#endif
 #if NH_3D_IC
   memcpy( m_pbICFlag            + uiOffset, pcCU->getICFlag(),            iSizeInBool );
@@ -1409,6 +1400,6 @@
 
   memcpy( pCtu->getQP() + m_absZIdxInCtu, m_phQP, sizeInChar  );
-#if H_3D_NBDV
-  memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
+#if NH_3D_NBDV
+  memcpy( pCtu->getDvInfo() + m_absZIdxInCtu, m_pDvInfo, sizeof(* m_pDvInfo) * m_uiNumPartition );
 #endif
 
@@ -1419,10 +1410,12 @@
   memcpy( pCtu->getMergeFlag()         + m_absZIdxInCtu, m_pbMergeFlag,         iSizeInBool  );
   memcpy( pCtu->getMergeIndex()        + m_absZIdxInCtu, m_puhMergeIndex,       iSizeInUchar );
-  #if H_3D_VSP
-  memcpy( rpcCU->getVSPFlag()           + m_uiAbsIdxInLCU, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
-  memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
-#endif
-#if H_3D_SPIVMP
-  memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
+#if NH_3D_VSP
+  memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
+#endif
+#if NH_3D_DBBP
+  memcpy( pCtu->getDvInfo()            + m_absZIdxInCtu, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
+#endif
+#if NH_3D_SPIVMP
+  memcpy( pCtu->getSPIVMPFlag()        + m_absZIdxInCtu, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
 #endif
 
@@ -1461,6 +1454,9 @@
 #endif
 #endif
-#if H_3D_DBBP
-  memcpy( rpcCU->getDBBPFlag()          + m_uiAbsIdxInLCU, m_pbDBBPFlag,          iSizeInBool  );
+#if NH_3D_DBBP
+  memcpy( pCtu->getDBBPFlag()          + m_absZIdxInCtu, m_pbDBBPFlag,          iSizeInBool  );
+#endif
+#if NH_3D_ARP
+  memcpy( pCtu->getARPW()              + m_absZIdxInCtu, m_puhARPW,             iSizeInUchar );
 #endif
 
@@ -1497,11 +1493,7 @@
   }
 
-#if H_3D_ARP
-  memcpy( rpcCU->getARPW()             + m_uiAbsIdxInLCU, m_puhARPW,             iSizeInUchar );
-#endif
 #if NH_3D_IC
   memcpy( pCtu->getICFlag() + m_absZIdxInCtu, m_pbICFlag, sizeof( *m_pbICFlag ) * m_uiNumPartition );
 #endif
-
   pCtu->getTotalBins() = m_uiTotalBins;
 }
@@ -1512,7 +1504,4 @@
 #endif
 
-#if H_3D_VSP
-  memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
-#endif
 #if H_3D_SPIVMP
   memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
@@ -1535,10 +1524,4 @@
   memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
 #endif
-#endif
-#if H_3D_DBBP
-  memcpy( rpcCU->getDBBPFlag()          + uiPartOffset, m_pbDBBPFlag,          iSizeInBool  );
-#endif
-#if H_3D_ARP
-  memcpy( rpcCU->getARPW()             + uiPartOffset, m_puhARPW,             iSizeInUchar );
 #endif
 
@@ -2093,5 +2076,5 @@
   return uiCtx;
 }
-#if H_3D_ARP
+#if NH_3D_ARP
 UInt TComDataCU::getCTXARPWFlag( UInt uiAbsPartIdx )
 {
@@ -2100,12 +2083,16 @@
   UInt        uiCtx = 0;
   
-  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  pcTempCU = getPULeft( uiTempPartIdx, m_absZIdxInCtu + uiAbsPartIdx );
   uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
     return uiCtx;
 }
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
 {
+  const TComSPS* sps = getSlice()->getSPS();
+  UInt uiMaxCUWidth = sps->getMaxCUWidth();
+  UInt uiMaxCUHeight = sps->getMaxCUHeight();
+  
   // get coded and reconstructed depth view
   TComPicYuv* depthPicYuv = NULL;
@@ -2113,8 +2100,6 @@
   
   // DBBP is a texture coding tool
-  if( getSlice()->getIsDepth() )
-  {
-    return NULL;
-  }  
+  assert( !getSlice()->getIsDepth() );
+  
 #if H_3D_FCO
   TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
@@ -2143,17 +2128,17 @@
     depthPicYuv   = baseDepthPic->getPicYuvRec();
     depthPicYuv->extendPicBorder();
-    uiDepthStride = depthPicYuv->getStride();
+    uiDepthStride = depthPicYuv->getStride(COMPONENT_Y);
     
-    Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
-    Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
+    Int iBlkX = ( getCtuRsAddr() % baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
+    Int iBlkY = ( getCtuRsAddr() / baseDepthPic->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCtu()+uiAbsPartIdx ] ];
     
-    Int iPictureWidth  = depthPicYuv->getWidth();
-    Int iPictureHeight = depthPicYuv->getHeight();
+    Int iPictureWidth  = depthPicYuv->getWidth(COMPONENT_Y);
+    Int iPictureHeight = depthPicYuv->getHeight(COMPONENT_Y);
     
     
     Bool depthRefineFlag = false;
-#if H_3D_NBDV_REF
-    depthRefineFlag = m_pcSlice->getDepthRefinementFlag(  );
-#endif // H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
+    depthRefineFlag = m_pcSlice->getDepthRefinementFlag();
+#endif // NH_3D_NBDV_REF
     
     TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
@@ -2166,5 +2151,5 @@
     Int depthPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((cDv.getVer()+2)>>2));
     
-    pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride;
+    pDepthPels = depthPicYuv->getAddr(COMPONENT_Y) + depthPosX + depthPosY * uiDepthStride;
   }
 #endif
@@ -2178,5 +2163,5 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
 {
@@ -2490,5 +2475,5 @@
 }
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
 {
@@ -2497,14 +2482,13 @@
 #endif
 
-#if H_3D_VSP
+#if NH_3D_VSP
 Void TComDataCU::setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
 {
   setSubPart<Char>( iVSPFlag, m_piVSPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
 }
-#if H_3D_VSP
 template<typename T>
 Void TComDataCU::setSubPartT( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx )
 {
-  UInt uiCurrPartNumQ = (m_pcPic->getNumPartInCU() >> (2 * uiCUDepth)) >> 2;
+  UInt uiCurrPartNumQ = (m_pcPic->getNumPartitionsInCtu() >> (2 * uiCUDepth)) >> 2;
   switch ( m_pePartSize[ uiCUAddr ] )
   {
@@ -2638,5 +2622,4 @@
 }
 #endif
-#endif
 
 Void TComDataCU::setInterDirSubParts( UInt uiDir, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
@@ -2724,5 +2707,5 @@
 
 // This is for use by a leaf/sub CU object only, with no additional AbsPartIdx
-#if NH_3D_IC
+#if NH_3D_IC || NH_3D_VSP
 Void TComDataCU::getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx, Bool bLCU)
 {
@@ -3058,6 +3041,5 @@
 }
 
-#if H_3D_VSP
-
+#if NH_3D_VSP
 /** Add a VSP merging candidate
  * \Inputs
@@ -3113,5 +3095,5 @@
         predFlag[iRefListIdX] = 1;
         mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
-#if H_3D_NBDV
+#if NH_3D_NBDV
         mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
 #endif
@@ -3121,5 +3103,9 @@
 
   dirVSP = (predFlag[0] | (predFlag[1] << 1));
-  m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
+  m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true
+#if NH_3D_SPIVMP
+    , false
+#endif
+    );
   if ( mrgCandIdx == iCount )
   {
@@ -3131,8 +3117,7 @@
   return false;
 }
-
-#endif
-
-#if H_3D_IV_MERGE
+#endif
+
+#if NH_3D_IV_MERGE
 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
 {
@@ -3165,5 +3150,5 @@
       if(!bRemove)
       {
-#if H_3D_NBDV
+#if NH_3D_NBDV
         if(iLoop) // For IvMcShift candidate
         {
@@ -3186,10 +3171,17 @@
 
 #endif
-#if H_3D
+#if NH_3D_MLC
+/** Construct a extended list of merging candidates
+ * \param pcMvFieldNeighbours
+ * \param puhInterDirNeighbours
+ * \param vspFlag
+ * \param pbSPIVMPFlag
+ * \param numValidMergeCand
+ */
 Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
   , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   , Bool* pbSPIVMPFlag
 #endif
@@ -3197,5 +3189,5 @@
   )
 {
-  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
+  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
   {
     return;
@@ -3213,14 +3205,22 @@
     extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
     extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
+#if NH_3D_VSP
     vspFlag[ui] = 0;
-  }
-
-  // add candidates to temporal list
-  // insert MPI ... IvShift candidate
+#endif
+  }
+
+  // insert MPI ... IvShift candidate to extMergeCandList
   for (Int i=0; i<=MRG_IVSHIFT; i++)
   {
     if (m_mergCands[i].m_bAvailable)
     {
-      m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag);
+      m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt
+#if NH_3D_VSP
+        , vspFlag
+#endif
+#if NH_3D_SPIVMP
+        , pbSPIVMPFlag
+#endif
+        );
       iCount++;
       if (iCount >= getSlice()->getMaxNumMergeCand())
@@ -3229,14 +3229,15 @@
   }
 
-  // insert remaining base candidates
-  while (iCount < getSlice()->getMaxNumMergeCand() && m_baseListidc < getSlice()->getMaxNumMergeCand())
-  {
-    uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[m_baseListidc];
-    extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[m_baseListidc<<1].getMv(), pcMvFieldNeighbours[m_baseListidc<<1].getRefIdx());
+  Int iCountBase = m_numSpatialCands;
+  // insert remaining base candidates to extMergeCandList
+  while (iCount < getSlice()->getMaxNumMergeCand() && iCountBase < getSlice()->getMaxNumMergeCand())
+  {
+    uhInterDirNeighboursExt[iCount] = puhInterDirNeighbours[iCountBase];
+    extMergeCandList[iCount<<1].setMvField(pcMvFieldNeighbours[iCountBase<<1].getMv(), pcMvFieldNeighbours[iCountBase<<1].getRefIdx());
     if ( getSlice()->isInterB() )
     {
-      extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());
-    }
-    m_baseListidc++;
+      extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(iCountBase<<1)+1].getMv(), pcMvFieldNeighbours[(iCountBase<<1)+1].getRefIdx());
+    }
+    iCountBase++;
     iCount++;
   }
@@ -3260,27 +3261,46 @@
 }
 
-/** Constructs a list of merging candidates
+
+
+/** Derive 3D merge candidates
  * \param uiAbsPartIdx
  * \param uiPUIdx 
- * \param uiDepth
  * \param pcMvFieldNeighbours
+ * \param puhInterDirNeighbours
+ * \param pcMvFieldSP
  * \param puhInterDirNeighbours
  * \param numValidMergeCand
  */
-// HM 12.0 based merge candidate list construction
-
-Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
-{
-
-  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
-  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
+Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+#if NH_3D_SPIVMP
+      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+      , Int& numValidMergeCand, Int mrgCandIdx
+)
+{
+#if NH_3D_IV_MERGE
   TComMv cZeroMv;
-  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
-  {
-    abCandIsInter[ui] = false;
-    pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
-    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
+  TComMvField tmpMV[2];  
+#endif
+
+  //////////////////////////////////
+  //////// GET DISPARITIES  ////////
+  //////////////////////////////////
+#if NH_3D_IV_MERGE
+  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
+  m_cDefaultDisInfo = cDisInfo;
+#elif NH_3D_VSP
+  // for xAddVspCand()
+  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
+#endif
+
+  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
+  {
+    return;
   }
   numValidMergeCand = getSlice()->getMaxNumMergeCand();
+  //////////////////////////////////
+  //////// DERIVE LOCATIONS ////////
+  //////////////////////////////////
   // compute the location of the current PU
   Int xP, yP, nPSW, nPSH;
@@ -3288,436 +3308,42 @@
 
   Int iCount = 0;
-
   UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
-  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
-
-  //left
-  UInt uiLeftPartIdx = 0;
-  TComDataCU* pcCULeft = 0;
-  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
-  Bool isAvailableA1 = pcCULeft &&
-    pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
-    !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
-    !pcCULeft->isIntra( uiLeftPartIdx ) ;
-  if ( isAvailableA1 )
-  {
-    m_bAvailableFlagA1 = 1;
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
-    // get Mv from Left
-    pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-
-    iCount ++;
-  }
-  
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-  // above
-  UInt uiAbovePartIdx = 0;
-  TComDataCU* pcCUAbove = 0;
-  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
-  Bool isAvailableB1 = pcCUAbove &&
-  pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
-  !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
-  !pcCUAbove->isIntra( uiAbovePartIdx );
-  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
-  {
-    m_bAvailableFlagB1 = 1;
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
-    // get Mv from Left
-    pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-
-  // above right
-  UInt uiAboveRightPartIdx = 0;
-  TComDataCU* pcCUAboveRight = 0;
-  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
-  Bool isAvailableB0 = pcCUAboveRight &&
-  pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
-  !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
-  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
-  {
-    m_bAvailableFlagB0 = 1;
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
-    // get Mv from Left
-    pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-
-  //left bottom
-  UInt uiLeftBottomPartIdx = 0;
-  TComDataCU* pcCULeftBottom = 0;
-  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
-  Bool isAvailableA0 = pcCULeftBottom &&
-  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
-  !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
-  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
-  {
-    m_bAvailableFlagA0 = 1;
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
-    // get Mv from Left
-    pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-  // above left 
-  if( iCount < 4 )
-  {
-    UInt uiAboveLeftPartIdx = 0;
-    TComDataCU* pcCUAboveLeft = 0;
-    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
-    Bool isAvailableB2 = pcCUAboveLeft &&
-    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
-    !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
-    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
-        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
-    {
-      m_bAvailableFlagB2 = 1;
-      abCandIsInter[iCount] = true;
-      // get Inter Dir
-      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
-      // get Mv from Left
-      pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-      if ( getSlice()->isInterB() )
-      {
-        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-      }
-      if ( mrgCandIdx == iCount )
-      {
-        return;
-      }
-      iCount ++;
-    }
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-  if ( getSlice()->getEnableTMVPFlag())
-  {
-    //>> MTK colocated-RightBottom
-    UInt uiPartIdxRB;
-
-    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );  
-
-    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
-    UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
-
-    TComMv cColMv;
-    Int iRefIdx;
-    Int uiLCUIdx = -1;
-
-    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
-    {
-    }
-    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
-    {
-    }
-    else
-    {
-      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
-        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
-        uiLCUIdx = getAddr();
-      }
-      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
-      }
-      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
-        uiLCUIdx = getAddr() + 1;
-      }
-      else //is the right bottom corner of LCU                       
-      {
-        uiAbsPartAddr = 0;
-      }
-    }
-
-    iRefIdx = 0;
-    Bool bExistMV = false;
-    UInt uiPartIdxCenter;
-    UInt uiCurLCUIdx = getAddr();
-    Int dir = 0;
-    UInt uiArrayAddr = iCount;
-    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
-    bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
-    if( bExistMV == false )
-    {
-      bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
-    }
-    if( bExistMV )
-    {
-      dir |= 1;
-      pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
-    }
-
-    if ( getSlice()->isInterB() )
-    {
-#if NH_3D_TMVP //to be changed to NH_3D_TMVP in future migration
-      iRefIdx = 0;
-#endif
-      bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
-      if( bExistMV == false )
-      {
-        bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
-      }
-      if( bExistMV )
-      {
-        dir |= 2;
-        pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
-      }
-    }
-
-    if (dir != 0)
-    {
-      puhInterDirNeighbours[uiArrayAddr] = dir;
-      abCandIsInter[uiArrayAddr] = true;
-#if H_3D_NBDV
-      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
-      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
-#endif
-      if ( mrgCandIdx == iCount )
-      {
-        return;
-      }
-      iCount++;
-    }
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-  UInt uiArrayAddr = iCount;
-  UInt uiCutoff = uiArrayAddr;
-  
-  if ( getSlice()->isInterB() && iCount<5)  // JCT3V-F0129 by Qualcomm
-  {
-    UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
-    UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
-
-    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
-    {
-      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
-      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
-      {
-        abCandIsInter[uiArrayAddr] = true;
-        puhInterDirNeighbours[uiArrayAddr] = 3;
-
-        // get Mv from cand[i] and cand[j]
-        pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
-        pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
-
-        Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
-        Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
-        if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
-        {
-          abCandIsInter[uiArrayAddr] = false;
-        }
-        else
-        {
-          uiArrayAddr++;
-        }
-      }
-    }
-  }
-  // early termination
-  if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
-  {
-    return;
-  }
-  
-  Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
-  Int r = 0;
-  Int refcnt = 0;
-  while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
-  {
-    abCandIsInter[uiArrayAddr] = true;
-    puhInterDirNeighbours[uiArrayAddr] = 1;
-    pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
-
-    if ( getSlice()->isInterB() )
-    {
-      puhInterDirNeighbours[uiArrayAddr] = 3;
-      pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
-    }
-    uiArrayAddr++;
-    if ( refcnt == iNumRefIdx - 1 )
-    {
-      r = 0;
-    }
-    else
-    {
-      ++r;
-      ++refcnt;
-    }
-  }
-  
-  numValidMergeCand = uiArrayAddr;
-}
-
-
-
-/** Constructs a list of merging candidates
- * \param uiAbsPartIdx
- * \param uiPUIdx 
- * \param uiDepth
- * \param pcMvFieldNeighbours
- * \param puhInterDirNeighbours
- * \param numValidMergeCand
- */
-#if H_3D
-Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
-#else
-Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
-#endif
-#if H_3D_SPIVMP
-      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#endif
-      , Int& numValidMergeCand, Int mrgCandIdx
-)
-{
-#if H_3D_IV_MERGE
-  ////////////////////////////
-  //////// INIT LISTS ////////
-  ////////////////////////////
-  TComMv cZeroMv;
-#else
-  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
-#endif
-#if H_3D
-  TComMvField tmpMV[2];
-  UChar tmpDir;
-
-
-  //////////////////////////////////
-  //////// GET DISPARITIES  ////////
-  //////////////////////////////////
-  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
-  m_cDefaultDisInfo = cDisInfo;
-
-  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // current slice is not both dependent view or depth
-  {
-    return;
-  }
-#else
-  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
-  {
-    abCandIsInter[ui] = false;
-    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
-    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
-  }
-#endif
-
-  numValidMergeCand = getSlice()->getMaxNumMergeCand();
-#if H_3D
-  //////////////////////////////////
-  //////// DERIVE LOCATIONS ////////
-  //////////////////////////////////
-#endif
-  // compute the location of the current PU
-  Int xP, yP, nPSW, nPSH;
-  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
-
-  Int iCount = 0;
-
-  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
-#if !H_3D
-  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
-#endif
-  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
-  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
-#if H_3D
+#if NH_3D_TEXT_MERGE
   Bool bMPIFlag   = getSlice()->getMpiFlag(); 
+  Int  tmpDir;
+#endif 
+#if NH_3D_IV_MERGE || NH_3D_TEXT_MERGE
   Bool bIsDepth = getSlice()->getIsDepth();
-#endif 
+#endif
 
 #if NH_3D_IC
   Bool bICFlag = getICFlag(uiAbsPartIdx);
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   Bool bARPFlag = getARPW(uiAbsPartIdx) > 0;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
   assert(bDBBPFlag == getDBBPFlag(0));  
 #endif
 
-#if H_3D
-#if H_3D_NBDV
+#if NH_3D_NBDV
   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)  
   {
-    pcMvFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
-    pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
-  }
-#endif
-  // Clean version for MCL construction align with WD
-  // init mergCands list
+    pcMFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
+    pcMFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
+  }
+#endif
+  // init containers
   for (Int i = 0; i<MRG_IVSHIFT+1; i++)
-  {
     m_mergCands[i].init();
-  }
-
-  m_baseListidc = 0;
-
+
+  m_numSpatialCands = 0;
+
+  //////////////////////////////////
+  ///////// GET VSP FLAGS //////////
+  //////////////////////////////////
   //left
   UInt uiLeftPartIdx = 0;
@@ -3727,80 +3353,83 @@
   if (getAvailableFlagA1())
   {
-    m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
-#if H_3D_VSP
+    m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
+#if NH_3D_VSP
     , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
 #if NH_3D_IC
       && !bICFlag
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
       && !bARPFlag
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
       && !bDBBPFlag
 #endif
       )
 #endif
+#if NH_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above
-
   if (getAvailableFlagB1())
   {
-    m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
-#if H_3D_VSP
+    m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
+#if NH_3D_VSP
     , false
 #endif
+#if NH_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above right
-
   if (getAvailableFlagB0())
   {
-    m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
-#if H_3D_VSP
-    ,
-      false
-#endif
+    m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
+#if NH_3D_VSP
+    , false
+#endif
+#if NH_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // left bottom
-
   if (getAvailableFlagA0())
   {
-    m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
-#if H_3D_VSP
+    m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
+#if NH_3D_VSP
     , false
 #endif
+#if NH_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above left
-
   if (getAvailableFlagB2())
   {
-    m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
-#if H_3D_VSP
+    m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
+#if NH_3D_VSP
     , false
 #endif
+#if NH_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
-  }
-
-#endif
-
-
-#if H_3D_IV_MERGE
+    m_numSpatialCands++;
+  }
+
+
+#if NH_3D_TEXT_MERGE
 
   /////////////////////////////////////////////
@@ -3828,5 +3457,5 @@
 
       this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
-      pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+      pcTexRec->getTopLeftSamplePos( this->getCtuRsAddr(), this->getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
 
       Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
@@ -3853,6 +3482,7 @@
 
       Int         iTexPosX, iTexPosY;
+#if NH_3D_INTEGER_MV_DEPTH
       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
-
+#endif
       Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
       Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
@@ -3868,5 +3498,5 @@
 
       pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
-      TComDataCU* pcDefaultCU    = pcTexPic->getCU( iTexCenterCUAddr );
+      TComDataCU* pcDefaultCU    = pcTexPic->getCtu( iTexCenterCUAddr );
 
       if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
@@ -3887,6 +3517,10 @@
               {
                 bSPIVMPFlag = true;
+#if NH_3D_INTEGER_MV_DEPTH
                 TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
                 cMv >>= 2;
+#else
+                TComMv cMv = cDefaultMvField.getMv();
+#endif
                 cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
                 break;
@@ -3913,5 +3547,5 @@
             iTexPosY     = i + iOffsetY; 
             pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
-            pcTexCU  = pcTexPic->getCU( iTexCUAddr );
+            pcTexCU  = pcTexPic->getCtu( iTexCUAddr );
 
             if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
@@ -3925,6 +3559,10 @@
                 if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
                 {
+#if NH_3D_INTEGER_MV_DEPTH
                   TComMv cMv = cTexMvField.getMv() + cMvRounding;
                   cMv >>=2;          
+#else
+                  TComMv cMv = cTexMvField.getMv();
+#endif         
                   pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
                 }
@@ -3945,7 +3583,5 @@
           }
         }
-#if H_3D
-      }
-#endif
+      }
 #if H_3D_FCO
     }
@@ -3975,4 +3611,7 @@
     }
   }
+#endif
+
+#if NH_3D_IV_MERGE
   /////////////////////////////////////////////////////////////////
   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
@@ -3992,5 +3631,9 @@
   if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
   {
+#if H_3D_IC
     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
+#else
+    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, false );
+#endif
   }  
 
@@ -4048,5 +3691,5 @@
         spiMvpFlag = true;
       }
-#if H_3D_DBBP
+#if NH_3D_DBBP
       spiMvpFlag &= !bDBBPFlag;
 #endif
@@ -4069,17 +3712,158 @@
 #endif
 
+  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
+
+#if NH_3D_VSP
+  /////////////////////////////////////////////////
+  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
+  /////////////////////////////////////////////////
+  if (iCount<getSlice()->getMaxNumMergeCand())
+  {
+    if (
+      (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
+#if NH_3D_IC
+      !bICFlag &&
+#endif
+#if NH_3D_ARP
+      !bARPFlag &&
+#endif
 #if H_3D
-  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
+      (nPSW + nPSH > 12) &&
+#endif
+#if NH_3D_DBBP
+      !bDBBPFlag &&
+#endif
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
+    {
+      return;
+    }
+
+    // early termination
+    if (iCount == getSlice()->getMaxNumMergeCand())
+    {
+      return;
+    }
+  }
+#endif
+
+  iCount += m_mergCands[MRG_B0].m_bAvailable;
+
+#if NH_3D_IV_MERGE 
+  /////////////////////////////////////////////
+  //////// INTER VIEW DISP COMP (IvDC) ////////
+  /////////////////////////////////////////////
+  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
+  {
+    assert(iCount < getSlice()->getMaxNumMergeCand());
+
+    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+    if( ( ivCandDir[1] & 1 ) == 1 )
+    {
+      tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
+    }
+    if( ( ivCandDir[1] & 2 ) == 2 )
+    {
+      tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
+    }
+
+    Bool bRemoveSpa = false; //pruning to A1, B1
+    for(Int i = 0; i < 2; i ++)
+    {
+      if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 
+      {
+        continue;
+      }
+      if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
+      {
+        bRemoveSpa                      = true;
+        break;
+      }      
+    }
+    if(!bRemoveSpa)
+    {
+#if NH_3D_NBDV
+      tmpMV[0].getMv().setIDVFlag (false);
+      tmpMV[1].getMv().setIDVFlag (false);
+#endif
+      m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
+
+      if ( mrgCandIdx == iCount )
+        return;
+      iCount ++;
+
+      // early termination
+      if (iCount == getSlice()->getMaxNumMergeCand()) 
+      {
+        return;
+      }
+    }
+  } 
+#endif // H_3D_IV_MERGE 
+
+  iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
+
+#if NH_3D_IV_MERGE
+  ////////////////////////////////////////////////////
+  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
+  ////////////////////////////////////////////////////
+  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 
+  {
+    if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
+    {
+      return;
+    }
+    //early termination
+    if (iCount == getSlice()->getMaxNumMergeCand()) 
+    {
+      return;
+    }
+  }
+#endif
+}
+#endif
+
+//! Construct a list of merging candidates
+Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
+{
+  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
+#if NH_3D_MLC
+  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
 #else
+  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
+#endif
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
+  {
+    abCandIsInter[ui] = false;
+    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
+    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
+  }
+  numValidMergeCand = getSlice()->getMaxNumMergeCand();
+  // compute the location of the current PU
+  Int xP, yP, nPSW, nPSH;
+  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
+
+  Int iCount = 0;
+
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
+  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
+  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
+
   //left
   UInt uiLeftPartIdx = 0;
   TComDataCU* pcCULeft = 0;
   pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
+
   Bool isAvailableA1 = pcCULeft &&
-    pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
-    !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
-    !pcCULeft->isIntra( uiLeftPartIdx ) ;
+                       pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
+                       !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
+                       pcCULeft->isInter( uiLeftPartIdx ) ;
+
   if ( isAvailableA1 )
   {
+#if NH_3D_MLC
+    m_bAvailableFlagA1 = 1;
+#endif
     abCandIsInter[iCount] = true;
     // get Inter Dir
@@ -4091,5 +3875,4 @@
       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4100,19 +3883,23 @@
 
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
-
   // above
   UInt uiAbovePartIdx = 0;
   TComDataCU* pcCUAbove = 0;
   pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+
   Bool isAvailableB1 = pcCUAbove &&
-    pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
-    !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
-    !pcCUAbove->isIntra( uiAbovePartIdx );
+                       pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
+                       !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
+                       pcCUAbove->isInter( uiAbovePartIdx );
+
   if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
   {
+#if NH_3D_MLC
+    m_bAvailableFlagB1 = 1;
+#endif
     abCandIsInter[iCount] = true;
     // get Inter Dir
@@ -4124,5 +3911,4 @@
       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4132,5 +3918,5 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
@@ -4141,9 +3927,14 @@
   TComDataCU* pcCUAboveRight = 0;
   pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+
   Bool isAvailableB0 = pcCUAboveRight &&
-    pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
-    !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
+                       pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
+                       pcCUAboveRight->isInter( uiAboveRightPartIdx );
+
   if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
   {
+#if NH_3D_MLC
+    m_bAvailableFlagB0 = 1;
+#endif
     abCandIsInter[iCount] = true;
     // get Inter Dir
@@ -4155,5 +3946,4 @@
       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4163,117 +3953,23 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
-#endif
-
-
-#if H_3D_VSP
-  /////////////////////////////////////////////////
-  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
-  /////////////////////////////////////////////////
-  if (iCount<getSlice()->getMaxNumMergeCand())
-  {
-    if (
-      (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
-#if NH_3D_IC
-      !bICFlag &&
-#endif
-#if H_3D_ARP
-      !bARPFlag &&
-#endif
-#if H_3D
-      (nPSW + nPSH > 12) &&
-#endif
-#if H_3D_DBBP
-      !bDBBPFlag &&
-#endif
-      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
-    {
-      return;
-    }
-
-    // early termination
-    if (iCount == getSlice()->getMaxNumMergeCand())
-    {
-      return;
-    }
-#endif
-#if H_3D_VSP
-  }
-#endif
-
-#if H_3D
-  iCount += m_mergCands[MRG_B0].m_bAvailable;
-#endif
-
-
-#if H_3D_IV_MERGE 
-  /////////////////////////////////////////////
-  //////// INTER VIEW DISP COMP (IvDC) ////////
-  /////////////////////////////////////////////
-  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
-  {
-    assert(iCount < getSlice()->getMaxNumMergeCand());
-
-    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
-    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
-    if( ( ivCandDir[1] & 1 ) == 1 )
-    {
-      tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
-    }
-    if( ( ivCandDir[1] & 2 ) == 2 )
-    {
-      tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
-    }
-
-    Bool bRemoveSpa = false; //pruning to A1, B1
-    for(Int i = 0; i < 2; i ++)
-    {
-      if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 
-      {
-        continue;
-      }
-      if (ivCandDir[1] == m_mergCands[MRG_A1+i].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+i].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+i].m_cMvField[1])
-      {
-        bRemoveSpa                      = true;
-        break;
-      }      
-    }
-    if(!bRemoveSpa)
-    {
-#if H_3D_NBDV
-      tmpMV[0].getMv().setIDVFlag (false);
-      tmpMV[1].getMv().setIDVFlag (false);
-#endif
-      m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
-
-      if ( mrgCandIdx == iCount )
-        return;
-      iCount ++;
-
-      // early termination
-      if (iCount == getSlice()->getMaxNumMergeCand()) 
-      {
-        return;
-      }
-    }
-  } 
-#endif // H_3D_IV_MERGE 
-
-
-#if H_3D
-  iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
-#else
+
   //left bottom
   UInt uiLeftBottomPartIdx = 0;
   TComDataCU* pcCULeftBottom = 0;
   pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+
   Bool isAvailableA0 = pcCULeftBottom &&
-  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
-  !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
+                       pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
+                       pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
+
   if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
   {
+#if NH_3D_MLC
+    m_bAvailableFlagA0 = 1;
+#endif
     abCandIsInter[iCount] = true;
     // get Inter Dir
@@ -4292,10 +3988,10 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
 
-  // above left 
+  // above left
   if( iCount < 4 )
   {
@@ -4303,10 +3999,15 @@
     TComDataCU* pcCUAboveLeft = 0;
     pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+
     Bool isAvailableB2 = pcCUAboveLeft &&
-    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
-    !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
+                         pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
+                         pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
+
     if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
         && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
     {
+#if NH_3D_MLC
+      m_bAvailableFlagB2 = 1;
+#endif
       abCandIsInter[iCount] = true;
       // get Inter Dir
@@ -4326,84 +4027,59 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
-#endif
-
-
-#if H_3D_IV_MERGE
-  ////////////////////////////////////////////////////
-  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
-  ////////////////////////////////////////////////////
-  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 
-  {
-    if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
-    {
-      return;
-    }
-    //early termination
-    if (iCount == getSlice()->getMaxNumMergeCand()) 
-    {
-      return;
-    }
-  }
-#endif
-#if !H_3D
-  if ( getSlice()->getEnableTMVPFlag())
+
+  if ( getSlice()->getEnableTMVPFlag() )
   {
     //>> MTK colocated-RightBottom
     UInt uiPartIdxRB;
 
-    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );  
+    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
 
     UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
-    UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
+    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
 
     TComMv cColMv;
     Int iRefIdx;
-    Int uiLCUIdx = -1;
-
-    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
-    {
-    }
-    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
-    {
-    }
-    else
-    {
-      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
-        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
-        uiLCUIdx = getAddr();
-      }
-      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
-      }
-      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+    Int ctuRsAddr = -1;
+
+    if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
+        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
+    {
+      if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
+        ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
+        ctuRsAddr = getCtuRsAddr();
+      }
+      else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
+      }
+      else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
       {
         uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
-        uiLCUIdx = getAddr() + 1;
-      }
-      else //is the right bottom corner of LCU                       
+        ctuRsAddr = getCtuRsAddr() + 1;
+      }
+      else //is the right bottom corner of CTU
       {
         uiAbsPartAddr = 0;
       }
     }
-    
-    
+
     iRefIdx = 0;
+
     Bool bExistMV = false;
     UInt uiPartIdxCenter;
-    UInt uiCurLCUIdx = getAddr();
     Int dir = 0;
     UInt uiArrayAddr = iCount;
     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
-    bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
+    bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
     if( bExistMV == false )
     {
-      bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+      bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx );
     }
     if( bExistMV )
@@ -4415,8 +4091,11 @@
     if ( getSlice()->isInterB() )
     {
-      bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
+#if NH_3D_TMVP
+      iRefIdx = 0;
+#endif
+      bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
       if( bExistMV == false )
       {
-        bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+        bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
       }
       if( bExistMV )
@@ -4426,9 +4105,14 @@
       }
     }
-    
+
     if (dir != 0)
     {
       puhInterDirNeighbours[uiArrayAddr] = dir;
       abCandIsInter[uiArrayAddr] = true;
+#if NH_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+
       if ( mrgCandIdx == iCount )
       {
@@ -4438,20 +4122,28 @@
     }
   }
-  // early termination  
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
+
   UInt uiArrayAddr = iCount;
   UInt uiCutoff = uiArrayAddr;
-    
-  if ( getSlice()->isInterB())
-  {
-    UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
-    UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
+
+#if NH_3D_MLC
+  if ( getSlice()->isInterB() && iCount<5)
+#else
+  if ( getSlice()->isInterB() )
+#endif
+  {
+    static const UInt NUM_PRIORITY_LIST=12;
+    static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
+    static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
 
     for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
     {
-      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
+      assert(idx<NUM_PRIORITY_LIST);
+      Int i = uiPriorityList0[idx];
+      Int j = uiPriorityList1[idx];
       if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
       {
@@ -4477,9 +4169,11 @@
   }
   // early termination
-  if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
+  if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
+
   Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
+
   Int r = 0;
   Int refcnt = 0;
@@ -4496,4 +4190,5 @@
     }
     uiArrayAddr++;
+
     if ( refcnt == iNumRefIdx - 1 )
     {
@@ -4506,363 +4201,6 @@
     }
   }
-
   numValidMergeCand = uiArrayAddr;
-#endif
-}
-#else
-
-//! Construct a list of merging candidates
-Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
-{
-  UInt uiAbsPartAddr = m_absZIdxInCtu + uiAbsPartIdx;
-  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
-  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
-  {
-    abCandIsInter[ui] = false;
-    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
-    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
-  }
-  numValidMergeCand = getSlice()->getMaxNumMergeCand();
-  // compute the location of the current PU
-  Int xP, yP, nPSW, nPSH;
-  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
-
-  Int iCount = 0;
-
-  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
-  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
-  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
-  deriveLeftBottomIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
-
-  //left
-  UInt uiLeftPartIdx = 0;
-  TComDataCU* pcCULeft = 0;
-  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
-
-  Bool isAvailableA1 = pcCULeft &&
-                       pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
-                       !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
-                       pcCULeft->isInter( uiLeftPartIdx ) ;
-
-  if ( isAvailableA1 )
-  {
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
-    // get Mv from Left
-    pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-  // above
-  UInt uiAbovePartIdx = 0;
-  TComDataCU* pcCUAbove = 0;
-  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
-
-  Bool isAvailableB1 = pcCUAbove &&
-                       pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
-                       !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
-                       pcCUAbove->isInter( uiAbovePartIdx );
-
-  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
-  {
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
-    // get Mv from Left
-    pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  // above right
-  UInt uiAboveRightPartIdx = 0;
-  TComDataCU* pcCUAboveRight = 0;
-  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
-
-  Bool isAvailableB0 = pcCUAboveRight &&
-                       pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
-                       pcCUAboveRight->isInter( uiAboveRightPartIdx );
-
-  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
-  {
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
-    // get Mv from Left
-    pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  //left bottom
-  UInt uiLeftBottomPartIdx = 0;
-  TComDataCU* pcCULeftBottom = 0;
-  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
-
-  Bool isAvailableA0 = pcCULeftBottom &&
-                       pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
-                       pcCULeftBottom->isInter( uiLeftBottomPartIdx ) ;
-
-  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
-  {
-    abCandIsInter[iCount] = true;
-    // get Inter Dir
-    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
-    // get Mv from Left
-    pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-    if ( getSlice()->isInterB() )
-    {
-      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-    }
-    if ( mrgCandIdx == iCount )
-    {
-      return;
-    }
-    iCount ++;
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  // above left
-  if( iCount < 4 )
-  {
-    UInt uiAboveLeftPartIdx = 0;
-    TComDataCU* pcCUAboveLeft = 0;
-    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
-
-    Bool isAvailableB2 = pcCUAboveLeft &&
-                         pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
-                         pcCUAboveLeft->isInter( uiAboveLeftPartIdx );
-
-    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
-        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
-    {
-      abCandIsInter[iCount] = true;
-      // get Inter Dir
-      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
-      // get Mv from Left
-      pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
-      if ( getSlice()->isInterB() )
-      {
-        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
-      }
-      if ( mrgCandIdx == iCount )
-      {
-        return;
-      }
-      iCount ++;
-    }
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  if ( getSlice()->getEnableTMVPFlag() )
-  {
-    //>> MTK colocated-RightBottom
-    UInt uiPartIdxRB;
-
-    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );
-
-    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
-    const UInt numPartInCtuWidth  = m_pcPic->getNumPartInCtuWidth();
-    const UInt numPartInCtuHeight = m_pcPic->getNumPartInCtuHeight();
-
-    TComMv cColMv;
-    Int iRefIdx;
-    Int ctuRsAddr = -1;
-
-    if (   ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth () ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples () )  // image boundary check
-        && ( ( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
-    {
-      if ( ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 ) &&           // is not at the last column of CTU
-        ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 ) )              // is not at the last row    of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + numPartInCtuWidth + 1 ];
-        ctuRsAddr = getCtuRsAddr();
-      }
-      else if ( uiAbsPartIdxTmp % numPartInCtuWidth < numPartInCtuWidth - 1 )           // is not at the last column of CTU But is last row of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + numPartInCtuWidth + 1) % m_pcPic->getNumPartitionsInCtu() ];
-      }
-      else if ( uiAbsPartIdxTmp / numPartInCtuWidth < numPartInCtuHeight - 1 )          // is not at the last row of CTU But is last column of CTU
-      {
-        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
-        ctuRsAddr = getCtuRsAddr() + 1;
-      }
-      else //is the right bottom corner of CTU
-      {
-        uiAbsPartAddr = 0;
-      }
-    }
-
-    iRefIdx = 0;
-
-    Bool bExistMV = false;
-    UInt uiPartIdxCenter;
-    Int dir = 0;
-    UInt uiArrayAddr = iCount;
-    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
-    bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_0, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx );
-    if( bExistMV == false )
-    {
-      bExistMV = xGetColMVP( REF_PIC_LIST_0, getCtuRsAddr(), uiPartIdxCenter,  cColMv, iRefIdx );
-    }
-    if( bExistMV )
-    {
-      dir |= 1;
-      pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
-    }
-
-    if ( getSlice()->isInterB() )
-    {
-#if NH_3D_TMVP
-      iRefIdx =0; 
-#endif
-      bExistMV = ctuRsAddr >= 0 && xGetColMVP( REF_PIC_LIST_1, ctuRsAddr, uiAbsPartAddr, cColMv, iRefIdx);
-      if( bExistMV == false )
-      {
-        bExistMV = xGetColMVP( REF_PIC_LIST_1, getCtuRsAddr(), uiPartIdxCenter, cColMv, iRefIdx );
-      }
-      if( bExistMV )
-      {
-        dir |= 2;
-        pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
-      }
-    }
-
-    if (dir != 0)
-    {
-      puhInterDirNeighbours[uiArrayAddr] = dir;
-      abCandIsInter[uiArrayAddr] = true;
-
-      if ( mrgCandIdx == iCount )
-      {
-        return;
-      }
-      iCount++;
-    }
-  }
-  // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  UInt uiArrayAddr = iCount;
-  UInt uiCutoff = uiArrayAddr;
-
-  if ( getSlice()->isInterB() )
-  {
-    static const UInt NUM_PRIORITY_LIST=12;
-    static const UInt uiPriorityList0[NUM_PRIORITY_LIST] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
-    static const UInt uiPriorityList1[NUM_PRIORITY_LIST] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
-
-    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
-    {
-      assert(idx<NUM_PRIORITY_LIST);
-      Int i = uiPriorityList0[idx];
-      Int j = uiPriorityList1[idx];
-      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
-      {
-        abCandIsInter[uiArrayAddr] = true;
-        puhInterDirNeighbours[uiArrayAddr] = 3;
-
-        // get Mv from cand[i] and cand[j]
-        pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
-        pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
-
-        Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
-        Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
-        if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
-        {
-          abCandIsInter[uiArrayAddr] = false;
-        }
-        else
-        {
-          uiArrayAddr++;
-        }
-      }
-    }
-  }
-  // early termination
-  if (uiArrayAddr == getSlice()->getMaxNumMergeCand())
-  {
-    return;
-  }
-
-  Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
-
-  Int r = 0;
-  Int refcnt = 0;
-  while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
-  {
-    abCandIsInter[uiArrayAddr] = true;
-    puhInterDirNeighbours[uiArrayAddr] = 1;
-    pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
-
-    if ( getSlice()->isInterB() )
-    {
-      puhInterDirNeighbours[uiArrayAddr] = 3;
-      pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
-    }
-    uiArrayAddr++;
-
-    if ( refcnt == iNumRefIdx - 1 )
-    {
-      r = 0;
-    }
-    else
-    {
-      ++r;
-      ++refcnt;
-    }
-  }
-  numValidMergeCand = uiArrayAddr;
-}
-#endif
+}
 
 /** Check whether the current PU and a spatial neighboring PU are in a same ME region.
@@ -5122,5 +4460,5 @@
   UInt partAddr;
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( getDBBPFlag(0) )
   {
@@ -5142,5 +4480,5 @@
   const TComSPS &sps=*(m_pcSlice->getSPS());
   Int  iMvShift = 2;
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( getSlice()->getIsDepth() )
     iMvShift = 0;
@@ -5666,5 +5004,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
 {
@@ -5676,5 +5014,5 @@
     Int iViewIdx = getSlice()->getDefaultRefViewIdx();
     pDisp->m_aVIdxCan = iViewIdx;
-    Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepthY() - 1 )) ];
+    Int iDisp     = getSlice()->getDepthToDisparityB( iViewIdx )[ (Int64) (1 << ( getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 )) ];
 
     cMv.setHor(iDisp);
@@ -5743,11 +5081,11 @@
 }
 #endif
-#if H_3D_NBDV 
+#if NH_3D_NBDV 
 //Notes from QC:
-//TBD#1: DoNBDV related contributions are just partially integrated under the marco of H_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
+//TBD#1: DoNBDV related contributions are just partially integrated under the marco of NH_3D_NBDV_REF, remove this comment once DoNBDV and BVSP are done
 //TBD#2: set of DvMCP values need to be done as part of inter-view motion prediction process. Remove this comment once merge related integration is done
 //To be checked: Parallel Merge features for NBDV, related to DV_DERIVATION_PARALLEL_B0096 and LGE_IVMP_PARALLEL_MERGE_B0136 are not integrated. The need of these features due to the adoption of CU-based NBDV is not clear. We need confirmation on this, especially by proponents
 Void TComDataCU::getDisMvpCandNBDV( DisInfo* pDInfo
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
 , Bool bDepthRefine
 #endif
@@ -5772,5 +5110,5 @@
     }
   }
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   if( !m_pcSlice->getDepthRefinementFlag( ) )
   {
@@ -5795,5 +5133,5 @@
     ///*** Derive center position ***
     UInt uiPartIdxCenter;
-    Int  uiLCUIdx   = getAddr();
+    Int  uiLCUIdx = getCtuRsAddr();
     xDeriveCenterIdx(uiPartIdx, uiPartIdxCenter );
 
@@ -5822,5 +5160,5 @@
         pDInfo->m_aVIdxCan  = iTargetViewIdx;
 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
         TComPic* picDepth = NULL;   
 #if H_3D_FCO_VSP_DONBDV_E0163
@@ -5844,5 +5182,5 @@
         }
         pDInfo->m_acDoNBDV  = cColMv;
-#endif //H_3D_NBDV_REF
+#endif //NH_3D_NBDV_REF
         return;
       }
@@ -5858,5 +5196,5 @@
   bCheckMcpDv = true; 
   if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_LEFT
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
     , bDepthRefine 
 #endif
@@ -5868,7 +5206,7 @@
   if(pcTmpCU != NULL )
   {
-    bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
+    bCheckMcpDv = ( ( getCtuRsAddr() - pcTmpCU->getCtuRsAddr() ) == 0);
     if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, pDInfo, bCheckMcpDv, &cIDVInfo, DVFROM_ABOVE
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
       , bDepthRefine 
 #endif
@@ -5889,5 +5227,5 @@
           pDInfo->m_acNBDV = cDispVec;
           pDInfo->m_aVIdxCan = cIDVInfo.m_aVIdxCan[iList][ curPos ];
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
 #if H_3D_FCO_VSP_DONBDV_E0163
           TComPic* picDepth  = NULL;
@@ -5927,5 +5265,5 @@
     pDInfo->m_aVIdxCan = getSlice()->getDefaultRefViewIdx();
 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
     TComPic* picDepth = NULL;
 #if H_3D_FCO_VSP_DONBDV_E0163
@@ -5953,10 +5291,10 @@
 }
 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
 Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT )
 {
-  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
-  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
-  
+  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth(COMPONENT_Y);
+  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight(COMPONENT_Y);
+
   Int depthStartPosX = Clip3(0,   iPictureWidth - 1,  iBlkX + ((mv->getHor()+2)>>2));
   Int depthStartPosY = Clip3(0,   iPictureHeight - 1, iBlkY + ((mv->getVer()+2)>>2));
@@ -5964,6 +5302,6 @@
   Int depthEndPosY   = Clip3(0,   iPictureHeight - 1, iBlkY + iBlkHeight - 1 + ((mv->getVer()+2)>>2));
 
-  Pel* depthTL  = pcBaseViewDepthPicYuv->getLumaAddr();
-  Int depStride =  pcBaseViewDepthPicYuv->getStride();
+  Pel* depthTL  = pcBaseViewDepthPicYuv->getAddr(COMPONENT_Y);
+  Int depStride =  pcBaseViewDepthPicYuv->getStride(COMPONENT_Y);
 
   Pel  maxDepthVal = 0;
@@ -5980,11 +5318,12 @@
   if (picDepth)
   {
-    UInt uiAbsPartAddrCurrCU = m_uiAbsIdxInLCU + uiPartAddr;
+    UInt uiAbsPartAddrCurrCU = m_absZIdxInCtu + uiPartAddr;
     Int iWidth, iHeight;
     getPartIndexAndSize( uiPartIdx, uiPartAddr, iWidth, iHeight ); // The modified value of uiPartAddr won't be used any more
 
     TComPicYuv* pcBaseViewDepthPicYuv = picDepth->getPicYuvRec();
-    Int iBlkX = ( getAddr() % picDepth->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
-    Int iBlkY = ( getAddr() / picDepth->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
+    const TComSPS   &sps =*(getSlice()->getSPS());
+    Int iBlkX = ( getCtuRsAddr() % picDepth->getFrameWidthInCtus() ) * sps.getMaxCUWidth()  + g_auiRasterToPelX[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
+    Int iBlkY = ( getCtuRsAddr() / picDepth->getFrameWidthInCtus() ) * sps.getMaxCUHeight() + g_auiRasterToPelY[ g_auiZscanToRaster[ uiAbsPartAddrCurrCU ] ];
 
     Int* aiShiftLUT = getSlice()->getDepthToDisparityB(refViewIdx );
@@ -5994,9 +5333,9 @@
   }
 }
-#endif //H_3D_NBDV_REF
+#endif //NH_3D_NBDV_REF
 
 
 Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paIDVInfo, UInt uiMvpDvPos
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
 , Bool bDepthRefine 
 #endif
@@ -6019,5 +5358,5 @@
           pNbDvInfo->m_acNBDV = cMvPred;
           pNbDvInfo->m_aVIdxCan = refViewIdx;
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
           TComPic* picDepth = NULL;
           assert(getSlice()->getRefPic(eRefPicList, refId)->getPOC() == getSlice()->getPOC());          
@@ -6065,6 +5404,6 @@
 {
   UInt uiPartIdx = 0;
-  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();  
-  Int uiLCUIdx = getAddr();
+  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInCtuWidth();  
+  Int uiLCUIdx = getCtuRsAddr();
 
   UInt uiPartIdxRB;
@@ -6072,10 +5411,10 @@
   UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
 
-  if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
+  if (( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
   {
     riLCUIdxRBNb  = -1;
     riPartIdxRBNb = -1;
   }
-  else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
+  else if(( m_pcPic->getCtu(m_ctuRsAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
   {
     riLCUIdxRBNb  = -1;
@@ -6085,5 +5424,5 @@
   {
     if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
-      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+      ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) ) // is not at the last row    of LCU
     {
       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
@@ -6095,5 +5434,5 @@
       riLCUIdxRBNb  = -1;
     }
-    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+    else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInCtuHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
     {
       riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
@@ -6111,5 +5450,11 @@
 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth )
 {
-  UInt uiCurrPartNumb = m_pcPic->getNumPartInCU() >> (uiDepth << 1);
+#if NH_3D_VSP // bug fix
+  UInt uiCurrPartNumb = m_pcPic->getNumPartitionsInCtu() >> (uiDepth << 1);
+  assert(m_pcPic->getNumPartitionsInCtu() ==m_pcPic->getNumPartInCtuWidth()*m_pcPic->getNumPartInCtuHeight());
+
+#else
+  UInt uiCurrPartNumb = m_pcPic->getNumPartInCtuWidth() >> (uiDepth << 1);
+#endif
   for (UInt ui = 0; ui < uiCurrPartNumb; ui++ )
   {
@@ -6117,5 +5462,5 @@
   }
 }
-#if H_3D_VSP
+#if NH_3D_VSP  || NH_3D_DBBP
 Void TComDataCU::setDvInfoSubParts( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPUIdx, UInt uiDepth )
 {
@@ -6130,7 +5475,7 @@
   Int iColViewIdx, iColRefViewIdx;
   TComPic *pColPic = getSlice()->getRefPic( eRefPicList, refidx);
-  TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
+  TComDataCU *pColCU = pColPic->getCtu( uiCUAddr );
   iColViewIdx = pColCU->getSlice()->getViewIndex();
-  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==SIZE_NONE||pColCU->isIntra(uiPartUnitIdx))
+  if (pColCU->getPic()==0||pColCU->getPartitionSize(uiPartUnitIdx)==NUMBER_OF_PART_SIZES||pColCU->isIntra(uiPartUnitIdx))
   {
     return false;
@@ -6194,7 +5539,7 @@
 
   Bool depthRefineFlag = false; 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 
-#endif // H_3D_NBDV_REF
+#endif // NH_3D_NBDV_REF
 
   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
@@ -6250,5 +5595,5 @@
 #endif
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
 {
@@ -6267,17 +5612,17 @@
 Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
 {
-  uiBaseAbsPartIdx += m_uiAbsIdxInLCU;
+  uiBaseAbsPartIdx += m_absZIdxInCtu;
   Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
   Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
   Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
   Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
-  Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth();
+  Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + iCurrPelX/getPic()->getMinCUWidth();
   ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
-  ruiPartAddr -= m_uiAbsIdxInLCU;  
+  ruiPartAddr -= m_absZIdxInCtu;  
 }
 
 Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
 {
-  uiAbsPartIdx += getZorderIdxInCU();
+  uiAbsPartIdx += getZorderIdxInCtu();
   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
@@ -6291,7 +5636,7 @@
     for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
     {
-      iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth();
+      iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInCtuWidth() + j/getPic()->getMinCUWidth();
       uiPartAddr = g_auiRasterToZscan[iCurrRaster];
-      uiPartAddr -= getZorderIdxInCU();  
+      uiPartAddr -= getZorderIdxInCtu();  
 
       m_puhInterDir[uiPartAddr] = uiDir;
@@ -6301,8 +5646,8 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Bool
 TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc , Bool bIsDepth           
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -6323,7 +5668,7 @@
 
   Int  iCurrPosX, iCurrPosY;
-  pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
-
-#if !H_3D_SPIVMP
+  pcBaseRec->getTopLeftSamplePos( getCtuRsAddr(), getZorderIdxInCtu() + uiPartAddr, iCurrPosX, iCurrPosY );
+
+#if !NH_3D_SPIVMP
   iCurrPosX  += ( iWidth  >> 1 );
   iCurrPosY  += ( iHeight >> 1 );
@@ -6331,7 +5676,7 @@
 
   Bool depthRefineFlag = false; 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   depthRefineFlag = m_pcSlice->getDepthRefinementFlag( ); 
-#endif // H_3D_NBDV_REF
+#endif // NH_3D_NBDV_REF
 
   TComMv      cDv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
@@ -6342,5 +5687,5 @@
 
   Bool abPdmAvailable[8] =  {false, false, false, false, false, false, false, false};
-#if H_3D_NBDV
+#if NH_3D_NBDV
   for( Int i = 0; i < 8; i++)
   {
@@ -6352,5 +5697,5 @@
   {
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     ////////////////////////////////
     //////////sub-PU IvMC///////////
@@ -6358,5 +5703,9 @@
     if(!m_pcSlice->getIsDepth())
     {
+#if H_3D_DBBP
       if (!getDBBPFlag(0))
+#else
+      if (1)
+#endif
       {
         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
@@ -6390,9 +5739,9 @@
         }
 
-        Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
-        Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 
+        Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+        Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 
 
         pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
-        TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
+        TComDataCU* pcDefaultCU    = pcBasePic->getCtu( iRefCenterCUAddr );
         if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
         {
@@ -6418,6 +5767,6 @@
                       abPdmAvailable[ uiCurrRefListId ] = true;
                       TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
-#if H_3D_NBDV 
-#if H_3D_IV_MERGE
+#if NH_3D_NBDV 
+#if NH_3D_IV_MERGE
                       if( !bIsDepth )
                       {
@@ -6427,5 +5776,5 @@
                         cMv.setIDVVer    (cDv.getVer());  
                         cMv.setIDVVId    (iViewIndex); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                       }
 #endif
@@ -6452,9 +5801,9 @@
             for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
             {
-              iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
-              iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 
+              iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
+              iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 
 
               pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
-              pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+              pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
               if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
               {
@@ -6524,5 +5873,5 @@
     ////////////////////////////////
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     if(m_pcSlice->getIsDepth())
     {
@@ -6530,6 +5879,10 @@
       iCurrPosY  += ( iHeight >> 1 );
     }
+#if H_3D_DBBP
     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
 #else
+    for(Int iLoopCan = ( m_pcSlice->getIsDepth() ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#endif
+#else
     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
 #endif
@@ -6541,12 +5894,12 @@
       Int         iBaseAbsPartIdx;
 
-      Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2 );
-      Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2 );
-
-      Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
-      Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
+      Int offsetW = (iLoopCan == 0) ? 0 : ( iWidth  * 2);
+      Int offsetH = (iLoopCan == 0) ? 0 : ( iHeight * 2);
+
+      Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth (COMPONENT_Y) - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
+      Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight(COMPONENT_Y) - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
       pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
 
-      TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+      TComDataCU* pcBaseCU    = pcBasePic->getCtu( iBaseCUAddr );
       if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
       {
@@ -6575,6 +5928,6 @@
                     abPdmAvailable[ (uiCurrRefListId + (iLoopCan<<2)) ] = true;
                     TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
-#if H_3D_NBDV 
-#if H_3D_IV_MERGE
+#if NH_3D_NBDV 
+#if NH_3D_IV_MERGE
                     if( !bIsDepth )
                     {
@@ -6584,5 +5937,5 @@
                       cMv.setIDVVer    (cDv.getVer());  
                       cMv.setIDVVId    (iViewIndex); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                     }
 #endif
@@ -6600,6 +5953,10 @@
       }
     }
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
+#if H_3D_DBBP
     for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
+#else
+    for(Int iLoopCan = ( m_pcSlice->getIsDepth()  ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++)
+#endif
 #else
     for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
@@ -6630,9 +5987,9 @@
             abPdmAvailable[ iRefListId + 2 + (iLoopCan<<2) ] = true;
             paiPdmRefIdx  [ iRefListId + 2 + (iLoopCan<<2) ] = iPdmRefIdx;
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
             TComMv cMv = depthRefineFlag ? pDInfo->m_acDoNBDV : pDInfo->m_acNBDV; 
 #endif
             cMv.setHor( cMv.getHor() + ioffsetDV );
-#if H_3D_IV_MERGE 
+#if NH_3D_IV_MERGE 
             if( bIsDepth )
             {
@@ -6655,9 +6012,8 @@
 }
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TComDataCU::setARPWSubParts ( UChar w, UInt uiAbsPartIdx, UInt uiDepth )
 {
-  assert( sizeof( *m_puhARPW) == 1 );
-  memset( m_puhARPW + uiAbsPartIdx, w, m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ) );
+  setSubPart<UChar>( w, m_puhARPW, uiAbsPartIdx, uiDepth, 0 );
 }
 #endif
@@ -6728,5 +6084,5 @@
 #endif
 
-#if H_3D_VSP
+#if NH_3D_VSP
 Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
 {
@@ -6784,10 +6140,10 @@
   TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
   Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
-  Int numPartsLine    = cu->getPic()->getNumPartInWidth();
+  Int numPartsLine    = cu->getPic()->getNumPartInCtuWidth();
 
   Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
   Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
 
-  Int refDepStride = picRefDepth->getStride();
+  Int refDepStride = picRefDepth->getStride( COMPONENT_Y );
 
   TComMv tmpMv(0, 0);
@@ -6795,5 +6151,5 @@
 
   Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
-  Pel *refDepth     = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;
+  Pel *refDepth     = picRefDepth->getAddr( COMPONENT_Y, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refDepOffset;
 
   if ((height % 8))
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComDataCU.h	(revision 1274)
@@ -50,7 +50,4 @@
 #include "TComPattern.h"
 
-#if H_3D_ARP
-#include "TComYuv.h"
-#endif
 #if H_3D
 #include <algorithm>
@@ -65,5 +62,5 @@
 static const UInt NUM_MOST_PROBABLE_MODES=3;
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 typedef struct _DBBPTmpData
 {
@@ -167,14 +164,14 @@
   Char*         m_apiMVPNum[NUM_REF_PIC_LIST_01];       ///< array of number of possible motion vectors predictors
   Bool*         m_pbIPCMFlag;         ///< array of intra_pcm flags
-#if H_3D_NBDV
+#if NH_3D_NBDV
   DisInfo*      m_pDvInfo;
 #endif
-#if H_3D_VSP
+#if NH_3D_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
+#if NH_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
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   UChar*        m_puhARPW;
 #endif
@@ -193,9 +190,9 @@
 #endif
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
   DbbpTmpData   m_sDBBPTmpData;
 #endif
-#if H_3D
+#if NH_3D_MLC
   Bool          m_bAvailableFlagA1;    ///< A1 available flag
   Bool          m_bAvailableFlagB1;    ///< B1 available flag
@@ -220,10 +217,8 @@
   UInt          m_uiTotalBins;        ///< sum of partition bins
   Char          m_codedQP;
-#if H_3D
-  DisInfo       m_cDefaultDisInfo;    ///< Default disparity information for initializing
-#endif
-#if H_3D_IV_MERGE
-  TComMotionCand  m_mergCands[MRG_IVSHIFT+1];
-  Int           m_baseListidc;
+#if NH_3D_MLC
+  DisInfo         m_cDefaultDisInfo;    ///< Default disparity information for initializing
+  TComMotionCand  m_mergCands[MRG_IVSHIFT+1];   ///< Motion candidates for merge mode
+  Int             m_numSpatialCands;
 #endif
 
@@ -235,8 +230,8 @@
   Bool          xAddMVPCand           ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
   Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
-#if H_3D_VSP
+#if NH_3D_VSP
   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
 #endif
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ); 
 #endif
@@ -251,5 +246,5 @@
 
   /// compute scaling factor from POC difference
-#if !H_3D_ARP
+#if !NH_3D_ARP
   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
 #endif
@@ -257,5 +252,5 @@
   Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
 
-#if H_3D_VSP
+#if NH_3D_VSP
   Void xSetMvFieldForVSP  ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize );
 #endif
@@ -268,5 +263,6 @@
   // create / destroy / initialize / copy
   // -------------------------------------------------------------------------------------------------------------------
-#if H_3D_ARP
+#if NH_3D_ARP
+  /// compute scaling factor from POC difference
   Int           xGetDistScaleFactor   ( Int iCurrPOC, Int iCurrRefPOC, Int iColPOC, Int iColRefPOC );
 #endif 
@@ -282,11 +278,11 @@
   Void          initSubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx, UInt uiDepth, Int qp );
   Void          setOutsideCUPart      ( UInt uiAbsPartIdx, UInt uiDepth );
-#if H_3D_NBDV
-  Void          copyDVInfoFrom (TComDataCU* pcCU, UInt uiAbsPartIdx);
+#if NH_3D_NBDV
+  Void          copyDVInfoFrom        (TComDataCU* pcCU, UInt uiAbsPartIdx);
 #endif
 
   Void          copySubCU             ( TComDataCU* pcCU, UInt uiPartUnitIdx );
   Void          copyInterPredInfoFrom ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefPicList 
-#if H_3D_NBDV
+#if NH_3D_NBDV
   , Bool bNBDV = false
 #endif
@@ -319,4 +315,8 @@
 #endif
 
+#if NH_3D_ARP
+  Void          setSlice              ( TComSlice* pcSlice)     { m_pcSlice = pcSlice;       }
+  Void          setPic                ( TComDataCU* pcCU  )     { m_pcPic              = pcCU->getPic(); }
+#endif
   // -------------------------------------------------------------------------------------------------------------------
   // member functions for CU data
@@ -329,5 +329,5 @@
   Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Pel*          getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride);
 #endif
@@ -353,5 +353,5 @@
   Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Bool*         getDBBPFlag           ()                        { return m_pbDBBPFlag;               }
   Bool          getDBBPFlag           ( UInt uiIdx )            { return m_pbDBBPFlag[uiIdx];        }
@@ -454,5 +454,5 @@
   template <typename T>
   Void          setSubPart            ( T bParameter, T* pbBaseCtu, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
-#if H_3D_VSP
+#if H_3D_VSP || NH_3D_DBBP
   template<typename T>
   Void          setSubPartT           ( T uiParameter, T* puhBaseLCU, UInt uiCUAddr, UInt uiCUDepth, UInt uiPUIdx );
@@ -480,15 +480,17 @@
   Void          setIPCMFlag           (UInt uiIdx, Bool b )     { m_pbIPCMFlag[uiIdx] = b;           }
   Void          setIPCMFlagSubParts   (Bool bIpcmFlag, UInt uiAbsPartIdx, UInt uiDepth);
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiDepth );
+#if H_3D_VSP || NH_3D_DBBP
   Void          setDvInfoSubParts     ( DisInfo cDvInfo, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth);
+#endif
   DisInfo*      getDvInfo             ()                        { return m_pDvInfo;                 }
   DisInfo       getDvInfo             (UInt uiIdx)              { return m_pDvInfo[uiIdx];          }
 #endif
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Void          xDeriveRightBottomNbIdx(Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
   Bool          xCheckSpatialNBDV (TComDataCU* pcTmpCU, UInt uiIdx, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, IDVInfo* paMvpDvInfo,
                                    UInt uiMvpDvPos
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   , Bool bDepthRefine = false
 #endif
@@ -496,9 +498,13 @@
   Bool          xGetColDisMV      ( Int currCandPic, RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
   Void          getDisMvpCandNBDV ( DisInfo* pDInfo
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
    , Bool bDepthRefine = false
 #endif
    ); 
    
+#if NH_3D_IV_MERGE
+  Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
+#endif
+
 #if H_3D
   Void          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
@@ -507,21 +513,21 @@
    Bool          getNeighDepth (UInt uiPartIdx, UInt uiPartAddr, Pel* pNeighDepth, Int index);
 #endif
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
   Void          estimateDVFromDM(Int refViewIdx, UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred );
-#endif //H_3D_NBDV_REF
+#endif //NH_3D_NBDV_REF
 #endif
 #if  H_3D_FAST_TEXTURE_ENCODING
   Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   Void          getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight);
   Void          getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr );
   Void          setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight );
 #endif
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc, Bool bIsDepth           
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , TComMvField* pcMFieldSP, UChar* puhInterDirSP
 #endif    
@@ -529,10 +535,9 @@
     );   
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   UChar*        getARPW            ()                        { return m_puhARPW;               }
   UChar         getARPW            ( UInt uiIdx )            { return m_puhARPW[uiIdx];        }
   Void          setARPW            ( UInt uiIdx, UChar w )   { m_puhARPW[uiIdx] = w;           }
   Void          setARPWSubParts    ( UChar w, UInt uiAbsPartIdx, UInt uiDepth );
-  Double        getARPWFactor      ( UInt uiIdx );
 #endif
 #if NH_3D_IC
@@ -542,4 +547,6 @@
   Void          setICFlagSubParts  ( Bool bICFlag,  UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
   Bool          isICFlagRequired   ( UInt uiAbsPartIdx );
+  Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
+#elif NH_3D_VSP
   Void          getPartIndexAndSize( UInt uiPartIdx, UInt& ruiPartAddr, Int& riWidth, Int& riHeight, UInt uiAbsPartIdx = 0, Bool bLCU = false);
 #else
@@ -654,31 +661,30 @@
   Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
 
-#if H_3D
-  Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;}
-  Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;}
-  Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;}
-  Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
-  Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
+#if NH_3D_MLC
+  Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;   }
+  Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;   }
+  Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;   }
+  Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;   }
+  Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;   }
   Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
   Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
     , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , Bool* pbSPIVMPFlag
 #endif
     , Int& numValidMergeCand
     );
-  Void          getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1);
-  Void          xGetInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
-#else
+  Void          xGetInterMergeCandidates      ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+#if NH_3D_SPIVMP
+  , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+  , Int& numValidMergeCand, Int mrgCandIdx = -1 );
+#endif
   Void          getInterMergeCandidates       ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1 );
-#endif
-#if H_3D_SPIVMP
-                                            , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
-#endif
-
-#if H_3D_VSP
-#if H_3D_SPIVMP
+
+#if NH_3D_VSP
+#if NH_3D_SPIVMP
   Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
   Bool          getSPIVMPFlag        ( UInt uiIdx )            { return m_pbSPIVMPFlag[uiIdx];   }
@@ -723,5 +729,5 @@
   UInt          getCtxSkipFlag                  ( UInt   uiAbsPartIdx                                 );
   UInt          getCtxInterDir                  ( UInt   uiAbsPartIdx                                 );
-#if H_3D_ARP
+#if NH_3D_ARP
   UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
 #endif  
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.cpp	(revision 1274)
@@ -75,5 +75,5 @@
 };
 
-#if H_3D_ARP
+#if NH_3D_ARP
 const Short TComInterpolationFilter::m_lumaFilterARP[4][NTAPS_LUMA_ARP] =
 {
@@ -361,5 +361,5 @@
  */
 Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -372,16 +372,15 @@
   else if (isLuma(compID))
   {
-#if H_3D_ARP
+    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
     if(filterType)
     {
-      filterHor<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
+      filterHor<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterARP[frac]);
     }
     else
     {
 #endif
-
-    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
-#if H_3D_ARP
+#if NH_3D_ARP
     }
 #endif
@@ -392,5 +391,16 @@
     const UInt csx = getComponentScaleX(compID, fmt);
     assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
+    if(filterType)
+    {
+      filterHor<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
+    }
+    else
+    {
+#endif
     filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
+#if NH_3D_ARP
+    }
+#endif
   }
 }
@@ -414,5 +424,5 @@
  */
 Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -425,15 +435,15 @@
   else if (isLuma(compID))
   {
-#if H_3D_ARP
+    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
     if(filterType)
     {
-      filterVer<NTAPS_LUMA_ARP>(g_bitDepthY, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);    
+      filterVer<NTAPS_LUMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterARP[frac]);    
     }
     else
     {
 #endif
-    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
     filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
-#if H_3D_ARP
+#if NH_3D_ARP
     }
 #endif
@@ -444,39 +454,17 @@
     const UInt csy = getComponentScaleY(compID, fmt);
     assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
+#if NH_3D_ARP
+    if(filterType)
+    {
+      filterVer<NTAPS_CHROMA_ARP>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);    
+    }
+    else
+    {
+#endif
     filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
-  }
-}
-
-#if H_3D_ARP
-    , Bool filterType
-#endif
-
-#if H_3D_ARP
-    if(filterType)
-    {
-      filterHor<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilterARP[frac]);
-    }
-    else
-    {
-#endif
-#if H_3D_ARP
-    }
-#endif
-#if H_3D_ARP
-    , Bool filterType
-#endif
-#if H_3D_ARP
-    if(filterType)
-    {
-      filterVer<NTAPS_CHROMA_ARP>(g_bitDepthC, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilterARP[frac]);
-    }
-    else
-    {
-#endif
-#if H_3D_ARP
-    }
-#endif
-
-
-
+#if NH_3D_ARP
+    }
+#endif
+    }
+    }
 //! \}
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1274)
@@ -45,5 +45,5 @@
 //! \{
 
-#if H_3D_ARP
+#if NH_3D_ARP
 #define NTAPS_LUMA_ARP    2 ///< Number of taps for luma
 #define NTAPS_CHROMA_ARP  2 ///< Number of taps for chroma
@@ -63,5 +63,5 @@
   static const TFilterCoeff m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA];     ///< Luma filter taps
   static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps
-#if H_3D_ARP
+#if NH_3D_ARP
   static const Short m_lumaFilterARP  [4][NTAPS_LUMA_ARP];     ///< Luma filter taps for ARP
   static const Short m_chromaFilterARP[8][NTAPS_CHROMA_ARP];   ///< Chroma filter taps for ARP
@@ -83,10 +83,10 @@
 
   Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
 );
   Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
@@ -94,11 +94,4 @@
 };
 
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
-
 //! \}
 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1274)
@@ -40,5 +40,5 @@
 #include "assert.h"
 #include <stdlib.h>
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 #include "TComDataCU.h"
 #include "TComPic.h"
@@ -328,8 +328,8 @@
 }
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 Void TComCUMvField::setMvFieldSP( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  )
 {
-  uiAbsPartIdx += pcCU->getZorderIdxInCU();
+  uiAbsPartIdx += pcCU->getZorderIdxInCtu();
   Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
   Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
@@ -341,7 +341,7 @@
     for (Int j=iStartPelX; j < iEndPelX; j += pcCU->getPic()->getMinCUWidth())
     {
-      Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
+      Int iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInCtuWidth() + j/pcCU->getPic()->getMinCUWidth();
       Int uiPartAddr = g_auiRasterToZscan[iCurrRaster];
-      uiPartAddr -= pcCU->getZorderIdxInCU();  
+      uiPartAddr -= pcCU->getZorderIdxInCtu();  
 
       m_pcMv[uiPartAddr] = cMvField.getMv();
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1274)
@@ -50,5 +50,5 @@
 // ====================================================================================================================
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 class TComDataCU;
 #endif
@@ -60,9 +60,9 @@
 } AMVPInfo;
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
 typedef struct _DisCand 
 {
   TComMv m_acNBDV;              // DV from NBDV
-#if H_3D_NBDV_REF 
+#if NH_3D_NBDV_REF 
   TComMv m_acDoNBDV;            // DV from DoNBDV
 #endif  
@@ -107,5 +107,5 @@
   Int getHor   () const { return  m_acMv.getHor(); }
   Int getVer   () const { return  m_acMv.getVer(); }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   Bool operator== ( const TComMvField& rcMv ) const
   {
@@ -167,8 +167,8 @@
   Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
   Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
 #endif
-#if H_3D_VSP
+#if NH_3D_VSP
   Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
   Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
@@ -192,5 +192,6 @@
 //! \}
 
-#if H_3D_IV_MERGE
+#if NH_3D_MLC
+/// class for container of merge candidate
 class TComMotionCand
 {
@@ -199,8 +200,10 @@
   TComMvField           m_cMvField[2];
   UChar                 m_uDir;
-#if H_3D_VSP
+#if NH_3D_VSP
   Int                   m_iVspFlag;
-#endif  
+#endif
+#if NH_3D_SPIVMP
   Bool                  m_bSPIVMPFlag;
+#endif
 
 public:
@@ -209,8 +212,10 @@
     m_bAvailable = false;
     m_uDir = 0;
-#if H_3D_VSP
+#if NH_3D_VSP
     m_iVspFlag = 0;
 #endif
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = false;
+#endif
   }
 
@@ -226,8 +231,10 @@
     m_bAvailable = false;
     m_uDir = 0;
-#if H_3D_VSP
+#if NH_3D_VSP
     m_iVspFlag = 0;
 #endif
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = false;
+#endif
     m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
     m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
@@ -235,8 +242,10 @@
 
   Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
     , Int vspFlag
 #endif
+#if NH_3D_SPIVMP
     , Bool bSPIVMPFlag
+#endif
     )
   {
@@ -245,16 +254,19 @@
     m_cMvField[1] = pcMvFieldNeighbours[1];
     m_uDir = uhInterDirNeighbours;
-#if H_3D_VSP
+#if NH_3D_VSP
     m_iVspFlag = vspFlag;
 #endif
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = bSPIVMPFlag;
-  }
-
-
+#endif
+  }
+  
   Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
     , Int* vspFlag
 #endif
+#if NH_3D_SPIVMP
     , Bool* pbSPIVMPFlag
+#endif
     )
   {
@@ -262,8 +274,10 @@
     pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
     puhInterDirNeighbours[iCount] = m_uDir;
-#if H_3D_VSP
+#if NH_3D_VSP
     vspFlag[iCount] = m_iVspFlag;
 #endif
+#if NH_3D_SPIVMP
     pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
+#endif
   }
 };
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMv.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMv.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComMv.h	(revision 1274)
@@ -57,5 +57,5 @@
   Short m_iHor;     ///< horizontal component of motion vector
   Short m_iVer;     ///< vertical component of motion vector
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Bool  m_bIDV;       
   Short m_iIDVHor;    
@@ -72,5 +72,5 @@
   m_iHor(0),
   m_iVer(0)
-#if H_3D_NBDV
+#if NH_3D_NBDV
   , m_bIDV(false)
   , m_iIDVHor(0)
@@ -84,5 +84,5 @@
   m_iHor(iHor),
   m_iVer(iVer)
- #if H_3D_NBDV
+ #if NH_3D_NBDV
   , m_bIDV(false)
   , m_iIDVHor(0)
@@ -101,10 +101,10 @@
   Void  setVer    ( Short i )                   { m_iVer = i;                               }
   Void  setZero   ()                            { m_iHor = m_iVer = 0; 
- #if H_3D_NBDV
+ #if NH_3D_NBDV
    m_bIDV = false; m_iIDVHor = m_iIDVVer = 0;
    m_iIDVVId = 0; 
 #endif
  }
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Void   setIDVHor  (Short i)                    {m_iIDVHor = i;}
   Void   setIDVVer  (Short i)                    {m_iIDVVer = i;}
@@ -120,5 +120,5 @@
   Int   getAbsHor () const { return abs( m_iHor );   }
   Int   getAbsVer () const { return abs( m_iVer );   }
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Short getIDVHor () const { return m_iIDVHor;       }
   Short getIDVVer () const { return m_iIDVVer;       }
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.cpp	(revision 1274)
@@ -78,5 +78,5 @@
   m_bReduceBitsQTL    = 0;
 #endif
-#if H_3D_NBDV
+#if NH_3D_NBDV
   m_iNumDdvCandPics   = 0;
   m_eRapRefList       = REF_PIC_LIST_0;
@@ -143,4 +143,29 @@
 }
 #if NH_3D
+#if NH_3D_ARP
+Void TComPic::getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx )
+{
+  Int iMaxCUWidth   = (Int) ( getPicSym()->getSPS().getMaxCUWidth()  );
+  Int iMaxCuHeight  = (Int) ( getPicSym()->getSPS().getMaxCUHeight() );
+
+  UInt uiMaxTotalCUDepth = getPicSym()->getSPS().getMaxTotalCUDepth(); 
+  Int iBaseUnitWidth  = iMaxCUWidth >> uiMaxTotalCUDepth;
+  Int iBaseUnitHeight = iMaxCUWidth >> uiMaxTotalCUDepth;
+
+  Int iNumCuInWidth   = getPicYuvRec()->getWidth(COMPONENT_Y) / iMaxCUWidth;
+  iNumCuInWidth      += ( getPicYuvRec()->getWidth(COMPONENT_Y) % iMaxCUWidth ) ? 1 : 0;
+
+
+  Int iCuX            = iX / iMaxCUWidth;
+  Int iCuY            = iY / iMaxCuHeight;
+  Int iBaseX          = ( iX - iCuX * iMaxCUWidth  ) / iBaseUnitWidth;
+  Int iBaseY          = ( iY - iCuY * iMaxCuHeight ) / iBaseUnitHeight;
+  Int iCuSizeInBases  = iMaxCuHeight                 / iBaseUnitWidth;
+
+  riCuAddr            = iCuY   * iNumCuInWidth + iCuX;
+  Int iRastPartIdx    = iBaseY * iCuSizeInBases  + iBaseX;
+  riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
+}
+#endif
 Void TComPic::compressMotion(Int scale)
 #else
@@ -283,5 +308,5 @@
   return getPicYuv( layerIdInNuh, poc, recon );
 }
-#if H_3D_ARP
+#if NH_3D_ARP
 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
 {
@@ -303,6 +328,6 @@
 #endif // NH_MV
 
-#if H_3D_NBDV 
-Int TComPic::getDisCandRefPictures( Int iColPOC )
+#if NH_3D_NBDV 
+Int TComPic::getDisCandRefPictures(Int iColPOC)
 {
   UInt       uiTempLayerCurr = 7;
@@ -310,6 +335,8 @@
   UInt       numDdvCandPics  = 0;
 
-  if ( !currSlice->getEnableTMVPFlag() )
+  if(!currSlice->getEnableTMVPFlag())
+  {
     return numDdvCandPics;
+  }
 
   numDdvCandPics += 1;
@@ -318,18 +345,18 @@
   UInt pocDiff = 255;
 
-  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
-  {
-    UInt x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
-
-    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
+  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr++)
+  {
+    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
+
+    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     {
       if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() 
-        && (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) && numDdvCandPics!=2)
+         && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) && numDdvCandPics != 2)
       {
         TComSlice* refSlice    = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx());
-        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP())? 1: 0; 
+        Bool       bRAP        = (refSlice->getViewIndex() && refSlice->isIRAP()) ? 1 : 0; 
         UInt       uiTempLayer = currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer(); 
         
-        if( bRAP )
+        if(bRAP)
         {
           this->setRapRefIdx(i);
@@ -350,15 +377,15 @@
   UInt idx = 0;
   
-  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2: 1); lpNr ++)
-  {
-    UInt x = lpNr? currSlice->getColFromL0Flag() : 1-currSlice->getColFromL0Flag();
+  for(UInt lpNr = 0; lpNr < (currSlice->isInterB() ? 2 : 1); lpNr++)
+  {
+    Bool x = lpNr ? currSlice->getColFromL0Flag() : 1 - currSlice->getColFromL0Flag();
     
-    for (UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
+    for(UInt i = 0; i < currSlice->getNumRefIdx(RefPicList(x)); i++)
     {
       Int iTempPoc = currSlice->getRefPic((RefPicList)x, i)->getPOC();
-      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr): (pocCurr - iTempPoc);
+      Int iTempDiff = (iTempPoc > pocCurr) ? (iTempPoc - pocCurr) : (pocCurr - iTempPoc);
       
-      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() &&  (x == currSlice->getColFromL0Flag()||currSlice->getRefPOC((RefPicList)x, i)!= iColPOC) 
-        && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
+      if(currSlice->getViewIndex() == currSlice->getRefPic((RefPicList)x, i)->getViewIndex() && (x == currSlice->getColFromL0Flag() || currSlice->getRefPOC((RefPicList)x, i) != iColPOC) 
+         && currSlice->getRefPic((RefPicList)x, i)->getSlice(getCurrSliceIdx())->getTLayer() == uiTempLayerCurr && pocDiff > iTempDiff)
       {
         pocDiff = iTempDiff;
@@ -369,8 +396,8 @@
   }
 
-  if( pocDiff < 255 )
+  if(pocDiff < 255)
   {
     this->setRapRefIdx(idx);
-    this->setRapRefList((RefPicList) z );
+    this->setRapRefList((RefPicList) z);
     numDdvCandPics = 2;
   }
@@ -383,11 +410,12 @@
   TComSlice* currSlice = getSlice(getCurrSliceIdx());
   const Int numCandPics = this->getNumDdvCandPics();
+
   for(Int curCandPic = 0; curCandPic < numCandPics; curCandPic++)
   {
     RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
     Int        curCandPicRefIdx = 0;
-    if( curCandPic == 0 ) 
+    if(curCandPic == 0) 
     { 
-      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1-currSlice->getColFromL0Flag() : 0);
+      eCurRefPicList   = RefPicList(currSlice->isInterB() ? 1 - currSlice->getColFromL0Flag() : 0);
       curCandPicRefIdx = currSlice->getColRefIdx();
     }
@@ -397,24 +425,27 @@
       curCandPicRefIdx = this->getRapRefIdx();
     }
-    TComPic* pcCandColPic = currSlice->getRefPic( eCurRefPicList, curCandPicRefIdx);
-    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0);// currently only support single slice
+
+    TComPic* pcCandColPic = currSlice->getRefPic(eCurRefPicList, curCandPicRefIdx);
+    TComSlice* pcCandColSlice = pcCandColPic->getSlice(0); // currently only support single slice
 
     if(!pcCandColSlice->isIntra())
     {
-      for( Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2: 1); iColRefDir ++ )
-      {
-        for( Int iColRefIdx =0; iColRefIdx < pcCandColSlice->getNumRefIdx(( RefPicList )iColRefDir ); iColRefIdx++)
+      for(Int iColRefDir = 0; iColRefDir < (pcCandColSlice->isInterB() ? 2 : 1); iColRefDir++)
+      {
+        for(Int iColRefIdx = 0; iColRefIdx < pcCandColSlice->getNumRefIdx((RefPicList)iColRefDir); iColRefIdx++)
         {
           m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = false;
           Int iColViewIdx    = pcCandColSlice->getViewIndex();
-          Int iColRefViewIdx = pcCandColSlice->getRefPic( ( RefPicList )iColRefDir, iColRefIdx)->getViewIndex();
+          Int iColRefViewIdx = pcCandColSlice->getRefPic((RefPicList)iColRefDir, iColRefIdx)->getViewIndex();
           if(iColViewIdx == iColRefViewIdx)
+          {
             continue;
-
-          for(Int iCurrRefDir = 0;(iCurrRefDir < (currSlice->isInterB() ? 2: 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false ); iCurrRefDir++)
+          }
+
+          for(Int iCurrRefDir = 0; (iCurrRefDir < (currSlice->isInterB() ? 2 : 1)) && (m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] == false); iCurrRefDir++)
           {
-            for( Int iCurrRefIdx =0; iCurrRefIdx < currSlice->getNumRefIdx(( RefPicList )iCurrRefDir ); iCurrRefIdx++)
+            for(Int iCurrRefIdx = 0; iCurrRefIdx < currSlice->getNumRefIdx((RefPicList)iCurrRefDir); iCurrRefIdx++)
             {
-              if( currSlice->getRefPic( ( RefPicList )iCurrRefDir, iCurrRefIdx )->getViewIndex() == iColRefViewIdx )
+              if(currSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iColRefViewIdx)
               {  
                 m_abTIVRINCurrRL[curCandPic][iColRefDir][iColRefIdx] = true;
@@ -428,4 +459,5 @@
   }
 }
+
 Bool TComPic::isTempIVRefValid(Int currCandPic, Int iColRefDir, Int iColRefIdx)
 {
@@ -433,27 +465,27 @@
 }
 
-Void TComPic::checkTextureRef(  )
+Void TComPic::checkTextureRef()
 {
   TComSlice* pcCurrSlice = getSlice(getCurrSliceIdx());
-  TComPic* pcTextPic = pcCurrSlice->getTexturePic();
+  TComPic* pcTextPic = pcCurrSlice->getIvPic(0, getViewIndex());
 #if H_3D_FCO
   if ( pcTextPic )
   {
 #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();
+    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++)
+
+        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 )
+          if(pcCurrSlice->getRefPOC((RefPicList)iCurrRefDir, iCurrRefIdx ) == iTextRefPOC && 
+             pcCurrSlice->getRefPic((RefPicList)iCurrRefDir, iCurrRefIdx)->getViewIndex() == iTextRefViewId)
           {  
             m_aiTexToDepRef[iTextRefDir][iTextRefIdx] = iCurrRefIdx;
@@ -461,5 +493,4 @@
         }
       }
-
     }
 #if H_3D_FCO
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPic.h	(revision 1274)
@@ -97,9 +97,9 @@
   Bool                  m_bReduceBitsQTL;
 #endif
-#if H_3D_NBDV
+#if NH_3D_NBDV
   UInt        m_uiRapRefIdx;
   RefPicList  m_eRapRefList;
   Int         m_iNumDdvCandPics;
-  Bool        m_abTIVRINCurrRL  [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
+  Bool        m_abTIVRINCurrRL [2][2][MAX_NUM_REF]; //whether an inter-view reference picture with the same view index of the inter-view reference picture of temporal reference picture of current picture exists in current reference picture lists
   Int         m_aiTexToDepRef  [2][MAX_NUM_REF];
 #endif
@@ -182,4 +182,7 @@
 #endif
 #if NH_3D
+#if NH_3D_ARP
+  Void          getCUAddrAndPartIdx( Int iX, Int iY, Int& riCuAddr, Int& riAbsZorderIdx );
+#endif
   Void          compressMotion(Int scale); 
 #else   
@@ -209,5 +212,5 @@
   Void          print( Bool legend );
 #endif
-#if H_3D_NBDV
+#if NH_3D_NBDV
   Int           getNumDdvCandPics()                    {return m_iNumDdvCandPics;   }
   Int           getDisCandRefPictures(Int iColPOC);
@@ -248,5 +251,5 @@
   Void        push_back( TComList<TComPic*>* list ) { m_lists.push_back( list );   }
   Int         size     ()                           { return (Int) m_lists.size(); } 
-#if H_3D_ARP
+#if NH_3D_ARP
   TComList<TComPic*>*  getPicList   ( Int layerIdInNuh );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1274)
@@ -91,5 +91,8 @@
   m_iPicHeight        = iPicHeight;
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
+  m_iCuWidth        = uiMaxCUWidth;
+  m_iCuHeight       = uiMaxCUHeight;
+
   m_iNumCuInWidth   = m_iPicWidth / m_iCuWidth;
   m_iNumCuInWidth  += ( m_iPicWidth % m_iCuWidth ) ? 1 : 0;
@@ -292,6 +295,5 @@
   fclose(pFile);
 }
-#if H_3D
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Void
 TComPicYuv::getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY )
@@ -319,5 +321,8 @@
   riAbsZorderIdx      = g_auiRasterToZscan[ iRastPartIdx ];
 }
-#endif
+
+#endif
+
+#if H_3D
 Void TComPicYuv::setLumaTo( Pel pVal )
 {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPicYuv.h	(revision 1274)
@@ -80,8 +80,10 @@
 
   Bool  m_bIsBorderExtended;
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   Int   m_iBaseUnitWidth;       ///< Width of Base Unit (with maximum depth or minimum size, m_iCuWidth >> Max. Depth)
   Int   m_iBaseUnitHeight;      ///< Height of Base Unit (with maximum depth or minimum size, m_iCuHeight >> Max. Depth)
   Int   m_iNumCuInWidth;
+  Int   m_iCuWidth;             ///< Width of Coding Unit (CU)
+  Int   m_iCuHeight;            ///< Height of Coding Unit (CU)
 #endif
 
@@ -168,5 +170,5 @@
   Void  setLumaTo    ( Pel pVal );  
   Void  setChromaTo  ( Pel pVal );  
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   // sample to block and block to sample conversion
   Void  getTopLeftSamplePos( Int iCuAddr, Int iAbsZorderIdx, Int& riX, Int& riY );
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1274)
@@ -82,6 +82,6 @@
     }
   }
-#if H_3D_VSP
-  m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int));
+#if NH_3D_VSP
+  m_pDepthBlock = (Int*) malloc(MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH*sizeof(Int));
   if (m_pDepthBlock == NULL)
   {
@@ -94,5 +94,5 @@
 TComPrediction::~TComPrediction()
 {
-#if H_3D_VSP
+#if NH_3D_VSP
   if (m_pDepthBlock != NULL)
   {
@@ -123,5 +123,5 @@
   m_cYuvPredTemp.destroy();
 
-#if H_3D_ARP
+#if NH_3D_ARP
   m_acYuvPredBase[0].destroy();
   m_acYuvPredBase[1].destroy();
@@ -182,10 +182,10 @@
 
     m_cYuvPredTemp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
-#if H_3D_ARP
-    m_acYuvPredBase[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
-    m_acYuvPredBase[1] .create( g_uiMaxCUWidth, g_uiMaxCUHeight );
-#endif
-#if H_3D_VSP
-    m_cYuvDepthOnVsp.create( g_uiMaxCUWidth, g_uiMaxCUHeight );
+#if NH_3D_ARP
+    m_acYuvPredBase[0] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
+    m_acYuvPredBase[1] .create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
+#endif
+#if NH_3D_VSP
+    m_cYuvDepthOnVsp.create( MAX_CU_SIZE, MAX_CU_SIZE, chromaFormatIDC );
 #endif
 
@@ -648,5 +648,5 @@
       Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
       Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
-#if H_3D_ARP
+#if NH_3D_ARP
       if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
 #else
@@ -661,5 +661,5 @@
 }
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
 {
@@ -670,8 +670,10 @@
     pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
   }
+#if H_3D_ARP // check this!
   if( pcCU->getARPW( uiPartAddr ) != 0 )
   {
     return;
   }
+#endif
 
   // horizontal sub-PU merge
@@ -747,7 +749,11 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU)
 {
+  const TComSPS* sps = pcCU->getSlice()->getSPS();
+  UInt uiMaxCUWidth = sps->getMaxCUWidth();
+  UInt uiMaxCUHeight = sps->getMaxCUHeight();
+  
   // find virtual partitioning for this CU based on depth block
   // segmentation of texture block --> mask IDs
@@ -757,6 +763,6 @@
   Int iSumDepth = 0;
   Int iSubSample = 4;
-  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();
+  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
+  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y);
   TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
   if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
@@ -764,6 +770,6 @@
     cDv.setVer(0);
   }
-  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);
+  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
+  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
   
   UInt t=0;
@@ -852,5 +858,5 @@
   }
 
-  PartSize matchedPartSize = SIZE_NONE;
+  PartSize matchedPartSize = NUMBER_OF_PART_SIZES;
 
   Int iMaxMatchSum = 0;
@@ -867,5 +873,5 @@
   }
 
-  AOF( matchedPartSize != SIZE_NONE );
+  AOF( matchedPartSize != NUMBER_OF_PART_SIZES );
 
   return matchedPartSize;
@@ -874,4 +880,8 @@
 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU)
 {
+  const TComSPS* sps = pcCU->getSlice()->getSPS();
+  UInt uiMaxCUWidth = sps->getMaxCUWidth();
+  UInt uiMaxCUHeight = sps->getMaxCUHeight();
+  
   // segmentation of texture block --> mask IDs
   Pel*  pDepthBlockStart      = pDepthPels;
@@ -885,6 +895,6 @@
   iSumDepth  = pDepthPels[ 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();  
+  Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(COMPONENT_Y);
+  Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(COMPONENT_Y);  
   TComMv cDv = pcCU->getSlice()->getDepthRefinementFlag(  ) ? pcCU->getDvInfo(0).m_acDoNBDV : pcCU->getDvInfo(0).m_acNBDV;
   if( pcCU->getSlice()->getDepthRefinementFlag(  ) )
@@ -892,6 +902,6 @@
     cDv.setVer(0);
   }
-  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);
+  Int iBlkX = ( pcCU->getCtuRsAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getHor()+2)>>2);
+  Int iBlkY = ( pcCU->getCtuRsAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCtus() ) * uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCtu() ] ]+ ((cDv.getVer()+2)>>2);
   if (iBlkX>(Int)(iPictureWidth - uiWidth))
   {
@@ -1008,10 +1018,10 @@
 }
 
-Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize )
-{
-  Pel*  piSrc[2]    = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};
-  UInt  uiSrcStride = pInYuv[0]->getStride();
-  Pel*  piDst       = pOutYuv->getLumaAddr(uiPartAddr);
-  UInt  uiDstStride = pOutYuv->getStride();
+Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY )
+{
+  Pel*  piSrc[2]    = {pInYuv[0]->getAddr(COMPONENT_Y, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Y, uiPartAddr)};
+  UInt  uiSrcStride = pInYuv[0]->getStride(COMPONENT_Y);
+  Pel*  piDst       = pOutYuv->getAddr(COMPONENT_Y, uiPartAddr);
+  UInt  uiDstStride = pOutYuv->getStride(COMPONENT_Y);
   
   UInt  uiMaskStride= MAX_CU_SIZE;
@@ -1052,5 +1062,5 @@
         right  = (x==uiWidth-1)  ? tmpTar[y*uiWidth+x] : tmpTar[y*uiWidth+x+1];
         
-        piDst[x] = (l!=r) ? ClipY( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 )) : tmpTar[y*uiWidth+x]; 
+        piDst[x] = (l!=r) ? ClipBD( Pel(( left + (tmpTar[y*uiWidth+x] << 1) + right ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
       }
       piDst     += uiDstStride;
@@ -1070,5 +1080,5 @@
         bottom = (y==uiHeight-1) ? tmpTar[y*uiWidth+x] : tmpTar[(y+1)*uiWidth+x];
         
-        piDst[x] = (t!=b) ? ClipY( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 )) : tmpTar[y*uiWidth+x];
+        piDst[x] = (t!=b) ? ClipBD( Pel(( top + (tmpTar[y*uiWidth+x] << 1) + bottom ) >> 2 ), bitDepthY) : tmpTar[y*uiWidth+x];
       }
       piDst     += uiDstStride;
@@ -1083,10 +1093,10 @@
   
   // now combine chroma
-  Pel*  piSrcU[2]       = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };
-  Pel*  piSrcV[2]       = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };
-  UInt  uiSrcStrideC    = pInYuv[0]->getCStride();
-  Pel*  piDstU          = pOutYuv->getCbAddr(uiPartAddr);
-  Pel*  piDstV          = pOutYuv->getCrAddr(uiPartAddr);
-  UInt  uiDstStrideC    = pOutYuv->getCStride();
+  Pel*  piSrcU[2]       = { pInYuv[0]->getAddr(COMPONENT_Cb, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cb, uiPartAddr) };
+  Pel*  piSrcV[2]       = { pInYuv[0]->getAddr(COMPONENT_Cr, uiPartAddr), pInYuv[1]->getAddr(COMPONENT_Cr, uiPartAddr) };
+  UInt  uiSrcStrideC    = pInYuv[0]->getStride(COMPONENT_Cb);
+  Pel*  piDstU          = pOutYuv->getAddr(COMPONENT_Cb, uiPartAddr);
+  Pel*  piDstV          = pOutYuv->getAddr(COMPONENT_Cr, uiPartAddr);
+  UInt  uiDstStrideC    = pOutYuv->getStride(COMPONENT_Cb);
   UInt  uiWidthC        = uiWidth >> 1;
   UInt  uiHeightC       = uiHeight >> 1;
@@ -1134,6 +1144,6 @@
         if (l!=r)
         {
-          filSrcU = ClipC( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ));
-          filSrcV = ClipC( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ));
+          filSrcU = ClipBD( Pel(( leftU + (tmpTarU[y*uiWidthC+x] << 1) + rightU ) >> 2 ), bitDepthY);
+          filSrcV = ClipBD( Pel(( leftV + (tmpTarV[y*uiWidthC+x] << 1) + rightV ) >> 2 ), bitDepthY);
         }
         else
@@ -1167,6 +1177,6 @@
         if (t!=b)
         {
-          filSrcU = ClipC( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ));
-          filSrcV = ClipC( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ));
+          filSrcU = ClipBD( Pel(( topU + (tmpTarU[y*uiWidthC+x] << 1) + bottomU ) >> 2 ), bitDepthY);
+          filSrcV = ClipBD( Pel(( topV + (tmpTarV[y*uiWidthC+x] << 1) + bottomV ) >> 2 ), bitDepthY);
         }
         else
@@ -1205,26 +1215,26 @@
   {
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
-#if H_3D_VSP
+#if NH_3D_VSP
     if ( pcCU->getVSPFlag(uiPartAddr) == 0)
     {
 #endif
-    if ( eRefPicList != REF_PIC_LIST_X )
-    {
-      if( pcCU->getSlice()->getPPS()->getUseWP())
-      {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
+      if ( eRefPicList != REF_PIC_LIST_X )
+      {
+        if( pcCU->getSlice()->getPPS()->getUseWP())
+        {
+          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
+        }
+        else
+        {
+          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
+        }
+        if ( pcCU->getSlice()->getPPS()->getUseWP() )
+        {
+          xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
+        }
       }
       else
       {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
-      }
-      if ( pcCU->getSlice()->getPPS()->getUseWP() )
-      {
-        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
-      }
-    }
-    else
-    {
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0)  
         {
@@ -1258,60 +1268,60 @@
         {
 #endif
+          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
+          {
+            xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
+          }
+          else
+          {
+            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
+          }
+#if NH_3D_SPIVMP
+        }
+#endif
+      }
+#if NH_3D_VSP
+    }
+    else
+    {
       if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
       {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
+        xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
       }
       else
       {
-        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
-      }
-#if H_3D_SPIVMP
-        }
-#endif
-    }
-#if H_3D_VSP
+        xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
+      }
+    }
+#endif
+    return;
+  }
+
+  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
+  {
+    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
+
+#if NH_3D_VSP
+    if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
+    {
+#endif
+    if ( eRefPicList != REF_PIC_LIST_X )
+    {
+      if( pcCU->getSlice()->getPPS()->getUseWP())
+      {
+        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
+      }
+      else
+      {
+        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
+      }
+      if ( pcCU->getSlice()->getPPS()->getUseWP() )
+      {
+        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
+      }
     }
     else
     {
-      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
-      {
-        xPredInterUniVSP( pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
-      }
-      else
-      {
-        xPredInterBiVSP ( pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
-      }
-    }
-#endif
-    return;
-  }
-
-  for ( iPartIdx = 0; iPartIdx < pcCU->getNumPartitions(); iPartIdx++ )
-  {
-    pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iWidth, iHeight );
-
-#if H_3D_VSP
-    if ( pcCU->getVSPFlag(uiPartAddr) == 0 )
-    {
-#endif
-    if ( eRefPicList != REF_PIC_LIST_X )
-    {
-      if( pcCU->getSlice()->getPPS()->getUseWP())
-      {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true );
-      }
-      else
-      {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
-      }
-      if ( pcCU->getSlice()->getPPS()->getUseWP() )
-      {
-        xWeightedPredictionUni( pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred );
-      }
-    }
-    else
-    {
-#if H_3D_SPIVMP
-       if (pcCU->getSPIVMPFlag(uiPartAddr)!=0)  
+#if NH_3D_SPIVMP
+      if (pcCU->getSPIVMPFlag(uiPartAddr)!=0)  
       {
         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
@@ -1343,17 +1353,17 @@
       {
 #endif
-      if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
-      {
-        xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
-      }
-      else
-      {
-        xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
-      }
-#if H_3D_SPIVMP
-       }
-#endif
-    }
-#if H_3D_VSP
+        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
+        {
+          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
+        }
+        else
+        {
+          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
+        }
+#if NH_3D_SPIVMP
+      }
+#endif
+    }
+#if NH_3D_VSP
     }
     else
@@ -1381,17 +1391,15 @@
   pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx );
 #endif
-#if H_3D_ARP
-  if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
-  {
-    xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
+#if NH_3D_ARP
+  if(  pcCU->getARPW( uiPartAddr ) > 0 )
+  {
+    if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC() )
+  {
+      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , pcYuvPred , bi ); 
   }
   else
   {
-    if(  pcCU->getARPW( uiPartAddr ) > 0 
-      && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N 
-      && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() 
-      )
-    {
-      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi );
+      xPredInterUniARP( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, bi );
+    }      
     }
     else
@@ -1404,5 +1412,5 @@
     Bool bICFlag = pcCU->getICFlag( uiPartAddr ) && ( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getViewIndex() != pcCU->getSlice()->getViewIndex() ) && ( isLuma(compID) || (iWidth > 8) );
       xPredInterBlk(compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID))
-#if H_3D_ARP
+#if NH_3D_ARP
         , false
 #endif
@@ -1412,11 +1420,10 @@
 #endif
   }
-#if H_3D_ARP
-    }
-  }
-#endif
-}
-
-#if H_3D_VSP
+#if NH_3D_ARP
+  }
+#endif
+}
+
+#if NH_3D_VSP
 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
 {
@@ -1439,5 +1446,5 @@
 Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
 {
-  UInt numPartsInLine       = pcCU->getPic()->getNumPartInWidth();
+  UInt numPartsInLine       = pcCU->getPic()->getNumPartInCtuWidth();
   UInt horiNumPartsInSubPU  = widthSubPU >> 2;
   UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
@@ -1455,23 +1462,23 @@
       pcCU->clipMv(cMv);
 
-      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
-      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
-
-    }
-  }
-}
-
-#endif
-
-#if H_3D_ARP
-Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
-{
-  Int         iRefIdx      = pNewMvFiled ? pNewMvFiled->getRefIdx() : pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
-  TComMv      cMv          = pNewMvFiled ? pNewMvFiled->getMv()     : pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+      xPredInterBlk( COMPONENT_Y,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
+      xPredInterBlk( COMPONENT_Cb, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
+      xPredInterBlk( COMPONENT_Cr, pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) );
+    }
+  }
+}
+#endif
+
+#if NH_3D_ARP
+//temporal ARP
+Void TComPrediction::xPredInterUniARP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
+{
+  Int         iRefIdx      = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
+  TComMv      cMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
   Bool        bTobeScaled  = false;
   TComPic* pcPicYuvBaseCol = NULL;
   TComPic* pcPicYuvBaseRef = NULL;
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
   DisInfo cDistparity;
   cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;
@@ -1482,16 +1489,6 @@
   UChar dW = pcCU->getARPW ( uiPartAddr );
 
-  {
     Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
-    if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
-    {
-      bTobeScaled = true;
-    }
-
-    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
-
-    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
-
-    if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
+  if (arpRefIdx < 0 || !pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
     {
       dW = 0;
@@ -1500,5 +1497,10 @@
     else
     {
-      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
+    if( arpRefIdx != iRefIdx )
+    {
+      bTobeScaled = true;
+    }
+    pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
+    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
     }
 
@@ -1507,5 +1509,5 @@
       Int iCurrPOC    = pcCU->getSlice()->getPOC();
       Int iColRefPOC  = pcCU->getSlice()->getRefPOC( eRefPicList, iRefIdx );
-      Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList,  0);
+    Int iCurrRefPOC = pcCU->getSlice()->getRefPOC( eRefPicList, arpRefIdx );
       Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iCurrRefPOC, iCurrPOC, iColRefPOC);
       if ( iScale != 4096 )
@@ -1513,12 +1515,15 @@
         cMv = cMv.scaleMv( iScale );
       }
-      iRefIdx = 0;
-    }
+    iRefIdx = arpRefIdx;
   }
 
   pcCU->clipMv(cMv);
   TComPicYuv* pcPicYuvRef = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec();
-  xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
-  xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), true );
+
+  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
+  {
+    const ComponentID compID=ComponentID(comp);
+    xPredInterBlk  ( compID,  pcCU, pcPicYuvRef, uiPartAddr, &cMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+  }
 
   if( dW > 0 )
@@ -1536,14 +1541,14 @@
     pcCU->clipMv( cNBDV );
     
-    pcPicYuvRef = pcPicYuvBaseCol->getPicYuvRec();
-    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, true );
+    TComPicYuv* pcPicYuvBaseColRec = pcPicYuvBaseCol->getPicYuvRec();
+    TComPicYuv* pcPicYuvBaseRefRec = pcPicYuvBaseRef->getPicYuvRec();
     
-    pcPicYuvRef = pcPicYuvBaseRef->getPicYuvRec();
-    xPredInterLumaBlk  ( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
-  
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, true );
+    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
+    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
+    {
+      const ComponentID compID=ComponentID(comp);
+      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseColRec, uiPartAddr, &cNBDV, iWidth, iHeight, pYuvB0, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+      xPredInterBlk  ( compID,  pcCU, pcPicYuvBaseRefRec, uiPartAddr, &cMVwithDisparity, iWidth, iHeight, pYuvB1, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+    }    
     
     pYuvB0->subtractARP( pYuvB0 , pYuvB1 , uiPartAddr , iWidth , iHeight );
@@ -1553,5 +1558,5 @@
       pYuvB0->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     }
-    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi );
+    rpcYuvPred->addARP( rpcYuvPred , pYuvB0 , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() );
   }
 }
@@ -1562,6 +1567,4 @@
   TComMv      cDMv          = pcCU->getCUMvField( eBaseRefPicList )->getMv( uiPartAddr );
   TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eBaseRefPicList, iRefIdx );  
-  TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();
-  Int uiLCUAddr,uiAbsPartAddr;
   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
@@ -1569,6 +1572,8 @@
   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
-  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
-  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+
+  Int uiLCUAddr,uiAbsPartAddr;
+  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
 
   TComPic* pcPicYuvBaseTRef = NULL;
@@ -1622,5 +1627,6 @@
 }
 
-Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
+//inter-view ARP
+Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
 {
   Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
@@ -1635,17 +1641,7 @@
   Bool bTMVAvai = false;     
   TComMv cBaseTMV;
-  if( pNewMvFiled )
-  {
-    iRefIdx = pNewMvFiled->getRefIdx(); 
-    cDMv = pNewMvFiled->getMv();
-  }
+
   pcCU->clipMv(cTempDMv);
 
-  assert(dW > 0);
-  if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
-  {
-    dW = 0;
-  }
-  Int uiLCUAddr,uiAbsPartAddr;
   Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
   Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
@@ -1653,6 +1649,8 @@
   irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
   irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
-  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
-  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+  
+  Int uiLCUAddr,uiAbsPartAddr;
+  pcPicYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCtu( uiLCUAddr );
   if( pcCU->getSlice()->isInterB() && !pcCU->getSlice()->getIsDepth() )
   {
@@ -1725,5 +1723,5 @@
       RefPicList eRefPicListCurr = RefPicList(iList);
       Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
-      if( iRef != -1)
+      if( iRef != -1 && pcCU->getSlice()->getArpRefPicAvailable( eRefPicListCurr, pcPicYuvBaseCol->getViewIndex()))
       {
         pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef);  
@@ -1759,9 +1757,13 @@
   }
 
-  xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
-  xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ),        bTMVAvai);
-
-  if( dW > 0 && bTMVAvai ) 
-  {
+  for (UInt comp=COMPONENT_Y; comp< rpcYuvPred->getNumberValidComponents(); comp++)
+  {
+    const ComponentID compID=ComponentID(comp);
+    xPredInterBlk  ( compID,  pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi || ( dW > 0 && bTMVAvai ), pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), bTMVAvai );
+  }
+
+  if( dW > 0 ) 
+  {
+    assert ( bTMVAvai );
     TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
     TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
@@ -1777,13 +1779,12 @@
       pYuvCurrTRef->clear(); pYuvBaseTRef->clear();
     }
-    xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
-
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true,   true);
-
-    xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true); 
-
-    if (iWidth > 8)
-      xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, true,   true); 
+
+    UInt uiCompNum = ( iWidth > 8 ) ? 3: 1;
+    for (UInt comp=COMPONENT_Y; comp< uiCompNum; comp++)
+    {
+      const ComponentID compID=ComponentID(comp);
+      xPredInterBlk  ( compID,  pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+      xPredInterBlk  ( compID,  pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv, iWidth, iHeight, pYuvBaseTRef, true, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)), true );
+    }
 
     pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight );  
@@ -1792,5 +1793,5 @@
       pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
     }
-    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); 
+    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi, pcCU->getSlice()->getSPS()->getBitDepths() ); 
   }
 }
@@ -1847,6 +1848,5 @@
 }
 
-#if H_3D_VSP
-
+#if NH_3D_VSP
 Void TComPrediction::xPredInterBiVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred )
 {
@@ -1870,7 +1870,6 @@
   }
 
-  xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred );
-}
-
+  xWeightedAverage( &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() );
+}
 #endif
 
@@ -1892,5 +1891,5 @@
 
 Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth 
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType
 #endif
@@ -1914,10 +1913,9 @@
   Int     yFrac  = mv->getVer() & ((1<<shiftVer)-1);
 
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( cu->getSlice()->getIsDepth() )
   {
     refOffset = mv->getHor() + mv->getVer() * refStride;
     ref       = refPic->getAddr(compID, cu->getCtuRsAddr(), cu->getZorderIdxInCtu() + partAddr ) + refOffset;
-
     xFrac     = 0;
     yFrac     = 0;
@@ -1937,5 +1935,5 @@
     m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP 
+#if NH_3D_ARP 
     , filterType
 #endif 
@@ -1949,5 +1947,5 @@
     m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     , filterType
 #endif
@@ -1962,5 +1960,5 @@
 
     m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth
-#if H_3D_ARP 
+#if NH_3D_ARP 
     , filterType
 #endif 
@@ -1971,5 +1969,5 @@
     m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     , filterType
 #endif 
@@ -2208,4 +2206,5 @@
 
   // LLS parameters estimation
+
   Int x = 0, y = 0, xx = 0, xy = 0;
   Int precShift = std::max(0, bitDepth - 12);
@@ -2264,39 +2263,43 @@
   else
   {
-    xy += xx >> IC_REG_COST_SHIFT;
-    xx += xx >> IC_REG_COST_SHIFT;
-    Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift);
-    Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift);
-    const Int iShift = IC_CONST_SHIFT;
-    const Int iShiftA2 = 6;
-    const Int iAccuracyShift = 15;
-    Int iScaleShiftA2 = 0;
-    Int iScaleShiftA1 = 0;
+  xy += xx >> IC_REG_COST_SHIFT;
+  xx += xx >> IC_REG_COST_SHIFT;
+  Int a1 = ( xy << iCountShift ) - ((y * x) >> precShift);
+  Int a2 = ( xx << iCountShift ) - ((x * x) >> precShift);
+  const Int iShift = IC_CONST_SHIFT;
+      const Int iShiftA2 = 6;
+      const Int iAccuracyShift = 15;
+
+      Int iScaleShiftA2 = 0;
+      Int iScaleShiftA1 = 0;
     Int a1s;
     Int a2s;
-    
-    a1 = Clip3(0, 2*a2, a1);
-    iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
-    iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
-    
-    if( iScaleShiftA1 < 0 )
-    {
-      iScaleShiftA1 = 0;
-    }
-    if( iScaleShiftA2 < 0 )
-    {
-      iScaleShiftA2 = 0;
-    }
-    
-    Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1;
-
-    a2s = a2 >> iScaleShiftA2;
-    a1s = a1 >> iScaleShiftA1;
-    
-    a = a1s * m_uiaShift[ a2s ];
-    a = a >> iScaleShiftA;
-    b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
-  }
-}
+
+      a1 = Clip3(0, 2*a2, a1);
+      iScaleShiftA2 = GetMSB( abs( a2 ) ) - iShiftA2;
+      iScaleShiftA1 = iScaleShiftA2 - IC_SHIFT_DIFF;
+
+      if( iScaleShiftA1 < 0 )
+      {
+        iScaleShiftA1 = 0;
+      }
+
+      if( iScaleShiftA2 < 0 )
+      {
+        iScaleShiftA2 = 0;
+      }
+
+      Int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1;
+
+
+      a2s = a2 >> iScaleShiftA2;
+
+      a1s = a1 >> iScaleShiftA1;
+
+      a = a1s * m_uiaShift[ a2s ];
+      a = a >> iScaleShiftA;
+      b = (  y - ( ( a * x ) >> iShift ) + ( 1 << ( iCountShift - 1 ) ) ) >> iCountShift;
+    }
+  }   
 #endif
 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComPrediction.h	(revision 1274)
@@ -45,4 +45,7 @@
 #include "TComWeightPrediction.h"
 
+#if NH_3D_ARP
+#include "TComPic.h"
+#endif
 // forward declaration
 class TComMv;
@@ -77,5 +80,5 @@
   TComYuv   m_acYuvPred[NUM_REF_PIC_LIST_01];
   TComYuv   m_cYuvPredTemp;
-#if H_3D_ARP
+#if NH_3D_ARP
   TComYuv   m_acYuvPredBase[2];
 #endif
@@ -91,5 +94,5 @@
 #endif
 
-#if H_3D_VSP
+#if NH_3D_VSP
   Int*    m_pDepthBlock;         ///< Store a depth block, local variable, to prevent memory allocation every time
   TComYuv m_cYuvDepthOnVsp;
@@ -100,13 +103,13 @@
 
   // motion compensation functions
-#if H_3D_ARP
-  Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false, TComMvField * pNewMvFiled = NULL );
+#if NH_3D_ARP
+  Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
+  Void xPredInterUniARPviewRef  ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi );
   Bool xCheckBiInterviewARP     ( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eBaseRefPicList, TComPic*& pcPicYuvCurrTRef, TComMv& cBaseTMV, Int& iCurrTRefPoc );
-  Void xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled = NULL );
 #endif
 
   Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi=false          );
   Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv* pcYuvPred          );
-#if H_3D_VSP
+#if NH_3D_VSP
   Void xPredInterUniVSP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
   Void xPredInterBiVSP          ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv*& rpcYuvPred );
@@ -114,5 +117,5 @@
 
   Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth
-#if H_3D_ARP
+#if NH_3D_ARP
     , Bool filterType = false
 #endif
@@ -122,8 +125,5 @@
  );
 
-#if H_3D_ARP
-    , Bool filterType = false
-#endif
-#if H_3D_VSP
+#if NH_3D_VSP
   Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
 #endif
@@ -137,5 +137,5 @@
   Void xDCPredFiltering( const Pel* pSrc, Int iSrcStride, Pel* pDst, Int iDstStride, Int iWidth, Int iHeight, ChannelType channelType );
   Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   Bool xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 );
   Void xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr );
@@ -184,8 +184,8 @@
 #endif
   
-#if H_3D_DBBP
+#if NH_3D_DBBP
   PartSize      getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU);
   Bool          getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU);
-  Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize );
+  Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr, UInt partSize, Int bitDepthY );
 #endif
 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.cpp	(revision 1274)
@@ -311,5 +311,5 @@
   m_bUseEstimatedVSD        = false; 
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_bUseMask                = false;
 #endif
@@ -340,5 +340,5 @@
   rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( m_bUseMask )
   {
@@ -397,5 +397,5 @@
   }
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( m_bUseMask )
   {
@@ -446,5 +446,5 @@
   }
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( m_bUseMask )
   {
@@ -468,5 +468,5 @@
   rcDP.bitDepth   = bitDepth;
   rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( m_bUseMask )
   {
@@ -656,5 +656,5 @@
 // ====================================================================================================================
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 // --------------------------------------------------------------------------------------------------------------------
 // Masked distortion functions
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRdCost.h	(revision 1274)
@@ -167,5 +167,5 @@
 #endif
   Int                     m_iCostScale;
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Bool                    m_bUseMask;
 #endif
@@ -206,5 +206,5 @@
   Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void    setUseMask(Bool b) { m_bUseMask = b; }
 #endif
@@ -302,5 +302,5 @@
   static Distortion xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
   static Distortion xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
-#if H_3D_DBBP
+#if NH_3D_DBBP
   static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
   static UInt xGetMaskedSAD     ( DistParam* pcDtParam );
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRom.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComRom.cpp	(revision 1274)
@@ -564,5 +564,5 @@
 Bool g_disableNumbering = false; 
 Bool g_disableHLSTrace = false; 
-UInt64 g_stopAtCounter       = 937234; 
+UInt64 g_stopAtCounter       = 0; 
 Bool g_traceCopyBack         = false; 
 Bool g_decTraceDispDer       = false; 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.cpp	(revision 1274)
@@ -224,4 +224,5 @@
     m_aaiCodedScale [i].resize(MAX_NUM_LAYERS);
   }
+  
 #endif
 
@@ -277,5 +278,5 @@
     m_iSliceChromaQpDelta[component] = 0;
   }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   m_maxNumMergeCand = MRG_MAX_NUM_CANDS_MEM;
 #else
@@ -1995,5 +1996,5 @@
       m_dimensionId[i][j] = 0;
     }
-#if H_3D_ARP
+#if NH_3D_ARP
 #endif
   }  
@@ -2031,6 +2032,6 @@
 Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) const
 {
-  assert( scalType >= 0 && scalType <= MAX_NUM_SCALABILITY_TYPES ); 
-  assert( scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) );
+  assert( (Int)scalType >= 0 && (Int)scalType <= MAX_NUM_SCALABILITY_TYPES );
+  assert( (Int)scalType == MAX_NUM_SCALABILITY_TYPES || getScalabilityMaskFlag( scalType ) );
   Int scalIdx = 0; 
   for( Int curScalType = 0; curScalType < scalType; curScalType++ )
@@ -3584,21 +3585,23 @@
 #endif
 }
-#if H_3D
-Void TComSlice::setDefaultRefView( )
-{
-  setDefaultRefViewIdx( -1 );
-  setDefaultRefViewIdxAvailableFlag( false ); 
+#if NH_3D_NBDV
+Void TComSlice::setDefaultRefView()
+{
+  setDefaultRefViewIdx(-1);
+  setDefaultRefViewIdxAvailableFlag(false); 
 
   Int valid = 0;
   Int DefaultRefViewIdx = -1;
-  for( UInt curViewIdx = 0; curViewIdx < getViewIndex() && valid == 0; curViewIdx++ )
-  {
-    for( Int iRefListId = 0; ( iRefListId < (isInterB() ? 2 : 1) ) && !isIntra() && valid == 0; iRefListId++ )
-    {
-      RefPicList eRefPicList = RefPicList( iRefListId );
-      Int        iNumRefPics = getNumRefIdx( eRefPicList );
-      for( Int i = 0; i < iNumRefPics; i++ )
+
+  for(UInt curViewIdx = 0; curViewIdx < getViewIndex() && valid == 0; curViewIdx++)
+  {
+    for(Int iRefListId = 0; (iRefListId < (isInterB() ? 2 : 1)) && !isIntra() && valid == 0; iRefListId++)
+    {
+      RefPicList eRefPicList = RefPicList(iRefListId);
+      Int        iNumRefPics = getNumRefIdx(eRefPicList);
+
+      for(Int i = 0; i < iNumRefPics; i++)
       { 
-        if(getPOC() == getRefPic( eRefPicList, i )->getPOC() && curViewIdx == getRefPic( eRefPicList, i )->getViewIndex())
+        if(getPOC() == getRefPic(eRefPicList, i)->getPOC() && curViewIdx == getRefPic(eRefPicList, i)->getViewIndex())
         {
           valid = 1;
@@ -3609,13 +3612,14 @@
     }
   }
-  if( valid )
-  {
-    setDefaultRefViewIdx( DefaultRefViewIdx );
-    setDefaultRefViewIdxAvailableFlag( true );   
-  }
-}
-#endif
-
-#if H_3D_ARP
+
+  if(valid)
+  {
+    setDefaultRefViewIdx(DefaultRefViewIdx);
+    setDefaultRefViewIdxAvailableFlag(true);
+  }
+}
+#endif
+
+#if NH_3D_ARP
 Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
 {
@@ -3684,4 +3688,17 @@
           m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
         }
+      }
+    }
+  }
+  if( m_nARPStepNum > 1)
+  {
+    for(Int i = 0; i < getNumActiveRefLayerPics(); i ++ )
+    {
+      Int  iLayerId = getRefPicLayerId( i );
+      Int  iViewIdx =   getVPS()->getViewIndex(iLayerId);
+      Bool bIsDepth = ( getVPS()->getDepthId  ( iLayerId ) == 1 );
+      if( iViewIdx<getViewIndex() && !bIsDepth )
+      {
+        setBaseViewRefPicList( ivPicLists->getPicList( iLayerId ), iViewIdx );
       }
     }
@@ -3844,9 +3861,9 @@
   setupLUT = setupLUT || getViewSynthesisPredFlag( ); 
 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   setupLUT = setupLUT || getDepthRefinementFlag( );
 #endif  
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   setupLUT = setupLUT || ( getIvMvPredFlag() && getIsDepth() );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComSlice.h	(revision 1274)
@@ -2594,5 +2594,5 @@
   Int        m_aiAlterRefIdx   [2]; 
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
   Bool       m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
@@ -2706,18 +2706,17 @@
   Int                         getNumCurCmpLIds( )                      const         { return (Int) m_inCmpRefViewIdcs.size();                       }
   TComPic*                    getIvPic( Bool depthFlag, Int viewIndex) const         { return  m_ivPicsCurrPoc[ depthFlag ? 1 : 0 ][ viewIndex ];    }
-#endif                                                                                                                                          
+#endif                                                                                                                                               
 #if NH_3D                                                                                                                                             
   TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
-#endif                                                                                                                                               
-#if NH_3D_IC
+#endif                            
+#if NH_3D_IC                                                                                                                                          
   Void                        setApplyIC( Bool b )                                   { m_bApplyIC = b;                                               }
   Bool                        getApplyIC()                                           { return m_bApplyIC;                                            }
-  Void                        xSetApplyIC();
-  Void                        xSetApplyIC(Bool bUseLowLatencyICEnc);
-
+  Void                        xSetApplyIC();                                                                                                         
+  Void                        xSetApplyIC(Bool bUseLowLatencyICEnc);                                                                                 
   Void                        setIcSkipParseFlag( Bool b )                           { m_icSkipParseFlag = b;                                        }
   Bool                        getIcSkipParseFlag()                                   { return m_icSkipParseFlag;                                     }
 #endif                                                                                                                                               
-#if H_3D_ARP                                                                                                                                         
+#if NH_3D_ARP                                                                                                                                         
   Void                        setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic; }                  
   Void                        setARPStepNum( TComPicLists*ivPicLists );                                                                              
@@ -2926,5 +2925,5 @@
   Int                         getAlterRefIdx          ( RefPicList e )               { return  m_aiAlterRefIdx[e];                                   }
 #endif                                                                                                                                               
-#if H_3D_ARP                                                                                                                                         
+#if NH_3D_ARP                                                                                                                                         
   Int                         getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];                                  }
   Void                        setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;                                   }
@@ -3074,4 +3073,12 @@
   Int                         getMpiSubPbSize           ( )                          { return m_mpiSubPbSize           ;                             };
   Int                         getSubPbSize              ( )                          { return m_subPbSize              ;                             };
+#if NH_3D_NBDV
+  Int                         getDefaultRefViewIdx()                                 { return m_iDefaultRefViewIdx;                                  }
+  Void                        setDefaultRefViewIdx(Int iViewIdx)                     { m_iDefaultRefViewIdx = iViewIdx;                              }
+
+  Bool                        getDefaultRefViewIdxAvailableFlag()                    { return m_bDefaultRefViewIdxAvailableFlag;                     }
+  Void                        setDefaultRefViewIdxAvailableFlag(Bool bViewIdx)       { m_bDefaultRefViewIdxAvailableFlag = bViewIdx;                 }
+  Void                        setDefaultRefView( );
+#endif
 #endif
   // Inference 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.cpp	(revision 1274)
@@ -487,23 +487,24 @@
 }
 
-#if H_3D_ARP
-Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
-{
-  addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip );
-  addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip );
-}
-
-Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
+#if NH_3D_ARP
+Void TComYuv::addARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
+{
+  addARPLuma   ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth   , uiHeight    , bClip , clipBitDepths);
+  addARPChroma ( pcYuvSrc0, pcYuvSrc1, uiAbsPartIdx, uiWidth>>1, uiHeight>>1 , bClip , clipBitDepths);
+}
+
+Void TComYuv::addARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
 {
   Int x, y;
 
-  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
-  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-
-  UInt iSrc0Stride = pcYuvSrc0->getStride();
-  UInt iSrc1Stride = pcYuvSrc1->getStride();
-  UInt iDstStride  = getStride();
-  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthY;
+  Pel* pSrc0 = pcYuvSrc0->getAddr( COMPONENT_Y, uiAbsPartIdx );
+  Pel* pSrc1 = pcYuvSrc1->getAddr( COMPONENT_Y, uiAbsPartIdx );
+  Pel* pDst  = getAddr( COMPONENT_Y, uiAbsPartIdx );
+
+  UInt iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
+  UInt iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
+  UInt iDstStride  = getStride(COMPONENT_Y);
+  const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_LUMA];
+  Int iIFshift = IF_INTERNAL_PREC - clipbd;
   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
   for ( y = uiHeight-1; y >= 0; y-- )
@@ -514,5 +515,5 @@
       if( bClip )
       {
-        pDst[x] = ClipY( ( pDst[x] + iOffSet ) >> iIFshift );
+        pDst[x] = Pel(ClipBD<Int>(Int( ( pDst[x] + iOffSet ) >> iIFshift ), clipbd));
       }
     }
@@ -523,20 +524,25 @@
 }
 
-Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip )
+Void TComYuv::addARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, Bool bClip, const BitDepths &clipBitDepths )
 {
   Int x, y;
 
-  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
-  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
-  Pel* pDstU = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV = getCrAddr( uiAbsPartIdx );
-
-  UInt  iSrc0Stride = pcYuvSrc0->getCStride();
-  UInt  iSrc1Stride = pcYuvSrc1->getCStride();
-  UInt  iDstStride  = getCStride();
-
-  Int iIFshift = IF_INTERNAL_PREC - g_bitDepthC;
+  Pel* pSrcU0 = pcYuvSrc0->getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcU1 = pcYuvSrc1->getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcV0 = pcYuvSrc0->getAddr( COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pSrcV1 = pcYuvSrc1->getAddr( COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pDstU = getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV = getAddr( COMPONENT_Cr, uiAbsPartIdx );
+
+  UInt  iSrc0StrideCb = pcYuvSrc0->getStride(COMPONENT_Cb);
+  UInt  iSrc1StrideCb = pcYuvSrc1->getStride(COMPONENT_Cb);
+  UInt  iDstStrideCb  = getStride(COMPONENT_Cb);
+
+  UInt  iSrc0StrideCr = pcYuvSrc0->getStride(COMPONENT_Cr);
+  UInt  iSrc1StrideCr = pcYuvSrc1->getStride(COMPONENT_Cr);
+  UInt  iDstStrideCr  = getStride(COMPONENT_Cr);
+
+  const Int clipbd = clipBitDepths.recon[CHANNEL_TYPE_CHROMA];
+  Int iIFshift = IF_INTERNAL_PREC - clipbd;
   Int iOffSet  = ( 1 << ( iIFshift - 1 ) ) + IF_INTERNAL_OFFS;
 
@@ -549,9 +555,72 @@
       if( bClip )
       {
-        pDstU[x] = ClipC( ( pDstU[x] + iOffSet ) >> iIFshift );
-        pDstV[x] = ClipC( ( pDstV[x] + iOffSet ) >> iIFshift );
-      }
-    }
-
+        pDstU[x] = Pel(ClipBD<Int>( Int( ( pDstU[x] + iOffSet ) >> iIFshift ), clipbd));
+        pDstV[x] = Pel(ClipBD<Int>( Int( ( pDstV[x] + iOffSet ) >> iIFshift ), clipbd));
+      }
+    }
+
+    pSrcU0 += iSrc0StrideCb;
+    pSrcU1 += iSrc1StrideCb;
+    pSrcV0 += iSrc0StrideCr;
+    pSrcV1 += iSrc1StrideCr;
+    pDstU  += iDstStrideCb;
+    pDstV  += iDstStrideCr;
+  }
+}
+
+Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
+
+  if (uiWidth > 8 && pcYuvSrc1->getNumberValidComponents() > 1)
+  {
+    subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
+}
+}
+
+Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  Int x, y;
+
+  Pel* pSrc0 = pcYuvSrc0->getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Pel* pSrc1 = pcYuvSrc1->getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Pel* pDst  = getAddr           (COMPONENT_Y, uiAbsPartIdx );
+
+  Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Y);
+  Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Y);
+  Int  iDstStride  = getStride(COMPONENT_Y);
+  for ( y = uiHeight-1; y >= 0; y-- )
+  {
+    for ( x = uiWidth-1; x >= 0; x-- )
+    {
+      pDst[x] = pSrc0[x] - pSrc1[x];
+    }
+    pSrc0 += iSrc0Stride;
+    pSrc1 += iSrc1Stride;
+    pDst  += iDstStride;
+  }
+}
+
+Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
+{
+  Int x, y;
+
+  Pel* pSrcU0 = pcYuvSrc0->getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcU1 = pcYuvSrc1->getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pSrcV0 = pcYuvSrc0->getAddr(COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pSrcV1 = pcYuvSrc1->getAddr(COMPONENT_Cr, uiAbsPartIdx );
+  Pel* pDstU  = getAddr(COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV  = getAddr(COMPONENT_Cr, uiAbsPartIdx );
+
+  Int  iSrc0Stride = pcYuvSrc0->getStride(COMPONENT_Cb);
+  Int  iSrc1Stride = pcYuvSrc1->getStride(COMPONENT_Cb);
+  Int  iDstStride  = getStride( COMPONENT_Cb );
+  for ( y = uiHeight-1; y >= 0; y-- )
+  {
+    for ( x = uiWidth-1; x >= 0; x-- )
+    {
+      pDstU[x] = pSrcU0[x] - pSrcU1[x];
+      pDstV[x] = pSrcV0[x] - pSrcV1[x];
+    }
     pSrcU0 += iSrc0Stride;
     pSrcU1 += iSrc1Stride;
@@ -563,71 +632,12 @@
 }
 
-Void TComYuv::subtractARP( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  subtractARPLuma  ( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth    , uiHeight    );
-
-  if (uiWidth > 8)
-    subtractARPChroma( pcYuvSrc0, pcYuvSrc1,  uiAbsPartIdx, uiWidth>>1 , uiHeight>>1 );
-}
-
-Void TComYuv::subtractARPLuma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  Int x, y;
-
-  Pel* pSrc0 = pcYuvSrc0->getLumaAddr( uiAbsPartIdx );
-  Pel* pSrc1 = pcYuvSrc1->getLumaAddr( uiAbsPartIdx );
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-
-  Int  iSrc0Stride = pcYuvSrc0->getStride();
-  Int  iSrc1Stride = pcYuvSrc1->getStride();
-  Int  iDstStride  = getStride();
-  for ( y = uiHeight-1; y >= 0; y-- )
-  {
-    for ( x = uiWidth-1; x >= 0; x-- )
-    {
-      pDst[x] = pSrc0[x] - pSrc1[x];
-    }
-    pSrc0 += iSrc0Stride;
-    pSrc1 += iSrc1Stride;
-    pDst  += iDstStride;
-  }
-}
-
-Void TComYuv::subtractARPChroma( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight )
-{
-  Int x, y;
-
-  Pel* pSrcU0 = pcYuvSrc0->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcU1 = pcYuvSrc1->getCbAddr( uiAbsPartIdx );
-  Pel* pSrcV0 = pcYuvSrc0->getCrAddr( uiAbsPartIdx );
-  Pel* pSrcV1 = pcYuvSrc1->getCrAddr( uiAbsPartIdx );
-  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
-
-  Int  iSrc0Stride = pcYuvSrc0->getCStride();
-  Int  iSrc1Stride = pcYuvSrc1->getCStride();
-  Int  iDstStride  = getCStride();
-  for ( y = uiHeight-1; y >= 0; y-- )
-  {
-    for ( x = uiWidth-1; x >= 0; x-- )
-    {
-      pDstU[x] = pSrcU0[x] - pSrcU1[x];
-      pDstV[x] = pSrcV0[x] - pSrcV1[x];
-    }
-    pSrcU0 += iSrc0Stride;
-    pSrcU1 += iSrc1Stride;
-    pSrcV0 += iSrc0Stride;
-    pSrcV1 += iSrc1Stride;
-    pDstU  += iDstStride;
-    pDstV  += iDstStride;
-  }
-}
-
 Void TComYuv::multiplyARP( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
   multiplyARPLuma( uiAbsPartIdx , uiWidth , uiHeight , dW );
 
-  if (uiWidth > 8)
+  if ( uiWidth > 8 && getNumberValidComponents() > 1 )
+  {
     multiplyARPChroma( uiAbsPartIdx , uiWidth >> 1 , uiHeight >> 1 , dW );
+}
 }
 
@@ -641,6 +651,6 @@
 Void TComYuv::multiplyARPLuma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
-  Pel* pDst  = getLumaAddr( uiAbsPartIdx );
-  Int  iDstStride  = getStride();
+  Pel* pDst  = getAddr(COMPONENT_Y, uiAbsPartIdx );
+  Int  iDstStride  = getStride(COMPONENT_Y);
   for ( Int y = uiHeight-1; y >= 0; y-- )
   {
@@ -652,8 +662,8 @@
 Void TComYuv::multiplyARPChroma( UInt uiAbsPartIdx , UInt uiWidth , UInt uiHeight , UChar dW )
 {
-  Pel* pDstU  = getCbAddr( uiAbsPartIdx );
-  Pel* pDstV  = getCrAddr( uiAbsPartIdx );
-
-  Int  iDstStride  = getCStride();
+  Pel* pDstU  = getAddr( COMPONENT_Cb, uiAbsPartIdx );
+  Pel* pDstV  = getAddr( COMPONENT_Cr, uiAbsPartIdx );
+
+  Int  iDstStride  = getStride( COMPONENT_Cb );
   for ( Int y = uiHeight-1; y >= 0; y-- )
   {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TComYuv.h	(revision 1274)
@@ -206,8 +206,8 @@
 #if NH_3D
   Void         addClipPartLuma( Int bitDepth, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiTrUnitIdx, UInt uiPartSize );
-#if H_3D_ARP
-  Void         addARP                     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
-  Void         addARPLuma                 ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
-  Void         addARPChroma               ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip );
+#if NH_3D_ARP
+  Void         addARP                     ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
+  Void         addARPLuma                 ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
+  Void         addARPChroma               ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight , Bool bClip, const BitDepths &clipBitDepths );
   Void         subtractARP                ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
   Void         subtractARPLuma            ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt uiAbsPartIdx, UInt uiWidth , UInt uiHeight );
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibCommon/TypeDef.h	(revision 1274)
@@ -70,4 +70,5 @@
 #if NH_3D
 #define NH_3D_VSO                         1
+#define NH_3D_NBDV                        1
 #define NH_3D_TMVP                        1   // QC_TMVP_C0047 
                                               // Sony_M23639
@@ -92,4 +93,26 @@
                                               // HHI_QTLPC_RAU_OFF_C0160 JCT3V-C0160 change 2: quadtree limitation and predictive coding switched off in random access units 
                                               // MTK_TEX_DEP_PAR_G0055 Texture-partition-dependent depth partition. JCT3V-G0055
+
+#define NH_3D_NBDV_REF                    1
+#define NH_3D_MLC                         1
+#define NH_3D_VSP                         1
+#define NH_3D_IV_MERGE                    1
+#define NH_3D_SPIVMP                      1
+#define NH_3D_INTEGER_MV_DEPTH            1
+#define NH_3D_TEXT_MERGE                  1
+#define NH_3D_DBBP                         1
+#define BUF_FIX 1
+#define NH_3D_ARP                         1  // Advanced residual prediction (ARP), JCT3V-D0177
+                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
+                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
+                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
+                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
+                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
+                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
+                                              // QC_I0051_ARP_SIMP          
+                                              // SHARP_ARP_CHROMA_I0104     
+                                              // MTK_I0072_IVARP_SCALING_FIX
+                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
+                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
 
 #endif
@@ -121,16 +144,4 @@
                                               // MTK_TEXTURE_MRGCAND_BUGFIX_E0182  Bug fix for TEXTURE MERGING CANDIDATE     , JCT3V-E0182
                                               // LGE_SIMP_DISP_AVAIL_J0041    // Use 2 status for disparity availability - DISP_AVAILABLE and DISP_NONE
-#define H_3D_ARP                          1   // Advanced residual prediction (ARP), JCT3V-D0177
-                                              // QC_MTK_INTERVIEW_ARP_F0123_F0108 JCT3V-F0123; JCT3V-F0108
-                                              // SHARP_ARP_REF_CHECK_F0105        ARP reference picture selection and DPB check
-                                              // LGE_ARP_CTX_F0161                JCT3V-F0161
-                                              // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
-                                              // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
-                                              // MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085  Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
-                                              // QC_I0051_ARP_SIMP          
-                                              // SHARP_ARP_CHROMA_I0104     
-                                              // MTK_I0072_IVARP_SCALING_FIX
-                                              // SEC_ARP_VIEW_REF_CHECK_J0037    Signaling iv_res_pred_weight_idx when the current slice has both view and temporal reference picture(s), JCT3V-J0037 item1
-                                              // SEC_ARP_REM_ENC_RESTRICT_K0035    Removal of encoder restriction of ARP, JCT3V-K0035
 #define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
                                               // Unifying rounding offset, for IC part, JCT3V-D0135
@@ -146,5 +157,5 @@
                                               // SEC_IC_NEIGHBOR_CLIP_I0080    // Clipping of neighboring sample position, JCT3V-I0080
                                               // LGE_CHROMA_IC_J0050_J0034
-#if H_3D_NBDV
+#if NH_3D_NBDV
 #define H_3D_NBDV_REF                     1   // Depth oriented neighboring block disparity derivation
                                               // MTK_D0156
@@ -312,5 +323,5 @@
 #endif
 ////   ****** NEIGHBOURING BLOCK-BASED DISPARITY VECTOR  *********
-#if H_3D_NBDV
+#if NH_3D_NBDV
 #define DVFROM_LEFT                       0
 #define DVFROM_ABOVE                      1
@@ -318,5 +329,5 @@
 #endif
 ///// ***** ADVANCED INTERVIEW RESIDUAL PREDICTION *********
-#if H_3D_ARP
+#if NH_3D_ARP
 #define H_3D_ARP_WFNR                     3
 #endif
@@ -334,13 +345,4 @@
 /// GT: Move values which are not flags to CommonDef.h and convert to static int !!
 ///////////////////////////////////////////////////////////////////////////////////
-///// ***** VIEW SYNTHESIS PREDICTION *********
-#if H_3D_VSP
-#define H_3D_VSP_BLOCKSIZE                4   // Supported values: 1, 2, and 4
-#if H_3D_VSP_BLOCKSIZE == 1
-#define H_3D_VSP_CONSTRAINED              1   // Constrained VSP @ 1x1
-#else
-#define H_3D_VSP_CONSTRAINED              0
-#endif
-#endif
 ///// ***** ILLUMATION COMPENSATION *********
 #if NH_3D_IC
@@ -351,5 +353,5 @@
 #endif
 ///// ***** DEPTH BASED BLOCK PARTITIONING *********
-#if H_3D_DBBP
+#if NH_3D_DBBP
 #define DBBP_INVALID_SHORT                (-4)
 #define DBBP_PACK_MODE               SIZE_2NxN
@@ -735,5 +737,5 @@
   MD_ABOVE_LEFT         ///< MVP of above left block
 };
-#if H_3D
+#if NH_3D_MLC
 enum DefaultMergCandOrder
 {
@@ -748,5 +750,5 @@
   MRG_A0,               ///< Left bottom
   MRG_B2,               ///< Above left
-  MRG_IVSHIFT,          ///< Shifted IVMC of Shifted IVDC. (These are mutually exclusive)
+  MRG_IVSHIFT,          ///< Shifted IVMC or Shifted IVDC. (These are mutually exclusive)
   MRG_COL               ///< Temporal co-located
 };
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1274)
@@ -1840,5 +1840,5 @@
   else
   {
-    vpsVui->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1 ); 
+    vpsVui->setVpsNumVideoSignalInfoMinus1( (pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag()) ? 0 : 1 );
   }
 
@@ -2805,5 +2805,5 @@
     {
       READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       pcSlice->setMaxNumMergeCand(( ( pcSlice->getMpiFlag() || pcSlice->getIvMvPredFlag() || pcSlice->getViewSynthesisPredFlag() ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
 #else
@@ -3376,5 +3376,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -3400,5 +3400,5 @@
 
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
   {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 1274)
@@ -117,5 +117,5 @@
   Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex );
-#if H_3D_ARP 
+#if NH_3D_ARP 
   Void parseARPW            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -127,5 +127,5 @@
   Void  parseSDCFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void  parseDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1274)
@@ -52,5 +52,5 @@
   m_ppcYuvReco = NULL;
   m_ppcCU      = NULL;
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_ppcYuvRecoDBBP = NULL;
 #endif
@@ -81,5 +81,5 @@
   m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
   m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
 #endif
@@ -95,6 +95,6 @@
     m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
     m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
-#if H_3D_DBBP
-    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
+#if NH_3D_DBBP
+    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC );
 #endif
 }
@@ -119,5 +119,5 @@
     m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
     m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
-#if H_3D_DBBP
+#if NH_3D_DBBP
     m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
 #endif
@@ -127,5 +127,5 @@
   delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
   delete [] m_ppcCU     ; m_ppcCU      = NULL;
-#if H_3D_DBBP
+#if NH_3D_DBBP
   delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
 #endif
@@ -152,5 +152,5 @@
     setIsChromaQpAdjCoded(true);
   }
-
+  
   // start from the top level CU
   xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment);
@@ -163,5 +163,5 @@
 Void TDecCu::decompressCtu( TComDataCU* pCtu )
 {
-#if !H_3D_IV_MERGE
+#if !NH_3D_IV_MERGE
   xDecompressCU( pCtu, 0,  0 );
 #endif
@@ -283,9 +283,9 @@
     pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP
   }
-#if H_3D_NBDV 
+#if NH_3D_NBDV 
   DisInfo DvInfo; 
   DvInfo.m_acNBDV.setZero();
   DvInfo.m_aVIdxCan = 0;
-#if H_3D_NBDV_REF  
+#if NH_3D_NBDV_REF  
   DvInfo.m_acDoNBDV.setZero();
 #endif
@@ -293,27 +293,43 @@
 if(!pcCU->getSlice()->isIntra())
   {
-#if H_3D_ARP && H_3D_IV_MERGE
-    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() )
+#if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
+    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
 #else 
+#if NH_3D_IV_MERGE && NH_3D_VSP
+    if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
+#else
+#if NH_3D_ARP && NH_3D_VSP
+    if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() )
+#else
+#if NH_3D_VSP
+    if( pcCU->getSlice()->getViewSynthesisPredFlag() )
+#else
 #if H_3D_ARP
-    if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) )
+    if( pcCU->getSlice()->getIvResPredFlag( ) )
 #else
 #if H_3D_IV_MERGE
     if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) )
 #else
+#if NH_3D_DBBP
+    if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )
+#else
     if (0)
 #endif
 #endif
 #endif
-    {
-      m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true );
-      m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx);
+#endif
+#endif
+#endif
+#endif
+    {
+      m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true);
+      m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
       PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0);
       UChar cWidTemp     = m_ppcCU[uiDepth]->getWidth(0);
       UChar cHeightTemp  = m_ppcCU[uiDepth]->getHeight(0);
-      m_ppcCU[uiDepth]->setWidth  ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth)  );
-      m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
-      m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
-#if H_3D_IV_MERGE
+      m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth));
+      m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
+      m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
+#if NH_3D_IV_MERGE
       if( pcCU->getSlice()->getIsDepth())
       {
@@ -323,5 +339,5 @@
       {
 #endif
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
       if( pcCU->getSlice()->getDepthBasedBlkPartFlag() )  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
       {
@@ -333,5 +349,5 @@
         m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
       }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       }
 #endif
@@ -346,9 +362,8 @@
       }
 #endif
-
       pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth);
-      m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth );
-      m_ppcCU[uiDepth]->setWidth  ( 0, cWidTemp );
-      m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp );
+      m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth);
+      m_ppcCU[uiDepth]->setWidth(0, cWidTemp);
+      m_ppcCU[uiDepth]->setHeight(0, cHeightTemp);
      }
   }
@@ -381,6 +396,10 @@
     m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
     m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
     m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx);
+    TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
+    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
+#else
+#if NH_3D_MLC
     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
@@ -389,4 +408,5 @@
     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
 #endif
+#endif
     Int numValidMergeCand = 0;
     for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui )
@@ -396,5 +416,5 @@
     m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
     UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
 #endif
@@ -403,38 +423,42 @@
 #endif
 
-#if H_3D_VSP
+
+#if NH_3D_VSP
     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
-#if H_3D_SPIVMP
+#endif
+#if NH_3D_SPIVMP
     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
     TComMvField*  pcMvFieldSP;
     UChar* puhInterDirSP;
-    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
-    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
-#endif
+    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
+    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
+#endif
+
+#if NH_3D_MLC
     m_ppcCU[uiDepth]->initAvailableFlags();
+#endif
     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#if NH_3D_MLC
     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pcMvFieldSP, puhInterDirSP
 #endif
       , numValidMergeCand, uiMergeIndex );
 
-    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
-#if H_3D_SPIVMP
+    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if NH_3D_VSP
+      , vspFlag
+#endif
+#if NH_3D_SPIVMP
       , bSPIVMPFlag
 #endif
       , numValidMergeCand );
+#endif
+#if NH_3D_VSP
     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
-#else
-#if H_3D
-    m_ppcCU[uiDepth]->initAvailableFlags();
-    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
-    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
-#else
-    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
-#endif
-#endif
+#endif
+
     pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
 
@@ -448,5 +472,5 @@
         pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
         pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
-#if H_3D_VSP
+#if NH_3D_VSP
         if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
         {
@@ -481,5 +505,5 @@
       }
     }
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
     if (bSPIVMPFlag[uiMergeIndex])
@@ -506,5 +530,5 @@
 
     xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
     xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -531,5 +555,5 @@
 #endif
       xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -551,5 +575,5 @@
 #endif
   xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -574,5 +598,5 @@
 {
   TComPic* pcPic = pCtu->getPic();
-#if !H_3D_IV_MERGE
+#if !NH_3D_IV_MERGE
   TComSlice * pcSlice = pCtu->getSlice();
   const TComSPS &sps=*(pcSlice->getSPS());
@@ -617,5 +641,5 @@
   {
     case MODE_INTER:
-#if H_3D_DBBP
+#if NH_3D_DBBP
     if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
     {
@@ -637,5 +661,5 @@
       }
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
     }
 #endif
@@ -845,5 +869,5 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -851,4 +875,6 @@
   AOF(!pcCU->getSlice()->isIntra());
   PartSize ePartSize = pcCU->getPartitionSize( 0 );
+  
+  Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
   
   // get collocated depth block
@@ -871,5 +897,5 @@
   
   // first, extract the two sets of motion parameters
-  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
+  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
   {
@@ -877,4 +903,5 @@
     
     pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
+    assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2  );  // only uni-prediction allowed
     
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
@@ -884,8 +911,10 @@
     }
     
+#if H_3D
     AOF( pcCU->getARPW(uiPartAddr) == 0 );
     AOF( pcCU->getICFlag(uiPartAddr) == false );
     AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false );
     AOF( pcCU->getVSPFlag(uiPartAddr) == 0 );
+#endif
   }
   
@@ -927,13 +956,13 @@
   
   // reconstruct final prediction signal by combining both segments
-  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize);
+  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY);
 
   // inter recon
-  xDecodeInterTexture( pcCU, 0, uiDepth );
+  xDecodeInterTexture( pcCU, uiDepth );
   
   // clip for only non-zero cbp case
-  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
-  {
-    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
+  if  ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) )
+  {
+    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
   }
   else
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecCu.h	(revision 1274)
@@ -62,5 +62,5 @@
   TComDataCU**        m_ppcCU;            ///< CU data array
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   TComYuv**           m_ppcYuvRecoDBBP;
 #endif
@@ -102,5 +102,5 @@
   Void xReconInter              ( TComDataCU* pcCU, UInt uiDepth );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void xReconInterDBBP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1274)
@@ -105,5 +105,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -129,5 +129,5 @@
   pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
 
-#if H_3D_ARP
+#if NH_3D_ARP
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
 #else
@@ -240,5 +240,6 @@
   UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) );
   UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
-#if H_3D_IV_MERGE
+//#if H_3D_IV_MERGE
+#if NH_3D_MLC
   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
@@ -247,10 +248,10 @@
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   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
-#if H_3D_IV_MERGE
+  TComMvField*  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
+  UChar* puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
+#endif
+#if NH_3D_IV_MERGE
   pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx);
 #endif
@@ -260,9 +261,13 @@
   }
   Int numValidMergeCand = 0;
+#if !NH_3D
   Bool hasMergedCandList = false;
+#else
+  Bool isMerged = false;
+#endif
 
   pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
   pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 );
-#if H_3D
+#if NH_3D
   for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset )
   {
@@ -296,8 +301,10 @@
 
   ////// Parse CUs extension syntax
+#if NH_3D_DBBP
   decodeDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); 
-  decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth ); 
-
-#if H_3D_ARP
+#endif
+  //decodeSDCFlag ( pcCU, uiAbsPartIdx, uiDepth );
+
+#if NH_3D_ARP
   decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -312,5 +319,5 @@
     {
       UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
-#if H_3D_DBBP
+#if NH_3D_DBBP
       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
 #else
@@ -321,5 +328,5 @@
         if ( !isMerged )
         {
-#if H_3D_VSP
+#if NH_3D_VSP
           Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
@@ -330,15 +337,14 @@
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
             , pcMvFieldSP, puhInterDirSP
 #endif
             , numValidMergeCand );
           pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
             , bSPIVMPFlag
 #endif
             , numValidMergeCand );
           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
-
 #else
 #if H_3D
@@ -358,5 +364,5 @@
       {
         uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
-#if H_3D_VSP
+#if NH_3D_VSP
         Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
@@ -367,10 +373,10 @@
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           , pcMvFieldSP, puhInterDirSP
 #endif
           ,numValidMergeCand, uiMergeIndex );
         pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           , bSPIVMPFlag
 #endif
@@ -398,6 +404,6 @@
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
-#if H_3D_VSP
-#if H_3D_DBBP
+#if NH_3D_VSP
+#if NH_3D_DBBP
           if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
 #else
@@ -490,5 +496,34 @@
         {
           pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
+
+#if NH_3D_MLC
+#if NH_3D_VSP
+          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
+          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if NH_3D_SPIVMP
+          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+          pcSubCU->initAvailableFlags();
+#endif
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+#if NH_3D_MLC
+          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
+#if NH_3D_SPIVMP
+            , pcMvFieldSP, puhInterDirSP
+#endif
+            , numValidMergeCand );
+          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if NH_3D_VSP
+            , vspFlag
+#endif
+#if NH_3D_SPIVMP
+            , bSPIVMPFlag
+#endif
+            , numValidMergeCand );
+#if NH_3D_VSP
+          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
+#endif
+#endif
           pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
           hasMergedCandList = true;
@@ -498,5 +533,34 @@
       {
         uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
+
+#if NH_3D_MLC
+#if NH_3D_VSP
+        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
+        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if NH_3D_SPIVMP
+        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+        pcSubCU->initAvailableFlags();
+#endif
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#if NH_3D_MLC
+        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
+#if NH_3D_SPIVMP
+          , pcMvFieldSP, puhInterDirSP
+#endif
+          ,numValidMergeCand, uiMergeIndex );
+        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if NH_3D_VSP
+          , vspFlag
+#endif
+#if NH_3D_SPIVMP
+          , bSPIVMPFlag
+#endif
+          ,numValidMergeCand );
+#if NH_3D_VSP
+        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
+#endif
+#endif
       }
 
@@ -512,7 +576,43 @@
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
-
-        }
-      }
+#if NH_3D_VSP
+          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
+          {
+            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
+            {
+              UInt dummy;
+              Int vspSize;
+              Int width, height;
+              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
+              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
+              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
+            }
+          }
+#endif
+        }
+      }
+#if NH_3D_SPIVMP
+      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );  
+      if (bSPIVMPFlag[uiMergeIndex] != 0)
+      {
+        Int iWidth, iHeight;
+        UInt uiIdx;
+        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
+
+        UInt uiSPAddr;
+
+        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+        {
+          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+        }
+      }
+#endif
     }
     else
@@ -551,5 +651,5 @@
   }
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   delete[] pcMvFieldSP;
   delete[] puhInterDirSP;
@@ -619,5 +719,5 @@
 }
 
-#if H_3D
+#if NH_3D
 Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList )
 {
@@ -1070,5 +1170,5 @@
 }
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecEntropy.h	(revision 1274)
@@ -85,5 +85,5 @@
   virtual Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0;
   virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex ) = 0;
-#if H_3D_ARP
+#if NH_3D_ARP
   virtual Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
@@ -95,5 +95,5 @@
   virtual Void parseSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   virtual Void parseDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
@@ -145,5 +145,5 @@
   Void decodeMvdPU        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList );
   Void decodeMVPIdxPU     ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList );
-#if H_3D
+#if NH_3D
   Void decodeMvsAMVP      ( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, 
 RefPicList eRefList );
@@ -174,5 +174,5 @@
   Void decodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 
-#if H_3D_ARP
+#if NH_3D_ARP
   Void decodeARPW              ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -183,5 +183,5 @@
   Void decodeSDCFlag           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void decodeDBBPFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1274)
@@ -122,19 +122,19 @@
   }
 
-#if H_3D_NBDV 
+#if NH_3D_NBDV 
   if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
   {
-    Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
-    rpcPic->setNumDdvCandPics(rpcPic->getDisCandRefPictures(iColPoc));
+    Int iColPoc = pcSlice->getRefPOC(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
+    pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
   }
 
   if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
   {
-    rpcPic->checkTemporalIVRef();
+    pcPic->checkTemporalIVRef();
   }
 
   if(pcSlice->getIsDepth())
   {
-    rpcPic->checkTextureRef();
+    pcPic->checkTextureRef();
   }
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 1274)
@@ -73,5 +73,5 @@
 , m_cCUMergeFlagExtSCModel                   ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUMergeIdxExtSCModel                    ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_ARP
+#if NH_3D_ARP
 , m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
@@ -119,5 +119,5 @@
 , m_cSDCFlagSCModel                  ( 1,             1,  NUM_SDC_FLAG_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
 , m_cDBBPFlagSCModel             ( 1,             1,                 DBBP_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
@@ -164,5 +164,5 @@
   m_cCUMergeFlagExtSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
   m_cCUMergeIdxExtSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
-#if H_3D_ARP
+#if NH_3D_ARP
   m_cCUPUARPWSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_ARPW );
 #endif
@@ -210,5 +210,5 @@
   m_cSDCFlagSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_cDBBPFlagSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_DBBP_FLAG );
 #endif
@@ -240,7 +240,4 @@
   m_cCUDISFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_FLAG );
   m_cCUDISTypeSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
-#endif
-#if H_3D_ARP
-  m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
 #endif
 #if H_3D_DIM
@@ -256,7 +253,4 @@
 #if H_3D_DIM_SDC
   m_cSDCFlagSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
-#endif
-#if H_3D_DBBP
-  m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
 
@@ -2417,20 +2411,17 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
-  UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1;
   UInt uiW = 0;
   UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
   UInt uiCode = 0;
 
-  assert ( uiMaxW > 0 );
-
-  m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) );
+  m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
 
   uiW = uiCode;
   if( 1 == uiW )   
   {
-    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
+    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__ARP_FLAG));
     uiW += ( 1 == uiCode ? 1 : 0 );
   }
@@ -2539,5 +2530,5 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -2547,9 +2538,9 @@
   UInt uiSymbol = 0;
   
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) RExt__DECODER_DEBUG_BIT_STATISTICS_PASS_OPT_ARG(STATS__CABAC_BITS__DBBP_FLAG) );
   DTRACE_CU("dbbp_flag", uiSymbol)
   PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
   AOF( ePartSize == SIZE_2NxN || ePartSize == SIZE_Nx2N );
-  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
+  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4;
   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx, 0, uiDepth);
   pcCU->setDBBPFlagSubParts(uiSymbol, uiAbsPartIdx+uiPUOffset, 1, uiDepth);
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecSbac.h	(revision 1274)
@@ -121,5 +121,5 @@
   Void  parseSDCFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void parseDBBPFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -139,5 +139,5 @@
   Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
   Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void parseARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
@@ -190,5 +190,5 @@
   ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
   ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
-#if H_3D_ARP
+#if NH_3D_ARP
   ContextModel3DBuffer m_cCUPUARPWSCModel;
 #endif
@@ -240,5 +240,5 @@
   ContextModel3DBuffer m_cSDCFlagSCModel;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   ContextModel3DBuffer m_cDBBPFlagSCModel;
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1274)
@@ -292,5 +292,5 @@
 
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Void
 CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
@@ -1149,22 +1149,9 @@
     pcSlice->getTempRefPicLists( m_cListPic, m_refPicSetInterLayer0, m_refPicSetInterLayer1, tempRefPicLists, usedAsLongTerm, numPocTotalCurr);
     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); 
-#if H_3D
+#if NH_3D_NBDV
     pcSlice->setDefaultRefView();
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     pcSlice->setARPStepNum(m_ivPicLists);
-    if( pcSlice->getARPStepNum() > 1 )
-    {
-      // GT: This seems to be broken, not all nuh_layer_ids are necessarily present
-      for(Int iLayerId = 0; iLayerId < nalu.m_nuhLayerId; iLayerId ++ )
-      {
-        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
-        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
-        if( iViewIdx<getViewIndex() && !bIsDepth )
-        {
-          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
-        }
-      }
-    }
 #endif
 #else
@@ -1174,5 +1161,5 @@
 #if NH_3D
     pcSlice->checkInCompPredRefLayers(); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 #if H_3D_FCO
     //assert( !getIsDepth() );
@@ -1271,5 +1258,5 @@
   }
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 #if H_3D_FCO
   if( !pcSlice->getIsDepth() && m_pcCamParsCollector )
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibDecoder/TDecTop.h	(revision 1274)
@@ -81,5 +81,5 @@
   Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   Void  copyCamParamForSlice( TComSlice* pcSlice );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1274)
@@ -2195,5 +2195,5 @@
     }
 #endif
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
     assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM);
 #else
@@ -2202,5 +2202,5 @@
     if (!pcSlice->isIntra())
     {
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
 #else
@@ -2578,5 +2578,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -2901,5 +2901,5 @@
 #endif
     
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TEncCavlc::codeDBBPFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCavlc.h	(revision 1274)
@@ -126,5 +126,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
@@ -136,5 +136,5 @@
   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void codeDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1274)
@@ -68,5 +68,5 @@
   m_ppcTempCU      = new TComDataCU*[m_uhTotalDepth-1];
 
-#if H_3D_ARP
+#if NH_3D_ARP
   m_ppcWeightedTempCU = new TComDataCU*[m_uhTotalDepth-1];
 #endif 
@@ -79,5 +79,5 @@
   m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1];
   m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
-#if H_3D_DBBP
+#if NH_3D_DBBP
   m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1];
 #endif
@@ -92,6 +92,6 @@
     m_ppcBestCU[i] = new TComDataCU; m_ppcBestCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
     m_ppcTempCU[i] = new TComDataCU; m_ppcTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
-#if H_3D_ARP
-    m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
+#if NH_3D_ARP
+    m_ppcWeightedTempCU[i] = new TComDataCU; m_ppcWeightedTempCU[i]->create( chromaFormat, uiNumPartitions, uiWidth, uiHeight, false, uiMaxWidth >> (m_uhTotalDepth - 1) );
 #endif  
 
@@ -105,6 +105,6 @@
 
     m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight, chromaFormat);
-#if H_3D_DBBP
-    m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight);
+#if NH_3D_DBBP
+    m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight, chromaFormat);
 #endif
 
@@ -146,5 +146,5 @@
       m_ppcTempCU[i]->destroy();      delete m_ppcTempCU[i];      m_ppcTempCU[i] = NULL;
     }
-#if H_3D_ARP
+#if NH_3D_ARP
     if(m_ppcWeightedTempCU[i])
     {
@@ -180,5 +180,5 @@
       m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
     }
-#if H_3D_DBBP
+#if NH_3D_DBBP
     if(m_ppcOrigYuvDBBP[i])
     {
@@ -198,5 +198,5 @@
   }
 
-#if H_3D_ARP
+#if NH_3D_ARP
   if(m_ppcWeightedTempCU)
   {
@@ -240,5 +240,5 @@
     m_ppcOrigYuv = NULL;
   }
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if(m_ppcOrigYuvDBBP)
   {
@@ -280,4 +280,8 @@
   m_ppcTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
 
+#if NH_3D_ARP
+  m_ppcWeightedTempCU[0]->initCtu( pCtu->getPic(), pCtu->getCtuRsAddr() );
+#endif
+
 #if KWU_RC_MADPRED_E0227
   m_LCUPredictionSAD = 0;
@@ -441,9 +445,9 @@
   Bool    earlyDetectionSkipMode = false;
 
-#if H_3D_VSP
+#if NH_3D_NBDV
   DisInfo DvInfo; 
   DvInfo.m_acNBDV.setZero();
   DvInfo.m_aVIdxCan = 0;
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
   DvInfo.m_acDoNBDV.setZero();
 #endif
@@ -584,17 +588,33 @@
 #endif
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
       if( rpcTempCU->getSlice()->getSliceType() != I_SLICE )
       {
-#if H_3D_ARP && H_3D_IV_MERGE
-        if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() )
+#if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP
+        if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
 #else 
-#if H_3D_ARP
-        if( rpcTempCU->getSlice()->getVPS()->getUseAdvRP(rpcTempCU->getSlice()->getLayerId()) )
+#if NH_3D_IV_MERGE && NH_3D_VSP
+        if( rpcTempCU->getSlice()->getIvMvPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
+#else
+#if NH_3D_ARP && NH_3D_VSP
+        if( rpcTempCU->getSlice()->getIvResPredFlag() || rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
+#else
+#if NH_3D_VSP
+        if( rpcTempCU->getSlice()->getViewSynthesisPredFlag() )
+#else
+#if NH_3D_ARP
+        if( rpcTempCU->getSlice()->getIvResPredFlag() )
 #else
 #if H_3D_IV_MERGE
         if( rpcTempCU->getSlice()->getVPS()->getIvMvPredFlag(rpcTempCU->getSlice()->getLayerId()) )
 #else
+#if NH_3D_DBBP
+        if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() )
+#else
         if (0)
+#endif
+#endif
+#endif
+#endif
 #endif
 #endif
@@ -602,6 +622,6 @@
         {
           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
-          rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
-#if H_3D_IV_MERGE
+          rpcTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);
+#if NH_3D_IV_MERGE
           if (rpcTempCU->getSlice()->getIsDepth() )
           {
@@ -611,5 +631,5 @@
           {
 #endif 
-#if H_3D_NBDV_REF
+#if NH_3D_NBDV_REF
             if( rpcTempCU->getSlice()->getDepthRefinementFlag() )
             {
@@ -621,5 +641,5 @@
               rpcTempCU->getDisMvpCandNBDV(&DvInfo);
             }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
           }
 #endif
@@ -659,6 +679,6 @@
           rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );//by Competition for inter_2Nx2N
 #endif
-#if H_3D_VSP
-            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP  || NH_3D_DBBP
+          rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
         }
@@ -673,6 +693,6 @@
 
         rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-          rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP  || NH_3D_DBBP
+        rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
 
@@ -690,13 +710,13 @@
           rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
 #endif
-#if H_3D_VSP
-            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
-#endif
-#if H_3D_DBBP
+#if NH_3D_VSP  || NH_3D_DBBP
+          rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#endif
+#if NH_3D_DBBP
             if( rpcTempCU->getSlice()->getDepthBasedBlkPartFlag() && rpcTempCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
             {
               xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false );
               rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode  );
-#if H_3D_VSP
+#if NH_3D_VSP  || NH_3D_DBBP
               rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -780,6 +800,6 @@
 #endif
               rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-                rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP || NH_3D_DBBP
+              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
 
@@ -799,5 +819,5 @@
 #endif
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -822,5 +842,5 @@
 
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -861,5 +881,5 @@
 #endif
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -882,5 +902,5 @@
 
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -909,5 +929,5 @@
 
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -929,5 +949,5 @@
 #endif
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -957,5 +977,5 @@
 
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -977,5 +997,5 @@
 #endif
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -997,5 +1017,5 @@
 #endif
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -1018,5 +1038,5 @@
 #endif
                 rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
+#if NH_3D_VSP || NH_3D_DBBP
                 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
@@ -1034,11 +1054,11 @@
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU );
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP || NH_3D_DBBP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD );
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP || NH_3D_DBBP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
 #if NH_3D_QTLPC
@@ -1049,11 +1069,11 @@
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N );
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP || NH_3D_DBBP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
             xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N );
             rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D_VSP
-              rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#if NH_3D_VSP || NH_3D_DBBP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
 #if NH_3D_QTLPC
@@ -1270,4 +1290,8 @@
       DEBUG_STRING_NEW(sTempDebug)
 
+#if NH_3D_ARP
+      m_ppcWeightedTempCU[uhNextDepth]->setSlice( m_ppcWeightedTempCU[ uiDepth]->getSlice()); 
+      m_ppcWeightedTempCU[uhNextDepth]->setPic  ( m_ppcWeightedTempCU[ uiDepth] ); 
+#endif
       for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ )
       {
@@ -1575,5 +1599,5 @@
 
     m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
@@ -1612,5 +1636,5 @@
   // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
-#if H_3D
+#if NH_3D_DBBP
   m_pcEntropyCoder->encodeDBBPFlag( pcCU, uiAbsPartIdx );
 #endif
@@ -1618,5 +1642,5 @@
   m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx, false );
 #endif  
-#if H_3D_ARP
+#if NH_3D_ARP
   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
@@ -1763,5 +1787,5 @@
 {
   assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE );
-#if H_3D_IV_MERGE
+#if NH_3D_MLC
   TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
@@ -1792,5 +1816,5 @@
 #endif
 
-#if H_3D_ARP
+#if NH_3D_ARP
   DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
 #else
@@ -1798,41 +1822,71 @@
 
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
-#if H_3D_VSP
-#if !H_3D_ARP
+
+#if NH_3D_SPIVMP
+  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
+  memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+  TComMvField*  pcMvFieldSP;
+  UChar* puhInterDirSP;
+  pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
+  puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
+#endif
+
+#if NH_3D_VSP
+#if !NH_3D_ARP
   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
-  InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
-  rpcTempCU->m_bAvailableFlagA1 = 0;
-  rpcTempCU->m_bAvailableFlagB1 = 0;
-  rpcTempCU->m_bAvailableFlagB0 = 0;
-  rpcTempCU->m_bAvailableFlagA0 = 0;
-  rpcTempCU->m_bAvailableFlagB2 = 0;
+#if NH_3D_MLC
+  rpcTempCU->initAvailableFlags();
+#endif
   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
-  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand );
-#endif
-#else
-#if H_3D
-  rpcTempCU->m_bAvailableFlagA1 = 0;
-  rpcTempCU->m_bAvailableFlagB1 = 0;
-  rpcTempCU->m_bAvailableFlagB0 = 0;
-  rpcTempCU->m_bAvailableFlagA0 = 0;
-  rpcTempCU->m_bAvailableFlagB2 = 0;
-  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
-  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
-#else
+#if NH_3D_MLC
+  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
+#if NH_3D_SPIVMP
+    , pcMvFieldSP, puhInterDirSP
+#endif
+    , numValidMergeCand 
+    );
+
+  rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
+#if NH_3D_SPIVMP
+    , bSPIVMPFlag
+#endif
+    , numValidMergeCand 
+    );
+#endif
+#endif
+#else
+#if NH_3D_MLC
+  rpcTempCU->initAvailableFlags();
+#endif
   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
-#endif
-#endif
-#if H_3D_IV_MERGE
+#if NH_3D_MLC
+  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
+#if H_3D_SPIVMP
+    , pcMvFieldSP, puhInterDirSP
+#endif
+    , numValidMergeCand 
+    );
+#if NH_3D_MLC
+  rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
+#if H_3D_SPIVMP
+    , bSPIVMPFlag
+#endif
+    , numValidMergeCand 
+    );
+#endif
+#endif
+#endif
+
+#if NH_3D_MLC
   Int mergeCandBuffer[MRG_MAX_NUM_CANDS_MEM];
 #else
   Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
 #endif
-#if H_3D_ARP
-for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
+#if NH_3D_MLC
+  for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
 #else
   for( UInt ui = 0; ui < numValidMergeCand; ++ui )
 #endif
-
   {
     mergeCandBuffer[ui] = 0;
@@ -1852,7 +1906,11 @@
   DEBUG_STRING_NEW(bestStr)
 
-#if H_3D_ARP
+#if NH_3D_ARP
   Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1;
+#if H_3D_IC
   if( nARPWMax < 0 || bICFlag )
+#else
+  if( nARPWMax < 0 )
+#endif
   {
     nARPWMax = 0;
@@ -1860,5 +1918,9 @@
   for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
   {
+#if NH_3D_IV_MERGE
     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
+#else
+    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS * sizeof(Int) );
+#endif
     rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
     rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
@@ -1867,20 +1929,16 @@
 #endif
     rpcTempCU->getDvInfo(0) = cOrigDisInfo;
-    rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth );
+    rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, uhDepth );
+#if NH_3D_VSP
     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
-#if H_3D_SPIVMP
-    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
-    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
-    TComMvField*  pcMvFieldSP;
-    UChar* puhInterDirSP;
-    pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartition()*2]; 
-    puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; 
-#endif
-#if H_3D
+#endif
+#if NH_3D
+#if NH_3D_MLC
     rpcTempCU->initAvailableFlags();
+#endif
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -1888,6 +1946,9 @@
       );
 
-    rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
-#if H_3D_SPIVMP
+    rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
+#if NH_3D_VSP
+      , vspFlag
+#endif
+#if NH_3D_SPIVMP
       , bSPIVMPFlag
 #endif
@@ -1896,5 +1957,5 @@
 
 #else
-    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, numValidMergeCand );
+    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
 #endif
 
@@ -1926,7 +1987,4 @@
           rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
 #endif
-#if H_3D_ARP
-          rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
-#endif
           rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, 0, uhDepth );
           rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
@@ -1934,8 +1992,12 @@
           rpcTempCU->setMergeFlagSubParts( true, 0, 0, uhDepth ); // interprets depth relative to CTU level
           rpcTempCU->setMergeIndexSubParts( uiMergeCand, 0, 0, uhDepth ); // interprets depth relative to CTU level
-#if H_3D_VSP
+#if NH_3D_ARP
+          rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#endif
+
+#if NH_3D_VSP
           rpcTempCU->setVSPFlagSubParts( vspFlag[uiMergeCand], 0, 0, uhDepth );
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
           if (bSPIVMPFlag[uiMergeCand])
@@ -1956,6 +2018,6 @@
           else
 #endif
-#if H_3D_VSP
           {
+#if NH_3D_VSP
             if ( vspFlag[uiMergeCand] )
             {
@@ -1987,11 +2049,11 @@
             {
 #endif
-          rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to CTU 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
+            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to CTU 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 NH_3D_VSP
             }
+#endif
           }
-#endif
           // do MC
           m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
@@ -2027,5 +2089,5 @@
           rpcTempCU->setDISFlagSubParts( false, 0, uhDepth );
 #endif
-#if H_3D_VSP // possible bug fix
+#if NH_3D_VSP
           if( rpcTempCU->getSkipFlag(0) )
           {
@@ -2160,12 +2222,11 @@
   }
   DEBUG_STRING_APPEND(sDebug, bestStr)
-#if H_3D_SPIVMP
+#if NH_3D_ARP
+ }
+#endif
+#if NH_3D_SPIVMP
  delete[] pcMvFieldSP;
  delete[] puhInterDirSP;
 #endif
-#if H_3D_ARP
- }
-#endif
-
 }
 
@@ -2184,5 +2245,5 @@
 
   // prior to this, rpcTempCU will have just been reset using rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
-#if H_3D
+#if H_3D || NH_3D_ARP
   const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(0);
 #endif
@@ -2192,8 +2253,12 @@
 #endif
   UChar uhDepth = rpcTempCU->getDepth( 0 );
-#if H_3D_ARP
+#if NH_3D_ARP
     Bool bFirstTime = true;
     Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
+#if H_3D_IC
     if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || rpcTempCU->getICFlag(0) )
+#else
+    if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N )
+#endif
     {
       nARPWMax = 0;
@@ -2223,8 +2288,8 @@
   rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
   rpcTempCU->setChromaQpAdjSubParts( rpcTempCU->getCUTransquantBypass(0) ? 0 : m_cuChromaQpOffsetIdxPlus1, 0, uhDepth );
-#if H_3D_ARP
+#if NH_3D_ARP
       rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
       if( bFirstTime == false && nARPWMax )
       {
@@ -2249,5 +2314,5 @@
   m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
         if( nARPWMax )
         {
@@ -2260,5 +2325,5 @@
   if ( !rpcTempCU->getMergeAMP() )
   {
-#if H_3D_ARP
+#if NH_3D_ARP
         if( nARPWMax )
         {
@@ -2281,9 +2346,9 @@
 
   m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false DEBUG_STRING_PASS_INTO(sTest) );
-#if H_3D_VSP // possible bug fix
-      if( rpcTempCU->getQtRootCbf(0)==0 )
-      {
-        rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
-      }
+#if NH_3D_VSP
+  if( rpcTempCU->getQtRootCbf(0)==0 )
+  {
+    rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
+  }
 #endif
 #if NH_3D_VSO // M4
@@ -2377,5 +2442,5 @@
       }
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     }
 #endif
@@ -2385,13 +2450,13 @@
 }
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment )
 {
-  UInt  uiWidth     = pOrigYuv->getWidth ( );
-  UInt  uiHeight    = pOrigYuv->getHeight( );
-  Pel*  piSrc       = pOrigYuv->getLumaAddr( );
-  UInt  uiSrcStride = pOrigYuv->getStride();
-  Pel*  piDst       = pOrigYuvTemp->getLumaAddr( );
-  UInt  uiDstStride = pOrigYuvTemp->getStride();
+  UInt  uiWidth     = pOrigYuv->getWidth (COMPONENT_Y);
+  UInt  uiHeight    = pOrigYuv->getHeight(COMPONENT_Y);
+  Pel*  piSrc       = pOrigYuv->getAddr(COMPONENT_Y);
+  UInt  uiSrcStride = pOrigYuv->getStride(COMPONENT_Y);
+  Pel*  piDst       = pOrigYuvTemp->getAddr(COMPONENT_Y);
+  UInt  uiDstStride = pOrigYuvTemp->getStride(COMPONENT_Y);
   
   UInt  uiMaskStride= MAX_CU_SIZE;
@@ -2418,10 +2483,10 @@
   
   // now invalidate chroma
-  Pel*  piSrcU       = pOrigYuv->getCbAddr();
-  Pel*  piSrcV       = pOrigYuv->getCrAddr();
-  UInt  uiSrcStrideC = pOrigYuv->getCStride();
-  Pel*  piDstU       = pOrigYuvTemp->getCbAddr( );
-  Pel*  piDstV       = pOrigYuvTemp->getCrAddr( );
-  UInt  uiDstStrideC = pOrigYuvTemp->getCStride();
+  Pel*  piSrcU       = pOrigYuv->getAddr(COMPONENT_Cb);
+  Pel*  piSrcV       = pOrigYuv->getAddr(COMPONENT_Cr);
+  UInt  uiSrcStrideC = pOrigYuv->getStride(COMPONENT_Cb);
+  Pel*  piDstU       = pOrigYuvTemp->getAddr(COMPONENT_Cb);
+  Pel*  piDstV       = pOrigYuvTemp->getAddr(COMPONENT_Cr);
+  UInt  uiDstStrideC = pOrigYuvTemp->getStride(COMPONENT_Cb);
   pMask = pMaskStart;
   
@@ -2444,5 +2509,7 @@
   }
 }
-
+#endif
+
+#if H_3D_DIS
 Void TEncCu::xCheckRDCostDIS( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
 {
@@ -2518,5 +2585,7 @@
   xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
 }
-
+#endif
+
+#if NH_3D_DBBP
 Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG )
 {
@@ -2540,6 +2609,5 @@
   AOF( uiWidth == uiHeight );
   
-#if H_3D_DBBP
-  // Is this correct here, was under the macro SEC_DBBP_DISALLOW_8x8_I0078, however the function is related to Single Depth Mode
+#if NH_3D_DBBP
   if(uiWidth <= 8)
   {
@@ -2592,5 +2660,5 @@
     rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize;
     rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment;
-    m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], false, false, bUseMRG );
+    m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], false, bUseMRG );
     m_pcRdCost->setUseMask(false);
     
@@ -2601,6 +2669,8 @@
     pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0);
     
+#if NH_3D_VSP
     AOF( rpcTempCU->getSPIVMPFlag(0) == false );
     AOF( rpcTempCU->getVSPFlag(0) == 0 );
+#endif
     
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
@@ -2621,5 +2691,5 @@
   rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
   
-  UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxCUDepth() - uhDepth ) << 1 ) ) >> 4;
+  UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uhDepth ) << 1 ) ) >> 4;
   for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
   {
@@ -2647,5 +2717,6 @@
   
   // reconstruct final prediction signal by combining both segments
-  m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize);
+  Int bitDepthY = rpcTempCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
+  m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight, 0, eVirtualPartSize, bitDepthY);
   m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
   
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncCu.h	(revision 1274)
@@ -69,5 +69,5 @@
   TComDataCU**            m_ppcBestCU;      ///< Best CUs in each depth
   TComDataCU**            m_ppcTempCU;      ///< Temporary CUs in each depth
-#if H_3D_ARP
+#if NH_3D_ARP
   TComDataCU**            m_ppcWeightedTempCU;
 #endif
@@ -82,5 +82,5 @@
   TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   TComYuv**               m_ppcOrigYuvDBBP;
 #endif
@@ -155,5 +155,5 @@
   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
   Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG = false );
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1274)
@@ -151,5 +151,5 @@
 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
-#if H_3D_ARP
+#if NH_3D_ARP
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
 #else
@@ -188,5 +188,5 @@
 #endif
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncEntropy::encodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -874,7 +874,12 @@
 
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
+  if( bRD )
+  {
+    uiAbsPartIdx = 0;
+  }
+  
   if( pcCU->getSlice()->getDepthBasedBlkPartFlag() && 
     ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || 
@@ -883,8 +888,4 @@
       pcCU->getSlice()->getDefaultRefViewIdxAvailableFlag() )
   {
-    if( bRD )
-    {
-      uiAbsPartIdx = 0;
-    }
     m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx );
   }
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncEntropy.h	(revision 1274)
@@ -84,5 +84,5 @@
   virtual Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
-#if H_3D_ARP
+#if NH_3D_ARP
   virtual Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
@@ -94,5 +94,5 @@
   virtual Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   virtual Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
@@ -173,5 +173,5 @@
   Void encodeMergeFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void encodeMergeIndex   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void encodeARPW         ( TComDataCU* pcCU, UInt uiAbspartIdx );
 #endif
@@ -183,5 +183,5 @@
   Void encodeSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void encodeDBBPFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1274)
@@ -1443,5 +1443,5 @@
     }   
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
     // This needs to be done after initialization of 3D tool parameters.
     pcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( )   ) ? 1 : 0 ));
@@ -1471,22 +1471,10 @@
     pcSlice->setRefPicList ( rcListPic );
 #endif
-#if H_3D
+#if NH_3D_NBDV
     pcSlice->setDefaultRefView();
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
     pcSlice->setARPStepNum(m_ivPicLists);
-    if(pcSlice->getARPStepNum() > 1)
-    {
-      for(Int iLayerId = 0; iLayerId < getLayerId(); iLayerId ++ )
-      {
-        Int  iViewIdx =   pcSlice->getVPS()->getViewIndex(iLayerId);
-        Bool bIsDepth = ( pcSlice->getVPS()->getDepthId  ( iLayerId ) == 1 );
-        if( iViewIdx<getViewIndex() && !bIsDepth )
-        {
-          pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );
-        }
-      }
-    }
 #endif
 #if NH_3D_IC
@@ -1731,8 +1719,8 @@
     UInt uiNumSliceSegments = 1;
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
       if(pcSlice->getViewIndex() && !pcSlice->getIsDepth()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
       {
-        Int iColPoc = pcSlice->getRefPOC(RefPicList(1-pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
+        Int iColPoc = pcSlice->getRefPOC(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
         pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc));
       }
@@ -1743,5 +1731,5 @@
 #endif
 
-#if H_3D_NBDV
+#if NH_3D_NBDV
       if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done.
       {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 1274)
@@ -68,5 +68,5 @@
 , m_cCUMergeFlagExtSCModel             ( 1,             1,                      NUM_MERGE_FLAG_EXT_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUMergeIdxExtSCModel              ( 1,             1,                      NUM_MERGE_IDX_EXT_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
-#if H_3D_ARP
+#if NH_3D_ARP
 , m_cCUPUARPWSCModel                   ( 1,             1,                      NUM_ARPW_CTX                         , m_contextModels + m_numContextModels, m_numContextModels)
 #endif                                                                                                               
@@ -114,5 +114,5 @@
 , m_cSDCFlagSCModel                    ( 1,             1,                       NUM_SDC_FLAG_CTX                    , m_contextModels + m_numContextModels, m_numContextModels)
 #endif                                                                                                          
-#if H_3D_DBBP                                                                                                  
+#if NH_3D_DBBP
 , m_cDBBPFlagSCModel                   ( 1,             1,                       DBBP_NUM_FLAG_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
@@ -148,5 +148,5 @@
   m_cCUMergeFlagExtSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT);
   m_cCUMergeIdxExtSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT);
-#if H_3D_ARP
+#if NH_3D_ARP
   m_cCUPUARPWSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_ARPW );
 #endif
@@ -194,5 +194,5 @@
   m_cSDCFlagSCModel.initBuffer                    ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
 #endif                                           
-#if H_3D_DBBP                                    
+#if NH_3D_DBBP
   m_cDBBPFlagSCModel.initBuffer                   ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
@@ -235,5 +235,5 @@
       curCost += m_cCUMergeFlagExtSCModel.calcCost             ( curSliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT);
       curCost += m_cCUMergeIdxExtSCModel.calcCost              ( curSliceType, qp, (UChar*)INIT_MERGE_IDX_EXT);
-#if H_3D_ARP
+#if NH_3D_ARP
       curCost += m_cCUPUARPWSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_ARPW );
 #endif                                                     
@@ -244,5 +244,5 @@
       curCost += m_cSDCFlagSCModel.calcCost                    ( curSliceType, qp, (UChar*)INIT_SDC_FLAG );
 #endif                                                     
-#if H_3D_DBBP                                              
+#if NH_3D_DBBP
       curCost += m_cDBBPFlagSCModel.calcCost                   ( curSliceType, qp, (UChar*)INIT_DBBP_FLAG );
 #endif
@@ -302,7 +302,4 @@
   m_cCUDISTypeSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_DIS_TYPE );
 #endif
-#if H_3D_ARP
-  m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
-#endif
 #if H_3D_DIM
   m_cDepthIntraModeSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );
@@ -317,7 +314,4 @@
 #if H_3D_DIM_SDC
   m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
-#endif
-#if H_3D_DBBP
-  m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
 
@@ -971,5 +965,5 @@
 }
 
-#if H_3D_ARP
+#if NH_3D_ARP
 Void TEncSbac::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -2647,5 +2641,5 @@
 #endif
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
 Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSbac.h	(revision 1274)
@@ -140,5 +140,5 @@
   Void codeMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeMergeIndex    ( TComDataCU* pcCU, UInt uiAbsPartIdx );
-#if H_3D_ARP
+#if NH_3D_ARP
   Void codeARPW          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
@@ -150,5 +150,5 @@
   Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
@@ -212,5 +212,5 @@
   ContextModel3DBuffer m_cCUMergeFlagExtSCModel;
   ContextModel3DBuffer m_cCUMergeIdxExtSCModel;
-#if H_3D_ARP
+#if NH_3D_ARP
   ContextModel3DBuffer m_cCUPUARPWSCModel;
 #endif
@@ -262,5 +262,5 @@
   ContextModel3DBuffer m_cSDCFlagSCModel;
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
   ContextModel3DBuffer m_cDBBPFlagSCModel;
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1274)
@@ -3876,8 +3876,8 @@
 //! estimation of best merge coding
 Void TEncSearch::xMergeEstimation( TComDataCU* pcCU, TComYuv* pcYuvOrg, Int iPUIdx, UInt& uiInterDir, TComMvField* pacMvField, UInt& uiMergeIndex, Distortion& ruiCost, TComMvField* cMvFieldNeighbours, UChar* uhInterDirNeighbours, Int& numValidMergeCand 
-#if H_3D_VSP
+#if NH_3D_VSP
                                  , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -3891,5 +3891,5 @@
   UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
   if( pcCU->getDBBPFlag(0) )
@@ -3898,5 +3898,5 @@
     AOF( iPUIdx == 0 );
     AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
-    AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
+    AOF( pDBBPTmpData->eVirtualPartSize != NUMBER_OF_PART_SIZES );
     
     // temporary change of partition size for candidate derivation
@@ -3923,5 +3923,5 @@
 
   PartSize partSize = pcCU->getPartitionSize( 0 );
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(0) == false )
 #else
@@ -3932,9 +3932,9 @@
     {
       pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set
-#if H_3D
+#if NH_3D_MLC
       pcCU->initAvailableFlags();
-      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
+      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3943,11 +3943,11 @@
 
       pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
         , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         , pbSPIVMPFlag
 #endif
-                                        , numValidMergeCand
+        , numValidMergeCand
         );
 #else
@@ -3959,9 +3959,9 @@
   else
   {
-#if H_3D
+#if NH_3D_MLC
     pcCU->initAvailableFlags();
-    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
+    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3970,11 +3970,11 @@
 
     pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_VSP
+#if NH_3D_VSP
       , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pbSPIVMPFlag
 #endif
-                                      , numValidMergeCand
+      , numValidMergeCand
       );
 #else
@@ -3985,5 +3985,5 @@
   xRestrictBipredMergeCand( pcCU, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
   if( pcCU->getDBBPFlag(0) )
   {
@@ -4008,9 +4008,9 @@
 
     PartSize ePartSize = pcCU->getPartitionSize( 0 );
-#if H_3D_VSP
+#if NH_3D_VSP
     pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
 #endif
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx )); 
     if (pbSPIVMPFlag[uiMergeCand])
@@ -4031,6 +4031,6 @@
     else
 #endif
-#if H_3D_VSP
-#if H_3D_DBBP
+#if NH_3D_VSP
+#if NH_3D_DBBP
       if ( vspFlag[uiMergeCand] && !pcCU->getDBBPFlag(0) )
 #else
@@ -4068,5 +4068,5 @@
     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
-#if H_3D_VSP
+#if NH_3D_VSP
       }
 #endif
@@ -4179,5 +4179,5 @@
   Distortion   biPDistTemp = std::numeric_limits<Distortion>::max();
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM];
@@ -4214,5 +4214,5 @@
 
     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
-#if H_3D_VSP
+#if NH_3D_VSP
     pcCU->setVSPFlagSubParts( 0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr) );
 #endif
@@ -4557,5 +4557,5 @@
     } // end if bTestNormalMC
 #endif
-#if H_3D_DBBP
+#if NH_3D_DBBP
     // test merge mode for DBBP (2Nx2N)
     if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N || pcCU->getDBBPFlag(0) )
@@ -4597,5 +4597,5 @@
       Distortion uiMRGCost = std::numeric_limits<Distortion>::max();
 
-#if H_3D_VSP
+#if NH_3D_VSP
       Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
       memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
@@ -4606,21 +4606,20 @@
       DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
       memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
       TComMvField*  pcMvFieldSP;
       UChar* puhInterDirSP;
-      pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
-      puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
-#endif
-      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours
-
-#if H_3D_VSP
+      pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
+      puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
+#endif
+      xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
+#if NH_3D_VSP
                       , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif 
-, numValidMergeCand);
+                      );
 
       if ( uiMRGCost < uiMECost )
@@ -4629,8 +4628,8 @@
         pcCU->setMergeFlagSubParts ( true,          uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setMergeIndexSubParts( uiMRGIndex,    uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
-#if H_3D_VSP
+#if NH_3D_VSP
         pcCU->setVSPFlagSubParts( vspFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );  
         if (bSPIVMPFlag[uiMRGIndex]!=0)
@@ -4655,6 +4654,6 @@
         else
 #endif
-#if H_3D_VSP
-#if H_3D_DBBP
+#if NH_3D_VSP
+#if NH_3D_DBBP
         if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
 #else
@@ -4692,4 +4691,7 @@
         pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
         pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
+#if NH_3D_VSP
+          }
+#endif
 #if H_3D
           }
@@ -4705,5 +4707,5 @@
       else
       {
-#if H_3D_SPIVMP        
+#if NH_3D_SPIVMP        
         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
 #endif
@@ -4711,5 +4713,5 @@
         pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setInterDirSubParts ( uiMEInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
-#if H_3D_VSP
+#if NH_3D_VSP
         pcCU->setVSPFlagSubParts ( 0,             uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
         pcCU->setDvInfoSubParts(OriginalDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
@@ -4718,5 +4720,5 @@
         pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMEMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
       }
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       delete[] pcMvFieldSP;
       delete[] puhInterDirSP;
@@ -4754,5 +4756,5 @@
   {
 
-#if H_3D_DBBP
+#if NH_3D_DBBP
     DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
     if( pcCU->getDBBPFlag(0) )
@@ -4761,5 +4763,5 @@
       AOF( uiPartIdx == 0 );
       AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
-      AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
+      AOF( pDBBPTmpData->eVirtualPartSize != NUMBER_OF_PART_SIZES );
       AOF( iRoiWidth == iRoiHeight );
       
@@ -4786,5 +4788,5 @@
 
     pcCU->fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
-#if H_3D_DBBP
+#if NH_3D_DBBP
     if( pcCU->getDBBPFlag(0) )
     {
@@ -5014,10 +5016,14 @@
   if ( pcCU->getSlice()->testWeightPred() && pcCU->getSlice()->getSliceType()==P_SLICE )
   {
-    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
+    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) 
+#if NH_3D_ARP
+      , false //add this for IC, otherwise, it could be removed
+#endif
+      );
   }
   else
   {
     xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) 
-#if H_3D_ARP
+#if NH_3D_ARP
       , false
 #endif
@@ -5114,5 +5120,5 @@
 
   m_pcRdCost->setPredictor  ( *pcMvPred );
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( pcCU->getSlice()->getIsDepth() )
   {
@@ -5123,5 +5129,5 @@
 #endif
     m_pcRdCost->setCostScale  ( 2 );    
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   }
 #endif
@@ -5150,5 +5156,5 @@
 
   m_pcRdCost->getMotionCost( true, 0, pcCU->getCUTransquantBypass(uiPartAddr) );
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( ! pcCU->getSlice()->getIsDepth() )
   {
@@ -5163,10 +5169,10 @@
   rcMv += (cMvHalf <<= 1);
   rcMv +=  cMvQter;
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   }
 #endif
 
   UInt uiMvBits = m_pcRdCost->getBits( rcMv.getHor(), rcMv.getVer() );
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( pcCU->getSlice()->getIsDepth() )
   {
@@ -5182,5 +5188,5 @@
 {
   Int  iMvShift = 2;
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( pcCU->getSlice()->getIsDepth() )
   {
@@ -5340,5 +5346,5 @@
   UInt uiSearchRange = m_iSearchRange;
   pcCU->clipMv( rcMv );
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
   if( ! pcCU->getSlice()->getIsDepth() )
 #endif
@@ -5360,10 +5366,10 @@
       TComMv cMv = m_acMvPredictors[index];
       pcCU->clipMv( cMv );
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
       if( ! pcCU->getSlice()->getIsDepth() )
       {      
 #endif
         cMv >>= 2;
-#if NH_3D_FULL_PEL_DEPTH_MAP_MV_ACC
+#if NH_3D_INTEGER_MV_DEPTH
       }
 #endif
@@ -5788,5 +5794,5 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
 #endif
@@ -5884,6 +5890,6 @@
   const Double zeroCost     = (pcCU->isLosslessCoded( 0 )) ? (nonZeroCost+1) : (m_pcRdCost->calcRdCost( zeroResiBits, zeroDistortion ));
 #endif
-#if H_3D_SPIVMP
-    if ( dZeroCost < dCost || pcCU->getQtRootCbf(0)==0)
+#if NH_3D_SPIVMP
+    if ( zeroCost < nonZeroCost || pcCU->getQtRootCbf(0)==0)
 #else
   if ( zeroCost < nonZeroCost || !pcCU->getQtRootCbf(0) )
@@ -7104,5 +7110,5 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
 #endif
@@ -7131,5 +7137,5 @@
     m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
 #endif
-#if H_3D_ARP
+#if NH_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , 0  );
 #endif
@@ -7137,5 +7143,5 @@
     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
 #endif
-#if H_3D
+#if NH_3D_DBBP
     m_pcEntropyCoder->encodeDBBPFlag( pcCU, 0, true );
 #endif
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.h	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSearch.h	(revision 1274)
@@ -409,11 +409,11 @@
                                     TComMvField* cMvFieldNeighbours,
                                     UChar*       uhInterDirNeighbours,
-#if H_3D_VSP
+                                    Int&         numValidMergeCand
+#if NH_3D_VSP
                                   , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                                   , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
-                                    Int&         numValidMergeCand
                                    );
 
Index: branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1271)
+++ branches/HTM-14.1-update-dev2/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1274)
@@ -567,5 +567,5 @@
   rpcSlice->setSliceSegmentMode     ( m_pcCfg->getSliceSegmentMode()     );
   rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 #else
   rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
