Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/CommonDef.h	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/CommonDef.h	(revision 1233)
@@ -363,5 +363,5 @@
 #endif
 
-#if H_3D_IV_MERGE
+#if NH_3D_MLC
 #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-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1233)
@@ -3193,5 +3193,12 @@
 
 #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
@@ -3204,5 +3211,5 @@
   )
 {
-  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
+  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))
   {
     return;
@@ -3220,14 +3227,22 @@
     extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
     extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
+#if H_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 H_3D_VSP
+        , vspFlag
+#endif
+#if H_3D_SPIVMP
+        , pbSPIVMPFlag
+#endif
+        );
       iCount++;
       if (iCount >= getSlice()->getMaxNumMergeCand())
@@ -3236,14 +3251,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++;
   }
@@ -3267,27 +3283,44 @@
 }
 
-/** 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 H_3D_SPIVMP
+      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+      , Int& numValidMergeCand, Int mrgCandIdx
+)
+{
+#if H_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);
+#endif
+  TComMvField tmpMV[2];
+  UChar tmpDir;
+
+  //////////////////////////////////
+  //////// GET DISPARITIES  ////////
+  //////////////////////////////////
+#if H_3D_IV_MERGE
+  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
+  m_cDefaultDisInfo = cDisInfo;
+#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;
@@ -3295,401 +3328,5 @@
 
   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 H_3D_TMVP
-      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 NH_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 );
@@ -3710,21 +3347,20 @@
 #endif
 
-#if H_3D
 #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;
@@ -3734,5 +3370,5 @@
   if (getAvailableFlagA1())
   {
-    m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+    m_mergCands[MRG_A1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
 #if H_3D_VSP
     , (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
@@ -3748,63 +3384,67 @@
       )
 #endif
+#if H_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above
-
   if (getAvailableFlagB1())
   {
-    m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+    m_mergCands[MRG_B1].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
 #if H_3D_VSP
     , false
 #endif
+#if H_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above right
-
   if (getAvailableFlagB0())
   {
-    m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+    m_mergCands[MRG_B0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
 #if H_3D_VSP
     ,
       false
 #endif
+#if H_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // left bottom
-
   if (getAvailableFlagA0())
   {
-    m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+    m_mergCands[MRG_A0].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
 #if H_3D_VSP
     , false
 #endif
+#if H_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
+    m_numSpatialCands++;
   }
 
   // above left
-
   if (getAvailableFlagB2())
   {
-    m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+    m_mergCands[MRG_B2].setCand( &pcMFieldNeighbours[m_numSpatialCands<<1], puhInterDirNeighbours[m_numSpatialCands]
 #if H_3D_VSP
     , false
 #endif
+#if H_3D_SPIVMP
       , false
+#endif
       ); 
-    m_baseListidc++;
-  }
-
-#endif
+    m_numSpatialCands++;
+  }
 
 
@@ -4076,17 +3716,160 @@
 #endif
 
+  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable;
+
+#if H_3D_VSP
+  /////////////////////////////////////////////////
+  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
+  /////////////////////////////////////////////////
+  if (iCount<getSlice()->getMaxNumMergeCand())
+  {
+    if (
+      (!getAvailableFlagA1() || !(pcCULeft->getVSPFlag(uiLeftPartIdx) != 0)) &&
+#if H_3D_IC
+      !bICFlag &&
+#endif
+#if H_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 H_3D_DBBP
+      !bDBBPFlag &&
+#endif
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
+    {
+      return;
+    }
+
+    // early termination
+    if (iCount == getSlice()->getMaxNumMergeCand())
+    {
+      return;
+    }
+#endif
+#if H_3D_VSP
+  }
+#endif
+
+  iCount += m_mergCands[MRG_B0].m_bAvailable;
+
+#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 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 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
+}
+#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
@@ -4098,5 +3881,4 @@
       pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4107,19 +3889,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
@@ -4131,5 +3917,4 @@
       pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4139,5 +3924,5 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
@@ -4148,9 +3933,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
@@ -4162,5 +3952,4 @@
       pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
     }
-
     if ( mrgCandIdx == iCount )
     {
@@ -4170,117 +3959,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 H_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 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 
-
-
-#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
@@ -4299,10 +3994,10 @@
   }
   // early termination
-  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  if (iCount == getSlice()->getMaxNumMergeCand())
   {
     return;
   }
 
-  // above left 
+  // above left
   if( iCount < 4 )
   {
@@ -4310,10 +4005,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
@@ -4333,84 +4033,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 )
@@ -4422,8 +4097,11 @@
     if ( getSlice()->isInterB() )
     {
-      bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
+#if H_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 )
@@ -4433,9 +4111,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 )
       {
@@ -4445,20 +4128,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))
       {
@@ -4484,9 +4175,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;
@@ -4503,4 +4196,5 @@
     }
     uiArrayAddr++;
+
     if ( refcnt == iNumRefIdx - 1 )
     {
@@ -4513,360 +4207,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() )
-    {
-      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.
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.h	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComDataCU.h	(revision 1233)
@@ -197,5 +197,5 @@
   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 +220,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
 
@@ -654,10 +652,10 @@
   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
@@ -670,12 +668,11 @@
     , 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 H_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
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TComMotionInfo.h	(revision 1233)
@@ -192,5 +192,6 @@
 //! \}
 
-#if H_3D_IV_MERGE
+#if NH_3D_MLC
+/// class for container of merge candidate
 class TComMotionCand
 {
@@ -202,5 +203,7 @@
   Int                   m_iVspFlag;
 #endif  
+#if H_3D_SPIVMP
   Bool                  m_bSPIVMPFlag;
+#endif
 
 public:
@@ -212,5 +215,7 @@
     m_iVspFlag = 0;
 #endif
+#if H_3D_SPIVMP
     m_bSPIVMPFlag = false;
+#endif
   }
 
@@ -229,5 +234,7 @@
     m_iVspFlag = 0;
 #endif
+#if H_3D_SPIVMP
     m_bSPIVMPFlag = false;
+#endif
     m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
     m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
@@ -238,5 +245,7 @@
     , Int vspFlag
 #endif
+#if H_3D_SPIVMP
     , Bool bSPIVMPFlag
+#endif
     )
   {
@@ -248,13 +257,16 @@
     m_iVspFlag = vspFlag;
 #endif
+#if H_3D_SPIVMP
     m_bSPIVMPFlag = bSPIVMPFlag;
-  }
-
-
+#endif
+  }
+  
   Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
 #if H_3D_VSP
     , Int* vspFlag
 #endif
+#if H_3D_SPIVMP
     , Bool* pbSPIVMPFlag
+#endif
     )
   {
@@ -265,5 +277,7 @@
     vspFlag[iCount] = m_iVspFlag;
 #endif
+#if H_3D_SPIVMP
     pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
+#endif
   }
 };
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TypeDef.h	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibCommon/TypeDef.h	(revision 1233)
@@ -71,4 +71,5 @@
 #define NH_3D_NBDV                        1
 #define NH_3D_NBDV_REF                    1
+#define NH_3D_MLC                         1
 #endif
 
@@ -712,5 +713,5 @@
   MD_ABOVE_LEFT         ///< MVP of above left block
 };
-#if H_3D
+#if NH_3D_MLC
 enum DefaultMergCandOrder
 {
@@ -725,5 +726,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-dev3-ETRI/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1233)
@@ -385,6 +385,11 @@
     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];
+#else
     TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
     UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
+#endif
 #endif
     Int numValidMergeCand = 0;
@@ -402,7 +407,9 @@
 #endif
 
+
 #if H_3D_VSP
     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+#endif
 #if H_3D_SPIVMP
     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
@@ -413,6 +420,10 @@
     puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
 #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
@@ -421,19 +432,17 @@
       , numValidMergeCand, uiMergeIndex );
 
-    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
+    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if H_3D_VSP
+      , vspFlag
+#endif
 #if H_3D_SPIVMP
       , bSPIVMPFlag
 #endif
       , numValidMergeCand );
+#endif
+#if H_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 );
 
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 1233)
@@ -236,5 +236,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];
@@ -483,5 +484,34 @@
         {
           pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); // temporarily set.
+
+#if NH_3D_MLC
+#if H_3D_VSP
+          Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
+          memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if H_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 H_3D_SPIVMP
+            , pcMvFieldSP, puhInterDirSP
+#endif
+            , numValidMergeCand );
+          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if H_3D_VSP
+            , vspFlag
+#endif
+#if H_3D_SPIVMP
+            , bSPIVMPFlag
+#endif
+            , numValidMergeCand );
+#if H_3D_VSP
+          pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
+#endif
+#endif
           pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); // restore.
           hasMergedCandList = true;
@@ -491,5 +521,34 @@
       {
         uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
+
+#if NH_3D_MLC
+#if H_3D_VSP
+        Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
+        memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if H_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 H_3D_SPIVMP
+          , pcMvFieldSP, puhInterDirSP
+#endif
+          ,numValidMergeCand, uiMergeIndex );
+        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if H_3D_VSP
+          , vspFlag
+#endif
+#if H_3D_SPIVMP
+          , bSPIVMPFlag
+#endif
+          ,numValidMergeCand );
+#if H_3D_VSP
+        pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
+#endif
+#endif
       }
 
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1233)
@@ -1762,5 +1762,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];
@@ -1797,4 +1797,5 @@
 
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to CTU level
+
 #if H_3D_VSP
 #if !H_3D_ARP
@@ -1802,26 +1803,55 @@
   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 H_3D_SPIVMP
+    , pcMvFieldSP, puhInterDirSP
+#endif
+    , numValidMergeCand 
+    );
+
+  rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
+#if H_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
@@ -1831,7 +1861,10 @@
 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
 #else
+#if NH_3D_MLC
+  for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
+#else
   for( UInt ui = 0; ui < numValidMergeCand; ++ui )
 #endif
-
+#endif
   {
     mergeCandBuffer[ui] = 0;
@@ -1887,5 +1920,8 @@
       );
 
-    rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
+    rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
+#if H_3D_VSP
+      , vspFlag
+#endif
 #if H_3D_SPIVMP
       , bSPIVMPFlag
Index: branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1232)
+++ branches/HTM-14.1-update-dev3-ETRI/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1233)
@@ -3925,7 +3925,7 @@
     {
       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
@@ -3942,5 +3942,5 @@
         , pbSPIVMPFlag
 #endif
-                                        , numValidMergeCand
+        , numValidMergeCand
         );
 #else
@@ -3952,7 +3952,7 @@
   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
@@ -3969,5 +3969,5 @@
       , pbSPIVMPFlag
 #endif
-                                      , numValidMergeCand
+      , numValidMergeCand
       );
 #else
