Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1259)
@@ -131,5 +131,5 @@
   m_piVSPFlag            = NULL;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag         = NULL;
 #endif
@@ -188,5 +188,5 @@
     m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
 #endif
@@ -379,5 +379,5 @@
     }
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
 #endif
@@ -630,6 +630,6 @@
   memset( m_piVSPFlag         , 0,                        m_uiNumPartition * sizeof( *m_piVSPFlag ) );
 #endif
-#if H_3D_SPIVMP
-    m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
+#if NH_3D_SPIVMP
+  memset( m_pbSPIVMPFlag      , 0,                     m_uiNumPartition * sizeof( *m_pbSPIVMPFlag ) );   
 #endif
 #if H_3D_DIM_SDC
@@ -642,7 +642,4 @@
     memset( m_bDISFlag          + firstElement, false,                    numElements * sizeof( *m_bDISFlag ) );
     memset( m_uiDISType         + firstElement,     0,                    numElements * sizeof( *m_uiDISType) );
-#endif
-#if H_3D_SPIVMP
-    memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
 #endif
 
@@ -799,6 +796,6 @@
     m_piVSPFlag[ui]     = 0;
 #endif
-#if H_3D_SPIVMP
-      m_pbSPIVMPFlag[ui] = 0;
+#if NH_3D_SPIVMP
+    m_pbSPIVMPFlag[ui] = 0;
 #endif
 
@@ -900,5 +897,5 @@
   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
@@ -981,6 +978,6 @@
     m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
 #endif
-#if H_3D_SPIVMP
-      m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
+#if NH_3D_SPIVMP
+    m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
 #endif
 #if H_3D_ARP
@@ -1088,5 +1085,5 @@
   m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
 #endif
@@ -1243,5 +1240,5 @@
   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()            + uiAbsPartIdx;
 #endif
@@ -1301,5 +1298,5 @@
   memcpy( m_pDvInfo             + uiOffset, pcCU->getDvInfo(),            sizeof( *m_pDvInfo ) * uiNumPartition );
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
 #endif
@@ -1427,6 +1424,6 @@
   memcpy( pCtu->getVSPFlag()           + m_absZIdxInCtu, m_piVSPFlag,           sizeof( Char ) * m_uiNumPartition );
 #endif
-#if H_3D_SPIVMP
-  memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
+#if NH_3D_SPIVMP
+  memcpy( pCtu->getSPIVMPFlag()        + m_absZIdxInCtu, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
 #endif
 
@@ -2494,5 +2491,5 @@
 }
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
 {
@@ -3123,5 +3120,5 @@
   dirVSP = (predFlag[0] | (predFlag[1] << 1));
   m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , false
 #endif
@@ -3138,5 +3135,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
 {
@@ -3202,5 +3199,5 @@
   , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   , Bool* pbSPIVMPFlag
 #endif
@@ -3238,5 +3235,5 @@
         , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         , pbSPIVMPFlag
 #endif
@@ -3292,5 +3289,5 @@
  */
 Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -3298,5 +3295,5 @@
 )
 {
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   TComMv cZeroMv;
 #endif
@@ -3307,5 +3304,5 @@
   //////// GET DISPARITIES  ////////
   //////////////////////////////////
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
   m_cDefaultDisInfo = cDisInfo;
@@ -3335,4 +3332,7 @@
   Bool bIsDepth = getSlice()->getIsDepth();
 #endif 
+#if NH_3D_IV_MERGE
+  Bool bIsDepth = getSlice()->getIsDepth();
+#endif
 
 #if H_3D_IC
@@ -3384,5 +3384,5 @@
       )
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , false
 #endif
@@ -3398,5 +3398,5 @@
     , false
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , false
 #endif
@@ -3412,5 +3412,5 @@
     , false
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , false
 #endif
@@ -3426,5 +3426,5 @@
     , false
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , false
 #endif
@@ -3440,5 +3440,5 @@
     , false
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , false
 #endif
@@ -3621,4 +3621,7 @@
     }
   }
+#endif
+
+#if NH_3D_IV_MERGE
   /////////////////////////////////////////////////////////////////
   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
@@ -3638,5 +3641,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
   }  
 
@@ -3752,5 +3759,5 @@
   iCount += m_mergCands[MRG_B0].m_bAvailable;
 
-#if H_3D_IV_MERGE 
+#if NH_3D_IV_MERGE 
   /////////////////////////////////////////////
   //////// INTER VIEW DISP COMP (IvDC) ////////
@@ -3807,5 +3814,5 @@
   iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   ////////////////////////////////////////////////////
   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
@@ -5018,5 +5025,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Void TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
 {
@@ -5028,5 +5035,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);
@@ -5607,5 +5614,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)
 {
@@ -5624,17 +5631,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]];
@@ -5648,7 +5655,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;
@@ -5658,8 +5665,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
@@ -5680,7 +5687,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 );
@@ -5709,5 +5716,5 @@
   {
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     ////////////////////////////////
     //////////sub-PU IvMC///////////
@@ -5715,5 +5722,9 @@
     if(!m_pcSlice->getIsDepth())
     {
+#if H_3D_DBBP
       if (!getDBBPFlag(0))
+#else
+      if (1)
+#endif
       {
         Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
@@ -5747,9 +5758,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 ))
         {
@@ -5776,5 +5787,5 @@
                       TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
 #if NH_3D_NBDV 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                       if( !bIsDepth )
                       {
@@ -5784,5 +5795,5 @@
                         cMv.setIDVVer    (cDv.getVer());  
                         cMv.setIDVVId    (iViewIndex); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                       }
 #endif
@@ -5809,9 +5820,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 ))
               {
@@ -5881,5 +5892,5 @@
     ////////////////////////////////
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     if(m_pcSlice->getIsDepth())
     {
@@ -5887,6 +5898,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
@@ -5898,12 +5913,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 ))
       {
@@ -5933,5 +5948,5 @@
                     TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
 #if NH_3D_NBDV 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                     if( !bIsDepth )
                     {
@@ -5941,5 +5956,5 @@
                       cMv.setIDVVer    (cDv.getVer());  
                       cMv.setIDVVId    (iViewIndex); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
                     }
 #endif
@@ -5957,6 +5972,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 ++)
@@ -5991,5 +6010,5 @@
 #endif
             cMv.setHor( cMv.getHor() + ioffsetDV );
-#if H_3D_IV_MERGE 
+#if NH_3D_IV_MERGE 
             if( bIsDepth )
             {
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComDataCU.h	(revision 1259)
@@ -173,5 +173,5 @@
   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
@@ -236,5 +236,5 @@
   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
@@ -499,4 +499,8 @@
    ); 
    
+#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);
@@ -513,13 +517,13 @@
   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    
@@ -665,5 +669,5 @@
     , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , Bool* pbSPIVMPFlag
 #endif
@@ -671,5 +675,5 @@
     );
   Void          xGetInterMergeCandidates      ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -679,5 +683,5 @@
 
 #if NH_3D_VSP
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
   Bool          getSPIVMPFlag        ( UInt uiIdx )            { return m_pbSPIVMPFlag[uiIdx];   }
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 1259)
@@ -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-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1259)
@@ -50,5 +50,5 @@
 // ====================================================================================================================
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
 class TComDataCU;
 #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,5 +167,5 @@
   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
@@ -203,5 +203,5 @@
   Int                   m_iVspFlag;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   Bool                  m_bSPIVMPFlag;
 #endif
@@ -215,5 +215,5 @@
     m_iVspFlag = 0;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = false;
 #endif
@@ -234,5 +234,5 @@
     m_iVspFlag = 0;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = false;
 #endif
@@ -245,5 +245,5 @@
     , Int vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , Bool bSPIVMPFlag
 #endif
@@ -257,5 +257,5 @@
     m_iVspFlag = vspFlag;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     m_bSPIVMPFlag = bSPIVMPFlag;
 #endif
@@ -266,5 +266,5 @@
     , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , Bool* pbSPIVMPFlag
 #endif
@@ -277,5 +277,5 @@
     vspFlag[iCount] = m_iVspFlag;
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
 #endif
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.cpp	(revision 1259)
@@ -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 )
@@ -320,4 +322,6 @@
 }
 #endif
+
+#if H_3D
 Void TComPicYuv::setLumaTo( Pel pVal )
 {
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPicYuv.h	(revision 1259)
@@ -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-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1259)
@@ -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
   if( pcCU->getARPW( uiPartAddr ) != 0 )
   {
     return;
   }
+#endif
 
   // horizontal sub-PU merge
@@ -1209,22 +1211,22 @@
     {
 #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,16 +1260,16 @@
         {
 #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 ( 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
     }
@@ -1312,6 +1314,6 @@
     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,14 +1345,14 @@
       {
 #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
-       }
+        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
     }
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComPrediction.h	(revision 1259)
@@ -140,5 +140,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 );
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.cpp	(revision 1259)
@@ -278,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
@@ -3854,5 +3854,5 @@
 #endif  
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   setupLUT = setupLUT || ( getIvMvPredFlag() && getIsDepth() );
 #endif
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TComSlice.h	(revision 1259)
@@ -2709,5 +2709,8 @@
 #if H_3D                                                                                                                                             
   TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
-#endif                                                                                                                                               
+#endif                            
+#if NH_3D_IV_MERGE
+  TComPic*                    getTexturePic       ()                                 { return  m_ivPicsCurrPoc[0][ m_viewIndex ];                    }
+#endif
 #if H_3D_IC                                                                                                                                          
   Void                        setApplyIC( Bool b )                                   { m_bApplyIC = b;                                               }
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibCommon/TypeDef.h	(revision 1259)
@@ -73,4 +73,6 @@
 #define NH_3D_MLC                         1
 #define NH_3D_VSP                         1
+#define NH_3D_IV_MERGE                    1
+#define NH_3D_SPIVMP                      1
 #endif
 
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1259)
@@ -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
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1259)
@@ -163,5 +163,5 @@
 Void TDecCu::decompressCtu( TComDataCU* pCtu )
 {
-#if !H_3D_IV_MERGE
+#if !NH_3D_IV_MERGE
   xDecompressCU( pCtu, 0,  0 );
 #endif
@@ -327,5 +327,5 @@
       m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth));
       m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);     
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       if( pcCU->getSlice()->getIsDepth())
       {
@@ -345,5 +345,5 @@
         m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
       }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       }
 #endif
@@ -392,5 +392,5 @@
     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
@@ -424,11 +424,11 @@
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
 #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()]; 
+    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; 
+    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; 
 #endif
 
@@ -439,5 +439,5 @@
 #if NH_3D_MLC
     m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -448,5 +448,5 @@
       , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , bSPIVMPFlag
 #endif
@@ -501,5 +501,5 @@
       }
     }
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
     if (bSPIVMPFlag[uiMergeIndex])
@@ -526,5 +526,5 @@
 
     xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
     xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -551,5 +551,5 @@
 #endif
       xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
       xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -571,5 +571,5 @@
 #endif
   xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment );
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
   xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -594,5 +594,5 @@
 {
   TComPic* pcPic = pCtu->getPic();
-#if !H_3D_IV_MERGE
+#if !NH_3D_IV_MERGE
   TComSlice * pcSlice = pCtu->getSlice();
   const TComSPS &sps=*(pcSlice->getSPS());
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1259)
@@ -244,10 +244,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
@@ -489,5 +489,5 @@
           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
 #endif
@@ -497,5 +497,5 @@
 #if NH_3D_MLC
           pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
             , pcMvFieldSP, puhInterDirSP
 #endif
@@ -505,5 +505,5 @@
             , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
             , bSPIVMPFlag
 #endif
@@ -526,5 +526,5 @@
         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
 #endif
@@ -534,5 +534,5 @@
 #if NH_3D_MLC
         pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           , pcMvFieldSP, puhInterDirSP
 #endif
@@ -542,5 +542,5 @@
           , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
           , bSPIVMPFlag
 #endif
@@ -579,4 +579,27 @@
         }
       }
+#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
@@ -612,5 +635,5 @@
   }
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
   delete[] pcMvFieldSP;
   delete[] puhInterDirSP;
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1259)
@@ -292,5 +292,5 @@
 
 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 Void
 CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
@@ -1167,5 +1167,5 @@
 #if NH_3D
     pcSlice->checkInCompPredRefLayers(); 
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
 #if H_3D_FCO
     //assert( !getIsDepth() );
@@ -1264,5 +1264,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-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibDecoder/TDecTop.h	(revision 1259)
@@ -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-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1259)
@@ -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
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1259)
@@ -615,5 +615,5 @@
           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
           rpcTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth);
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
           if (rpcTempCU->getSlice()->getIsDepth() )
           {
@@ -633,5 +633,5 @@
               rpcTempCU->getDisMvpCandNBDV(&DvInfo);
             }
-#if H_3D_IV_MERGE
+#if NH_3D_IV_MERGE
           }
 #endif
@@ -1810,4 +1810,13 @@
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
 
+#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 !H_3D_ARP
@@ -1820,5 +1829,5 @@
 #if NH_3D_MLC
   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , pcMvFieldSP, puhInterDirSP
 #endif
@@ -1827,5 +1836,5 @@
 
   rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     , bSPIVMPFlag
 #endif
@@ -1856,11 +1865,4 @@
 #endif
 #endif
-
-
-
-
-
-
-
 
 #if NH_3D_MLC
@@ -1983,5 +1985,5 @@
           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])
@@ -2206,5 +2208,5 @@
   }
   DEBUG_STRING_APPEND(sDebug, bestStr)
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
  delete[] pcMvFieldSP;
  delete[] puhInterDirSP;
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1259)
@@ -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 ));
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1259)
@@ -3872,5 +3872,5 @@
                                  , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -3929,5 +3929,5 @@
       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3939,5 +3939,5 @@
         , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
         , pbSPIVMPFlag
 #endif
@@ -3956,5 +3956,5 @@
     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pcMvFieldSP, puhInterDirSP
 #endif
@@ -3966,5 +3966,5 @@
       , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
       , pbSPIVMPFlag
 #endif
@@ -4005,5 +4005,5 @@
 #endif
 
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
     pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx )); 
     if (pbSPIVMPFlag[uiMergeCand])
@@ -4172,5 +4172,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];
@@ -4599,11 +4599,11 @@
       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()]; 
+      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
@@ -4611,5 +4611,5 @@
                       , vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif 
@@ -4624,5 +4624,5 @@
         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)
@@ -4700,5 +4700,5 @@
       else
       {
-#if H_3D_SPIVMP        
+#if NH_3D_SPIVMP        
         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
 #endif
@@ -4713,5 +4713,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;
@@ -5879,6 +5879,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) )
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.h	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSearch.h	(revision 1259)
@@ -413,5 +413,5 @@
                                   , Int* vspFlag
 #endif
-#if H_3D_SPIVMP
+#if NH_3D_SPIVMP
                                   , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
Index: branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1257)
+++ branches/HTM-14.1-update-dev3-MediaTek-Qualcomm/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1259)
@@ -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()        );
