Index: branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.cpp	(revision 935)
@@ -3258,6 +3258,10 @@
  *   false: otherwise
  */
+#if ETRIKHU_CLEANUP_H0083
+inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount)
+#else
 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
   Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
+#endif
 {
   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1)
@@ -3275,5 +3279,10 @@
   }
 
+#if ETRIKHU_CLEANUP_H0083
+  TComMvField mvVSP[2];
+  UChar dirVSP;
+#else
   rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+#endif
 
   Bool  refViewAvailFlag = false;
@@ -3290,16 +3299,28 @@
         refViewAvailFlag      = true;
         predFlag[iRefListIdX] = 1;
+#if ETRIKHU_CLEANUP_H0083
+        mvVSP[0+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
+#if H_3D_NBDV
+        mvVSP[0+iRefListIdX].getMv().setIDVFlag (false);
+#endif
+#else
         pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
 #if H_3D_NBDV
         pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].getMv().setIDVFlag (false);
 #endif
-      }
-    }
-  }
-
+#endif
+      }
+    }
+  }
+
+#if ETRIKHU_CLEANUP_H0083
+  dirVSP = (predFlag[0] | (predFlag[1] << 1));
+  m_mergCands[MRG_VSP].setCand( mvVSP, dirVSP, true, false);
+#else
   // Set values to be returned
   abCandIsInter        [iCount] = true;
   puhInterDirNeighbours[iCount] = (predFlag[0] | (predFlag[1] << 1));
   vspFlag              [iCount] = 1;
+#endif
 
   if ( mrgCandIdx == iCount )
@@ -3316,6 +3337,10 @@
 
 #if H_3D_IV_MERGE
+#if ETRIKHU_CLEANUP_H0083
+inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int* ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx )
+#else
 inline Bool TComDataCU::xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* ivCandDir, TComMv* ivCandMv, 
   Int* ivCandRefIdx, Int iPosIvDC, Int* vspFlag, Int &iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
+#endif
 {
   for(Int iLoop = 0; iLoop < 2; iLoop ++ ) 
@@ -3325,8 +3350,19 @@
     {
       Int iFirDispCand = -1;
+#if ETRIKHU_CLEANUP_H0083
+      TComMvField mvIvDcShift[2];
+      UChar dirIvDcShift;
+
+      if (xGetPosFirstAvailDmvCand(MRG_IVSHIFT, iFirDispCand))
+#else
       if (xGetPosFirstAvailDmvCand(iCount, pcMvFieldNeighbours, ivCandDir, iPosIvDC, vspFlag, iFirDispCand))
+#endif
       {
         TComMv cMv;
+#if ETRIKHU_CLEANUP_H0083
+        cMv = m_mergCands[iFirDispCand].m_cMvField[0].getMv();
+#else
         cMv = pcMvFieldNeighbours[(iFirDispCand<<1)].getMv();
+#endif
         cMv.setHor(cMv.getHor()+4);
         if(m_pcSlice->getVPS()->getViewSynthesisPredFlag(m_pcSlice->getLayerIdInVps()))
@@ -3338,4 +3374,10 @@
 #endif
 
+#if ETRIKHU_CLEANUP_H0083
+        dirIvDcShift = m_mergCands[iFirDispCand].m_uDir;
+        mvIvDcShift[0].setMvField(cMv, m_mergCands[iFirDispCand].m_cMvField[0].getRefIdx() );
+        mvIvDcShift[1].setMvField(m_mergCands[iFirDispCand].m_cMvField[1].getMv(), m_mergCands[iFirDispCand].m_cMvField[1].getRefIdx() );
+        m_mergCands[MRG_IVSHIFT].setCand(mvIvDcShift, dirIvDcShift, false, false);
+#else
         rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
 
@@ -3344,4 +3386,5 @@
         pcMvFieldNeighbours  [ iCount << 1      ].setMvField(cMv, pcMvFieldNeighbours[( iFirDispCand << 1)].getRefIdx() );
         pcMvFieldNeighbours  [(iCount << 1) + 1 ].setMvField(pcMvFieldNeighbours[(iFirDispCand << 1) + 1].getMv(), pcMvFieldNeighbours[( iFirDispCand << 1) + 1].getRefIdx() );
+#endif
         
         if( mrgCandIdx == iCount ) 
@@ -3374,5 +3417,9 @@
       if( !iLoop && ivCandDir[0] > 0)
       {
+#if ETRIKHU_CLEANUP_H0083
+        if(tmpDir == m_mergCands[MRG_IVMC].m_uDir && m_mergCands[MRG_IVMC].m_cMvField[0]==tmpMV[0] && m_mergCands[MRG_IVMC].m_cMvField[1]==tmpMV[1])
+#else
         if(tmpDir == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0]==tmpMV[0] && pcMvFieldNeighbours[1]==tmpMV[1])
+#endif
         {
             bRemove                         = true;
@@ -3381,4 +3428,14 @@
       if(!bRemove)
       {
+#if ETRIKHU_CLEANUP_H0083
+#if H_3D_NBDV
+        if(iLoop) // For IvMcShift candidate
+        {
+          tmpMV[0].getMv().setIDVFlag (false);
+          tmpMV[1].getMv().setIDVFlag (false);
+        }
+#endif
+        m_mergCands[MRG_IVSHIFT].setCand(tmpMV, tmpDir, false, false);
+#else
         rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
 
@@ -3400,4 +3457,5 @@
         }
 #endif
+#endif
         if( mrgCandIdx == iCount )
         {
@@ -3412,4 +3470,22 @@
 } 
 
+#if ETRIKHU_CLEANUP_H0083
+inline Bool TComDataCU::xGetPosFirstAvailDmvCand(Int iCount, Int& posFirstAvailDmvCand )
+{
+  for ( Int currListPos = 0; currListPos < iCount; currListPos++ )
+  {
+    if ( !m_mergCands[currListPos].m_bAvailable || ( currListPos == MRG_IVMC ) || ( currListPos == MRG_IVDC ) || ( m_mergCands[currListPos].m_iVspFlag != 0 ))
+    {
+      continue;
+    }
+    else if((m_mergCands[currListPos].m_bAvailable) && (m_mergCands[currListPos].m_cMvField[0].getRefIdx() != -1 ) && (getSlice()->getViewIndex() != getSlice()->getRefPic(RefPicList(0), m_mergCands[currListPos].m_cMvField[0].getRefIdx())->getViewIndex()))
+    {
+      posFirstAvailDmvCand = currListPos;
+      return true;
+    }
+  }
+  return false;  
+}
+#else
 inline Bool TComDataCU::xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int* ivCandDir, Int posIvDC, Int* vspFlag, Int& posFirstAvailDmvCand )
 {
@@ -3429,8 +3505,84 @@
  return false;  
 }
+#endif
                                       
 #endif
 
 #if H_3D
+#if ETRIKHU_CLEANUP_H0083
+
+Void TComDataCU::buildMCL(TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
+#if H_3D_VSP
+  , Int* vspFlag
+#endif
+#if H_3D_SPIVMP
+  , Bool* pbSPIVMPFlag
+#endif
+  , Int& numValidMergeCand
+  )
+{
+  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // for only dependent texture
+  {
+    return;
+  }
+
+  Int iCount = 0;
+  TComMv cZeroMv;
+
+  // init temporal list
+  TComMvField extMergeCandList[MRG_MAX_NUM_CANDS_MEM << 1];
+  UChar uhInterDirNeighboursExt[MRG_MAX_NUM_CANDS_MEM];
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
+  {
+    uhInterDirNeighboursExt[ui] = puhInterDirNeighbours[ui];
+    extMergeCandList[ui<<1].setMvField(cZeroMv, NOT_VALID);
+    extMergeCandList[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
+    vspFlag[ui] = 0;
+  }
+
+  // add candidates to temporal list
+  // insert MPI ... IvShift candidate
+  for (Int i=0; i<=MRG_IVSHIFT; i++)
+  {
+    if (m_mergCands[i].m_bAvailable)
+    {
+      m_mergCands[i].getCand(iCount, extMergeCandList, uhInterDirNeighboursExt, vspFlag, pbSPIVMPFlag);
+      iCount++;
+      if (iCount >= getSlice()->getMaxNumMergeCand())
+        break;
+    }
+  }
+
+  // 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());
+    if ( getSlice()->isInterB() )
+    {
+      extMergeCandList[(iCount<<1)+1].setMvField(pcMvFieldNeighbours[(m_baseListidc<<1)+1].getMv(), pcMvFieldNeighbours[(m_baseListidc<<1)+1].getRefIdx());
+    }
+    m_baseListidc++;
+    iCount++;
+  }
+
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
+  {
+    puhInterDirNeighbours[ui] = 0;
+    pcMvFieldNeighbours[ui<<1].setMvField(cZeroMv, NOT_VALID);
+    pcMvFieldNeighbours[(ui<<1)+1].setMvField(cZeroMv, NOT_VALID);
+  }
+  // copy extMergeCandList to output
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ui++ )
+  {
+    puhInterDirNeighbours[ui] = uhInterDirNeighboursExt[ui];
+    pcMvFieldNeighbours[ui<<1].setMvField(extMergeCandList[ui<<1].getMv(), extMergeCandList[ui<<1].getRefIdx());
+    if ( getSlice()->isInterB() )
+      pcMvFieldNeighbours[(ui<<1)+1].setMvField(extMergeCandList[(ui<<1)+1].getMv(), extMergeCandList[(ui<<1)+1].getRefIdx());
+  }
+  numValidMergeCand = iCount;
+  assert(iCount == getSlice()->getMaxNumMergeCand());
+}
+#else
 Void TComDataCU::rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV)
 {
@@ -3453,4 +3605,5 @@
   return;
 }
+#endif
 
 /** Constructs a list of merging candidates
@@ -3826,9 +3979,15 @@
 #endif
 #if H_3D_VSP
+#if !ETRIKHU_CLEANUP_H0083
       , Int* vspFlag
+#endif
       , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
+#if ETRIKHU_CLEANUP_H0083
+      , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#else
       , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
 #endif
       , Int& numValidMergeCand, Int mrgCandIdx
@@ -3841,5 +4000,7 @@
   ////////////////////////////
   TComMv cZeroMv;
+#if !ETRIKHU_CLEANUP_H0083
   Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
+#endif
 #else
   Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
@@ -3907,7 +4068,11 @@
 #if H_3D_DBBP
   Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
+#if MTK_DIS_SPBIP8X4_H0205
+  assert(bDBBPFlag == getDBBPFlag(0));  
+#endif
 #endif
 
 #if H_3D
+#if !ETRIKHU_CLEANUP_H0083
   Int  iPosLeftAbove[2] = {-1, -1};
 
@@ -3916,5 +4081,5 @@
   Int numA1B1B0 = 0;
   Int numA0B2 = 0;
-
+#endif
 #if H_3D_NBDV
   for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)  
@@ -3925,4 +4090,144 @@
 #endif
 
+
+#if ETRIKHU_CLEANUP_H0083
+
+
+  // Clean version for MCL construction align with WD
+  // init mergCands list
+  for (Int i = 0; i<MRG_IVSHIFT+1; i++)
+  {
+    m_mergCands[i].init();
+  }
+
+  m_baseListidc = 0;
+
+  //left
+  UInt uiLeftPartIdx = 0;
+  TComDataCU* pcCULeft = 0;
+  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );  
+
+  if (getAvailableFlagA1())
+  {
+    m_mergCands[MRG_A1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+#if H_3D_VSP
+    , 
+      (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+      )
+#endif
+      , false
+      ); 
+    m_baseListidc++;
+  }
+
+  // above
+  UInt uiAbovePartIdx = 0;
+  TComDataCU* pcCUAbove = 0;
+  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+
+  if (getAvailableFlagB1())
+  {
+    m_mergCands[MRG_B1].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+#if H_3D_VSP
+    ,
+      ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) != 0) 
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+      )
+#endif
+      , false
+      ); 
+    m_baseListidc++;
+  }
+
+  // above right
+  UInt uiAboveRightPartIdx = 0;
+  TComDataCU* pcCUAboveRight = 0;
+  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+
+  if (getAvailableFlagB0())
+  {
+    m_mergCands[MRG_B0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+#if H_3D_VSP
+    ,
+      ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) != 0) 
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+      )
+#endif
+      , false
+      ); 
+    m_baseListidc++;
+  }
+
+  // left bottom
+  UInt uiLeftBottomPartIdx = 0;
+  TComDataCU* pcCULeftBottom = getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+
+  if (getAvailableFlagA0())
+  {
+    m_mergCands[MRG_A0].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+#if H_3D_VSP
+    ,
+      (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) != 0
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+      )
+#endif
+      , false
+      ); 
+    m_baseListidc++;
+  }
+
+  // above left
+  UInt uiAboveLeftPartIdx = 0;
+  TComDataCU* pcCUAboveLeft = 0;
+  pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+
+  if (getAvailableFlagB2())
+  {
+    m_mergCands[MRG_B2].setCand( &pcMvFieldNeighbours[m_baseListidc<<1], puhInterDirNeighbours[m_baseListidc]
+#if H_3D_VSP
+    ,
+      ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) != 0) 
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+      )
+#endif
+      , false
+      ); 
+    m_baseListidc++;
+  }
+
+
+#if !ETRIKHU_BUGFIX_H0083
+  Bool A1_was_available = m_mergCands[MRG_A1].m_bAvailable;
+  Bool B1_was_available = m_mergCands[MRG_B1].m_bAvailable;
+#endif
+
+
+#else
   //left
   UInt uiLeftPartIdx = 0;
@@ -4041,4 +4346,5 @@
   iCountHEVC = numValidMergeCand;
 #endif
+#endif
 
 
@@ -4049,4 +4355,7 @@
   /////////////////////////////////////////////
 
+#if SHARP_SIMPLE_MERGE_H0062
+  bMPIFlag &= (nPSW + nPSH > 12);
+#endif
   if( bMPIFlag)
   {
@@ -4054,4 +4363,8 @@
     tmpMV[1].setMvField( cZeroMv, NOT_VALID );
     tmpDir        =  0;
+
+#if ETRIKHU_CLEANUP_H0083
+    Bool bSPIVMPFlag = false;
+#endif
 
     TComPic * pcTexPic = m_pcSlice->getTexturePic();
@@ -4092,4 +4405,67 @@
       Int         iTexPosX, iTexPosY;
       const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+#if MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
+      
+      Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iPUWidth ) >> 1 )  * iPUWidth + ( iPUWidth >> 1 );
+      Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iPUHeight ) >> 1 )  * iPUHeight + (iPUHeight >> 1);
+      Int         iTexCenterCUAddr, iTexCenterAbsPartIdx;
+
+      if(iWidth == iPUWidth && iHeight == iPUHeight)
+      {
+          iCenterPosX = iCurrPosX + (iWidth >> 1);
+          iCenterPosY = iCurrPosY + (iHeight >> 1);
+      }
+
+      // derivation of center motion parameters from the collocated texture CU
+
+      pcTexRec->getCUAddrAndPartIdx( iCenterPosX , iCenterPosY , iTexCenterCUAddr, iTexCenterAbsPartIdx );
+      TComDataCU* pcDefaultCU    = pcTexPic->getCU( iTexCenterCUAddr );
+
+      if( pcDefaultCU->getPredictionMode( iTexCenterAbsPartIdx ) != MODE_INTRA )
+      {
+          for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+          {
+              RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+
+              TComMvField cDefaultMvField;
+              pcDefaultCU->getMvField( pcDefaultCU, iTexCenterAbsPartIdx, eCurrRefPicList, cDefaultMvField );
+              Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
+              if (iDefaultRefIdx >= 0)
+              {
+                  Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eCurrRefPicList, iDefaultRefIdx);
+                  for (Int iRefPicList = 0; iRefPicList < m_pcSlice->getNumRefIdx( eCurrRefPicList ); iRefPicList++)
+                  {
+                      if (iDefaultRefPOC == m_pcSlice->getRefPOC(eCurrRefPicList, iRefPicList))
+                      {
+#if ETRIKHU_CLEANUP_H0083
+                        bSPIVMPFlag = true;
+#else
+                          pbSPIVMPFlag[iCount] = true;
+#endif
+                          TComMv cMv = cDefaultMvField.getMv() + cMvRounding;
+                          cMv >>= 2;
+                          clipMv( cMv );
+                          cMvFieldSaved[eCurrRefPicList].setMvField(cMv, iRefPicList) ;
+                          break;
+                      }
+                  }
+              }
+          }
+      }
+#if ETRIKHU_CLEANUP_H0083
+      if ( bSPIVMPFlag == true )
+#else
+      if ( pbSPIVMPFlag[iCount] == true )
+#endif
+      {   
+          iInterDirSaved = (cMvFieldSaved[0].getRefIdx()!=-1 ? 1: 0) + (cMvFieldSaved[1].getRefIdx()!=-1 ? 2: 0);
+          tmpDir = iInterDirSaved;
+          tmpMV[0] = cMvFieldSaved[0];
+          tmpMV[1] = cMvFieldSaved[1];
+      }
+
+      if ( iInterDirSaved != 0 )
+      {
+#endif
       for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
       {
@@ -4130,9 +4506,24 @@
             }
           }
+#if MTK_DIS_SPBIP8X4_H0205
+              if (iPUHeight + iPUWidth == 12)
+              {
+                if (puhInterDirSP[iPartition] == 3)
+                {
+                  puhInterDirSP[iPartition] = 1;
+                  pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
+                }
+              }
+#endif
+#if !MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
           else
           {
             if (iInterDirSaved ==0)
             {
+#if ETRIKHU_CLEANUP_H0083
+                  bSPIVMPFlag = true;
+#else
               pbSPIVMPFlag[iCount] = true;
+#endif
               tmpDir = puhInterDirSP[iPartition];
               tmpMV[0] = pcMvFieldSP[2*iPartition];
@@ -4153,7 +4544,11 @@
             cMvFieldSaved[1] = pcMvFieldSP[2*iPartition + 1];
           }
+#endif
           iPartition ++;
         }
       }
+#if MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133
+      }
+#endif
 #if H_3D_FCO
     }
@@ -4162,4 +4557,20 @@
     {
       Int iCnloop = 0;
+#if ETRIKHU_CLEANUP_H0083
+      for(iCnloop = 0; iCnloop < 2; iCnloop ++)
+      {
+        if ( !m_mergCands[MRG_A1+iCnloop].m_bAvailable )  // prunning to A1, B1
+        {
+          continue;
+        }
+        if (tmpDir == m_mergCands[MRG_A1+iCnloop].m_uDir && tmpMV[0]==m_mergCands[MRG_A1+iCnloop].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_A1+iCnloop].m_cMvField[1])
+        {
+          m_mergCands[MRG_A1+iCnloop].m_bAvailable = false;
+          break;
+        }      
+      }
+      m_mergCands[MRG_T].setCand( tmpMV, tmpDir, false, bSPIVMPFlag);
+
+#else
       Bool bRemoveSpa = false; //pruning
 
@@ -4221,5 +4632,5 @@
 
       puhInterDirNeighbours[iCount] = tmpDir;
-
+#endif
       if ( mrgCandIdx == iCount )
       {
@@ -4300,8 +4711,18 @@
       if( tmpDir != 0 )
       {
+#if !ETRIKHU_CLEANUP_H0083
         rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
+#endif
         m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV,  iViewIdx );
         m_iUseDDDCandIdx = iCount;
 
+#if ETRIKHU_CLEANUP_H0083
+        m_mergCands[MRG_D].setCand( tmpMV, tmpDir, false, false);
+        if ( mrgCandIdx == iCount )
+        {
+          return;
+        }
+        iCount ++;
+#else
         if( tmpDir == 1 )
         {
@@ -4332,4 +4753,5 @@
           iPosLeftAbove[ 1 ] = iCount + iLeftAboveAvail;
         }
+#endif
       }
     }
@@ -4340,5 +4762,7 @@
   /////////////////////////////////////////////////////////////////
 
+#if !ETRIKHU_CLEANUP_H0083
   Int  posIvDC          = -1;
+#endif
 
   // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift };  
@@ -4352,7 +4776,14 @@
   Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
 
+#if SHARP_SIMPLE_MERGE_H0062
+  ivMvPredFlag &= (nPSW + nPSH > 12);
+#endif
   if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
   {
+#if SEC_ADAPT_DISABLE_IVMP
+    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP, bICFlag );
+#else
     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP );
+#endif
   }  
 
@@ -4380,6 +4811,8 @@
 
     Bool bRemoveSpa = false; //pruning
+#if !ETRIKHU_CLEANUP_H0083
     Bool bIvMC = false;
     Int iCnloop=0;
+#endif
 
     if (!bIsDepth)
@@ -4387,4 +4820,15 @@
       for(Int i = 0; i < 2; i ++)
       {
+#if ETRIKHU_CLEANUP_H0083
+        if ( !m_mergCands[MRG_A1 + i].m_bAvailable ) // prunning to A1, B1
+        {
+          continue;
+        }
+        if (ivCandDir[0] == 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])
+        {
+          m_mergCands[MRG_A1+i].m_bAvailable = false;
+          break;
+        }      
+#else
         iCnloop = iPosLeftAbove[i];
         if ( iCnloop == -1 ) 
@@ -4397,8 +4841,15 @@
           break;
         }      
+#endif
       }
     }
     if (bIsDepth)
     {
+#if ETRIKHU_CLEANUP_H0083
+      if (m_mergCands[MRG_T].m_bAvailable && ivCandDir[0] == m_mergCands[MRG_T].m_uDir && tmpMV[0]==m_mergCands[MRG_T].m_cMvField[0] && tmpMV[1]==m_mergCands[MRG_T].m_cMvField[1])
+      {
+        bRemoveSpa                      = true;
+      }
+#else
       iCnloop = iCount-1;
       for(; iCnloop >= 0; iCnloop --)
@@ -4416,8 +4867,10 @@
         }
       }
+#endif
     }
 
     if (!bRemoveSpa)
     {
+#if !ETRIKHU_CLEANUP_H0083
       bIvMC = true;
       rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
@@ -4472,4 +4925,19 @@
     if (bIvMC)
     {
+#endif
+#if ETRIKHU_CLEANUP_H0083
+      Bool SPIVMPFlag = false;
+#if MTK_DIS_SPBIP8X4_H0205
+      if(!m_pcSlice->getIsDepth())
+#else
+      if(!m_pcSlice->getIsDepth() && getPartitionSize(0) == SIZE_2Nx2N )
+#endif
+      {
+        SPIVMPFlag = true;
+      }
+#if H_3D_DBBP
+      SPIVMPFlag &= !bDBBPFlag;
+#endif
+#else
       if(!m_pcSlice->getIsDepth() && getPartitionSize(0) == SIZE_2Nx2N )
       {
@@ -4479,4 +4947,8 @@
       pbSPIVMPFlag[iCount] &= !bDBBPFlag;
 #endif
+#endif
+#if ETRIKHU_CLEANUP_H0083
+      m_mergCands[MRG_IVMC].setCand( tmpMV, ivCandDir[0], false, SPIVMPFlag);
+#else
       if( ( ivCandDir[0] & 1 ) == 1 )
       {
@@ -4489,4 +4961,5 @@
 
       puhInterDirNeighbours[ iCount ] = ivCandDir[0];
+#endif
 
       if ( mrgCandIdx == iCount )
@@ -4506,5 +4979,9 @@
 
 #if H_3D
+#if ETRIKHU_CLEANUP_H0083
+  iCount += m_mergCands[MRG_A1].m_bAvailable + m_mergCands[MRG_B1].m_bAvailable + m_mergCands[MRG_B0].m_bAvailable;
+#else
   iCount += numA1B1B0;
+#endif
 #else
   //left
@@ -4635,10 +5112,26 @@
     for(Int i = 0; i < 2; i ++)
     {
+#if ETRIKHU_CLEANUP_H0083
+      if ( !m_mergCands[MRG_A1+i].m_bAvailable ) 
+#else
       Int iCnloop = iPosLeftAbove[i];
       if ( iCnloop == -1 ) 
+#endif
       {
         continue;
       }
+#if ETRIKHU_CLEANUP_H0083
+#if ETRIKHU_BUGFIX_H0083
+      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])
+#else
+      Int offset = 0;
+      offset += A1_was_available;
+      offset += B1_was_available;
+      offset += m_mergCands[MRG_B0].m_bAvailable;
+      if (puhInterDirNeighbours[offset] == m_mergCands[MRG_A1+i].m_uDir && pcMvFieldNeighbours[(offset<<1)]==m_mergCands[MRG_A1+i].m_cMvField[0] && pcMvFieldNeighbours[(offset<<1)+1]==m_mergCands[MRG_A1+i].m_cMvField[1])
+#endif
+#else
       if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+#endif
       {
         bRemoveSpa                      = true;
@@ -4648,4 +5141,11 @@
     if(!bRemoveSpa)
     {
+#if ETRIKHU_CLEANUP_H0083
+#if H_3D_NBDV
+      tmpMV[0].getMv().setIDVFlag (false);
+      tmpMV[1].getMv().setIDVFlag (false);
+#endif
+      m_mergCands[MRG_IVDC].setCand( tmpMV, ivCandDir[1], false, false);
+#else
       rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
       puhInterDirNeighbours[ iCount ] = ivCandDir[1];
@@ -4663,4 +5163,5 @@
 #endif
       posIvDC  = iCount;
+#endif
       if ( mrgCandIdx == iCount )
         return;
@@ -4690,5 +5191,12 @@
       !bARPFlag &&
 #endif
+#if SHARP_SIMPLE_MERGE_H0062
+      (nPSW + nPSH > 12) &&
+#endif
+#if ETRIKHU_CLEANUP_H0083
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount ) )
+#else
       xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
+#endif
   {
     return;
@@ -4706,5 +5214,9 @@
 
 #if H_3D
+#if ETRIKHU_CLEANUP_H0083
+  iCount += m_mergCands[MRG_A0].m_bAvailable + m_mergCands[MRG_B2].m_bAvailable;
+#else
   iCount += numA0B2;
+#endif
 #else
   //left bottom
@@ -4780,5 +5292,9 @@
   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 
   {
+#if ETRIKHU_CLEANUP_H0083
+    if(xAddIvMRGCand( mrgCandIdx,  iCount, ivCandDir, ivCandMv, ivCandRefIdx ) )
+#else
     if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
+#endif
     {
       return;
@@ -4793,4 +5309,5 @@
 
 #if H_3D
+#if !ETRIKHU_CLEANUP_H0083
   if (iCountHEVC + iCount3DV > getSlice()->getMaxNumMergeCand())
   {
@@ -4802,4 +5319,5 @@
   }
   numValidMergeCand = iCount;
+#endif
 #else
   if ( getSlice()->getEnableTMVPFlag())
@@ -6759,4 +7277,7 @@
 , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
+#if SEC_ADAPT_DISABLE_IVMP
+, Bool bICFlag
+#endif
 )
 {
@@ -6794,4 +7315,9 @@
     pacPdmMv[i].setIDVFlag   (false);
   }
+#endif
+
+#if SEC_ADAPT_DISABLE_IVMP
+  if(!bICFlag)
+  {
 #endif
 
@@ -6802,5 +7328,9 @@
   if(!m_pcSlice->getIsDepth())
   {
+#if MTK_DIS_SPBIP8X4_H0205
+    if (!getDBBPFlag(0))
+#else
     if( getPartitionSize(0) == SIZE_2Nx2N )
+#endif
     {
       Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
@@ -6959,4 +7489,14 @@
 
             }
+#if MTK_DIS_SPBIP8X4_H0205
+            if (iSPHeight + iSPWidth == 12)
+            {
+              if (puhInterDirSP[iPartition] == 3)
+              {
+                puhInterDirSP[iPartition] = 1;
+                pcMvFieldSP[2*iPartition + 1].setMvField(TComMv(0,0), -1);
+              }
+            }
+#endif
             iPartition ++;
           }
@@ -6980,5 +7520,9 @@
     iCurrPosY  += ( iHeight >> 1 );
   }
+#if MTK_DIS_SPBIP8X4_H0205
+  for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getDBBPFlag(0)) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#else
   for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getPartitionSize(uiPartAddr) != SIZE_2Nx2N) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#endif
 #else
   for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
@@ -7062,4 +7606,7 @@
   }
 
+#if SEC_ADAPT_DISABLE_IVMP
+  }
+#endif
 
   ////////////////////////////////
Index: branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComDataCU.h	(revision 935)
@@ -233,4 +233,9 @@
 #endif
 
+#if ETRIKHU_CLEANUP_H0083
+  TComMotionCand  m_mergCands[MRG_IVSHIFT+1];
+  Int           m_baseListidc;
+#endif
+
 protected:
   
@@ -239,11 +244,23 @@
   Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
 #if H_3D_VSP
+#if ETRIKHU_CLEANUP_H0083
+  Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount);
+#else
   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
                              Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo);
 #endif
+#endif
 #if H_3D_IV_MERGE
+#if ETRIKHU_CLEANUP_H0083
+  Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Int*   ivCandDir, TComMv* ivCandMv, Int* ivCandRefIdx ); 
+#else
   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int*   ivCandDir, TComMv* ivCandMv, 
                                Int* ivCandRefIdx, Int posIvDC, Int* vspFlag, Int &iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo   ); 
+#endif
+#if ETRIKHU_CLEANUP_H0083
+  Bool          xGetPosFirstAvailDmvCand( Int iCount, Int& iFirDispCand );
+#else
   Bool          xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int*  ivCandDir, Int posIvDC, Int* vspFlag, Int& iFirDispCand );
+#endif
 #endif
 
@@ -485,5 +502,7 @@
    
 #if H_3D
+#if !ETRIKHU_CLEANUP_H0083
   Void          rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV);
+#endif
   Bool          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
   Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
@@ -508,4 +527,7 @@
 #if H_3D_SPIVMP
     , TComMvField* pcMFieldSP, UChar* puhInterDirSP
+#endif
+#if SEC_ADAPT_DISABLE_IVMP
+    , Bool bICFlag
 #endif
     );   
@@ -635,5 +657,18 @@
   Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
   Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
+#if ETRIKHU_CLEANUP_H0083
   Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
+  Void          buildMCL(TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+#if H_3D_VSP
+    , Int* vspFlag
+#endif
+#if H_3D_SPIVMP
+    , Bool* pbSPIVMPFlag
+#endif
+    , Int& numValidMergeCand
+    );
+#else
+  Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
+#endif
   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
@@ -642,9 +677,15 @@
 #endif
 #if H_3D_VSP
+#if !ETRIKHU_CLEANUP_H0083
                                             , Int* vspFlag
+#endif
                                             , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
+#if ETRIKHU_CLEANUP_H0083
+                                            , TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#else
                                             , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
 #endif
                                             , Int& numValidMergeCand, Int mrgCandIdx = -1
Index: branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComMotionInfo.h	(revision 935)
@@ -198,3 +198,82 @@
 //! \}
 
+#if ETRIKHU_CLEANUP_H0083
+class TComMotionCand
+{
+public:
+  Bool                  m_bAvailable;
+  TComMvField           m_cMvField[2];
+  UChar                 m_uDir;
+#if H_3D_VSP
+  Int                   m_iVspFlag;
+#endif  
+  Bool                  m_bSPIVMPFlag;
+
+public:
+  TComMotionCand()
+  {
+    m_bAvailable = false;
+    m_uDir = 0;
+#if H_3D_VSP
+    m_iVspFlag = 0;
+#endif
+    m_bSPIVMPFlag = false;
+  }
+
+  ~TComMotionCand()
+  {
+
+  }
+
+  Void init()
+  {
+    TComMv cZeroMv;
+
+    m_bAvailable = false;
+    m_uDir = 0;
+#if H_3D_VSP
+    m_iVspFlag = 0;
+#endif
+    m_bSPIVMPFlag = false;
+    m_cMvField[0].setMvField(cZeroMv, NOT_VALID);
+    m_cMvField[1].setMvField(cZeroMv, NOT_VALID);
+  }
+
+  Void setCand(TComMvField* pcMvFieldNeighbours, UChar uhInterDirNeighbours
+#if H_3D_VSP
+    , Int vspFlag
+#endif
+    , Bool bSPIVMPFlag
+    )
+  {
+    m_bAvailable = true;
+    m_cMvField[0] = pcMvFieldNeighbours[0];
+    m_cMvField[1] = pcMvFieldNeighbours[1];
+    m_uDir = uhInterDirNeighbours;
+#if H_3D_VSP
+    m_iVspFlag = vspFlag;
+#endif
+    m_bSPIVMPFlag = bSPIVMPFlag;
+  }
+
+
+  Void getCand(Int iCount, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
+#if H_3D_VSP
+    , Int* vspFlag
+#endif
+    , Bool* pbSPIVMPFlag
+    )
+  {
+    pcMvFieldNeighbours[iCount<<1] = m_cMvField[0];
+    pcMvFieldNeighbours[(iCount<<1) + 1] = m_cMvField[1];
+    puhInterDirNeighbours[iCount] = m_uDir;
+#if H_3D_VSP
+    vspFlag[iCount] = m_iVspFlag;
+#endif
+    pbSPIVMPFlag[iCount] = m_bSPIVMPFlag;
+  }
+};
+#endif
+
+
 #endif // __TCOMMOTIONINFO__
Index: branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibCommon/TComPrediction.cpp	(revision 935)
@@ -519,5 +519,9 @@
       Int RefPOCL0 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_0, pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr))->getPOC();
       Int RefPOCL1 = pcCU->getSlice()->getRefPic(REF_PIC_LIST_1, pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr))->getPOC();
+#if MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085
+      if(!pcCU->getARPW(PartAddr) && RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
+#else
       if(RefPOCL0 == RefPOCL1 && pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr) == pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr))
+#endif
       {
         return true;
Index: branches/HTM-10.2-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 935)
@@ -108,4 +108,5 @@
                                               // MTK_ARP_FLAG_CABAC_SIMP_G0061 Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
                                               // MTK_ARP_REF_SELECTION_G0053 ARP Reference picture selection in JCT3V-G0053 
+#define MTK_ALIGN_SW_WD_BI_PRED_ARP_H0085 1   // Align the SW and WD for the bi-prediction ARP PUs by disallowing non-normative fast bi-prediction for ARP PUs, JCT3V-H0085
 
 #define H_3D_IC                           1   // Illumination Compensation, JCT3V-B0045, JCT3V-C0046, JCT3V-D0060
@@ -159,4 +160,6 @@
                                               // SEC_DEPTH_DV_DERIVAITON_G0074, Simplification of DV derivation for depth, JCT3V-G0074
                                               // QC_DEPTH_MERGE_SIMP_G0127 Remove DV candidate and shifting candidate for depth coding
+
+#define SEC_ADAPT_DISABLE_IVMP            1   // Disalbing IVMP merge candidates when IC is enabled, JCT3V-H0070
 
 #define H_3D_TMVP                         1   // QC_TMVP_C0047 
@@ -224,4 +227,9 @@
 #endif
 
+#define ETRIKHU_BUGFIX_H0083              1   // bug-fix for DV candidate pruning
+#define ETRIKHU_CLEANUP_H0083             1   // cleaned-up source code for constructing merging candidate list
+#define SHARP_SIMPLE_MERGE_H0062          1   // Restrict 3D-HEVC merge cand in small PUs
+#define MTK_DIS_SPBIP8X4_H0205            1   // Disable bi-prediction for 8x4 and 4x8 sub PU and remove the SPIVMP 2Nx2N restriction
+
 // Rate Control
 #define KWU_FIX_URQ                       1
@@ -325,5 +333,5 @@
 
 #define H_MV_HLS7_GEN                        0  // General changes (not tested)
-
+#define MPI_SUBPU_DEFAULT_MV_H0077_H0099_H0111_H0133    1
 
 
@@ -799,4 +807,23 @@
 };
 
+/// merging candidates
+#if ETRIKHU_CLEANUP_H0083
+enum DefaultMergCandOrder
+{
+  MRG_T = 0,            ///< MPI
+  MRG_D,                ///< DDD
+  MRG_IVMC,             ///< Temporal inter-view
+  MRG_A1,               ///< Left
+  MRG_B1,               ///< Above
+  MRG_B0,               ///< Above right
+  MRG_IVDC,             ///< Disparity inter-view
+  MRG_VSP,              ///< VSP
+  MRG_A0,               ///< Left bottom
+  MRG_B2,               ///< Above left
+  MRG_IVSHIFT,          ///< Shifted IVMC of Shifted IVDC. (These are mutually exclusive)
+  MRG_COL               ///< Temporal co-located
+};
+#endif
+
 /// coefficient scanning type used in ACS
 enum COEFF_SCAN_TYPE
Index: branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 935)
@@ -431,9 +431,21 @@
     m_ppcCU[uiDepth]->initAvailableFlags();
     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
-    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours 
+#if !ETRIKHU_CLEANUP_H0083
+      ,vspFlag
+#endif
+      , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+      , pcMvFieldSP, puhInterDirSP
 #endif
       , numValidMergeCand, uiMergeIndex );
+
+#if ETRIKHU_CLEANUP_H0083
+    m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
+#if H_3D_SPIVMP
+      , bSPIVMPFlag
+#endif
+      , numValidMergeCand );
+#endif
     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
 #else
Index: branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 935)
@@ -292,9 +292,21 @@
           pcSubCU->initAvailableFlags();
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
-          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours
+#if !ETRIKHU_CLEANUP_H0083
+            ,vspFlag
+#endif
+            , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-            , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+            , pcMvFieldSP, puhInterDirSP
 #endif
             , numValidMergeCand );
+
+#if ETRIKHU_CLEANUP_H0083
+          pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
+#if H_3D_SPIVMP
+            , bSPIVMPFlag
+#endif
+            , numValidMergeCand );
+#endif
           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
 
@@ -329,9 +341,21 @@
         pcSubCU->initAvailableFlags();
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
-        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours
+#if !ETRIKHU_CLEANUP_H0083
+          , vspFlag
+#endif
+          , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-          , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+          , pcMvFieldSP, puhInterDirSP
 #endif
           ,numValidMergeCand, uiMergeIndex );
+
+#if ETRIKHU_CLEANUP_H0083
+        pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag
+#if H_3D_SPIVMP
+          , bSPIVMPFlag
+#endif
+          ,numValidMergeCand );
+#endif
         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
         if(vspFlag[uiMergeIndex])
Index: branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 935)
@@ -2153,4 +2153,8 @@
   {
     pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
+#if MTK_DIS_SPBIP8X4_H0205
+    UInt uiCurrPartNumQ = (pcCU->getPic()->getNumPartInCU() >> (2 * uiDepth)) >> 2;
+    pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx + 2*uiCurrPartNumQ, 1, uiDepth);
+#endif
   }
 }
Index: branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncCu.cpp	(revision 935)
@@ -1814,10 +1814,24 @@
     rpcTempCU->initAvailableFlags();
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
-    rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo
+    rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
+#if !ETRIKHU_CLEANUP_H0083
+      , vspFlag
+#endif
+      , inheritedVSPDisInfo
 #if H_3D_SPIVMP
-      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+      , pcMvFieldSP, puhInterDirSP
 #endif
       , numValidMergeCand 
       );
+
+#if ETRIKHU_CLEANUP_H0083
+    rpcTempCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours, vspFlag
+#if H_3D_SPIVMP
+      , bSPIVMPFlag
+#endif
+      , numValidMergeCand 
+      );
+#endif
+
 #else
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
Index: branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 888)
+++ branches/HTM-10.2-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 935)
@@ -3697,12 +3697,26 @@
       pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
 #if H_3D_VSP
+#if !ETRIKHU_CLEANUP_H0083
                                         , vspFlag
+#endif
                                         , inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-                                        , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+        , pcMvFieldSP, puhInterDirSP
+#endif
+        , numValidMergeCand
+        );
+
+#if ETRIKHU_CLEANUP_H0083
+      pcCU->buildMCL( cMvFieldNeighbours,uhInterDirNeighbours
+#if H_3D_VSP
+        , vspFlag
+#endif
+#if H_3D_SPIVMP
+        , pbSPIVMPFlag
 #endif
                                         , numValidMergeCand
         );
+#endif
 #else
       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
@@ -3718,12 +3732,26 @@
     pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
+#if !ETRIKHU_CLEANUP_H0083
                                       , vspFlag
+#endif
                                       , inheritedVSPDisInfo
 #endif
 #if H_3D_SPIVMP
-                                      , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+      , pcMvFieldSP, puhInterDirSP
+#endif
+      , numValidMergeCand
+      );
+
+#if ETRIKHU_CLEANUP_H0083
+    pcCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours
+#if H_3D_VSP
+      , vspFlag
+#endif
+#if H_3D_SPIVMP
+      , pbSPIVMPFlag
 #endif
                                       , numValidMergeCand
       );
+#endif
 #else
     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
