Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.cpp	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.cpp	(revision 322)
@@ -5164,37 +5164,23 @@
 
 #if MERL_VSP_C0152
-#if LGE_SIMP_DVP_REFINE_C0112
-Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec, Bool bSimpleDvpRefine)
-#else
-Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec)
-#endif
+Pel TComDataCU::getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iBlkWidth, Int iBlkHeight, Int* aiShiftLUT, Int iShiftPrec, Bool bSimpleDvpRefine)
 {
   Int depStride =  pcBaseViewDepthPicYuv->getStride();
 
-  Int width  = pcBaseViewDepthPicYuv->getWidth();
-  Int height = pcBaseViewDepthPicYuv->getHeight();
-#if MTK_DVPREFINE_BVSP_BUG_FIX
-  Int depthPosX = Clip3(0,   width - iWidth,  iBlkX + (mv->getHor()>>2));
-  Int depthPosY = Clip3(0,   height - iHeight,  iBlkY + (mv->getVer()>>2));
-#else
-  Int depthPosX = Clip3(0,   width - iWidth  - 1,  iBlkX + (mv->getHor()>>2));
-  Int depthPosY = Clip3(0,   height- iHeight - 1,  iBlkY + (mv->getVer()>>2));
-#endif
-  Pel *depth  = pcBaseViewDepthPicYuv->getLumaAddr() + depthPosX + depthPosY * depStride;
-  Pel  maxDepth = 0;
-#if LGE_SIMP_DVP_REFINE_C0112
+  Int iPictureWidth  = pcBaseViewDepthPicYuv->getWidth();
+  Int iPictureHeight = pcBaseViewDepthPicYuv->getHeight();
+
+  Int depthPosX = Clip3(0,   iPictureWidth - iBlkWidth,  iBlkX + (mv->getHor()>>2));
+  Int depthPosY = Clip3(0,   iPictureHeight- iBlkHeight,  iBlkY + (mv->getVer()>>2));
+
+  Pel *pDepthPel   = pcBaseViewDepthPicYuv->getLumaAddr() + depthPosX + depthPosY * depStride;
+  Pel  maxDepthVal = 0;
+
   if ( bSimpleDvpRefine )
   {
-#if MTK_DVPREFINE_BVSP_BUG_FIX
-    Int depthStartPosX = Clip3(0,   width - iWidth,  iBlkX + (mv->getHor()>>2));
-    Int depthStartPosY = Clip3(0,   height - iHeight,  iBlkY + (mv->getVer()>>2));
-    Int depthEndPosX = Clip3(0,   width - 1,  iBlkX + iWidth - 1  + (mv->getHor()>>2));
-    Int depthEndPosY = Clip3(0,   height - 1,  iBlkY + iHeight - 1 + (mv->getVer()>>2));
-#else
-    Int depthStartPosX = Clip3(0,   width - iWidth  - 1,  iBlkX + (mv->getHor()>>2));
-    Int depthStartPosY = Clip3(0,   height- iHeight - 1,  iBlkY + (mv->getVer()>>2));
-    Int depthEndPosX = Clip3(0,   width - iWidth  - 1,  iBlkX + iWidth  + (mv->getHor()>>2));
-    Int depthEndPosY = Clip3(0,   height- iHeight - 1,  iBlkY + iHeight + (mv->getVer()>>2));
-#endif
+    Int depthStartPosX = Clip3(0,   iPictureWidth - iBlkWidth,  iBlkX + (mv->getHor()>>2));
+    Int depthStartPosY = Clip3(0,   iPictureHeight- iBlkHeight,  iBlkY + (mv->getVer()>>2));
+    Int depthEndPosX   = Clip3(0,   iPictureWidth - 1,  iBlkX + iBlkWidth - 1 + (mv->getHor()>>2));
+    Int depthEndPosY   = Clip3(0,   iPictureHeight - 1,  iBlkY + iBlkHeight - 1 + (mv->getVer()>>2));
     Int iCenterX = (depthStartPosX + depthEndPosX) >> 1;
     Int iCenterY = (depthStartPosY + depthEndPosY) >> 1;
@@ -5209,40 +5195,26 @@
     for (Int i = 0; i < 5; i++)
     {
-      if (maxDepth < aiDepth[i])
-        maxDepth = aiDepth[i];
+      if (maxDepthVal < aiDepth[i])
+        maxDepthVal = aiDepth[i];
     }
   }
   else
   {
-    for (Int j = 0; j < iHeight; j++)
-    {
-      for (Int i = 0; i < iWidth; i++)
-      {
-        if (maxDepth < depth[i])
-          maxDepth = depth[i];
-      }
-      depth += depStride;
-    }
-  }
-#else
-  for (Int j = 0; j < iHeight; j++)
-  {
-    for (Int i = 0; i < iWidth; i++)
-    {
-      if (maxDepth < depth[i])
-        maxDepth = depth[i];
-    }
-    depth += depStride;
-  }
-#endif
-  Int disparity = aiShiftLUT[ maxDepth ] << iShiftPrec;
-
-  return disparity;
-}
-#if LGE_SIMP_DVP_REFINE_C0112
+    for (Int j = 0; j < iBlkHeight; j++)
+    {
+      for (Int i = 0; i < iBlkWidth; i++)
+      {
+        if (maxDepthVal < pDepthPel[i])
+          maxDepthVal = pDepthPel[i];
+  }
+      pDepthPel += depStride;
+    }
+  }
+
+  Int iDisp = aiShiftLUT[ maxDepthVal ] << iShiftPrec;
+
+  return iDisp;
+}
 Void TComDataCU::estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred, Bool bSimpleDvpRefine)
-#else
-Void TComDataCU::estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred)
-#endif
 {
   if (picDepth)
@@ -5257,11 +5229,9 @@
     Int* aiShiftLUT;
     Int  iShiftPrec;
+
     getSlice()->getBWVSPLUTParam(aiShiftLUT, iShiftPrec);
-#if LGE_SIMP_DVP_REFINE_C0112
-    Pel x = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT, iShiftPrec, bSimpleDvpRefine );
-#else
-    Pel x = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT, iShiftPrec);
-#endif
-    cMvPred->setHor(x);
+
+    Pel iDisp = getMcpFromDM( pcBaseViewDepthPicYuv, cMvPred, iBlkX, iBlkY, iWidth, iHeight, aiShiftLUT, iShiftPrec, bSimpleDvpRefine );
+    cMvPred->setHor( iDisp );
     clipMv(*cMvPred);
   }
@@ -5270,209 +5240,219 @@
 
 #if H3D_NBDV
-Void TComDataCU::getDisMvpCandNBDV( UInt uiPartIdx, UInt uiPartAddr,DisInfo* pDInfo , Bool bParMerge
+
+Bool TComDataCU::xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, UInt uiPartIdx, UInt uiPartAddr, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, McpDisInfo* paMvpDvInfo, UInt uiMvpDvPos )
+{
+  Bool bDepthRefine = true; 
+
+  if( pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
+  {
+    Bool bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
+    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
+    {
+      RefPicList eRefPicList = RefPicList(iList);
+      Int      refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
+      TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
+
+      if( refId >= 0)
+      {
+        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId );
+        if (refViewIdx != m_pcSlice->getViewId()) // DCP
+        {          
+          clipMv(cMvPred);
+
+          TComPic* picDepth = getSlice()->getRefPicBaseDepth();
+
+          if (picDepth && bDepthRefine)
+            estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
+
+          pNbDvInfo->m_acMvCand[ pNbDvInfo->iN   ] = cMvPred;
+          pNbDvInfo->m_aVIdxCan[ pNbDvInfo->iN++ ] = refViewIdx;
+
+          return true;
+        }
+        else if ( bSearchForMvpDv && cMvPred.m_bDvMcp && bTmpIsSkipped )
+  {
+          paMvpDvInfo->m_acMvCand[iList][ uiMvpDvPos ] = cMvPred;
+          paMvpDvInfo->m_aVIdxCan[iList][ uiMvpDvPos ] = refViewIdx;
+          paMvpDvInfo->m_bAvailab[iList][ uiMvpDvPos ] = true;
+          paMvpDvInfo->m_bFound                        = true; 
+        }
+      }
+#if MERL_VSP_C0152
+      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
+      { 
+        TComPic* picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
+        if (picDepth && bDepthRefine)
+          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
+        
+        cMvPred.setVer(0);
+
+        pNbDvInfo->m_acMvCand[ pNbDvInfo->iN]   = cMvPred;
+        pNbDvInfo->m_aVIdxCan[ pNbDvInfo->iN++] = 0; // refViewIdx;
+        return true;
+      }
+#endif
+    }
+  }
+  return false; 
+}
+
+
+Void TComDataCU::xDeriveRightBottomNbIdx( PartSize eCUMode, UInt uiPartIdx, Int &riLCUIdxRBNb, Int &riPartIdxRBNb )
+{
+  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();  
+    Int uiLCUIdx = getAddr();
+  
+  UInt uiPartIdxRB;
+    deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB );  
+    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+
+    if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
+    {
+    riLCUIdxRBNb  = -1;
+    riPartIdxRBNb = -1;
+    }
+    else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
+    {
+    riLCUIdxRBNb  = -1;
+    riPartIdxRBNb = -1;
+    }
+    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
+      {
+      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+      }
+      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+      {
+      riPartIdxRBNb = -1;
+      riLCUIdxRBNb  = -1;
+      }
+      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+      {
+      riPartIdxRBNb = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+      riLCUIdxRBNb = uiLCUIdx + 1;
+      }
+      else //is the right bottom corner of LCU                       
+      {
+      riPartIdxRBNb = -1;
+      riLCUIdxRBNb  = -1;
+      }
+    }
+      }
+
+
+Void TComDataCU::getDisMvpCandNBDV( UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDInfo , Bool bParMerge
 #if MERL_VSP_C0152
                                 , Bool bDepthRefine
 #endif
                                 )
-{
-  PartSize eCUMode = getPartitionSize( uiPartAddr );
-  TComDataCU* pcTmpCU = NULL;
-  pDInfo->iN = 0;
-
-  RefPicList eRefPicList = REF_PIC_LIST_0 ;
-  //-- Get Spatial MV
-  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
-  UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
-
-  const Int iNumofDvMCP = 7;
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-  Int   aiDvMcpDvCandX[2][iNumofDvMCP] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal
-  Int   aiDvMcpDvCandY[2][iNumofDvMCP] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal
-#else
-  Int   aiDvMcpDvCand[2][iNumofDvMCP] = {{0,},    {0,}}; // dummy, 5 spatial + 1 temporal
-#endif
-  Bool  abDvMcpFlag  [2][iNumofDvMCP] = {{false,},{false,}}; 
-  TComMv cTmpMvPred, cMv;
-  Bool  bTmpIsSkipped = false;
-  Bool  bDvMcpIsFound = false;
-  Int   iLCUAddrDiff = 0;
-
+            {
+  //// ******* Init variables ******* /////
+  // Init disparity struct for results
+  pDInfo->iN = 0;  
+
+  // Init struct for disparities from MCP neighboring blocks
+  McpDisInfo cMvpDvInfo;
+  cMvpDvInfo.m_bFound = false; 
+  for (UInt iCurDvMcpCand = 0; iCurDvMcpCand < MCP_DIS_CANS; iCurDvMcpCand++)
+  {
+    for (UInt iList = 0; iList < 2; iList++)
+    {
+      cMvpDvInfo.m_acMvCand[iList][iCurDvMcpCand].setZero();
+      cMvpDvInfo.m_aVIdxCan[iList][iCurDvMcpCand] = 0; 
+      cMvpDvInfo.m_bAvailab[iList][iCurDvMcpCand] = false; 
+          }
+        }
+  
+  // Get Positions  
+  PartSize eCUMode    = getPartitionSize( uiPartAddr );    
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;  
+
+  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral  ( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
+
+  // Get parameters for parallel merge
   Int xP, yP, nPSW, nPSH;
   if( bParMerge)
     this->getPartPosition(uiPartIdx, xP, yP, nPSW, nPSH);
 
-  deriveLeftRightTopIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLT, uiPartIdxRT );
-  deriveLeftBottomIdxGeneral( eCUMode, uiPartAddr, uiPartIdx, uiPartIdxLB );
-
-#if MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
-  // copied from getInterMergeCand()
+  //// ******* Get disparity from temporal neighboring blocks ******* /////
   if ( getSlice()->getPPS()->getEnableTMVPFlag() )
-  {
+        {
     TComMv cColMv;
     Int iTargetViewIdx = 0;
-    Int iTStartViewIdx = 0;
-    UInt uiPartIdxRB, uiBRIdx;
-#if !MTK_SIMPLIFY_DVTC_C0135
-    Int uiViewIdxCurr= getSlice()->getViewId();
-#endif
+    Int iTStartViewIdx = 0;    
+   
+    ///*** Derive center position ***
     UInt uiPartIdxCenter;
+    Int  uiLCUIdx   = getAddr();
+
     xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter );
 
-    Int uiLCUIdx = getAddr();
-    Int uiLCUnew = uiLCUIdx;
-    eCUMode = getPartitionSize( 0 );
-    deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB );  
-    uiBRIdx = uiPartIdxLT;
-    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
-#if MTK_SIMPLIFY_DVTC_C0135
-    if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
-    {
-      uiLCUnew = -1;
-    }
-    else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
-    {
-      uiLCUnew = -1;
-    }
-    else
-#else
-    if ( (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) &&(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ))  // image boundary check
-#endif
-    {
-      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
-      {
-        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
-      }
-      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
-      {
-        uiBRIdx = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
-#if MTK_SIMPLIFY_DVTC_C0135
-        uiLCUnew = -1;
-#else
-        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU();
-#endif
-      }
-      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
-      {
-        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
-        uiLCUnew = uiLCUIdx + 1;
-      }
-      else //is the right bottom corner of LCU                       
-      {
-        uiBRIdx = 0;
-#if MTK_SIMPLIFY_DVTC_C0135
-        uiLCUnew = -1;
-#else
-        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU() + 1;
-#endif
-      }
-    }
-    const Int iNumofCandPic = 2;
-    for(Int i =0; i < iNumofCandPic; i++)
-    {
-      Int lpRef=0;
-      if(i == 0)
-      {   //check the col-located picture
-        eRefPicList = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
-#if COLLOCATED_REF_IDX
-        lpRef = getSlice()->getColRefIdx();
-#else
-        Int lpRef = 0;
-#endif
-      }
-      else
-      {
-        if(!(getPic()->getRapbCheck()))
+    ///*** Derive bottom right neighbour position ***
+    eCUMode          = getPartitionSize( 0 ); // Necessary?    
+    Int iLCUIdxRBNb  = -1;    
+    Int iPartIdxRBNb = -1;
+
+    xDeriveRightBottomNbIdx( eCUMode, uiPartIdx, iLCUIdxRBNb, iPartIdxRBNb );
+
+    ///*** Search temporal candidate pictures for disparity vector ***
+    const Int iNumCandPics = 2;
+    for(Int curCandPic = 0; curCandPic < iNumCandPics; curCandPic++)
+            {
+      // Get candidate picture
+      RefPicList eCurRefPicList   = REF_PIC_LIST_0 ;
+      Int        curCandPicRefIdx = 0;
+      
+      if( curCandPic == 0 ) // check the co-located picture
+      { 
+        eCurRefPicList   = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
+        curCandPicRefIdx = getSlice()->getColRefIdx();
+            }
+      else                  // check RAP
+      {
+        if( !(getPic()->getRapbCheck()) )
           break;
-        eRefPicList=getPic()->getRapRefList();
-        lpRef=getPic()->getRapRefIdx();
-      }
-
-      if( m_pcSlice->getViewId() == getSlice()->getRefPic( eRefPicList, lpRef)->getViewId() ) 
-      {
-#if !MTK_SIMPLIFY_DVTC_C0135
-        if (uiViewIdxCurr > 1)  
+
+        eCurRefPicList   = getPic()->getRapRefList();
+        curCandPicRefIdx = getPic()->getRapRefIdx();
+        }
+      
+       // Check BR and Center       
+      if( m_pcSlice->getViewId() == getSlice()->getRefPic( eCurRefPicList, curCandPicRefIdx)->getViewId() ) 
         {
-#endif
-          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
+        for(Int curPosition = 0; curPosition < 2; curPosition++) 
           {
+          Bool bCheck = false; 
+          if ( curPosition == 0 && iLCUIdxRBNb >= 0 )
+            bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, iLCUIdxRBNb, iPartIdxRBNb,  cColMv, iTargetViewIdx, iTStartViewIdx);
+
+          if (curPosition == 1 )
+            bCheck = xGetColDisMV( eCurRefPicList, curCandPicRefIdx, uiLCUIdx,   uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx );
+
+          if( bCheck )
+            {
             clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
+            TComPic* picDepth = getSlice()->getRefPicBaseDepth();
               if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
                 estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
 
               pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
               pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
             return ;
           }
-#if !MTK_SIMPLIFY_DVTC_C0135
+        } // Loop positions
         }
-#endif
-        if(xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx ))
-        {
-          clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
-              if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
-              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
-          return ;
-        }
-#if !MTK_SIMPLIFY_DVTC_C0135
-        if(uiViewIdxCurr == 1)  
-        {
-          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) ) 
-          {
-            clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
-              if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
-              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
-            return ;
-          }
-        }
-#endif
-      }
-    }
+    } // Loop candidate views
   } // if TMVP Flag
-#endif
+
   UInt uiIdx = 0;
+  Bool        bCheckMcpDv = false;   
+  TComDataCU* pcTmpCU     = NULL;
+  
+
+  //// ******* Get disparity from left block ******* /////
   pcTmpCU = getPULeft(uiIdx, uiPartIdxLB, true, false);
   if ( uiPartIdx == 1 && (eCUMode == SIZE_Nx2N || eCUMode == SIZE_nLx2N || eCUMode == SIZE_nRx2N) )
@@ -5489,80 +5469,56 @@
   }
 
-  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-  {
-    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
-    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-    {
-      eRefPicList = RefPicList(iList);
-      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
-      if( refId >= 0)
-      {
-        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
-        if (refViewIdx != m_pcSlice->getViewId()) // DCP
-        {
-          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          clipMv(cMvPred);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-          }
-#endif
+  bCheckMcpDv = true; 
+  if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, uiPartIdx, uiPartAddr, pDInfo, bCheckMcpDv, &cMvpDvInfo, DVFROM_LEFT ) )
+          return;
+
+
+  //// ******* Get disparity from above block ******* /////
+  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
+  if ( uiPartIdx == 1 && (eCUMode == SIZE_2NxN || eCUMode == SIZE_2NxnU || eCUMode == SIZE_2NxnD) )
+  {
+    pcTmpCU = NULL;
+  }
+
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP+nPSW-1, yP-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+
+  if(pcTmpCU != NULL )
+      {
+    bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
+    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, uiPartIdx, uiPartAddr, pDInfo, bCheckMcpDv, &cMvpDvInfo, DVFROM_ABOVE ) )
+        return;
+      }
+
+//// ******* Get disparity from above right block ******* /////
+  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
+
+  if (pcTmpCU && bParMerge) 
+  {
+    if (!pcTmpCU->isDiffMER(xP+nPSW, yP-1, xP, yP))
+    {
+      pcTmpCU = NULL;
+    }
+  }
+
+  if(pcTmpCU != NULL )
+    {
+    bCheckMcpDv = ( ( getAddr() - pcTmpCU->getAddr() ) == 0);
+    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, uiPartIdx, uiPartAddr, pDInfo, bCheckMcpDv, &cMvpDvInfo, DVFROM_ABOVERIGHT ) )
           return;
         }
-        else // MCP 
-        {
-          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
-          {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-            aiDvMcpDvCandX[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispX;
-            aiDvMcpDvCandY[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispY;
-#else
-            aiDvMcpDvCand[iList][DVFROM_LEFT] = cTmpMvPred.m_iDvMcpDispX;
-#endif
-            abDvMcpFlag  [iList][DVFROM_LEFT] = true; 
-            bDvMcpIsFound = true;
-          }
-        }
-      }
-#if MERL_VSP_C0152
-      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
-      {
-        TComPic* picDepth = NULL;
-        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
-        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
-        if (picDepth && bDepthRefine)
-          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
-        myMv.setVer(0);
-
-        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
-        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
-        return;
-      }
-#endif
-    }
-  }
-
-  pcTmpCU = getPUAbove(uiIdx, uiPartIdxRT, true, false, true);
-  if ( uiPartIdx == 1 && (eCUMode == SIZE_2NxN || eCUMode == SIZE_2NxnU || eCUMode == SIZE_2NxnD) )
-  {
-    pcTmpCU = NULL;
-  }
-
-  if (pcTmpCU && bParMerge) 
-  {
-    if (!pcTmpCU->isDiffMER(xP+nPSW-1, yP-1, xP, yP))
+
+
+//// ******* Get disparity from below left block ******* /////
+  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
+
+  if (pcTmpCU && bParMerge)
+  {
+    if (!pcTmpCU->isDiffMER(xP-1, yP+nPSH, xP, yP))
     {
       pcTmpCU = NULL;
@@ -5570,77 +5526,20 @@
   }
 
-  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-  {
-    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
-    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
-    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-    {
-      eRefPicList = RefPicList(iList);
-      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
-      if( refId >= 0)
-      {
-        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
-        if (refViewIdx!= m_pcSlice->getViewId())
-        {
-          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          clipMv(cMvPred);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-          }
-#endif
+  if( pcTmpCU != NULL )
+      {
+    bCheckMcpDv = true; 
+    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, uiPartIdx, uiPartAddr, pDInfo, bCheckMcpDv, &cMvpDvInfo, DVFROM_LEFTBELOW ) )
           return;
         }
-        else if(iLCUAddrDiff == 0) //MCP, within same LCU
-        {
-          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          if( cTmpMvPred.m_bDvMcp  && bTmpIsSkipped )
-          {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-            aiDvMcpDvCandX[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispX;
-            aiDvMcpDvCandY[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispY;
-#else
-            aiDvMcpDvCand[iList][DVFROM_ABOVE] = cTmpMvPred.m_iDvMcpDispX;
-#endif
-            abDvMcpFlag  [iList][DVFROM_ABOVE] = true; 
-            bDvMcpIsFound = true;
-          }
-        }
-      }
-#if MERL_VSP_C0152
-      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
-      {
-        TComPic* picDepth = NULL;
-        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
-        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
-        if (picDepth && bDepthRefine)
-          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
-        myMv.setVer(0);
-
-        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
-        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
-        return;
-      }
-#endif
-    }
-  }
-
-  pcTmpCU = getPUAboveRight(uiIdx, uiPartIdxRT, true, false, true);
+
+
+//// ******* Get disparity from above left block ******* /////
+  
+  pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
+  assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
 
   if (pcTmpCU && bParMerge) 
   {
-    if (!pcTmpCU->isDiffMER(xP+nPSW, yP-1, xP, yP))
+    if (!pcTmpCU->isDiffMER(xP-1, yP-1, xP, yP))
     {
       pcTmpCU = NULL;
@@ -5648,433 +5547,31 @@
   }
 
-  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ) )
-  {
-    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
-    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
-    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-    {
-      eRefPicList = RefPicList(iList);
-      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
-      if( refId >= 0)
-      {
-        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
-        if (refViewIdx!= m_pcSlice->getViewId())
-        {
-          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          clipMv(cMvPred);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-          }
-#endif
+  if( pcTmpCU != NULL )
+  {
+    bCheckMcpDv = (( getAddr() - pcTmpCU->getAddr() ) <= 1); 
+    if ( xCheckSpatialNBDV( pcTmpCU, uiIdx, uiPartIdx, uiPartAddr, pDInfo, bCheckMcpDv, &cMvpDvInfo, DVFROM_ABOVELEFT ) )
           return;
         }
-        else if(iLCUAddrDiff == 0)
+
+  //// ******* Search MCP blocks ******* /////
+  if( cMvpDvInfo.m_bFound ) 
+      {
+    for( Int curPos = 1 ; curPos < MCP_DIS_CANS - 1 ; curPos++ ) 
         {
-          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
+      for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
           {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-            aiDvMcpDvCandX[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispX;
-            aiDvMcpDvCandY[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispY;
-#else
-            aiDvMcpDvCand[iList][DVFROM_ABOVERIGHT] = cTmpMvPred.m_iDvMcpDispX;
-#endif
-            abDvMcpFlag  [iList][DVFROM_ABOVERIGHT] = true; 
-            bDvMcpIsFound = true;
-          }
-        }
-      }
-#if MERL_VSP_C0152
-      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
-      {
-        TComPic* picDepth = NULL;
-        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
-        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
-        if (picDepth && bDepthRefine)
-          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
-        myMv.setVer(0);
-
-        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
-        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
-        return;
-      }
-#endif
-    }
-  }
-
-  pcTmpCU = getPUBelowLeft(uiIdx, uiPartIdxLB, true, false);
-
-  if (pcTmpCU && bParMerge)
-  {
-    if (!pcTmpCU->isDiffMER(xP-1, yP+nPSH, xP, yP))
-    {
-      pcTmpCU = NULL;
-    }
-  }
-
-  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-  {
-    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
-    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-    {
-      eRefPicList = RefPicList(iList);
-      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
-      if( refId >= 0)
-      {
-        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
-        if (refViewIdx!= m_pcSlice->getViewId())
-        {
-          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          clipMv(cMvPred);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-          }
-#endif
+        if( cMvpDvInfo.m_bAvailab[iList][curPos] )
+            {
+          TComMv cDispVec = cMvpDvInfo.m_acMvCand[iList][ curPos ];
+          clipMv( cDispVec );
+
+          TComPic* picDepth = getSlice()->getRefPicBaseDepth();
+              if (picDepth && bDepthRefine)
+            estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cDispVec, true);
+
+          pDInfo->m_acMvCand[ pDInfo->iN]   = cDispVec;
+            pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
           return;
         }
-        else // MCP 
-        {
-          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
-          {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-            aiDvMcpDvCandX[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispX;
-            aiDvMcpDvCandY[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispY;
-#else
-            aiDvMcpDvCand[iList][DVFROM_LEFTBELOW] = cTmpMvPred.m_iDvMcpDispX;
-#endif
-            abDvMcpFlag  [iList][DVFROM_LEFTBELOW] = true; 
-            bDvMcpIsFound = true;
-          }
-        }
-      }
-#if MERL_VSP_C0152
-      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
-      {
-        TComPic* picDepth = NULL;
-        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
-        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
-        if (picDepth && bDepthRefine)
-          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
-        myMv.setVer(0);
-
-        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
-        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
-        return;
-      }
-#endif
-    }
-  }
-
-  // Above predictor search
-  pcTmpCU = getPUAboveLeft(uiIdx, (m_uiAbsIdxInLCU + uiPartAddr), true, false, true);
-  assert(uiPartIdxLT == (m_uiAbsIdxInLCU + uiPartAddr));
-
-  if (pcTmpCU && bParMerge) 
-  {
-    if (!pcTmpCU->isDiffMER(xP-1, yP-1, xP, yP))
-    {
-      pcTmpCU = NULL;
-    }
-  }
-
-  if(pcTmpCU != NULL && !pcTmpCU->isIntra( uiIdx ))
-  {
-    iLCUAddrDiff = getAddr() - pcTmpCU->getAddr();
-
-    bTmpIsSkipped = pcTmpCU->isSkipped( uiIdx );
-    for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-    {
-      eRefPicList = RefPicList(iList);
-      Int refId = pcTmpCU->getCUMvField(eRefPicList)->getRefIdx(uiIdx) ;
-      if( refId >= 0)
-      {
-        Int refViewIdx  = pcTmpCU->getSlice()->getRefViewId( eRefPicList, refId);
-        if (refViewIdx!= m_pcSlice->getViewId())
-        {
-          TComMv cMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          clipMv(cMvPred);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred; 
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cMvPred);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = cMvPred;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = refViewIdx;
-          }
-#endif
-          return;
-        }
-        else if(iLCUAddrDiff <= 1)
-        {
-          cTmpMvPred = pcTmpCU->getCUMvField(eRefPicList)->getMv(uiIdx);
-          if( cTmpMvPred.m_bDvMcp && bTmpIsSkipped )
-          {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-            aiDvMcpDvCandX[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispX;
-            aiDvMcpDvCandY[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispY;
-#else
-            aiDvMcpDvCand[iList][DVFROM_ABOVELEFT] = cTmpMvPred.m_iDvMcpDispX;
-#endif
-            abDvMcpFlag  [iList][DVFROM_ABOVELEFT] = true; 
-            bDvMcpIsFound = true;
-          }
-        }
-      }
-#if MERL_VSP_C0152
-      else if (pcTmpCU->getVSPIndex(uiIdx) != 0) // is VSP
-      {
-        TComPic* picDepth = NULL;
-        TComMv myMv = pcTmpCU->getCUMvField( eRefPicList )->getMv( uiIdx );
-        picDepth = pcTmpCU->getSlice()->getRefPicBaseDepth();
-        if (picDepth && bDepthRefine)
-          estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &myMv);
-        myMv.setVer(0);
-
-        pDInfo->m_acMvCand[ pDInfo->iN] = myMv;
-        pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0; // refViewIdx;
-        return;
-      }
-#endif
-    }
-  }
-#if !MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
-  // copied from getInterMergeCand()
-  if ( getSlice()->getPPS()->getEnableTMVPFlag() )
-  {
-    TComMv cColMv;
-    Int iTargetViewIdx = 0;
-    Int iTStartViewIdx = 0;
-    UInt uiPartIdxRB, uiBRIdx;
-#if !MTK_SIMPLIFY_DVTC_C0135
-    Int uiViewIdxCurr= getSlice()->getViewId();
-#endif
-    UInt uiPartIdxCenter;
-    xDeriveCenterIdx( eCUMode, uiPartIdx, uiPartIdxCenter );
-
-    Int uiLCUIdx = getAddr();
-    Int uiLCUnew = uiLCUIdx;
-    eCUMode = getPartitionSize( 0 );
-    deriveRightBottomIdx( eCUMode, uiPartIdx, uiPartIdxRB );  
-    uiBRIdx = uiPartIdxLT;
-    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
-#if MTK_SIMPLIFY_DVTC_C0135
-    if (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() )>= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )
-    {
-      uiLCUnew = -1;
-    }
-    else if(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() )>= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
-    {
-      uiLCUnew = -1;
-    }
-    else
-#else
-    if ( (( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) < m_pcSlice->getSPS()->getPicWidthInLumaSamples() ) &&(( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) < m_pcSlice->getSPS()->getPicHeightInLumaSamples() ))  // image boundary check
-#endif
-    {
-      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
-      {
-        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
-      }
-      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
-      {
-        uiBRIdx = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
-#if MTK_SIMPLIFY_DVTC_C0135
-        uiLCUnew = -1;
-#else
-        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU();
-#endif
-      }
-      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
-      {
-        uiBRIdx = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
-        uiLCUnew = uiLCUIdx + 1;
-      }
-      else //is the right bottom corner of LCU                       
-      {
-        uiBRIdx = 0;
-#if MTK_SIMPLIFY_DVTC_C0135
-        uiLCUnew = -1;
-#else
-        uiLCUnew = uiLCUIdx + m_pcPic->getFrameWidthInCU() + 1;
-#endif
-      }
-    }
-    const Int iNumofCandPic = 2;
-    for(Int i =0; i < iNumofCandPic; i++)
-    {
-      Int lpRef=0;
-      if(i == 0)
-      {   //check the col-located picture
-        eRefPicList = RefPicList(getSlice()->isInterB() ? getSlice()->getColDir() : 0);
-#if COLLOCATED_REF_IDX
-        lpRef = getSlice()->getColRefIdx();
-#else
-        Int lpRef = 0;
-#endif
-      }
-      else
-      {
-        if(!(getPic()->getRapbCheck()))
-          break;
-        eRefPicList=getPic()->getRapRefList();
-        lpRef=getPic()->getRapRefIdx();
-      }
-
-      if( m_pcSlice->getViewId() == getSlice()->getRefPic( eRefPicList, lpRef)->getViewId() ) 
-      {
-#if !MTK_SIMPLIFY_DVTC_C0135
-        if (uiViewIdxCurr > 1)  
-        {
-#endif
-          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) )
-          {
-            clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
-              if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
-
-              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
-            return ;
-          }
-#if !MTK_SIMPLIFY_DVTC_C0135
-        }
-#endif
-        if(xGetColDisMV( eRefPicList, lpRef, uiLCUIdx, uiPartIdxCenter,  cColMv, iTargetViewIdx, iTStartViewIdx ))
-        {
-          clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
-              if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
-              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
-          return ;
-        }
-#if !MTK_SIMPLIFY_DVTC_C0135
-        if(uiViewIdxCurr == 1)  
-        {
-          if( (uiLCUnew >= 0 && xGetColDisMV( eRefPicList, lpRef, uiLCUnew, uiBRIdx, cColMv, iTargetViewIdx, iTStartViewIdx)) ) 
-          {
-            clipMv(cColMv);
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-            pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-#else
-            {
-              TComPic* picDepth = NULL;
-              picDepth = getSlice()->getRefPicBaseDepth();
-              if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv, true);
-#else
-                estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &cColMv);
-#endif
-              pDInfo->m_acMvCand[ pDInfo->iN] = cColMv;
-              pDInfo->m_aVIdxCan[ pDInfo->iN++] = iTargetViewIdx;
-            }
-#endif
-            return ;
-          }
-        }
-#endif
-      }
-    }
-  } // if TMVP Flag
-#endif
-
-  if( bDvMcpIsFound ) // skip dvmcp
-  {
-    for( Int i=1 ; i<iNumofDvMCP-1 ; i++ ) // 5 spatial
-    {
-      for(Int iList = 0; iList < (getSlice()->isInterB() ? 2: 1); iList ++)
-      {
-        if( abDvMcpFlag[iList][i]==true )
-        {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-          TComMv dv( aiDvMcpDvCandX[iList][ i ], aiDvMcpDvCandY[iList][ i ] );
-#else
-          TComMv dv( aiDvMcpDvCand[iList][ i ], 0 );
-#endif
-          clipMv( dv );
-#if !MERL_MTK_VSP_DVP_REFINE_C0152_C0131
-          pDInfo->m_acMvCand[ pDInfo->iN] = dv;
-          pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
-#else
-          {
-            TComPic* picDepth = NULL;
-            picDepth = getSlice()->getRefPicBaseDepth();
-            if (picDepth && bDepthRefine)
-#if LGE_SIMP_DVP_REFINE_C0112
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &dv, true);
-#else
-              estimateDVFromDM(uiPartIdx, picDepth, uiPartAddr, &dv);
-#endif
-            pDInfo->m_acMvCand[ pDInfo->iN] = dv;
-            pDInfo->m_aVIdxCan[ pDInfo->iN++] = 0;
-          }
-#endif
-          return;
-        }
-
       }
     }
@@ -6771,5 +6268,4 @@
   iColViewIdx = pColCU->getSlice()->getViewId();
 #if MERL_VSP_C0152
-  //TComDataCU *pColCU = pColPic->getCU( uiCUAddr );
   if( pColCU->getCUMvField(eColRefPicList)->getRefIdx(uiAbsPartAddr) < 0)
   {
@@ -6786,12 +6282,5 @@
     if(pColCU->getSlice()->isInterB())
     {
-#if !QC_NBDV_LDB_FIX_C0055
-      if(ilist == 0 )
-        eColRefPicList = getSlice()->getCheckLDC() ? eRefPicList : RefPicList(1-getSlice()->getColDir());
-      else
-        eColRefPicList = getSlice()->getCheckLDC() ? (eRefPicList== REF_PIC_LIST_0? REF_PIC_LIST_1:REF_PIC_LIST_0 ): RefPicList(getSlice()->getColDir());
-#else
         eColRefPicList = RefPicList(ilist);
-#endif
     }
 
@@ -8008,9 +7497,5 @@
   else
   {
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
     Bool bAvailable = pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, cDisInfo.m_acMvCand[0], bRecon );       
-#else
-    Bool bAvailable = pcResidualGenerator->getResidualSamples( this, uiPartIdx, pcYuv, cDisInfo.m_acMvCand[0].getHor(), bRecon ); 
-#endif
     m_pePartSize[0] = m_peSaved;
     return bAvailable;
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.h	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDataCU.h	(revision 322)
@@ -287,4 +287,6 @@
   );
 #if H3D_NBDV
+  Void          xDeriveRightBottomNbIdx( PartSize eCUMode, UInt uiPartIdx, Int &uiLCUIdxRBNb, Int &uiPartIdxRBNb );
+  Bool          xCheckSpatialNBDV( TComDataCU* pcTmpCU, UInt uiIdx, UInt uiPartIdx, UInt uiPartAddr, DisInfo* pNbDvInfo, Bool bSearchForMvpDv, McpDisInfo* paMvpDvInfo, UInt uiMvpDvPos );
   Bool          xGetColDisMV( RefPicList eRefPicList, Int refidx, Int uiCUAddr, Int uiPartUnitIdx, TComMv& rcMv, Int & iTargetViewIdx, Int & iStartViewIdx );
 #endif 
@@ -550,11 +552,6 @@
 
 #if MERL_VSP_C0152
-#if LGE_SIMP_DVP_REFINE_C0112
   Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec, Bool bSimpleDvpRefine = false);
   Void          estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred, Bool bSimpleDvpRefine = false);
-#else
-  Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT, Int iShiftPrec);
-  Void          estimateDVFromDM(UInt uiPartIdx, TComPic* picDepth, UInt uiPartAddr, TComMv* cMvPred);
-#endif
 #endif
   Bool          getIViewOrgDepthMvPred( UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, TComMv& rcMv );
@@ -601,6 +598,4 @@
   Void          fillMvpCandBase       ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
   Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo , Int iMVPIdx=-1);
-#else
-  Void          fillMvpCand           ( UInt uiPartIdx, UInt uiPartAddr, RefPicList eRefPicList, Int iRefIdx, AMVPInfo* pInfo );
 #endif
   Bool          isDiffMER             ( Int xN, Int yN, Int xP, Int yP);
@@ -831,4 +826,6 @@
   Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
+ 
+
 #endif
 };
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDepthMapGenerator.cpp
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComDepthMapGenerator.cpp	(revision 322)
@@ -894,7 +894,5 @@
               cMv.m_bDvMcp = true;
               cMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor();
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
               cMv.m_iDvMcpDispY = pDInfo->m_acMvCand[0].getVer();
-#endif
 #endif //H3D_NBDV
               pcCU->clipMv( cMv );
@@ -1012,7 +1010,5 @@
           rcMv.m_bDvMcp = true;
           rcMv.m_iDvMcpDispX = pDInfo->m_acMvCand[0].getHor(); 
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
           rcMv.m_iDvMcpDispY = pDInfo->m_acMvCand[0].getVer();
-#endif
         }
         else { // AMVP ?
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMotionInfo.h	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMotionInfo.h	(revision 322)
@@ -66,4 +66,13 @@
   Int    iN;                                ///< number of motion vector predictor candidates
 } DisInfo;
+
+typedef struct _McpDisCand
+{
+  TComMv m_acMvCand[2][ MCP_DIS_CANS ];            ///< array of motion vector predictor candidates
+  Int    m_aVIdxCan[2][ MCP_DIS_CANS ];            ///< array of motion vector predictor candidates
+  Bool   m_bAvailab[2][ MCP_DIS_CANS ];
+  Bool   m_bFound;                                 ///< number of motion vector predictor candidates
+} McpDisInfo;
+
 #endif 
 // Class definition
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMv.h
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMv.h	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComMv.h	(revision 322)
@@ -60,7 +60,5 @@
   Bool  m_bDvMcp;       // is dv-mcp ?
   Int   m_iDvMcpDispX;  // disparity for dv-mcp
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Int   m_iDvMcpDispY;  // disparity for dv-mcp
-#endif
 #endif
 
@@ -75,7 +73,5 @@
   , m_bDvMcp(false)
   , m_iDvMcpDispX(0)
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   , m_iDvMcpDispY(0)
-#endif
 #endif
   {
@@ -88,7 +84,5 @@
   , m_bDvMcp(false)
   , m_iDvMcpDispX(0)
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   , m_iDvMcpDispY(0)
-#endif
 #endif
   {
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.cpp
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.cpp	(revision 322)
@@ -227,11 +227,6 @@
 
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
 Bool
 TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, TComMv iDisp, Bool bRecon  ) 
-#else
-Bool
-TComResidualGenerator::getResidualSamples( TComDataCU* pcCU, UInt uiPUIdx, TComYuv* pcYuv, Int iDisp, Bool bRecon  ) 
-#endif
 #else
 Bool
@@ -248,9 +243,5 @@
   pcCU->getPic()->getPicYuvRec()->getTopLeftSamplePos( pcCU->getAddr(), pcCU->getZorderIdxInCU() + uiPartAddr, iXPos, iYPos );
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
-  return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp, bRecon);   
-#else
   return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, iDisp, bRecon); 
-#endif
 #else
   return getResidualSamples( pcCU->getPic(), (UInt)iXPos, (UInt)iYPos, (UInt)iBlkWidth, (UInt)iBlkHeight, pcYuv, bRecon); 
@@ -259,13 +250,8 @@
   
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
 Bool
 TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp, Bool bRecon)  
 #else
 Bool
-TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp, Bool bRecon) 
-#endif
-#else
-Bool
 TComResidualGenerator::getResidualSamples( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Bool bRecon) 
 #endif
@@ -282,9 +268,5 @@
   UInt uiXPosInRefView = uiXPos , uiYPosInRefView = uiYPos;
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp, &uiXPosInRefView , &uiYPosInRefView , bRecon  );
-#else
-  xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, iDisp, &uiXPosInRefView , &uiYPosInRefView , bRecon  );
-#endif
 #else
   xSetPredResidualBlock( pcPic, uiBaseViewId, uiXPos, uiYPos, uiBlkWidth, uiBlkHeight, pcYuv, &uiXPosInRefView , &uiYPosInRefView , bRecon    );
@@ -500,13 +482,7 @@
 
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
 Void  
 TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp
                                              ,UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon )
-#else // MTK_RELEASE_DV_CONSTRAINT_C0129
-Void  
-TComResidualGenerator::xSetPredResidualBlock( TComPic* pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp 
-                                             ,UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon)
-#endif // MTK_RELEASE_DV_CONSTRAINT_C0129
 #else // H3D_NBDV
 Void  
@@ -531,10 +507,6 @@
   //===== get disparity =====
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Int iDisparity_y = iDisp.getVer();
   Int iDisparity   = iDisp.getHor();
-#else
-  Int iDisparity = iDisp;
-#endif
 #else //H3D_NBDV
   Int           iMidPosX    = Int( uiXPos + ( ( uiBlkWidth  - 1 ) >> 1 ) ) >> m_pcDepthMapGenerator->getSubSampExpX();
@@ -549,5 +521,4 @@
   Int           iYRefPosX0  = Int( uiXPos )     + ( iDisparity >> 2 );
   Int           iYRefPosX1  = iYRefPosX0        + 1;
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Int           iYMaxPosY   = Int( uiPicHeight ) - 1;
   Int           iYWeight3   = ( iDisparity_y & 3 );
@@ -555,14 +526,9 @@
   Int           iYRefPosY0  = Max( 0, Min( iYMaxPosY, Int( uiYPos )     + ( iDisparity_y >> 2 )) );
   Int           iYRefPosY1  = Max( 0, Min( iYMaxPosY, iYRefPosY0 + 1 ));
-#endif
   Int           iYMaxPosX   = Int( uiPicWidth ) - 1;
   Int           iSrcStrideY = pcBaseRes->getStride   ();
   Int           iDesStrideY = pcYuv    ->getStride   ();
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Pel*          pSrcSamplesY0= pcBaseRes->getLumaAddr ( 0 ) + iYRefPosY0 * iSrcStrideY;
   Pel*          pSrcSamplesY1= pcBaseRes->getLumaAddr ( 0 ) + iYRefPosY1 * iSrcStrideY;
-#else
-  Pel*          pSrcSamplesY= pcBaseRes->getLumaAddr ( 0 ) + uiYPos * iSrcStrideY;
-#endif
   Pel*          pDesSamplesY= pcYuv    ->getLumaAddr ();
 
@@ -575,9 +541,5 @@
     return;
 
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   for(   Int iY = 0; iY < iYHeight; iY++, pSrcSamplesY0 += iSrcStrideY, pSrcSamplesY1 += iSrcStrideY, pDesSamplesY += iDesStrideY )
-#else
-  for(   Int iY = 0; iY < iYHeight; iY++, pSrcSamplesY += iSrcStrideY, pDesSamplesY += iDesStrideY )
-#endif
   {
     for( Int iX = 0; iX < iYWidth; iX++ )
@@ -585,12 +547,8 @@
       Int iXPic0        = Max( 0, Min( iYMaxPosX, iYRefPosX0 + iX ) );
       Int iXPic1        = Max( 0, Min( iYMaxPosX, iYRefPosX1 + iX ) );
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
       Pel Temp1,Temp2;
       Temp1 =( iYWeight0 * pSrcSamplesY0[iXPic0] + iYWeight1 * pSrcSamplesY0[iXPic1] + 2 ) >> 2;
       Temp2 =( iYWeight0 * pSrcSamplesY1[iXPic0] + iYWeight1 * pSrcSamplesY1[iXPic1] + 2 ) >> 2;
       pDesSamplesY[iX]  = ( iYWeight2 * Temp1 + iYWeight3 * Temp2 + 2 ) >> 2;
-#else
-      pDesSamplesY[iX]  = ( iYWeight0 * pSrcSamplesY[iXPic0] + iYWeight1 * pSrcSamplesY[iXPic1] + 2 ) >> 2;
-#endif
     }
   }
@@ -603,5 +561,4 @@
   Int           iCRefPosX0  = Int( uiXPos     >> 1 ) + ( iDisparity >> 3 );
   Int           iCRefPosX1  = iCRefPosX0             + 1;
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Int           iCMaxPosY   = Int( uiPicHeight >> 1 ) - 1;
   Int           iCWeight3   = ( iDisparity_y & 7 );
@@ -609,9 +566,8 @@
   Int           iCRefPosY0  = Max( 0, Min( iCMaxPosY, Int( uiYPos >> 1 )     + ( iDisparity_y >> 3 )) );
   Int           iCRefPosY1  = Max( 0, Min( iCMaxPosY, iCRefPosY0 + 1 ));
-#endif
   Int           iCMaxPosX   = Int( uiPicWidth >> 1 ) - 1;
   Int           iSrcStrideC = pcBaseRes->getCStride();
   Int           iDesStrideC = pcYuv    ->getCStride();
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
+
 #if FIX_CHROMA_RESIDUAL_C0129
   Pel*          pSrcSamplesU0= pcBaseRes->getCbAddr ( 0 ) + iCRefPosY0 * iSrcStrideC;
@@ -625,17 +581,8 @@
   Pel*          pSrcSamplesV1= pcBaseRes->getCrAddr ( 0 ) + ( iCRefPosY1 >> 1 ) * iSrcStrideC;
 #endif
-#else
-  Pel*          pSrcSamplesU= pcBaseRes->getCbAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC;
-  Pel*          pSrcSamplesV= pcBaseRes->getCrAddr ( 0 ) + ( uiYPos >> 1 ) * iSrcStrideC;
-#endif
   Pel*          pDesSamplesU= pcYuv    ->getCbAddr ();
   Pel*          pDesSamplesV= pcYuv    ->getCrAddr ();
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   for(   Int iY = 0; iY < iCHeight; iY++, pSrcSamplesU0 += iSrcStrideC, pSrcSamplesU1 += iSrcStrideC, pDesSamplesU += iDesStrideC,
                                           pSrcSamplesV0 += iSrcStrideC, pSrcSamplesV1 += iSrcStrideC, pDesSamplesV += iDesStrideC )
-#else
-  for(   Int iY = 0; iY < iCHeight; iY++, pSrcSamplesU += iSrcStrideC, pDesSamplesU += iDesStrideC,
-                                          pSrcSamplesV += iSrcStrideC, pDesSamplesV += iDesStrideC )
-#endif
   {
     for( Int iX = 0; iX < iCWidth; iX++ )
@@ -643,5 +590,4 @@
       Int iXPic0        = Max( 0, Min( iCMaxPosX, iCRefPosX0 + iX ) );
       Int iXPic1        = Max( 0, Min( iCMaxPosX, iCRefPosX1 + iX ) );
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
       Pel Temp1,Temp2;
       Temp1 =( iCWeight0 * pSrcSamplesU0[iXPic0] + iCWeight1 * pSrcSamplesU0[iXPic1] + 4 ) >> 3;
@@ -651,8 +597,4 @@
       Temp2 =( iCWeight0 * pSrcSamplesV1[iXPic0] + iCWeight1 * pSrcSamplesV1[iXPic1] + 4 ) >> 3;
       pDesSamplesV[iX]  = ( iCWeight2 * Temp1 + iCWeight3 * Temp2 + 4 ) >> 3;
-#else
-      pDesSamplesU[iX]  = ( iCWeight0 * pSrcSamplesU[iXPic0] + iCWeight1 * pSrcSamplesU[iXPic1] + 4 ) >> 3;
-      pDesSamplesV[iX]  = ( iCWeight0 * pSrcSamplesV[iXPic0] + iCWeight1 * pSrcSamplesV[iXPic1] + 4 ) >> 3;
-#endif
     }
   }
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.h
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TComResidualGenerator.h	(revision 322)
@@ -70,11 +70,6 @@
 
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv, TComMv iDisp_x, Bool bRecon );
   Bool  getResidualSamples    ( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv , TComMv iDisp_x, Bool bRecon );
-#else
-  Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv, Int iDisp, Bool bRecon ); 
-  Bool  getResidualSamples    ( TComPic* pcPic, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv , Int iDisp, Bool bRecon ); 
-#endif
 #else // H3D_NBDV
   Bool  getResidualSamples    ( TComDataCU*   pcCU,  UInt uiPUIdx, TComYuv* pcYuv, Bool bRecon ); 
@@ -90,9 +85,5 @@
   Void  xClearResidual        (                      TComYuv* pcCUResidual, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight );
 #if H3D_NBDV
-#if MTK_RELEASE_DV_CONSTRAINT_C0129
   Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, TComMv iDisp, UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon  );    
-#else
-  Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, Int iDisp, UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon  ); 
-#endif
 #else
   Void  xSetPredResidualBlock ( TComPic*      pcPic, UInt uiBaseViewId, UInt uiXPos, UInt uiYPos, UInt uiBlkWidth, UInt uiBlkHeight, TComYuv* pcYuv, UInt * puiXPosInRefView , UInt * puiYPosInRefView , Bool bRecon  ); 
Index: /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TypeDef.h	(revision 321)
+++ /branches/HTM-6.1-Cleanup/source/Lib/TLibCommon/TypeDef.h	(revision 322)
@@ -117,8 +117,8 @@
                                               // FIX_LGE_IVMP_PARALLEL_MERGE_B0136
 
-#define QC_NBDV_LDB_FIX_C0055             1   // JCT3V-C0055
-#define MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097     1   // JCT3V-C0141/C0097
-#define MTK_RELEASE_DV_CONSTRAINT_C0129   1   // JCT3V-C0129
-#define MTK_SIMPLIFY_DVTC_C0135           1   // JCT3V-C0135
+                                              // QC_NBDV_LDB_FIX_C0055
+                                              // MTK_SAIT_TEMPORAL_FIRST_ORDER_C0141_C0097
+                                              // MTK_RELEASE_DV_CONSTRAINT_C0129   
+                                              // MTK_SIMPLIFY_DVTC_C0135           
 #define FIX_CHROMA_RESIDUAL_C0129         1 
 
@@ -186,4 +186,6 @@
 ///// ***** VSP *********
 #define MERL_VSP_C0152                    1 // JCT3V-C0152: 1: enable VSP-related tools; 0: disable VSP-related tools
+                                            // LGE_SIMP_DVP_REFINE_C0112            
+                                            // MERL_MTK_VSP_DVP_REFINE_C0152_C0131
 #if MERL_VSP_C0152
 #define MERL_VSP_C0152_BugFix_ForNoDepthCase     1// MERL bugfix for test condition of no depth
@@ -205,16 +207,13 @@
 
 #define MERL_VSP_COMPENSATION_C0152          1 // JCT3V-C0152: 1: add VSP merge candidate to merging candidate list; 0: not to add   (nocand).
-#define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  1 // JCT3V-C0152 && JCT3V-C0131: 1: refine disparity vector using a warped depth block; 0: not to refine  (mvp2off).
+
 
 #define MERL_VSP_BLOCKSIZE_C0152             4 // JCT3V-C0152: VSP block size, supported values: 1, 2 and 4.
 #define VSP_MERGE_POS                        5 // JCT3V-C0152: fixed position of VSP candidate in merge list, supported values: 5.
-#define LGE_SIMP_DVP_REFINE_C0112            1 // JCT3V-C0112: 1: simplification of refining disparity vector using a warped depth block
 #define MTK_DVPREFINE_BVSP_BUG_FIX               1
 
 #else // !MERL_VSP_C0152
 #define MERL_VSP_COMPENSATION_C0152          0 // JCT3V-C0152: 1: add VSP merge candidate to merging candidate list; 0: not to add
-#define MERL_MTK_VSP_DVP_REFINE_C0152_C0131  0 // JCT3V-C0152 && JCT3V-C0131: 1: refine disparity vector using a warped depth block; 0: not to refine
 #define MERL_VSP_BLOCKSIZE_C0152             4 // JCT3V-C0152: VSP block size, supported values: 1, 2 and 4.
-#define LGE_SIMP_DVP_REFINE_C0112            0 // JCT3V-C0112: 1: simplification of refining disparity vector using a warped depth block
 #endif
 
@@ -223,4 +222,5 @@
 #if H3D_NBDV                    
 #define DIS_CANS                          1
+#define MCP_DIS_CANS                      1
 #endif                                  
 
