Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 724)
@@ -109,8 +109,14 @@
 #define NUM_DEPTH_INTRA_MODE_CTX      8       ///< number of context models for depth intra modes
 #define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (DMM or RBC)
+#if QC_DIM_DELTADC_UNIFY_F0132
+#define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or RBC)
+#else
 #define NUM_DDC_DATA_CTX              2       ///< number of context models for deltaDC data (DMM or RBC)
+#endif
 #if H_3D_DIM_DMM
 #define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
+#if !SEC_DMM3_RBC_F0147
 #define NUM_DMM3_DATA_CTX             1       ///< number of context models for DMM3 data
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -371,7 +377,13 @@
 INIT_ARPW[3][NUM_ARPW_CTX] = 
 {
+#if LGE_ARP_CTX_F0161
+    { 162, 153, 154, 162 },
+    { 162, 153, 154, 162 },
+    { 162, 153, 154, 162 },
+#else
   { 154, 154, 154, 154 }, 
   { 154, 154, 154, 154 }, 
   { 154, 154, 154, 154 }, 
+#endif
 };
 #endif
@@ -381,7 +393,13 @@
 INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] =  
 {
+#if LGE_IC_CTX_F0160
+    { 154,  154,  154, },
+    { 154,  154,  154, },
+    { 154,  154,  154, },
+#else
   { CNU,  CNU,  CNU, }, 
   { 197,  185,  201, }, 
   { 197,  185,  201, }, 
+#endif
 };
 #endif
@@ -405,7 +423,13 @@
 INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] = 
 {
+#if QC_DIM_DELTADC_UNIFY_F0132
+  { 154 }, 
+  { 154 }, 
+  { 154 }, 
+#else
   { CNU, CNU }, 
   { CNU, CNU }, 
   { CNU, CNU }, 
+#endif
 };
 #if H_3D_DIM_DMM
@@ -417,4 +441,5 @@
   { CNU }, 
 };
+#if !SEC_DMM3_RBC_F0147
 static const UChar
 INIT_DMM3_DATA[3][NUM_DMM3_DATA_CTX] = 
@@ -424,4 +449,5 @@
   { CNU }, 
 };
+#endif
 #endif
 #if H_3D_DIM_RBC
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 724)
@@ -120,5 +120,7 @@
     m_dmmWedgeTabIdx[i] = NULL;
   }
+#if !SEC_DMM3_RBC_F0147
   m_dmm3IntraTabIdx = NULL;
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -143,4 +145,7 @@
 #if H_3D_VSP
   m_piVSPFlag            = NULL;
+#endif
+#if MTK_SPIVMP_F0110
+  m_pbSPIVMPFlag         = NULL;
 #endif
 #if H_3D_ARP
@@ -194,4 +199,7 @@
 #if H_3D_VSP
     m_piVSPFlag          = (Char*  )xMalloc(Char,   uiNumPartition);
+#endif
+#if MTK_SPIVMP_F0110
+    m_pbSPIVMPFlag       = (Bool*  )xMalloc(Bool,   uiNumPartition);
 #endif
     m_puhLumaIntraDir    = (UChar* )xMalloc(UChar,  uiNumPartition);
@@ -271,5 +279,7 @@
       m_dmmWedgeTabIdx[i]    = (UInt*)xMalloc(UInt, uiNumPartition);
     }
+#if !SEC_DMM3_RBC_F0147
     m_dmm3IntraTabIdx = (UInt*)xMalloc(UInt, uiNumPartition);
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -352,4 +362,7 @@
     if ( m_piVSPFlag          ) { xFree(m_piVSPFlag);           m_piVSPFlag         = NULL; }
 #endif
+#if MTK_SPIVMP_F0110
+    if ( m_pbSPIVMPFlag       ) { xFree(m_pbSPIVMPFlag);           m_pbSPIVMPFlag         = NULL; }
+#endif
     if ( m_puhLumaIntraDir    ) { xFree(m_puhLumaIntraDir);     m_puhLumaIntraDir   = NULL; }
     if ( m_puhChromaIntraDir  ) { xFree(m_puhChromaIntraDir);   m_puhChromaIntraDir = NULL; }
@@ -404,5 +417,7 @@
       if ( m_dmmWedgeTabIdx[i] ) { xFree( m_dmmWedgeTabIdx[i] ); m_dmmWedgeTabIdx[i] = NULL; }
     }
+#if !SEC_DMM3_RBC_F0147
     if ( m_dmm3IntraTabIdx ) { xFree( m_dmm3IntraTabIdx ); m_dmm3IntraTabIdx = NULL; }
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -555,4 +570,7 @@
 #if H_3D_VSP
     m_piVSPFlag[ui] = pcFrom->m_piVSPFlag[ui];
+#endif
+#if MTK_SPIVMP_F0110
+    m_pbSPIVMPFlag[ui] = pcFrom->m_pbSPIVMPFlag[ui];
 #endif
     m_puhLumaIntraDir[ui]=pcFrom->m_puhLumaIntraDir[ui];
@@ -598,4 +616,7 @@
     memset( m_piVSPFlag         + firstElement, 0,                        numElements * sizeof( *m_piVSPFlag ) );
 #endif
+#if MTK_SPIVMP_F0110
+    memset( m_pbSPIVMPFlag      + firstElement, 0,                        numElements * sizeof( *m_pbSPIVMPFlag ) );
+#endif
     memset( m_puhLumaIntraDir   + firstElement, DC_IDX,                   numElements * sizeof( *m_puhLumaIntraDir ) );
     memset( m_puhChromaIntraDir + firstElement, 0,                        numElements * sizeof( *m_puhChromaIntraDir ) );
@@ -622,5 +643,7 @@
       memset( m_dmmWedgeTabIdx[i] + firstElement, 0,                      numElements * sizeof( *m_dmmWedgeTabIdx[i] ) );
     }
+#if !SEC_DMM3_RBC_F0147
     memset( m_dmm3IntraTabIdx   + firstElement, 0,                        numElements * sizeof( *m_dmm3IntraTabIdx ) );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -776,4 +799,7 @@
       m_piVSPFlag[ui] = 0;
 #endif
+#if MTK_SPIVMP_F0110
+      m_pbSPIVMPFlag[ui] = 0;
+#endif
       m_puhLumaIntraDir[ui] = DC_IDX;
       m_puhChromaIntraDir[ui] = 0;
@@ -799,5 +825,7 @@
         m_dmmWedgeTabIdx[i] [ui] = 0;
       }
+#if !SEC_DMM3_RBC_F0147
       m_dmm3IntraTabIdx [ui] = 0;
+#endif
 #endif
 #if H_3D_DIM_SDC
@@ -873,4 +901,7 @@
 #if H_3D_VSP
   memset( m_piVSPFlag,          0, sizeof( Char  ) * m_uiNumPartition );
+#endif
+#if MTK_SPIVMP_F0110
+  memset( m_pbSPIVMPFlag,       0, sizeof( Bool  ) * m_uiNumPartition );
 #endif
   memset( m_puhLumaIntraDir,    DC_IDX, iSizeInUchar );
@@ -910,5 +941,7 @@
     memset( m_dmmWedgeTabIdx[i], 0, sizeof(UInt) * m_uiNumPartition );
   }
+#if !SEC_DMM3_RBC_F0147
   memset( m_dmm3IntraTabIdx, 0, sizeof(UInt) * m_uiNumPartition );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -968,4 +1001,7 @@
       m_pDvInfo[ ui ] = pcCU->m_pDvInfo[uiPartOffset+ui];
 #endif
+#if MTK_SPIVMP_F0110
+      m_pbSPIVMPFlag[ui]=pcCU->m_pbSPIVMPFlag[uiPartOffset+ui];
+#endif
       m_puhLumaIntraDir[ui]=pcCU->m_puhLumaIntraDir[uiPartOffset+ui];
       m_puhChromaIntraDir[ui]=pcCU->m_puhChromaIntraDir[uiPartOffset+ui];
@@ -992,5 +1028,7 @@
         m_dmmWedgeTabIdx[i] [ui] = pcCU->m_dmmWedgeTabIdx[i] [uiPartOffset+ui];
       }
+#if !SEC_DMM3_RBC_F0147
       m_dmm3IntraTabIdx [ui] = pcCU->m_dmm3IntraTabIdx[uiPartOffset+ui];
+#endif
 #endif
 #if H_3D_DIM_SDC
@@ -1116,4 +1154,7 @@
   m_piVSPFlag           = pcCU->getVSPFlag()          + uiPart;
 #endif
+#if MTK_SPIVMP_F0110
+  m_pbSPIVMPFlag        = pcCU->getSPIVMPFlag()          + uiPart;
+#endif
 
 #if H_3D_ARP
@@ -1146,5 +1187,7 @@
     m_dmmWedgeTabIdx[i] = pcCU->getDmmWedgeTabIdx( i ) + uiPart;
   }
+#if !SEC_DMM3_RBC_F0147
   m_dmm3IntraTabIdx = pcCU->getDmm3IntraTabIdx() + uiPart;
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -1269,4 +1312,7 @@
   m_piVSPFlag          = pcCU->getVSPFlag()               + uiAbsPartIdx;
   m_pDvInfo            = pcCU->getDvInfo()                + uiAbsPartIdx;
+#endif
+#if MTK_SPIVMP_F0110
+  m_pbSPIVMPFlag       = pcCU->getSPIVMPFlag()               + uiAbsPartIdx;
 #endif
 
@@ -1319,4 +1365,7 @@
 
 #endif
+#if MTK_SPIVMP_F0110
+  memcpy( m_pbSPIVMPFlag        + uiOffset, pcCU->getSPIVMPFlag(),        sizeof( Bool ) * uiNumPartition );
+#endif
   memcpy( m_puhLumaIntraDir     + uiOffset, pcCU->getLumaIntraDir(),      iSizeInUchar );
   memcpy( m_puhChromaIntraDir   + uiOffset, pcCU->getChromaIntraDir(),    iSizeInUchar );
@@ -1342,5 +1391,7 @@
     memcpy( m_dmmWedgeTabIdx[i] + uiOffset, pcCU->getDmmWedgeTabIdx( i ), sizeof(UInt) * uiNumPartition );
   }
+#if !SEC_DMM3_RBC_F0147
   memcpy( m_dmm3IntraTabIdx + uiOffset, pcCU->getDmm3IntraTabIdx(), sizeof(UInt) * uiNumPartition );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -1446,4 +1497,7 @@
   memcpy( rpcCU->getDvInfo()            + m_uiAbsIdxInLCU, m_pDvInfo,             sizeof( *m_pDvInfo ) * m_uiNumPartition );
 #endif
+#if MTK_SPIVMP_F0110
+  memcpy( rpcCU->getSPIVMPFlag()        + m_uiAbsIdxInLCU, m_pbSPIVMPFlag,        sizeof( Bool ) * m_uiNumPartition );
+#endif
   memcpy( rpcCU->getLumaIntraDir()      + m_uiAbsIdxInLCU, m_puhLumaIntraDir,     iSizeInUchar );
   memcpy( rpcCU->getChromaIntraDir()    + m_uiAbsIdxInLCU, m_puhChromaIntraDir,   iSizeInUchar );
@@ -1469,5 +1523,7 @@
     memcpy( rpcCU->getDmmWedgeTabIdx( i ) + m_uiAbsIdxInLCU, m_dmmWedgeTabIdx[i], sizeof(UInt) * m_uiNumPartition );
   }
+#if !SEC_DMM3_RBC_F0147
   memcpy( rpcCU->getDmm3IntraTabIdx() + m_uiAbsIdxInLCU, m_dmm3IntraTabIdx, sizeof(UInt) * m_uiNumPartition );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -1559,4 +1615,7 @@
 #if H_3D_VSP
   memcpy( rpcCU->getVSPFlag()           + uiPartOffset, m_piVSPFlag,           sizeof(Char) * uiQNumPart );
+#endif
+#if MTK_SPIVMP_F0110
+  memcpy( rpcCU->getSPIVMPFlag()        + uiPartOffset, m_pbSPIVMPFlag,        sizeof(Bool) * uiQNumPart );
 #endif
   memcpy( rpcCU->getLumaIntraDir()      + uiPartOffset, m_puhLumaIntraDir,     iSizeInUchar );
@@ -1582,5 +1641,7 @@
     memcpy( rpcCU->getDmmWedgeTabIdx( i ) + uiPartOffset, m_dmmWedgeTabIdx[i], sizeof(UInt) * uiQNumPart );
   }
+#if !SEC_DMM3_RBC_F0147
   memcpy( rpcCU->getDmm3IntraTabIdx() + uiPartOffset, m_dmm3IntraTabIdx, sizeof(UInt) * uiQNumPart );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -2313,4 +2374,15 @@
 {
   UInt        uiCtx = 0;
+
+#if LGE_IC_CTX_F0160
+  TComDataCU* pcTempCU = NULL;
+  UInt        uiTempPartIdx = 0;
+
+  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx    = ( pcTempCU ) ? pcTempCU->isIC( uiTempPartIdx ) : 0;
+
+  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx    += ( pcTempCU ) ? pcTempCU->isIC( uiTempPartIdx ) : 0;
+#endif
 
   return uiCtx;
@@ -2672,4 +2744,11 @@
   setSubPart<UChar>( uiMergeIndex, m_puhMergeIndex, uiAbsPartIdx, uiDepth, uiPartIdx );
 }
+
+#if MTK_SPIVMP_F0110
+Void TComDataCU::setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+  setSubPart<Bool>( bSPIVMPFlag, m_pbSPIVMPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+#endif
 
 #if H_3D_VSP
@@ -3266,6 +3345,11 @@
  *   false: otherwise
  */
+#if ETRIKHU_MERGE_REUSE_F0093
+inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
+  Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
+#else
 inline Bool TComDataCU::xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
                                      Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag )
+#endif
 {
   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() )
@@ -3282,4 +3366,8 @@
     return false;
   }
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+#endif
   
   Bool  refViewAvailFlag = false;
@@ -3366,6 +3454,11 @@
 
 #if H_3D_IV_MERGE
+#if ETRIKHU_MERGE_REUSE_F0093
+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  )
+#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 )
+#endif
 {
   for(Int iLoop = 0; iLoop < 2; iLoop ++ ) 
@@ -3385,4 +3478,9 @@
         }
         clipMv( cMv );
+
+#if ETRIKHU_MERGE_REUSE_F0093
+        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+#endif
+
         abCandIsInter        [ iCount ] = true;
         puhInterDirNeighbours[ iCount ] = puhInterDirNeighbours[iFirDispCand];
@@ -3404,13 +3502,26 @@
     if(ivCandDir[iLoop + 2])
     {
+#if ETRIKHU_MERGE_REUSE_F0093
+      TComMvField tmpMV[2];
+      UChar tmpDir = ivCandDir[iLoop + 2];
+#else
       abCandIsInter        [ iCount ] = true;
       puhInterDirNeighbours[ iCount ] = ivCandDir[iLoop + 2];
+#endif
       if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
       {
+#if ETRIKHU_MERGE_REUSE_F0093
+        tmpMV[0].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); 
+#else
         pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); 
+#endif
       }
       if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
       {
+#if ETRIKHU_MERGE_REUSE_F0093
+        tmpMV[1].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
+#else
         pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
+#endif
       }
      
@@ -3419,7 +3530,12 @@
       if( !iLoop && ivCandDir[0] > 0)
       {
+#if ETRIKHU_MERGE_REUSE_F0093
+        if(tmpDir == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0]==tmpMV[0] && pcMvFieldNeighbours[1]==tmpMV[1])
+#else
         if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[0] && pcMvFieldNeighbours[0 ]== pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[1]==pcMvFieldNeighbours[(iCount<<1)+1])
+#endif
         {
             bRemove                         = true;
+#if !ETRIKHU_MERGE_REUSE_F0093
             abCandIsInter        [ iCount ] = false;  
             puhInterDirNeighbours[ iCount ] = 0;
@@ -3427,8 +3543,25 @@
             pcMvFieldNeighbours  [ iCount<<1   ].setMvField( cZeroMv, NOT_VALID );
             pcMvFieldNeighbours  [(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+#endif
         }
       }
       if(!bRemove)
       {
+
+#if ETRIKHU_MERGE_REUSE_F0093
+        rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+
+        abCandIsInter[ iCount ] = true;
+        puhInterDirNeighbours[ iCount ] = ivCandDir[iLoop + 2];
+        if( ( ivCandDir[iLoop + 2] & 1 ) == 1 )
+        {
+          pcMvFieldNeighbours[ iCount<<1 ].setMvField( ivCandMv[ (iLoop<<1) + 4 ], ivCandRefIdx[ (iLoop<<1) + 4 ] ); 
+        }
+        if( ( ivCandDir[iLoop + 2] & 2 ) == 2 )
+        {
+          pcMvFieldNeighbours[ (iCount<<1)+1 ].setMvField( ivCandMv[ (iLoop<<1) + 5 ], ivCandRefIdx[ (iLoop<<1) + 5 ] );
+        }
+#endif
+
 #if H_3D_NBDV
         if(iLoop) // For IvMcShift candidate
@@ -3469,4 +3602,1896 @@
                                       
 #endif
+
+
+
+
+
+
+
+
+
+#if ETRIKHU_MERGE_REUSE_F0093
+Void TComDataCU::rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV)
+{
+  iCount3DV++;
+  for (int i=num; i>0; i--)
+  {
+    pcMvFieldNeighbours[(start+i)<<1].setMvField(pcMvFieldNeighbours[(start+i-1)<<1].getMv(), pcMvFieldNeighbours[(start+i-1)<<1].getRefIdx());
+    pcMvFieldNeighbours[((start+i)<<1)+1].setMvField(pcMvFieldNeighbours[((start+i-1)<<1)+1].getMv(), pcMvFieldNeighbours[((start+i-1)<<1)+1].getRefIdx());
+    puhInterDirNeighbours[start+i] = puhInterDirNeighbours[start+i-1];
+    iVSPIndexTrue[start+i] = iVSPIndexTrue[start+i-1];
+    inheritedVSPDisInfo[start+i].m_acDvInfo   = inheritedVSPDisInfo[start+i-1].m_acDvInfo;
+  }
+  TComMv  cZeroMv;
+  pcMvFieldNeighbours[start<<1].setMvField( cZeroMv, NOT_VALID );
+  pcMvFieldNeighbours[(start<<1)+1].setMvField( cZeroMv, NOT_VALID );
+  puhInterDirNeighbours[start] = 0;
+  iVSPIndexTrue[start] = 0;
+  inheritedVSPDisInfo[start].m_acDvInfo = m_cDefaultDisInfo;
+
+  return;
+}
+
+/** Constructs a list of merging candidates
+ * \param uiAbsPartIdx
+ * \param uiPUIdx 
+ * \param uiDepth
+ * \param pcMvFieldNeighbours
+ * \param puhInterDirNeighbours
+ * \param numValidMergeCand
+ */
+// HM 12.0 based merge candidate list construction
+
+Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx )
+{
+
+  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
+  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
+  TComMv cZeroMv;
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
+  {
+    abCandIsInter[ui] = false;
+    pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
+    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
+  }
+  numValidMergeCand = getSlice()->getMaxNumMergeCand();
+  // compute the location of the current PU
+  Int xP, yP, nPSW, nPSH;
+  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
+
+  Int iCount = 0;
+
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
+  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
+  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
+
+  //left
+  UInt uiLeftPartIdx = 0;
+  TComDataCU* pcCULeft = 0;
+  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
+  Bool isAvailableA1 = pcCULeft &&
+    pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
+    !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
+    !pcCULeft->isIntra( uiLeftPartIdx ) ;
+  if ( isAvailableA1 )
+  {
+    m_bAvailableFlagA1 = 1;
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
+    // get Mv from Left
+    pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+
+    iCount ++;
+  }
+  
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  // above
+  UInt uiAbovePartIdx = 0;
+  TComDataCU* pcCUAbove = 0;
+  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+  Bool isAvailableB1 = pcCUAbove &&
+  pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
+  !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
+  !pcCUAbove->isIntra( uiAbovePartIdx );
+  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
+  {
+    m_bAvailableFlagB1 = 1;
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
+    // get Mv from Left
+    pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+
+  // above right
+  UInt uiAboveRightPartIdx = 0;
+  TComDataCU* pcCUAboveRight = 0;
+  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+  Bool isAvailableB0 = pcCUAboveRight &&
+  pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
+  !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
+  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
+  {
+    m_bAvailableFlagB0 = 1;
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
+    // get Mv from Left
+    pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+
+  //left bottom
+  UInt uiLeftBottomPartIdx = 0;
+  TComDataCU* pcCULeftBottom = 0;
+  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+  Bool isAvailableA0 = pcCULeftBottom &&
+  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
+  !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
+  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
+  {
+    m_bAvailableFlagA0 = 1;
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
+    // get Mv from Left
+    pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  // above left 
+  if( iCount < 4 )
+  {
+    UInt uiAboveLeftPartIdx = 0;
+    TComDataCU* pcCUAboveLeft = 0;
+    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+    Bool isAvailableB2 = pcCUAboveLeft &&
+    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
+    !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
+    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
+        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
+    {
+      m_bAvailableFlagB2 = 1;
+      abCandIsInter[iCount] = true;
+      // get Inter Dir
+      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
+      // get Mv from Left
+      pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+      if ( getSlice()->isInterB() )
+      {
+        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      }
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount ++;
+    }
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  if ( getSlice()->getEnableTMVPFlag())
+  {
+    //>> MTK colocated-RightBottom
+    UInt uiPartIdxRB;
+
+    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );  
+
+    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+    UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+
+    TComMv cColMv;
+    Int iRefIdx;
+    Int uiLCUIdx = -1;
+
+    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
+    {
+    }
+    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
+    {
+    }
+    else
+    {
+      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
+        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+        uiLCUIdx = getAddr();
+      }
+      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
+      }
+      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+        uiLCUIdx = getAddr() + 1;
+      }
+      else //is the right bottom corner of LCU                       
+      {
+        uiAbsPartAddr = 0;
+      }
+    }
+
+    iRefIdx = 0;
+    Bool bExistMV = false;
+    UInt uiPartIdxCenter;
+    UInt uiCurLCUIdx = getAddr();
+    Int dir = 0;
+    UInt uiArrayAddr = iCount;
+    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
+    bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
+    if( bExistMV == false )
+    {
+      bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+    }
+    if( bExistMV )
+    {
+      dir |= 1;
+      pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
+    }
+
+    if ( getSlice()->isInterB() )
+    {
+#if H_3D_TMVP
+      iRefIdx = 0;
+#endif
+      bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
+      if( bExistMV == false )
+      {
+        bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+      }
+      if( bExistMV )
+      {
+        dir |= 2;
+        pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
+      }
+    }
+
+    if (dir != 0)
+    {
+      puhInterDirNeighbours[uiArrayAddr] = dir;
+      abCandIsInter[uiArrayAddr] = true;
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount++;
+    }
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  UInt uiArrayAddr = iCount;
+  UInt uiCutoff = uiArrayAddr;
+  
+  if ( getSlice()->isInterB() && iCount<5)  // JCT3V-F0129 by Qualcomm
+  {
+    UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
+    UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
+
+    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
+    {
+      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
+      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
+      {
+        abCandIsInter[uiArrayAddr] = true;
+        puhInterDirNeighbours[uiArrayAddr] = 3;
+
+        // get Mv from cand[i] and cand[j]
+        pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
+        pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
+
+        Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
+        Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
+        if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
+        {
+          abCandIsInter[uiArrayAddr] = false;
+        }
+        else
+        {
+          uiArrayAddr++;
+        }
+      }
+    }
+  }
+  // early termination
+  if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  
+  Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
+  Int r = 0;
+  Int refcnt = 0;
+  while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
+  {
+    abCandIsInter[uiArrayAddr] = true;
+    puhInterDirNeighbours[uiArrayAddr] = 1;
+    pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
+
+    if ( getSlice()->isInterB() )
+    {
+      puhInterDirNeighbours[uiArrayAddr] = 3;
+      pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
+    }
+    uiArrayAddr++;
+    if ( refcnt == iNumRefIdx - 1 )
+    {
+      r = 0;
+    }
+    else
+    {
+      ++r;
+      ++refcnt;
+    }
+  }
+  
+  numValidMergeCand = uiArrayAddr;
+}
+
+
+
+/** Constructs a list of merging candidates
+ * \param uiAbsPartIdx
+ * \param uiPUIdx 
+ * \param uiDepth
+ * \param pcMvFieldNeighbours
+ * \param puhInterDirNeighbours
+ * \param numValidMergeCand
+ */
+#if ETRIKHU_MERGE_REUSE_F0093
+Void TComDataCU::xGetInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
+#else
+Void TComDataCU::getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours
+#endif
+#if H_3D_VSP
+      , Int* vspFlag
+      , InheritedVSPDisInfo*  inheritedVSPDisInfo
+#endif
+#if MTK_SPIVMP_F0110
+      , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+      , Int& numValidMergeCand, Int mrgCandIdx
+)
+{
+  UInt uiAbsPartAddr = m_uiAbsIdxInLCU + uiAbsPartIdx;
+#if H_3D_IV_MERGE
+  ////////////////////////////
+  //////// INIT LISTS ////////
+  ////////////////////////////
+  TComMv cZeroMv;
+  Bool abCandIsInter[ MRG_MAX_NUM_CANDS_MEM ];
+#else
+  Bool abCandIsInter[ MRG_MAX_NUM_CANDS ];
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+  TComMvField tmpMV[2];
+  UChar tmpDir;
+
+  //////////////////////////////////
+  //////// GET DISPARITIES  ////////
+  //////////////////////////////////
+  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
+  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)
+  {
+    inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo;   // To prevent run-time error, this code must be executed always for merging process.
+  }
+  m_cDefaultDisInfo = cDisInfo;
+
+  if (!( getSlice()->getIsDepth() || getSlice()->getViewIndex()>0))  // current slice is not both dependent view or depth
+  {
+    return;
+  }
+#else
+  for( UInt ui = 0; ui < getSlice()->getMaxNumMergeCand(); ++ui )
+  {
+    abCandIsInter[ui] = false;
+#if H_3D_IV_MERGE
+    pcMvFieldNeighbours[ ( ui << 1 )     ].setMvField(cZeroMv, NOT_VALID);
+    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setMvField(cZeroMv, NOT_VALID);
+#else
+    pcMvFieldNeighbours[ ( ui << 1 )     ].setRefIdx(NOT_VALID);
+    pcMvFieldNeighbours[ ( ui << 1 ) + 1 ].setRefIdx(NOT_VALID);
+#endif
+  }
+#endif
+
+  numValidMergeCand = getSlice()->getMaxNumMergeCand();
+#if H_3D
+  //////////////////////////////////
+  //////// DERIVE LOCATIONS ////////
+  //////////////////////////////////
+#endif
+  // compute the location of the current PU
+  Int xP, yP, nPSW, nPSH;
+  this->getPartPosition(uiPUIdx, xP, yP, nPSW, nPSH);
+
+  Int iCount = 0;
+
+  UInt uiPartIdxLT, uiPartIdxRT, uiPartIdxLB;
+#if !ETRIKHU_MERGE_REUSE_F0093
+  PartSize cCurPS = getPartitionSize( uiAbsPartIdx );
+#endif
+  deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
+  deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Bool bMPIFlag   = getSlice()->getVPS()->getMPIFlag( getSlice()->getLayerIdInVps() );
+#endif
+#if QC_DEPTH_IV_MRG_F0125
+  Bool bIsDepth = getSlice()->getIsDepth();
+#if !BUGFIX_F0093
+  Bool bDepthIPMCAvai = false;
+#endif
+#endif 
+
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+  Bool bICFlag = getICFlag(uiAbsPartIdx);
+#endif
+#if H_3D_ARP
+  Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false;
+#endif
+#endif
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  Int  iPosLeftAbove[2] = {-1, -1};
+
+  Int iCountHEVC = 0;
+  Int iCount3DV = 0;
+  Int numA1B1B0 = 0;
+  Int numA0B2 = 0;
+
+#if H_3D_NBDV
+  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)  
+  {
+    pcMvFieldNeighbours[i<<1    ].getMv().setIDVFlag (false);
+    pcMvFieldNeighbours[(i<<1)+1].getMv().setIDVFlag (false);
+  }
+#endif
+
+  //left
+  UInt uiLeftPartIdx = 0;
+  TComDataCU* pcCULeft = 0;
+  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );  
+  if (getAvailableFlagA1())
+  {
+    iPosLeftAbove[0] = numA1B1B0;
+#if H_3D_VSP
+    if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+    {
+      vspFlag[numA1B1B0] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    numA1B1B0++;
+  }
+
+  // above
+  UInt uiAbovePartIdx = 0;
+  TComDataCU* pcCUAbove = 0;
+  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+  if ( getAvailableFlagB1())
+  {
+    iPosLeftAbove[1] = numA1B1B0;
+#if H_3D_VSP
+#if BUGFIX_2_F0093 && MTK_VSP_SIMPLIFICATION_F0111
+    if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) 
+#else
+    if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1
+#endif
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+    {
+      vspFlag[numA1B1B0] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+
+    numA1B1B0++;
+  }
+
+  // above right
+  UInt uiAboveRightPartIdx = 0;
+  TComDataCU* pcCUAboveRight = 0;
+  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+  if ( getAvailableFlagB0())
+  {
+#if H_3D_VSP
+#if BUGFIX_2_F0093 && MTK_VSP_SIMPLIFICATION_F0111
+    if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) 
+#else
+    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1
+#endif
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+    {
+      vspFlag[numA1B1B0] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    numA1B1B0++;
+  }
+  
+  // left bottom
+  UInt uiLeftBottomPartIdx = 0;
+  TComDataCU* pcCULeftBottom = getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+  if ( getAvailableFlagA0())
+  {
+#if H_3D_VSP
+    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+    {
+      vspFlag[numA1B1B0] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    iCountHEVC++;
+    numA0B2++;
+  }
+  
+  // above left
+  UInt uiAboveLeftPartIdx = 0;
+  TComDataCU* pcCUAboveLeft = 0;
+  pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+  if (getAvailableFlagB2())
+  {
+#if H_3D_VSP
+#if BUGFIX_2_F0093 && MTK_VSP_SIMPLIFICATION_F0111
+    if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) 
+#else
+    if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1
+#endif
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+    {
+      vspFlag[numA1B1B0+iCountHEVC] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    iCountHEVC++;
+    numA0B2++;
+  }
+
+  iCountHEVC = numValidMergeCand;
+#endif
+
+
+#if H_3D_IV_MERGE
+  
+  /////////////////////////////////////////////
+  //////// TEXTURE MERGE CANDIDATE (T) ////////
+  /////////////////////////////////////////////
+  
+#if SEC_MPI_ENABLING_MERGE_F0150
+  if( bMPIFlag)
+#else
+  if( m_pcSlice->getIsDepth())
+#endif
+  {
+    UInt uiPartIdxCenter;
+    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );    
+
+#if ETRIKHU_MERGE_REUSE_F0093
+    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+    Int tRef[2]={-1, -1};
+#endif
+
+#if H_3D_FCO
+    TComPic * pcTexturePic = m_pcSlice->getTexturePic();
+    TComDataCU *pcTextureCU = 0;
+    if ( pcTexturePic )
+        pcTextureCU = pcTexturePic->getCU( getAddr() );
+#else
+    TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() );
+#endif
+ 
+#if H_3D_FCO
+    if ( pcTextureCU && pcTexturePic->getReconMark() && !pcTextureCU->isIntra( uiPartIdxCenter ) )
+#else
+    if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdxCenter ) )
+#endif
+    {
+#if ETRIKHU_MERGE_REUSE_F0093
+      pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, tmpMV[0] );
+      tRef[0] = getPic()->isTextRefValid( REF_PIC_LIST_0, tmpMV[0].getRefIdx() );
+      if( (tmpMV[0].getRefIdx()>=0) && ( tRef[0] >= 0 ) )
+      {
+        TComMv cMvPred = tmpMV[0].getMv();
+        const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+        cMvPred+=cAdd;
+        cMvPred>>=2;
+        clipMv(cMvPred);
+        tmpMV[0].setMvField(cMvPred,tRef[0]);
+      }
+      if ( getSlice()->isInterB() )
+      {
+        pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, tmpMV[1] );
+        tRef[1] = getPic()->isTextRefValid( REF_PIC_LIST_1, tmpMV[1].getRefIdx() );
+        if( (tmpMV[1].getRefIdx()>=0) && ( tRef[1] >= 0) )
+        {
+          TComMv cMvPred = tmpMV[1].getMv();
+          const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+          cMvPred+=cAdd;
+          cMvPred>>=2;
+          clipMv(cMvPred);
+          tmpMV[1].setMvField(cMvPred,tRef[1]);
+        }
+      }
+
+      tmpDir = 0;
+      if( (tmpMV[0].getRefIdx()>=0) && ( tRef[0] >= 0 ) )
+      {
+        tmpDir += ((tmpMV[0].getRefIdx()>=0)?1:0);
+      }
+      if( (tmpMV[1].getRefIdx()>=0) && ( tRef[1] >= 0) )
+      {
+        tmpDir += ((tmpMV[1].getRefIdx()>=0)?2:0);
+      }
+
+      if( tmpDir != 0 )
+      {
+        Int iCnloop = 0;
+        Bool bRemoveSpa = false; //pruning
+
+        for(Int i = 0; i < 2; i ++)
+        {
+          iCnloop = iPosLeftAbove[i];
+          if ( iCnloop == -1 ) 
+          {
+            continue;
+          }
+          if(tmpDir == puhInterDirNeighbours[iCnloop] && tmpMV[0]==pcMvFieldNeighbours[(iCnloop<<1)] && tmpMV[1]==pcMvFieldNeighbours[(iCnloop<<1)+1])
+          {
+            bRemoveSpa                      = true;
+            break;
+          }      
+        }
+
+        if (!bRemoveSpa)
+        {
+          rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
+        }
+        else
+        {
+          rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (iCnloop-iCount), iCount3DV);
+          if (iCnloop<numA1B1B0)
+          {
+            numA1B1B0--;
+          }
+          iCountHEVC--;
+
+          if (iPosLeftAbove[0] != -1)
+          {
+            if (iCnloop == iPosLeftAbove[0])
+            {
+              iPosLeftAbove[0] = -1;
+            }
+            else
+            {
+              iPosLeftAbove[0]++;
+            }
+          }
+          if (iPosLeftAbove[1] != -1)
+          {
+            if (iCnloop == iPosLeftAbove[1])
+            {
+              iPosLeftAbove[1] = -1;
+            }
+            else
+            {
+              if (iCnloop > iPosLeftAbove[1])
+              {
+                iPosLeftAbove[1]++;
+              }
+            }
+          }
+        }
+
+        if( (tmpMV[0].getRefIdx()>=0) && ( tRef[0] >= 0 ) )
+        {
+          pcMvFieldNeighbours[iCount<<1].setMvField(tmpMV[0].getMv(), tRef[0]);
+        }
+        if ( getSlice()->isInterB())
+        {
+          if( (tmpMV[1].getRefIdx()>=0) && ( tRef[1] >= 0) )
+          {
+            pcMvFieldNeighbours[(iCount<<1)+1].setMvField(tmpMV[1].getMv(), tRef[1]);
+          }
+        }
+        puhInterDirNeighbours[iCount] = tmpDir;
+
+        if ( mrgCandIdx == iCount )
+        {
+          return;
+        }
+        iCount ++;
+
+#else
+      pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+      Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1].getRefIdx() );
+      if( (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
+      {
+        TComMv cMvPred = pcMvFieldNeighbours[iCount<<1].getMv();
+        const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+        cMvPred+=cAdd;
+        cMvPred>>=2;
+        clipMv(cMvPred);
+        pcMvFieldNeighbours[iCount<<1].setMvField(cMvPred,iValidDepRef);
+      }
+      if ( getSlice()->isInterB() )
+      {
+        pcTextureCU->getMvField( pcTextureCU, uiPartIdxCenter, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+        iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx() );
+        if( (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0) && ( iValidDepRef >= 0) )
+        {
+          TComMv cMvPred = pcMvFieldNeighbours[(iCount<<1)+1].getMv();
+          const TComMv cAdd( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+          cMvPred+=cAdd;
+          cMvPred>>=2;
+          clipMv(cMvPred);
+          pcMvFieldNeighbours[(iCount<<1)+1].setMvField(cMvPred,iValidDepRef);
+        }
+      }
+      puhInterDirNeighbours[iCount] = (pcMvFieldNeighbours[iCount<<1].getRefIdx()>=0)?1:0;
+      puhInterDirNeighbours[iCount] += (pcMvFieldNeighbours[(iCount<<1)+1].getRefIdx()>=0)?2:0;
+      if( puhInterDirNeighbours[iCount] != 0 )
+      {
+        abCandIsInter[iCount] = true;
+        if ( mrgCandIdx == iCount )
+        {
+          return;
+        }
+        iCount ++;
+      }
+#endif
+      }
+    }
+  }
+
+
+#if !ETRIKHU_MERGE_REUSE_F0093
+  //////////////////////////////////
+  //////// GET DISPARITIES  ////////
+  //////////////////////////////////
+
+  DisInfo cDisInfo = getDvInfo(uiAbsPartIdx);
+  for(Int i = 0; i < MRG_MAX_NUM_CANDS_MEM; i++)
+  {
+    inheritedVSPDisInfo[i].m_acDvInfo = cDisInfo;
+  }
+#endif
+
+  /////////////////////////////////////////////////////////////////
+  //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
+  /////////////////////////////////////////////////////////////////
+
+  Int  posIvDC          = -1;
+#if !ETRIKHU_MERGE_REUSE_F0093
+  Bool bLeftAvai        = false;
+  Int  iPosLeftAbove[2] = {-1, -1};
+#endif
+
+  // { IvMCL0, IvMCL1, IvDCL0, IvDCL1, IvMCL0Shift, IvMCL1Shift, IvDCL0Shift, IvDCL1Shift };  
+  // An enumerator would be appropriate here! 
+  TComMv ivCandMv    [8];
+  Int    ivCandRefIdx[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
+
+  // { IvMC, IvDC, IvMCShift, IvDCShift };  
+  Int    ivCandDir   [4] = {0, 0, 0, 0};
+
+  Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
+  
+  if ( ivMvPredFlag )
+  {
+    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir 
+#if QC_DEPTH_IV_MRG_F0125
+    , bIsDepth
+#endif
+#if MTK_SPIVMP_F0110
+    , pcMvFieldSP, puhInterDirSP
+#endif
+    );
+  }  
+  
+  ///////////////////////////////////////////////
+  //////// INTER VIEW MOTION COMP(IvMC) /////////
+  ///////////////////////////////////////////////
+
+  if( ivCandDir[0] )
+  {
+#if ETRIKHU_MERGE_REUSE_F0093
+    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+
+    if( ( ivCandDir[0] & 1 ) == 1 )
+    {
+      tmpMV[0].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
+    }
+    if( ( ivCandDir[0] & 2 ) == 2 )
+    {
+      tmpMV[1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
+    }
+
+    Bool bRemoveSpa = false; //pruning
+    Bool bIvMC = false;
+    Int iCnloop=0;
+
+#if BUGFIX_F0093
+    if (!bIsDepth)
+    {
+#endif
+      for(Int i = 0; i < 2; i ++)
+      {
+        iCnloop = iPosLeftAbove[i];
+        if ( iCnloop == -1 ) 
+        {
+          continue;
+        }
+        if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && tmpMV[0]==pcMvFieldNeighbours[(iCnloop<<1)] && tmpMV[1]==pcMvFieldNeighbours[(iCnloop<<1)+1])
+        {
+          bRemoveSpa                      = true;
+          break;
+        }      
+      }
+#if BUGFIX_F0093
+    }
+#endif
+#if QC_DEPTH_IV_MRG_F0125
+#if BUGFIX_F0093
+    if (bIsDepth)
+#else
+    if ( bIsDepth && !bRemoveSpa)
+#endif
+    {
+      iCnloop = iCount-1;
+      for(; iCnloop >= 0; iCnloop --)
+      {
+#if BUGFIX_F0093
+        if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==tmpMV[0] && pcMvFieldNeighbours[(iCnloop<<1)+1]==tmpMV[1])  // F0125 compatible with F0093
+#else
+        if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+#endif
+        {
+          bRemoveSpa                      = true;
+          break;
+        }
+      }
+#if !BUGFIX_F0093
+      if(!bRemoveSpa)
+      {
+        bDepthIPMCAvai = true;
+      }
+#endif
+    }
+#endif
+
+    if (!bRemoveSpa)
+    {
+      bIvMC = true;
+      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+
+      if (iPosLeftAbove[0] != -1)
+      {
+        iPosLeftAbove[0]++;
+      }
+      if (iPosLeftAbove[1] != -1)
+      {
+        iPosLeftAbove[1]++;
+      }
+    }
+    else if (bRemoveSpa && !bIsDepth)
+    {
+      bIvMC = true;
+      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (iCnloop-iCount), iCount3DV);
+
+      if (iCnloop<numA1B1B0)
+      {
+        numA1B1B0--;
+      }
+      iCountHEVC--;
+
+      if (iPosLeftAbove[0] != -1)
+      {
+        if (iCnloop == iPosLeftAbove[0])
+        {
+          iPosLeftAbove[0] = -1;
+        }
+        else
+        {
+          iPosLeftAbove[0]++;
+        }
+      }
+      if (iPosLeftAbove[1] != -1)
+      {
+        if (iCnloop == iPosLeftAbove[1])
+        {
+          iPosLeftAbove[1] = -1;
+        }
+        else
+        {
+          if (iCnloop > iPosLeftAbove[1])
+          {
+            iPosLeftAbove[1]++;
+          }
+        }
+      }
+    }
+
+    if (bIvMC)
+    {
+#if MTK_SPIVMP_F0110
+      pbSPIVMPFlag[iCount] = true;
+#endif
+      if( ( ivCandDir[0] & 1 ) == 1 )
+      {
+        pcMvFieldNeighbours[iCount<<1].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
+      }
+      if( ( ivCandDir[0] & 2 ) == 2 )
+      {
+        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
+      }
+
+      puhInterDirNeighbours[ iCount ] = ivCandDir[0];
+
+#if !BUGFIX_F0093
+#if QC_DEPTH_IV_MRG_F0125
+      if ( bDepthIPMCAvai || !bIsDepth )
+      {
+#endif
+#endif
+        if ( mrgCandIdx == iCount )
+        {
+          return;
+        }
+        iCount ++;
+#if !BUGFIX_F0093
+#if QC_DEPTH_IV_MRG_F0125
+      }
+#endif
+#endif
+    }
+#else
+    abCandIsInter        [ iCount ] = true;
+    puhInterDirNeighbours[ iCount ] = ivCandDir[0];    
+
+    if( ( ivCandDir[0] & 1 ) == 1 )
+    {
+      pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 0 ], ivCandRefIdx[ 0 ] );
+    }
+    if( ( ivCandDir[0] & 2 ) == 2 )
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 1 ], ivCandRefIdx[ 1 ] );
+    }
+#if QC_DEPTH_IV_MRG_F0125
+    if ( bIsDepth )
+    {
+      Bool bRemoveSpa = false;
+      Int iCnloop = iCount-1;
+      for(; iCnloop >= 0; iCnloop --)
+      {
+        if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+        {
+          bRemoveSpa                      = true;
+          abCandIsInter        [ iCount ] = false;
+
+          puhInterDirNeighbours[iCount]   = 0;
+          pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
+          pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+          break;
+        }
+      }
+      if(!bRemoveSpa)
+      {
+        bDepthIPMCAvai = true;
+      }
+    }
+    if ( bDepthIPMCAvai || !bIsDepth )
+    {
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount ++;
+#if QC_DEPTH_IV_MRG_F0125
+    }
+#endif
+
+#endif
+
+  } 
+
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#endif
+
+
+
+
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  iCount += numA1B1B0;
+#else
+#if H_3D
+  ////////////////////////////
+  //////// LEFT (A1) /////////
+  ////////////////////////////
+#endif
+  //left
+  UInt uiLeftPartIdx = 0;
+  TComDataCU* pcCULeft = 0;
+  pcCULeft = getPULeft( uiLeftPartIdx, uiPartIdxLB );
+  Bool isAvailableA1 = pcCULeft &&
+    pcCULeft->isDiffMER(xP -1, yP+nPSH-1, xP, yP) &&
+    !( uiPUIdx == 1 && (cCurPS == SIZE_Nx2N || cCurPS == SIZE_nLx2N || cCurPS == SIZE_nRx2N) ) &&
+    !pcCULeft->isIntra( uiLeftPartIdx ) ;
+  if ( isAvailableA1 )
+  {
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCULeft->getInterDir( uiLeftPartIdx );
+    // get Mv from Left
+    pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCULeft->getMvField( pcCULeft, uiLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+#if H_3D_IV_MERGE 
+    Bool bRemoveSpa = false; //pruning to inter-view candidates
+#if QC_DEPTH_IV_MRG_F0125
+    Int  iCnloop = bDepthIPMCAvai ? (iCount-2): (iCount-1);
+#else
+    Int  iCnloop    = iCount - 1;
+#endif
+    for(; iCnloop >= 0; iCnloop --)
+    {
+      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+      {
+        bRemoveSpa                      = true;
+        abCandIsInter        [ iCount ] = false;
+
+        //reset to the default value for MC
+        puhInterDirNeighbours[iCount]   = 0;
+        pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
+        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+        break;
+      }
+    }
+    if(!bRemoveSpa)
+    {
+      bLeftAvai = true;
+      iPosLeftAbove[0] = iCount;
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+#if H_3D_VSP
+      if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+      {
+        vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+        xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+      }
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount ++;
+    }
+#else // H_3D_IV_MERGE 
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+#endif // H_3D_IV_MERGE 
+  }
+
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#if H_3D
+  ////////////////////////////
+  //////// ABOVE (B1) ////////
+  ////////////////////////////
+#endif
+  // above
+  UInt uiAbovePartIdx = 0;
+  TComDataCU* pcCUAbove = 0;
+  pcCUAbove = getPUAbove( uiAbovePartIdx, uiPartIdxRT );
+  Bool isAvailableB1 = pcCUAbove &&
+    pcCUAbove->isDiffMER(xP+nPSW-1, yP-1, xP, yP) &&
+    !( uiPUIdx == 1 && (cCurPS == SIZE_2NxN || cCurPS == SIZE_2NxnU || cCurPS == SIZE_2NxnD) ) &&
+    !pcCUAbove->isIntra( uiAbovePartIdx );
+  if ( isAvailableB1 && (!isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAbove, uiAbovePartIdx ) ) )
+  {
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCUAbove->getInterDir( uiAbovePartIdx );
+    // get Mv from Left
+    pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCUAbove->getMvField( pcCUAbove, uiAbovePartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+#if H_3D_IV_MERGE 
+    Bool bRemoveSpa = false; //pruning to inter-view candidates
+#if QC_DEPTH_IV_MRG_F0125
+    Int iCnloop;
+    if( bIsDepth )
+      iCnloop = (bLeftAvai && bDepthIPMCAvai) ? (iCount-3) : ((bLeftAvai || bDepthIPMCAvai)  ? (iCount-2): (iCount-1));
+    else
+      iCnloop = bLeftAvai? (iCount-2): (iCount-1);
+#else
+    Int  iCnloop    = bLeftAvai? (iCount-2): (iCount-1);
+#endif
+    for(; iCnloop >= 0; iCnloop --)
+    {
+      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+      {
+        bRemoveSpa                      = true;
+        abCandIsInter        [ iCount ] = false;
+
+        //reset to the default value for MC
+        puhInterDirNeighbours[iCount]   = 0;
+
+        pcMvFieldNeighbours[iCount<<1]    .setMvField( cZeroMv, NOT_VALID );
+        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+        break;
+      }
+    }
+
+    if(!bRemoveSpa)
+    {
+      iPosLeftAbove[1] = iCount;
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+#if H_3D_VSP
+#if MTK_VSP_SIMPLIFICATION_F0111
+      if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+#else
+      if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+#endif
+      {
+
+        vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+        xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo);
+#endif
+      }
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount ++;
+    }
+#else // H_3D_IV_MERGE 
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+#endif // H_3D_IV_MERGE 
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+
+#if H_3D
+  //////////////////////////////////
+  //////// ABOVE RIGHT (B0) ////////
+  //////////////////////////////////
+#endif
+
+  // above right
+  UInt uiAboveRightPartIdx = 0;
+  TComDataCU* pcCUAboveRight = 0;
+  pcCUAboveRight = getPUAboveRight( uiAboveRightPartIdx, uiPartIdxRT );
+  Bool isAvailableB0 = pcCUAboveRight &&
+    pcCUAboveRight->isDiffMER(xP+nPSW, yP-1, xP, yP) &&
+    !pcCUAboveRight->isIntra( uiAboveRightPartIdx );
+  if ( isAvailableB0 && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveRight, uiAboveRightPartIdx ) ) )
+  {
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCUAboveRight->getInterDir( uiAboveRightPartIdx );
+    // get Mv from Left
+    pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCUAboveRight->getMvField( pcCUAboveRight, uiAboveRightPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+#if H_3D_NBDV
+    pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+#if H_3D_VSP
+#if MTK_VSP_SIMPLIFICATION_F0111
+    if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+#else
+    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      && !bICFlag
+#endif
+#if H_3D_ARP
+      && !bARPFlag
+#endif
+#endif
+      )
+#endif
+    {
+      vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#endif
+
+
+#if H_3D_IV_MERGE 
+  /////////////////////////////////////////////
+  //////// INTER VIEW DISP COMP (IvDC) ////////
+  /////////////////////////////////////////////
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand())
+#else
+  if( ivCandDir[1] )
+#endif
+  {
+    assert(iCount < getSlice()->getMaxNumMergeCand());
+
+#if ETRIKHU_MERGE_REUSE_F0093
+    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+    if( ( ivCandDir[1] & 1 ) == 1 )
+    {
+      tmpMV[0].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
+    }
+    if( ( ivCandDir[1] & 2 ) == 2 )
+    {
+      tmpMV[1].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
+    }
+#else
+    abCandIsInter        [ iCount ] = true;
+    puhInterDirNeighbours[ iCount ] = ivCandDir[1];
+    if( ( ivCandDir[1] & 1 ) == 1 )
+    {
+      pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
+    }
+    if( ( ivCandDir[1] & 2 ) == 2 )
+    {
+      pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
+    }
+#endif
+
+    Bool bRemoveSpa = false; //pruning to A1, B1
+    for(Int i = 0; i < 2; i ++)
+    {
+      Int iCnloop = iPosLeftAbove[i];
+      if ( iCnloop == -1 ) 
+      {
+        continue;
+      }
+      if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+      {
+        bRemoveSpa                      = true;
+#if !ETRIKHU_MERGE_REUSE_F0093
+        abCandIsInter        [ iCount ] = false;
+        //reset to the default value for MC
+        puhInterDirNeighbours[iCount]   = 0;
+        pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
+        pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+#endif
+        break;
+      }      
+    }
+    if(!bRemoveSpa)
+    {
+#if ETRIKHU_MERGE_REUSE_F0093
+      rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, (5-iCount), iCount3DV);
+      puhInterDirNeighbours[ iCount ] = ivCandDir[1];
+      if( ( ivCandDir[1] & 1 ) == 1 )
+      {
+        pcMvFieldNeighbours[ iCount<<1    ].setMvField( ivCandMv[ 2 ], ivCandRefIdx[ 2 ] );
+      }
+      if( ( ivCandDir[1] & 2 ) == 2 )
+      {
+        pcMvFieldNeighbours[(iCount<<1)+1 ].setMvField( ivCandMv[ 3 ], ivCandRefIdx[ 3 ] );
+      }
+#endif
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+      posIvDC  = iCount;
+      if ( mrgCandIdx == iCount )
+        return;
+      iCount ++;
+
+      // early termination
+      if (iCount == getSlice()->getMaxNumMergeCand()) 
+      {
+        return;
+      }
+    }
+  } 
+#endif // H_3D_IV_MERGE 
+
+#if H_3D_VSP
+  /////////////////////////////////////////////////
+  //////// VIEW SYNTHESIS PREDICTION (VSP) ////////
+  /////////////////////////////////////////////////
+#if ETRIKHU_MERGE_REUSE_F0093
+  if (iCount<getSlice()->getMaxNumMergeCand())
+  {
+#endif
+
+  if (
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      !bICFlag &&
+#endif
+#if H_3D_ARP
+      !bARPFlag &&
+#endif
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
+#else
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
+#endif
+  {
+    return;
+  }
+
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand())
+  {
+    return;
+  }
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+  }
+#endif
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  iCount += numA0B2;
+#else
+#if H_3D
+  ///////////////////////////////////
+  //////// LEFT BOTTOM (A0) ////////
+  ///////////////////////////////////
+#endif
+
+  //left bottom
+  UInt uiLeftBottomPartIdx = 0;
+  TComDataCU* pcCULeftBottom = 0;
+  pcCULeftBottom = this->getPUBelowLeft( uiLeftBottomPartIdx, uiPartIdxLB );
+  Bool isAvailableA0 = pcCULeftBottom &&
+  pcCULeftBottom->isDiffMER(xP-1, yP+nPSH, xP, yP) &&
+  !pcCULeftBottom->isIntra( uiLeftBottomPartIdx ) ;
+  if ( isAvailableA0 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCULeftBottom, uiLeftBottomPartIdx ) ) )
+  {
+    abCandIsInter[iCount] = true;
+    // get Inter Dir
+    puhInterDirNeighbours[iCount] = pcCULeftBottom->getInterDir( uiLeftBottomPartIdx );
+    // get Mv from Left
+    pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+    if ( getSlice()->isInterB() )
+    {
+      pcCULeftBottom->getMvField( pcCULeftBottom, uiLeftBottomPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+    }
+#if H_3D_NBDV
+    pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+    pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+#if H_3D_VSP
+    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+    {
+      vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+      xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+    }
+#endif
+    if ( mrgCandIdx == iCount )
+    {
+      return;
+    }
+    iCount ++;
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#if H_3D
+  ///////////////////////////////////
+  //////// LEFT ABOVE (B2) ////////
+  ///////////////////////////////////
+#endif
+
+  // above left 
+  if( iCount < 4 )
+  {
+    UInt uiAboveLeftPartIdx = 0;
+    TComDataCU* pcCUAboveLeft = 0;
+    pcCUAboveLeft = getPUAboveLeft( uiAboveLeftPartIdx, uiAbsPartAddr );
+    Bool isAvailableB2 = pcCUAboveLeft &&
+    pcCUAboveLeft->isDiffMER(xP-1, yP-1, xP, yP) &&
+    !pcCUAboveLeft->isIntra( uiAboveLeftPartIdx );
+    if ( isAvailableB2 && ( !isAvailableA1 || !pcCULeft->hasEqualMotion( uiLeftPartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) )
+        && ( !isAvailableB1 || !pcCUAbove->hasEqualMotion( uiAbovePartIdx, pcCUAboveLeft, uiAboveLeftPartIdx ) ) )
+    {
+      abCandIsInter[iCount] = true;
+      // get Inter Dir
+      puhInterDirNeighbours[iCount] = pcCUAboveLeft->getInterDir( uiAboveLeftPartIdx );
+      // get Mv from Left
+      pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_0, pcMvFieldNeighbours[iCount<<1] );
+      if ( getSlice()->isInterB() )
+      {
+        pcCUAboveLeft->getMvField( pcCUAboveLeft, uiAboveLeftPartIdx, REF_PIC_LIST_1, pcMvFieldNeighbours[(iCount<<1)+1] );
+      }
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+#if H_3D_VSP
+#if MTK_VSP_SIMPLIFICATION_F0111
+      if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#else
+      if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#endif
+      {
+        vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
+        xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
+      }
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount ++;
+    }
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+#endif
+
+
+#if H_3D_IV_MERGE
+  ////////////////////////////////////////////////////
+  //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
+  ////////////////////////////////////////////////////
+#if ETRIKHU_MERGE_REUSE_F0093
+  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() ) 
+  {
+    if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
+#else
+  if(  ivMvPredFlag  ) 
+  {
+    if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag))
+#endif
+    {
+      return;
+    }
+    //early termination
+    if (iCount == getSlice()->getMaxNumMergeCand()) 
+    {
+      return;
+    }
+  }
+#endif
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  if (iCountHEVC + iCount3DV > getSlice()->getMaxNumMergeCand())
+  {
+    iCount = getSlice()->getMaxNumMergeCand();
+  }
+  else
+  {
+    iCount = iCountHEVC + iCount3DV;
+  }
+  numValidMergeCand = iCount;
+#else
+#if H_3D
+  /////////////////////////////////
+  //////// Collocate (COL) ////////
+  /////////////////////////////////
+#endif
+  if ( getSlice()->getEnableTMVPFlag())
+  {
+    //>> MTK colocated-RightBottom
+    UInt uiPartIdxRB;
+
+    deriveRightBottomIdx( uiPUIdx, uiPartIdxRB );  
+
+    UInt uiAbsPartIdxTmp = g_auiZscanToRaster[uiPartIdxRB];
+    UInt uiNumPartInCUWidth = m_pcPic->getNumPartInWidth();
+
+    TComMv cColMv;
+    Int iRefIdx;
+    Int uiLCUIdx = -1;
+
+    if      ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelX() + g_auiRasterToPelX[uiAbsPartIdxTmp] + m_pcPic->getMinCUWidth() ) >= m_pcSlice->getSPS()->getPicWidthInLumaSamples() )  // image boundary check
+    {
+    }
+    else if ( ( m_pcPic->getCU(m_uiCUAddr)->getCUPelY() + g_auiRasterToPelY[uiAbsPartIdxTmp] + m_pcPic->getMinCUHeight() ) >= m_pcSlice->getSPS()->getPicHeightInLumaSamples() )
+    {
+    }
+    else
+    {
+      if ( ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 ) &&           // is not at the last column of LCU 
+        ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) ) // is not at the last row    of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + uiNumPartInCUWidth + 1 ];
+        uiLCUIdx = getAddr();
+      }
+      else if ( uiAbsPartIdxTmp % uiNumPartInCUWidth < uiNumPartInCUWidth - 1 )           // is not at the last column of LCU But is last row of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ (uiAbsPartIdxTmp + uiNumPartInCUWidth + 1) % m_pcPic->getNumPartInCU() ];
+      }
+      else if ( uiAbsPartIdxTmp / uiNumPartInCUWidth < m_pcPic->getNumPartInHeight() - 1 ) // is not at the last row of LCU But is last column of LCU
+      {
+        uiAbsPartAddr = g_auiRasterToZscan[ uiAbsPartIdxTmp + 1 ];
+        uiLCUIdx = getAddr() + 1;
+      }
+      else //is the right bottom corner of LCU                       
+      {
+        uiAbsPartAddr = 0;
+      }
+    }
+    
+    
+    iRefIdx = 0;
+    Bool bExistMV = false;
+    UInt uiPartIdxCenter;
+    UInt uiCurLCUIdx = getAddr();
+    Int dir = 0;
+    UInt uiArrayAddr = iCount;
+    xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );
+    bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_0, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx );
+    if( bExistMV == false )
+    {
+      bExistMV = xGetColMVP( REF_PIC_LIST_0, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+    }
+    if( bExistMV )
+    {
+      dir |= 1;
+      pcMvFieldNeighbours[ 2 * uiArrayAddr ].setMvField( cColMv, iRefIdx );
+    }
+
+    if ( getSlice()->isInterB() )
+    {
+#if H_3D_TMVP
+      iRefIdx = 0;
+#endif
+      bExistMV = uiLCUIdx >= 0 && xGetColMVP( REF_PIC_LIST_1, uiLCUIdx, uiAbsPartAddr, cColMv, iRefIdx);
+      if( bExistMV == false )
+      {
+        bExistMV = xGetColMVP( REF_PIC_LIST_1, uiCurLCUIdx, uiPartIdxCenter, cColMv, iRefIdx );
+      }
+      if( bExistMV )
+      {
+        dir |= 2;
+        pcMvFieldNeighbours[ 2 * uiArrayAddr + 1 ].setMvField( cColMv, iRefIdx );
+      }
+    }
+    
+    if (dir != 0)
+    {
+      puhInterDirNeighbours[uiArrayAddr] = dir;
+      abCandIsInter[uiArrayAddr] = true;
+#if H_3D_NBDV
+      pcMvFieldNeighbours[iCount<<1    ].getMv().setIDVFlag (false);
+      pcMvFieldNeighbours[(iCount<<1)+1].getMv().setIDVFlag (false);
+#endif
+      if ( mrgCandIdx == iCount )
+      {
+        return;
+      }
+      iCount++;
+    }
+  }
+  // early termination
+  if (iCount == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  UInt uiArrayAddr = iCount;
+  UInt uiCutoff = uiArrayAddr;
+    
+  if ( getSlice()->isInterB())
+  {
+#if H_3D_IV_MERGE
+    UInt uiPriorityList0[20] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3,    0, 4, 1, 4, 2, 4, 3, 4 };
+    UInt uiPriorityList1[20] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2,    4, 0, 4, 1, 4, 2, 4, 3 };
+#else
+    UInt uiPriorityList0[12] = {0 , 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3};
+    UInt uiPriorityList1[12] = {1 , 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2};
+#endif
+
+    for (Int idx=0; idx<uiCutoff*(uiCutoff-1) && uiArrayAddr!= getSlice()->getMaxNumMergeCand(); idx++)
+    {
+      Int i = uiPriorityList0[idx]; Int j = uiPriorityList1[idx];
+#if H_3D_VSP
+      Bool bValid = true;
+      if ( vspFlag[i] == 1 || vspFlag[j] == 1 )
+      {
+        bValid = false;
+      }
+      if( !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) )
+      {
+        assert(bValid == true);
+      }
+#endif
+#if H_3D_VSP
+      if (abCandIsInter[i] && abCandIsInter[j] && (puhInterDirNeighbours[i]&0x1) && (puhInterDirNeighbours[j]&0x2) && bValid)
+#else
+      if (abCandIsInter[i] && abCandIsInter[j]&& (puhInterDirNeighbours[i]&0x1)&&(puhInterDirNeighbours[j]&0x2))
+#endif
+      {
+        abCandIsInter[uiArrayAddr] = true;
+        puhInterDirNeighbours[uiArrayAddr] = 3;
+
+        // get Mv from cand[i] and cand[j]
+        pcMvFieldNeighbours[uiArrayAddr << 1].setMvField(pcMvFieldNeighbours[i<<1].getMv(), pcMvFieldNeighbours[i<<1].getRefIdx());
+        pcMvFieldNeighbours[( uiArrayAddr << 1 ) + 1].setMvField(pcMvFieldNeighbours[(j<<1)+1].getMv(), pcMvFieldNeighbours[(j<<1)+1].getRefIdx());
+
+        Int iRefPOCL0 = m_pcSlice->getRefPOC( REF_PIC_LIST_0, pcMvFieldNeighbours[(uiArrayAddr<<1)].getRefIdx() );
+        Int iRefPOCL1 = m_pcSlice->getRefPOC( REF_PIC_LIST_1, pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getRefIdx() );
+        if (iRefPOCL0 == iRefPOCL1 && pcMvFieldNeighbours[(uiArrayAddr<<1)].getMv() == pcMvFieldNeighbours[(uiArrayAddr<<1)+1].getMv())
+        {
+          abCandIsInter[uiArrayAddr] = false;
+        }
+        else
+        {
+          uiArrayAddr++;
+        }
+      }
+    }
+  }
+  // early termination
+  if (uiArrayAddr == getSlice()->getMaxNumMergeCand()) 
+  {
+    return;
+  }
+  Int iNumRefIdx = (getSlice()->isInterB()) ? min(m_pcSlice->getNumRefIdx(REF_PIC_LIST_0), m_pcSlice->getNumRefIdx(REF_PIC_LIST_1)) : m_pcSlice->getNumRefIdx(REF_PIC_LIST_0);
+  Int r = 0;
+  Int refcnt = 0;
+  while (uiArrayAddr < getSlice()->getMaxNumMergeCand())
+  {
+    abCandIsInter[uiArrayAddr] = true;
+    puhInterDirNeighbours[uiArrayAddr] = 1;
+    pcMvFieldNeighbours[uiArrayAddr << 1].setMvField( TComMv(0, 0), r);
+
+    if ( getSlice()->isInterB() )
+    {
+      puhInterDirNeighbours[uiArrayAddr] = 3;
+      pcMvFieldNeighbours[(uiArrayAddr << 1) + 1].setMvField(TComMv(0, 0), r);
+    }
+    uiArrayAddr++;
+    if ( refcnt == iNumRefIdx - 1 )
+    {
+      r = 0;
+    }
+    else
+    {
+      ++r;
+      ++refcnt;
+    }
+  }
+
+  numValidMergeCand = uiArrayAddr;
+#endif
+}
+
+
+
+
+#else
+
 /** Constructs a list of merging candidates
  * \param uiAbsPartIdx
@@ -3522,4 +5547,21 @@
   deriveLeftRightTopIdxGeneral( uiAbsPartIdx, uiPUIdx, uiPartIdxLT, uiPartIdxRT );
   deriveLeftBottomIdxGeneral  ( uiAbsPartIdx, uiPUIdx, uiPartIdxLB );
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Bool bMPIFlag   = getSlice()->getVPS()->getMPIFlag( getSlice()->getLayerIdInVps() );
+#endif
+#if QC_DEPTH_IV_MRG_F0125
+  Bool bIsDepth = getSlice()->getIsDepth();
+  Bool bDepthIPMCAvai = false;
+#endif 
+
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+  Bool bICFlag = getICFlag(uiAbsPartIdx);
+#endif
+#if H_3D_ARP
+  Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false;
+#endif
+#endif
+
 #if H_3D_IV_MERGE
   
@@ -3528,5 +5570,9 @@
   /////////////////////////////////////////////
 
+#if SEC_MPI_ENABLING_MERGE_F0150
+  if( bMPIFlag)
+#else
   if( m_pcSlice->getIsDepth())
+#endif
   {
     UInt uiPartIdxCenter;
@@ -3621,5 +5667,9 @@
   if ( ivMvPredFlag )
   {
-    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir );
+    getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir 
+#if QC_DEPTH_IV_MRG_F0125
+    , bIsDepth
+#endif
+    );
   }  
   
@@ -3642,4 +5692,30 @@
     }
 
+#if QC_DEPTH_IV_MRG_F0125
+    if ( bIsDepth )
+    {
+      Bool bRemoveSpa = false;
+      Int iCnloop = iCount-1;
+      for(; iCnloop >= 0; iCnloop --)
+      {
+        if(puhInterDirNeighbours[iCount] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==pcMvFieldNeighbours[(iCount<<1)] && pcMvFieldNeighbours[(iCnloop<<1)+1]==pcMvFieldNeighbours[(iCount<<1)+1])
+        {
+          bRemoveSpa                      = true;
+          abCandIsInter        [ iCount ] = false;
+
+          puhInterDirNeighbours[iCount]   = 0;
+          pcMvFieldNeighbours[iCount<<1].setMvField( cZeroMv, NOT_VALID );
+          pcMvFieldNeighbours[(iCount<<1)+1].setMvField( cZeroMv, NOT_VALID );
+          break;
+        }
+      }
+      if(!bRemoveSpa)
+      {
+        bDepthIPMCAvai = true;
+      }
+    }
+    if ( bDepthIPMCAvai || !bIsDepth )
+    {
+#endif
     if ( mrgCandIdx == iCount )
     {
@@ -3647,4 +5723,7 @@
     }
     iCount ++;
+#if QC_DEPTH_IV_MRG_F0125
+    }
+#endif
   } 
 
@@ -3682,5 +5761,9 @@
 #if H_3D_IV_MERGE 
     Bool bRemoveSpa = false; //pruning to inter-view candidates
+#if QC_DEPTH_IV_MRG_F0125
+    Int  iCnloop = bDepthIPMCAvai ? (iCount-2): (iCount-1);
+#else
     Int  iCnloop    = iCount - 1;
+#endif
     for(; iCnloop >= 0; iCnloop --)
     {
@@ -3706,8 +5789,19 @@
 #endif
 #if H_3D_VSP
-      if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1)
+      if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
       {
         vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
         xInheritVSPDisInfo(pcCULeft,uiLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
       }
 #endif
@@ -3758,5 +5852,13 @@
 #if H_3D_IV_MERGE 
     Bool bRemoveSpa = false; //pruning to inter-view candidates
+#if QC_DEPTH_IV_MRG_F0125
+    Int iCnloop;
+    if( bIsDepth )
+      iCnloop = (bLeftAvai && bDepthIPMCAvai) ? (iCount-3) : ((bLeftAvai || bDepthIPMCAvai)  ? (iCount-2): (iCount-1));
+    else
+      iCnloop = bLeftAvai? (iCount-2): (iCount-1);
+#else
     Int  iCnloop    = bLeftAvai? (iCount-2): (iCount-1);
+#endif
     for(; iCnloop >= 0; iCnloop --)
     {
@@ -3783,9 +5885,33 @@
 #endif
 #if H_3D_VSP
-      if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1)
+#if MTK_VSP_SIMPLIFICATION_F0111
+      if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#else
+      if (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#endif
       {
 
         vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
         xInheritVSPDisInfo(pcCUAbove,uiAbovePartIdx,iCount,inheritedVSPDisInfo);
+#endif
       }
 #endif
@@ -3839,8 +5965,32 @@
 #endif
 #if H_3D_VSP
-    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1)
+#if MTK_VSP_SIMPLIFICATION_F0111
+    if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+#else
+    if (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
+#endif
     {
       vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
       xInheritVSPDisInfo(pcCUAboveRight,uiAboveRightPartIdx,iCount,inheritedVSPDisInfo);
+#endif
     }
 #endif
@@ -3920,5 +6070,14 @@
   /////////////////////////////////////////////////
 
-  if ( xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
+  if (
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      !bICFlag &&
+#endif
+#if H_3D_ARP
+      !bARPFlag &&
+#endif
+#endif
+      xAddVspCand( mrgCandIdx, &cDisInfo, iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag ) )
   {
     return;
@@ -3960,8 +6119,19 @@
 #endif
 #if H_3D_VSP
-    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1)
+    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+        && !bICFlag
+#endif
+#if H_3D_ARP
+        && !bARPFlag
+#endif
+#endif
+        )
     {
       vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
       xInheritVSPDisInfo(pcCULeftBottom,uiLeftBottomPartIdx,iCount,inheritedVSPDisInfo);
+#endif
     }
 #endif
@@ -4009,8 +6179,32 @@
 #endif
 #if H_3D_VSP
-      if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1)
+#if MTK_VSP_SIMPLIFICATION_F0111
+      if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#else
+      if (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+          && !bICFlag
+#endif
+#if H_3D_ARP
+          && !bARPFlag
+#endif
+#endif
+          )
+#endif
       {
         vspFlag[iCount] = 1;
+#if !MTK_VSP_SIMPLIFICATION_F0111
         xInheritVSPDisInfo(pcCUAboveLeft,uiAboveLeftPartIdx,iCount,inheritedVSPDisInfo);
+#endif
       }
 #endif
@@ -4235,4 +6429,9 @@
   numValidMergeCand = uiArrayAddr;
 }
+
+
+#endif
+
+
 #if H_3D_VSP
 inline Void TComDataCU::xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount, InheritedVSPDisInfo*  inheritedVSPDisInfo)
@@ -4571,4 +6770,15 @@
 }
 
+#if LGE_IC_CTX_F0160
+Bool TComDataCU::isIC( UInt uiPartIdx )
+{
+    if ( m_pcSlice->isIntra () )
+    {
+        return false;
+    }
+    return ( ( getSkipFlag(uiPartIdx) || getPredictionMode(uiPartIdx) == MODE_INTER) && getICFlag( uiPartIdx ) && isICFlagRequired( uiPartIdx ) );
+}
+#endif
+
 // ====================================================================================================================
 // Protected member functions
@@ -5411,4 +7621,54 @@
   riPosX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelX();
   riPosY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIndex]] + getCUPelY();  
+}
+#endif
+#if QC_DEPTH_IV_MRG_F0125
+Bool TComDataCU::getDispNeighBlocks (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
+{
+  Pel pDepPos[3] = {0, 0, 0};
+  assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
+  Bool bDepAvail = false;
+  Pel *pDepth  = this->getPic()->getPicYuvRec()->getLumaAddr();
+  Int iDepStride =  this->getPic()->getPicYuvRec()->getStride();
+  TComMv cMv; 
+
+  Int xP, yP, nPSW, nPSH;
+  this->getPartPosition(uiPartIdx, xP, yP, nPSW, nPSH);
+
+  if(xP != 0 && yP != 0)
+  {
+    pDepPos[0] = pDepth[ (yP-1) * iDepStride + (xP-1) ];
+    bDepAvail = true;
+  }
+
+  if(xP != 0)
+  {
+    pDepPos[1] = pDepth[ (yP+nPSH-1) * iDepStride + (xP-1) ];
+    bDepAvail = true;
+  }
+
+  if(yP != 0)
+  {
+    pDepPos[2] = pDepth[ (yP-1) * iDepStride + (xP+nPSW-1) ];
+    bDepAvail = true;
+  }
+
+  if (bDepAvail)
+  {
+    Pel pAvgDepth = (xP != 0 && yP != 0) ? ((5*pDepPos[0] + 5*pDepPos[1] + 6*pDepPos[2] + 8)>>4) : (xP == 0) ? pDepPos[2] : pDepPos[1];
+    Int iDisp     = getSlice()->getDepthToDisparityB( 0 )[ pAvgDepth ];
+    cMv.setHor(iDisp);
+    cMv.setVer(0);
+    pDisp->m_acNBDV = cMv;
+    pDisp->m_aVIdxCan = 0;
+    return true;
+  }
+  else
+  {  
+    cMv.setZero();
+    pDisp->m_acNBDV = cMv;
+    pDisp->m_aVIdxCan = 0;
+    return false;
+  }
 }
 #endif
@@ -5942,7 +8202,65 @@
 }
 #endif
+
+#if MTK_SPIVMP_F0110
+Void TComDataCU::getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight)
+{
+  Int iSubPUSize = 1<<getSlice()->getVPS()->getSubPULog2Size(getSlice()->getLayerId());
+  iNumSPInOneLine = iPUWidth/iSubPUSize;
+  iNumSPInOneLine = iNumSPInOneLine < 1 ? 1: iNumSPInOneLine;
+  Int iNumSPInOneColumn = iPUHeight/iSubPUSize;
+  iNumSPInOneColumn = iNumSPInOneColumn < 1 ? 1: iNumSPInOneColumn;
+  iNumSP = iNumSPInOneLine * iNumSPInOneColumn;
+
+  iSPWidth = iNumSPInOneLine == 1 ? iPUWidth: iSubPUSize; 
+  iSPHeight = iNumSPInOneColumn == 1 ? iPUHeight: iSubPUSize; 
+}
+
+Void TComDataCU::getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr )
+{
+  uiBaseAbsPartIdx += m_uiAbsIdxInLCU;
+  Int iBasePelX = g_auiRasterToPelX[g_auiZscanToRaster[uiBaseAbsPartIdx]];
+  Int iBasePelY = g_auiRasterToPelY[g_auiZscanToRaster[uiBaseAbsPartIdx]];
+  Int iCurrPelX = iBasePelX + iPartIdx%iNumPartLine * iWidth;
+  Int iCurrPelY = iBasePelY + iPartIdx/iNumPartLine * iHeight;
+  Int iCurrRaster = iCurrPelY / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + iCurrPelX/getPic()->getMinCUWidth();
+  ruiPartAddr = g_auiRasterToZscan[iCurrRaster];
+  ruiPartAddr -= m_uiAbsIdxInLCU;  
+}
+
+Void TComDataCU::setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight )
+{
+  uiAbsPartIdx += getZorderIdxInCU();
+  Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
+  Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
+  Int iEndPelX = iStartPelX + iWidth;
+  Int iEndPelY = iStartPelY + iHeight;
+
+  Int iCurrRaster, uiPartAddr;
+
+  for (Int i=iStartPelY; i<iEndPelY; i+=getPic()->getMinCUHeight())
+  {
+    for (Int j=iStartPelX; j < iEndPelX; j += getPic()->getMinCUWidth())
+    {
+      iCurrRaster = i / getPic()->getMinCUHeight() * getPic()->getNumPartInWidth() + j/getPic()->getMinCUWidth();
+      uiPartAddr = g_auiRasterToZscan[iCurrRaster];
+      uiPartAddr -= getZorderIdxInCU();  
+
+      m_puhInterDir[uiPartAddr] = uiDir;
+    }
+  }
+}
+#endif
+
 #if H_3D_IV_MERGE
 Bool
-TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc )
+TComDataCU::getInterViewMergeCands(UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc 
+#if QC_DEPTH_IV_MRG_F0125
+, Bool bIsDepth           
+#endif
+#if MTK_SPIVMP_F0110
+, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+)
 {
   TComSlice*    pcSlice = getSlice ();  
@@ -5950,5 +8268,9 @@
   
   //--- get base CU/PU and check prediction mode ---
+#if QC_DEPTH_IV_MRG_F0125
+  TComPic*    pcBasePic   = pcSlice->getIvPic( bIsDepth, iViewIndex );
+#else
   TComPic*    pcBasePic   = pcSlice->getIvPic( false, iViewIndex );
+#endif
   TComPicYuv* pcBaseRec   = pcBasePic->getPicYuvRec   ();
 
@@ -5961,6 +8283,13 @@
   pcBaseRec->getTopLeftSamplePos( getAddr(), getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
 
+#if !MTK_SPIVMP_F0110
+#if QC_DEPTH_IV_MRG_F0125
+  iCurrPosX  += ( iWidth  >> 1 );
+  iCurrPosY  += ( iHeight >> 1 );
+#else
   iCurrPosX  += ( ( iWidth  - 1 ) >> 1 );
   iCurrPosY  += ( ( iHeight - 1 ) >> 1 );
+#endif
+#endif
 
   Bool depthRefineFlag = false; 
@@ -5979,24 +8308,165 @@
 #endif
 
+#if MTK_SPIVMP_F0110
+  ////////////////////////////////
+  //////////sub-PU IvMC///////////
+  ////////////////////////////////
+  
+  Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+  getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+  for (Int i=0; i<iNumSP; i++)
+  {
+    puhInterDirSP[i] = 0;
+    pcMvFieldSP[2*i].getMv().set(0, 0);
+    pcMvFieldSP[2*i+1].getMv().set(0,0);
+    pcMvFieldSP[2*i].setRefIdx(-1);
+    pcMvFieldSP[2*i+1].setRefIdx(-1);
+  }
+
+  Int         iBaseCUAddr;
+  Int         iBaseAbsPartIdx;
+  TComDataCU* pcBaseCU;
+  Int iPartition = 0;
+  Int iInterDirLast = 0;
+  TComMvField cMvFieldLast[2];
+
+  Int iDelX = iSPWidth/2;
+  Int iDelY = iSPHeight/2;
+
+  Int         iBasePosX, iBasePosY;
+  for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
+  {
+    for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iSPWidth)
+    {
+      iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, j + iDelX + ( (cDv.getHor() + 2 ) >> 2 ));
+      iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, i + iDelY + ( (cDv.getVer() + 2 ) >> 2 )); 
+
+      pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY, iBaseCUAddr, iBaseAbsPartIdx );
+      pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+      if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
+      {
+        for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+        {
+          RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+          Bool bLoop_stop = false;
+          for(Int iLoop = 0; iLoop < 2 && !bLoop_stop; ++iLoop)
+          {
+            RefPicList eBaseRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
+            TComMvField cBaseMvField;
+            pcBaseCU->getMvField( pcBaseCU, iBaseAbsPartIdx, eBaseRefPicList, cBaseMvField );
+            Int         iBaseRefIdx     = cBaseMvField.getRefIdx();
+            if (iBaseRefIdx >= 0)
+            {
+              Int iBaseRefPOC = pcBaseCU->getSlice()->getRefPOC(eBaseRefPicList, iBaseRefIdx);
+              if (iBaseRefPOC != pcSlice->getPOC())    
+              {
+                for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
+                {
+                  if (iBaseRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
+                  {
+                    abPdmAvailable[ uiCurrRefListId ] = true;
+                    TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
+
+                    if( !bIsDepth )
+                    {
+                      cMv.setIDVFlag   (true);
+                      cMv.setIDVHor    (cDv.getHor());                  
+                      cMv.setIDVVer    (cDv.getVer());  
+                      cMv.setIDVVId    (iViewIndex); 
+                    }
+
+                    clipMv( cMv );
+                    bLoop_stop = true;
+
+                    pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iPdmRefIdx);
+                    break;
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+
+      puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
+      if (puhInterDirSP[iPartition] == 0)
+      {
+        if (iInterDirLast != 0)
+        {
+          puhInterDirSP[iPartition] = iInterDirLast;
+          pcMvFieldSP[2*iPartition] = cMvFieldLast[0];
+          pcMvFieldSP[2*iPartition + 1] = cMvFieldLast[1];
+        }
+      }
+      else
+      {
+        if (iInterDirLast ==0)
+        {
+          availableMcDc[0] = puhInterDirSP[iPartition];
+          paiPdmRefIdx  [ 0 ] = pcMvFieldSP[2*iPartition].getRefIdx();
+          pacPdmMv      [ 0 ] = pcMvFieldSP[2*iPartition].getMv();
+          paiPdmRefIdx  [ 1 ] = pcMvFieldSP[2*iPartition+1].getRefIdx();
+          pacPdmMv      [ 1 ] = pcMvFieldSP[2*iPartition+1].getMv();
+
+          if (iPartition != 0)
+          {
+            for (Int iPart = iPartition-1; iPart >= 0; iPart--)
+            {
+              puhInterDirSP[iPart] = puhInterDirSP[iPartition];
+              pcMvFieldSP[2*iPart] = pcMvFieldSP[2*iPartition];
+              pcMvFieldSP[2*iPart + 1] = pcMvFieldSP[2*iPartition + 1];
+            }
+          }
+        }
+        iInterDirLast = puhInterDirSP[iPartition];
+        cMvFieldLast[0] = pcMvFieldSP[2*iPartition];
+        cMvFieldLast[1] = pcMvFieldSP[2*iPartition + 1];
+      }
+
+      iPartition ++;
+
+    }
+  }  
+
+  iCurrPosX  += ( iWidth  >> 1 );
+  iCurrPosY  += ( iHeight >> 1 );
+#endif
+
   ////////////////////////////////
   /////// IvMC + IvMCShift ///////
   ////////////////////////////////
 
-  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)  
+#if MTK_SPIVMP_F0110
+  for(Int iLoopCan = 1; iLoopCan < 2; iLoopCan ++) 
+#else
+  for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
+#endif
   {
     // iLoopCan == 0 --> IvMC
     // iLoopCan == 1 --> IvMCShift 
 
+#if !MTK_SPIVMP_F0110
     Int         iBaseCUAddr;
     Int         iBaseAbsPartIdx;
+#endif
 
     Int offsetW = (iLoopCan == 0) ? 0 : ( ((iWidth /2)*4) + 4 );
     Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
 
+#if MTK_SPIVMP_F0110
+    iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
+    iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
+#else
     Int         iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
     Int         iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
+#endif
     pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
 
+#if MTK_SPIVMP_F0110
+    pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+#else
     TComDataCU* pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
+#endif
     if(!( pcBaseCU->getPredictionMode( iBaseAbsPartIdx ) == MODE_INTRA ))
     {
@@ -6026,8 +8496,15 @@
                   TComMv cMv(cBaseMvField.getHor(), cBaseMvField.getVer());
 #if H_3D_NBDV 
-                  cMv.setIDVFlag   (true);
-                  cMv.setIDVHor    (cDv.getHor());                  
-                  cMv.setIDVVer    (cDv.getVer());  
-                  cMv.setIDVVId    (iViewIndex); 
+#if QC_DEPTH_IV_MRG_F0125
+                  if( !bIsDepth )
+                  {
+#endif
+                    cMv.setIDVFlag   (true);
+                    cMv.setIDVHor    (cDv.getHor());                  
+                    cMv.setIDVVer    (cDv.getVer());  
+                    cMv.setIDVVId    (iViewIndex); 
+#if QC_DEPTH_IV_MRG_F0125
+                  }
+#endif
 #endif
                   clipMv( cMv );
@@ -6044,5 +8521,9 @@
     }
   }
+#if MTK_SPIVMP_F0110
+  for(Int iLoopCan = 1; iLoopCan < 2; iLoopCan ++)
+#else
   for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
+#endif
   {
     availableMcDc[(iLoopCan << 1)] = ( abPdmAvailable[(iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[1 + (iLoopCan<<2)] ? 2 : 0);
@@ -6071,4 +8552,8 @@
 #endif
           cMv.setHor( cMv.getHor() + ioffsetDV );
+#if QC_DEPTH_IV_MRG_F0125
+          if( bIsDepth )
+            cMv.setHor((cMv.getHor()+2)>>2); 
+#endif
           cMv.setVer( 0 );
           clipMv( cMv );
@@ -6154,4 +8639,5 @@
   for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmmWedgeTabIdx[dmmType][uiAbsPartIdx+ui] = tabIdx; }
 }
+#if !SEC_DMM3_RBC_F0147
 Void  TComDataCU::setDmm3IntraTabIdxSubParts( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -6159,4 +8645,5 @@
   for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) { m_dmm3IntraTabIdx[uiAbsPartIdx+ui] = uiTIdx; }
 }
+#endif
 #endif
 #if H_3D_DIM_RBC
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 724)
@@ -198,4 +198,8 @@
                                       ///< 0: non-VSP; 1: VSP
 #endif
+#if MTK_SPIVMP_F0110
+  Bool*         m_pbSPIVMPFlag;       ///< array of sub-PU IVMP flags to indicate whehter a block uses sub-PU IVMP
+                                      ///< 0: non-SPIVMP; 1: SPIVMP
+#endif
 #if H_3D_ARP
   UChar*        m_puhARPW;
@@ -208,5 +212,7 @@
 #if H_3D_DIM_DMM
   UInt*         m_dmmWedgeTabIdx[DMM_NUM_TYPE]; 
+#if !SEC_DMM3_RBC_F0147
   UInt*         m_dmm3IntraTabIdx;
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -227,5 +233,11 @@
   UChar*        m_pucInterSDCMask;
 #endif
-
+#if ETRIKHU_MERGE_REUSE_F0093
+  Bool          m_bAvailableFlagA1;    ///< A1 available flag
+  Bool          m_bAvailableFlagB1;    ///< B1 available flag
+  Bool          m_bAvailableFlagB0;    ///< B0 available flag
+  Bool          m_bAvailableFlagA0;    ///< A0 available flag
+  Bool          m_bAvailableFlagB2;    ///< B2 available flag
+#endif
   // -------------------------------------------------------------------------------------------------------------------
   // misc. variables
@@ -244,4 +256,8 @@
   UInt*         m_sliceSegmentStartCU; ///< Start CU address of current slice
   Char          m_codedQP;
+#if ETRIKHU_MERGE_REUSE_F0093
+  DisInfo       m_cDefaultDisInfo;    ///< Default disparity information for initializing
+#endif
+
 protected:
   
@@ -250,10 +266,20 @@
   Bool          xAddMVPCandOrder      ( AMVPInfo* pInfo, RefPicList eRefPicList, Int iRefIdx, UInt uiPartUnitIdx, MVP_DIR eDir );
 #if H_3D_VSP
+#if ETRIKHU_MERGE_REUSE_F0093
+  Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
+                             Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo);
+#else
   Bool          xAddVspCand( Int mrgCandIdx, DisInfo* pDInfo, Int& iCount,
                              Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag );
 #endif
+#endif
 #if H_3D_IV_MERGE
+#if ETRIKHU_MERGE_REUSE_F0093
+  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   ); 
+#else
   Bool          xAddIvMRGCand( Int mrgCandIdx, Int& iCount, Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int*   ivCandDir, TComMv* ivCandMv, 
                                Int* ivCandRefIdx, Int posIvDC, Int* vspFlag ); 
+#endif
   Bool          xGetPosFirstAvailDmvCand( Int iCount, TComMvField* pcMvFieldNeighbours, Int*  ivCandDir, Int posIvDC, Int* vspFlag, Int& iFirDispCand );
 #endif
@@ -493,4 +519,12 @@
    ); 
    
+#if ETRIKHU_MERGE_REUSE_F0093
+  Void          rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV);
+#endif
+#if QC_DEPTH_IV_MRG_F0125
+  Bool          getDispNeighBlocks  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
+  Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
+#endif
+
 #if H_3D_NBDV_REF
   Pel           getMcpFromDM(TComPicYuv* pcBaseViewDepthPicYuv, TComMv* mv, Int iBlkX, Int iBlkY, Int iWidth, Int iHeight, Int* aiShiftLUT );
@@ -501,6 +535,18 @@
   Void          getIVNStatus       ( UInt uiPartIdx,  DisInfo* pDInfo, Bool& bIVFMerge,  Int& iIVFMaxD);
 #endif
+#if MTK_SPIVMP_F0110
+  Void          getSPPara(Int iPUWidth, Int iPUHeight, Int& iNumSP, Int& iNumSPInOneLine, Int& iSPWidth, Int& iSPHeight);
+  Void          getSPAbsPartIdx(UInt uiBaseAbsPartIdx, Int iWidth, Int iHeight, Int iPartIdx, Int iNumPartLine, UInt& ruiPartAddr );
+  Void          setInterDirSP( UInt uiDir, UInt uiAbsPartIdx, Int iWidth, Int iHeight );
+#endif
 #if H_3D_IV_MERGE
-  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc );   
+  Bool          getInterViewMergeCands          ( UInt uiPartIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDInfo, Int* availableMcDc 
+#if QC_DEPTH_IV_MRG_F0125
+    , Bool bIsDepth           
+#endif
+#if MTK_SPIVMP_F0110
+    , TComMvField* pcMFieldSP, UChar* puhInterDirSP
+#endif
+    );   
 #endif
 #if H_3D_ARP
@@ -538,8 +584,10 @@
   Void  setDmmWedgeTabIdxSubParts     ( UInt tabIdx, UInt dmmType, UInt uiAbsPartIdx, UInt uiDepth );
 
+#if !SEC_DMM3_RBC_F0147
   UInt* getDmm3IntraTabIdx            ()                      { return m_dmm3IntraTabIdx;        }
   UInt  getDmm3IntraTabIdx            ( UInt uiIdx )          { return m_dmm3IntraTabIdx[uiIdx]; }
   Void  setDmm3IntraTabIdx            ( UInt uiIdx, UInt uh ) { m_dmm3IntraTabIdx[uiIdx] = uh;   }
   Void  setDmm3IntraTabIdxSubParts    ( UInt uiTIdx, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -655,13 +703,36 @@
   
   Bool          hasEqualMotion              ( UInt uiAbsPartIdx, TComDataCU* pcCandCU, UInt uiCandAbsPartIdx );
-  Void          getInterMergeCandidates     ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+
+#if ETRIKHU_MERGE_REUSE_F0093
+  Bool          getAvailableFlagA1() { return m_bAvailableFlagA1;}
+  Bool          getAvailableFlagB1() { return m_bAvailableFlagB1;}
+  Bool          getAvailableFlagB0() { return m_bAvailableFlagB0;}
+  Bool          getAvailableFlagA0() { return m_bAvailableFlagA0;}
+  Bool          getAvailableFlagB2() { return m_bAvailableFlagB2;}
+  Void          initAvailableFlags() { m_bAvailableFlagA1 = m_bAvailableFlagB1 = m_bAvailableFlagB0 = m_bAvailableFlagA0 = m_bAvailableFlagB2 = 0;  }
+  Void          getInterMergeCandidates( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int& numValidMergeCand, Int mrgCandIdx = -1);
+  Void          xGetInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+#else
+  Void          getInterMergeCandidates ( UInt uiAbsPartIdx, UInt uiPUIdx, TComMvField* pcMFieldNeighbours, UChar* puhInterDirNeighbours
+#endif
 #if H_3D_VSP
                                             , Int* vspFlag
                                             , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
-                                            , Int& numValidMergeCand, Int mrgCandIdx = -1 );
+#if MTK_SPIVMP_F0110
+                                            , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
+                                            , Int& numValidMergeCand, Int mrgCandIdx = -1
+                                            );
 
 #if H_3D_VSP
   inline Void   xInheritVSPDisInfo(TComDataCU* pcCURef, UInt uiAbsPartIdx, Int iCount,  InheritedVSPDisInfo*  inheritedVSPDisInfo);
+
+#if MTK_SPIVMP_F0110
+  Bool*         getSPIVMPFlag        ()                        { return m_pbSPIVMPFlag;          }
+  Bool          getSPIVMPFlag        ( UInt uiIdx )            { return m_pbSPIVMPFlag[uiIdx];   }
+  Void          setSPIVMPFlag        ( UInt uiIdx, Bool n )     { m_pbSPIVMPFlag[uiIdx] = n;      }
+  Void          setSPIVMPFlagSubParts( Bool bSPIVMPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+#endif
 
   Char*         getVSPFlag        ()                        { return m_piVSPFlag;          }
@@ -681,4 +752,8 @@
   Bool          isSkipped ( UInt uiPartIdx );                                                     ///< SKIP (no residual)
   Bool          isBipredRestriction( UInt puIdx );
+
+#if LGE_IC_CTX_F0160
+  Bool          isIC      ( UInt uiPartIdx );
+#endif
 
   // -------------------------------------------------------------------------------------------------------------------
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.cpp	(revision 724)
@@ -40,4 +40,8 @@
 #include "assert.h"
 #include <stdlib.h>
+#if MTK_SPIVMP_F0110
+#include "TComDataCU.h"
+#include "TComPic.h"
+#endif
 
 //! \ingroup TLibCommon
@@ -323,4 +327,30 @@
   setAllRefIdx( mvField.getRefIdx(), eCUMode, iPartAddr, uiDepth, iPartIdx );
 }
+
+#if MTK_SPIVMP_F0110
+Void TComCUMvField::setMvFieldSP( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  )
+{
+  uiAbsPartIdx += pcCU->getZorderIdxInCU();
+  Int iStartPelX = g_auiRasterToPelX[g_auiZscanToRaster[uiAbsPartIdx]];
+  Int iStartPelY = g_auiRasterToPelY[g_auiZscanToRaster[uiAbsPartIdx]];
+  Int iEndPelX = iStartPelX + iWidth;
+  Int iEndPelY = iStartPelY + iHeight;
+
+  Int iCurrRaster, uiPartAddr;
+
+  for (Int i=iStartPelY; i<iEndPelY; i+=pcCU->getPic()->getMinCUHeight())
+  {
+    for (Int j=iStartPelX; j < iEndPelX; j += pcCU->getPic()->getMinCUWidth())
+    {
+      iCurrRaster = i / pcCU->getPic()->getMinCUHeight() * pcCU->getPic()->getNumPartInWidth() + j/pcCU->getPic()->getMinCUWidth();
+      uiPartAddr = g_auiRasterToZscan[iCurrRaster];
+      uiPartAddr -= pcCU->getZorderIdxInCU();  
+
+      m_pcMv[uiPartAddr] = cMvField.getMv();
+      m_piRefIdx[uiPartAddr] = cMvField.getRefIdx();
+    }
+  }
+}
+#endif
 
 /**Subsampling of the stored prediction mode, reference index and motion vector
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 724)
@@ -43,5 +43,4 @@
 #include "CommonDef.h"
 #include "TComMv.h"
-
 //! \ingroup TLibCommon
 //! \{
@@ -51,4 +50,7 @@
 // ====================================================================================================================
 
+#if MTK_SPIVMP_F0110
+class TComDataCU;
+#endif
 /// parameters for AMVP
 typedef struct _AMVPInfo
@@ -171,4 +173,7 @@
   Void    setAllRefIdx ( Int iRefIdx,                 PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
   Void    setAllMvField( TComMvField const & mvField, PartSize eMbMode, Int iPartAddr, UInt uiDepth, Int iPartIdx=0 );
+#if MTK_SPIVMP_F0110
+  Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
+#endif
 
   Void setNumPartition( Int iNumPart )
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 724)
@@ -425,5 +425,7 @@
   Bool dimDeltaDC = isDimDeltaDC( uiIntraMode );    
   Bool isDmmMode  = (dimType <  DMM_NUM_TYPE);
+#if !SEC_DMM3_RBC_F0147
   Bool isRbcMode  = (dimType == RBC_IDX);
+#endif
 
   Bool* biSegPattern  = NULL;
@@ -441,4 +443,5 @@
         dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ pcCU->getDmmWedgeTabIdx( dimType, uiAbsPartIdx ) ]);
       } break;
+#if !SEC_DMM3_RBC_F0147
     case( DMM3_IDX ): 
       {
@@ -452,4 +455,5 @@
         dmmSegmentation = &(g_dmmWedgeLists[ g_aucConvertToBit[iWidth] ][ uiTabIdx ]);
       } break;
+#endif
     case( DMM4_IDX ): 
       {
@@ -475,6 +479,10 @@
   assert( biSegPattern );
   Int* piMask = NULL;
+#if QC_DIM_DELTADC_UNIFY_F0132 || HHI_DIM_PREDSAMP_FIX_F0171
+  piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering
+#else
   if( isDmmMode ) piMask = pcCU->getPattern()->getAdiOrgBuf( iWidth, iHeight, m_piYuvExt ); // no filtering for DMM
   else            piMask = pcCU->getPattern()->getPredictorPtr( 0, g_aucConvertToBit[ iWidth ] + 2, m_piYuvExt );
+#endif
   assert( piMask );
   Int maskStride = 2*iWidth + 1;  
@@ -491,5 +499,9 @@
     Pel deltaDC2 = pcCU->getDimDeltaDC( dimType, 1, uiAbsPartIdx );
 #if H_3D_DIM_DMM
+#if QC_DIM_DELTADC_UNIFY_F0132 && !SEC_DMM3_RBC_F0147
+    if( isDmmMode || isRbcMode)
+#else
     if( isDmmMode )
+#endif
     {
 #if H_3D_DIM_DLT
@@ -502,5 +514,5 @@
     }
 #endif
-#if H_3D_DIM_RBC
+#if H_3D_DIM_RBC && !QC_DIM_DELTADC_UNIFY_F0132
     if( isRbcMode )
     {
@@ -549,4 +561,84 @@
 }
 
+#if MTK_SPIVMP_F0110
+Void TComPrediction::xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr )
+{
+  for (Int i = 0; i < iNumSP; i++)
+  {
+    uiMergedSPW[i] = iSPWidth;
+    uiMergedSPH[i] = iSPHeight;
+    pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, i, iNumSPInOneLine, uiSPAddr[i]);
+  }
+  // horizontal sub-PU merge
+  for (Int i=0; i<iNumSP; i++)
+  {
+    if (i % iNumSPInOneLine == iNumSPInOneLine - 1 || uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
+    {
+      continue;
+    }
+    for (Int j=i+1; j<i+iNumSPInOneLine-i%iNumSPInOneLine; j++)
+    {
+      if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]))
+      {
+        uiMergedSPW[i] += iSPWidth;
+        uiMergedSPW[j] = uiMergedSPH[j] = 0;
+      }
+      else
+      {
+        break;
+      }
+    }
+  }
+  //vertical sub-PU merge
+  for (Int i=0; i<iNumSP-iNumSPInOneLine; i++)
+  {
+    if (uiMergedSPW[i]==0 || uiMergedSPH[i]==0)
+    {
+      continue;
+    }
+    for (Int j=i+iNumSPInOneLine; j<iNumSP; j+=iNumSPInOneLine)
+    {
+      if (xCheckTwoSPMotion(pcCU, uiSPAddr[i], uiSPAddr[j]) && uiMergedSPW[i]==uiMergedSPW[j])
+      {
+        uiMergedSPH[i] += iSPHeight;
+        uiMergedSPH[j] = uiMergedSPW[j] = 0;
+      }
+      else
+      {
+        break;
+      }
+    }
+  }
+}
+
+Bool TComPrediction::xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 )
+{
+  if( pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr1))
+  {
+    return false;
+  }
+  if( pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr1))
+  {
+    return false;
+  }
+
+  if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(PartAddr0) >= 0)
+  {
+    if (pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_0)->getMv(PartAddr1))
+    {
+      return false;
+    }
+  }
+
+  if (pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(PartAddr0) >= 0)
+  {
+    if (pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr0) != pcCU->getCUMvField(REF_PIC_LIST_1)->getMv(PartAddr1))
+    {
+      return false;
+    }
+  }
+  return true;
+}
+#endif
 
 Void TComPrediction::motionCompensation ( TComDataCU* pcCU, TComYuv* pcYuvPred, RefPicList eRefPicList, Int iPartIdx )
@@ -580,12 +672,47 @@
       else
       {
-        if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
-        {
-          xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
+#if MTK_SPIVMP_F0110
+        if ( pcCU->getSPIVMPFlag(uiPartAddr)!=0)  
+        {
+          Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+          pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+          UInt uiW[256], uiH[256];
+          UInt uiSPAddr[256];
+
+          xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
+
+          //MC
+          for (Int i = 0; i < iNumSP; i++)
+          {
+            if (uiW[i]==0 || uiH[i]==0)
+            {
+              continue;
+            }
+            if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
+            {
+              xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
+            }
+            else
+            {
+              xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
+            }
+          }
         }
         else
         {
-          xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
-        }
+#endif
+          if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
+          {
+            xPredInterUni (pcCU, uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, pcYuvPred );
+          }
+          else
+          {
+            xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
+          }
+#if MTK_SPIVMP_F0110
+        }
+#endif
       }
 #if H_3D_VSP
@@ -631,4 +758,35 @@
       else
       {
+#if MTK_SPIVMP_F0110
+       if (pcCU->getSPIVMPFlag(uiPartAddr)!=0)  
+      {
+        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+        UInt uiW[256], uiH[256];
+        UInt uiSPAddr[256];
+
+        xGetSubPUAddrAndMerge(pcCU, uiPartAddr, iSPWidth, iSPHeight, iNumSPInOneLine, iNumSP, uiW, uiH, uiSPAddr);
+        //MC
+        for (Int i = 0; i < iNumSP; i++)
+        {
+          if (uiW[i]==0 || uiH[i]==0)
+          {
+            continue;
+          }
+          if( xCheckIdenticalMotion( pcCU, uiSPAddr[i] ))
+          {
+            xPredInterUni (pcCU, uiSPAddr[i], uiW[i], uiH[i], REF_PIC_LIST_0, pcYuvPred );
+          }
+          else
+          {
+            xPredInterBi  (pcCU, uiSPAddr[i], uiW[i], uiH[i], pcYuvPred);
+          }
+        }
+      }
+      else
+      {
+#endif
         if ( xCheckIdenticalMotion( pcCU, uiPartAddr ) )
         {
@@ -639,4 +797,7 @@
           xPredInterBi  (pcCU, uiPartAddr, iWidth, iHeight, pcYuvPred );
         }
+#if MTK_SPIVMP_F0110
+       }
+#endif
       }
 #if H_3D_VSP
@@ -664,4 +825,11 @@
   pcCU->clipMv(cMv);
 #if H_3D_ARP
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
+  {
+      xPredInterUniARPviewRef( pcCU , uiPartAddr , iWidth , iHeight , eRefPicList , rpcYuvPred , bi );
+  }
+  else
+#endif
   if(  pcCU->getARPW( uiPartAddr ) > 0 
     && pcCU->getPartitionSize(uiPartAddr)==SIZE_2Nx2N 
@@ -744,8 +912,17 @@
   // fetch virtual depth map
   pcBaseViewDepthPicYuv->extendPicBorder();
+
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  Int vspSize=0;
+  xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp,vspSize );
+  // sub-PU based compensation
+  xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize);
+  xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi, vspSize);
+#else
   xGetVirtualDepth( pcCU, pcBaseViewDepthPicYuv, &cDv, uiPartAddr, iWidth, iHeight, &m_cYuvDepthOnVsp );
   // sub-PU based compensation
   xPredInterLumaBlkFromDM   ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
   xPredInterChromaBlkFromDM ( pcCU, pcBaseViewTxtPicYuv, &m_cYuvDepthOnVsp, pShiftLUT, &cDv, uiPartAddr, iWidth, iHeight, pcCU->getSlice()->getIsDepth(), rpcYuvPred, bi );
+#endif
 }
 #endif
@@ -777,5 +954,10 @@
   if( cDistparity.bDV ) 
   {
+#if SHARP_ARP_REF_CHECK_F0105
+    Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList);
+    if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC()!= pcCU->getSlice()->getPOC() )
+#else
     if( dW > 0 && pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC()!= pcCU->getSlice()->getPOC() )
+#endif
     {
       bTobeScaled = true;
@@ -783,7 +965,14 @@
 
     pcPicYuvBaseCol =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getPOC(),                              cDistparity.m_aVIdxCan );
+
+#if SHARP_ARP_REF_CHECK_F0105
+    pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC(), cDistparity.m_aVIdxCan );
+
+    if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, cDistparity.m_aVIdxCan))
+#else
     pcPicYuvBaseRef =  pcCU->getSlice()->getBaseViewRefPic( pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC(), cDistparity.m_aVIdxCan );
     
     if( ( !pcPicYuvBaseCol || pcPicYuvBaseCol->getPOC() != pcCU->getSlice()->getPOC() ) || ( !pcPicYuvBaseRef || pcPicYuvBaseRef->getPOC() != pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() ) )
+#endif
     {
       dW = 0;
@@ -792,5 +981,9 @@
     else
     {
+#if SHARP_ARP_REF_CHECK_F0105
+      assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, arpRefIdx )->getPOC() );
+#else
       assert( pcPicYuvBaseCol->getPOC() == pcCU->getSlice()->getPOC() && pcPicYuvBaseRef->getPOC() == pcCU->getSlice()->getRefPic( eRefPicList, 0 )->getPOC() );
+#endif
     }
 
@@ -841,4 +1034,111 @@
   }
 }
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+Void TComPrediction::xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled )
+{
+  Int         iRefIdx       = pcCU->getCUMvField( eRefPicList )->getRefIdx( uiPartAddr );           
+  TComMv      cDMv          = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
+  TComMv      cTempDMv      = cDMv;
+  UChar       dW            = pcCU->getARPW ( uiPartAddr );
+
+  TComPic* pcPicYuvBaseTRef = NULL;
+  TComPic* pcPicYuvCurrTRef = NULL;
+  TComPic* pcPicYuvBaseCol  = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx );  
+  TComPicYuv* pcYuvBaseCol  = pcPicYuvBaseCol->getPicYuvRec();   
+  Bool bTMVAvai = false;     
+  TComMv cBaseTMV;
+  if( pNewMvFiled )
+  {
+    iRefIdx = pNewMvFiled->getRefIdx(); 
+    cDMv = pNewMvFiled->getMv();
+  }
+  pcCU->clipMv(cTempDMv);
+
+  assert(dW > 0);
+#if SHARP_ARP_REF_CHECK_F0105
+  if (!pcCU->getSlice()->getArpRefPicAvailable( eRefPicList, pcPicYuvBaseCol->getViewIndex()))
+  {
+    dW = 0;
+  }
+#endif
+  Int uiLCUAddr,uiAbsPartAddr;
+  Int irefPUX = pcCU->getCUPelX() + g_auiRasterToPelX[g_auiZscanToRaster[uiPartAddr]] + iWidth/2  + ((cDMv.getHor() + 2)>>2);
+  Int irefPUY = pcCU->getCUPelY() + g_auiRasterToPelY[g_auiZscanToRaster[uiPartAddr]] + iHeight/2 + ((cDMv.getVer() + 2)>>2);
+
+  irefPUX = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()-> getPicWidthInLumaSamples()-1, irefPUX);
+  irefPUY = (Int)Clip3<Int>(0, pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples()-1, irefPUY);  
+  pcYuvBaseCol->getCUAddrAndPartIdx( irefPUX, irefPUY, uiLCUAddr, uiAbsPartAddr);
+  TComDataCU *pColCU = pcPicYuvBaseCol->getCU( uiLCUAddr );
+
+  if(!pColCU->isIntra(uiAbsPartAddr))
+  {
+    TComMvField puMVField;
+    for(Int iList = 0; iList < (pColCU->getSlice()->isInterB() ? 2: 1) && !bTMVAvai; iList ++)
+    {
+      RefPicList eRefPicListCurr = RefPicList(iList);
+      Int iRef = pColCU->getCUMvField(eRefPicListCurr)->getRefIdx(uiAbsPartAddr);
+      if( iRef != -1)
+      {
+        pcPicYuvBaseTRef = pColCU->getSlice()->getRefPic(eRefPicListCurr, iRef);  
+        Int  iCurrPOC    = pColCU->getSlice()->getPOC();
+        Int  iCurrRefPOC = pcPicYuvBaseTRef->getPOC();
+        Int  iCurrRef    = pcCU->getSlice()->getFirstTRefIdx(eRefPicListCurr);
+        if( iCurrRef >= 0)
+        {
+          pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic(eRefPicListCurr,iCurrRef);  
+          Int iTargetPOC = pcPicYuvCurrTRef->getPOC();
+          {
+            pcPicYuvBaseTRef =  pcCU->getSlice()->getBaseViewRefPic(iTargetPOC,  pcPicYuvBaseCol->getViewIndex() );  
+            if(pcPicYuvBaseTRef)
+            {
+              cBaseTMV = pColCU->getCUMvField(eRefPicListCurr)->getMv(uiAbsPartAddr);
+              Int iScale = pcCU-> xGetDistScaleFactor(iCurrPOC, iTargetPOC, iCurrPOC, iCurrRefPOC);
+              if ( iScale != 4096 )
+                cBaseTMV = cBaseTMV.scaleMv( iScale );                  
+              bTMVAvai = true;
+              break;
+            }
+          }
+        }
+      }
+    }
+  }
+  if (bTMVAvai == false)
+  { 
+    bTMVAvai = true;
+    cBaseTMV.set(0, 0);
+    pcPicYuvBaseTRef =  pColCU->getSlice()->getRefPic(eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));  
+    pcPicYuvCurrTRef =  pcCU->getSlice()->getRefPic  (eRefPicList,  pcCU->getSlice()->getFirstTRefIdx(eRefPicList));      
+  }
+
+  xPredInterLumaBlk  ( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
+  xPredInterChromaBlk( pcCU, pcYuvBaseCol, uiPartAddr, &cTempDMv, iWidth, iHeight, rpcYuvPred, bi,        bTMVAvai);
+
+  if( dW > 0 && bTMVAvai ) 
+  {
+    TComYuv*    pYuvCurrTRef    = &m_acYuvPredBase[0];
+    TComYuv*    pYuvBaseTRef    = &m_acYuvPredBase[1];
+    TComPicYuv* pcYuvCurrTref   = pcPicYuvCurrTRef->getPicYuvRec();        
+    TComPicYuv* pcYuvBaseTref   = pcPicYuvBaseTRef->getPicYuvRec();  
+    TComMv      cTempMv         = cDMv + cBaseTMV;
+
+    pcCU->clipMv(cBaseTMV);
+    pcCU->clipMv(cTempMv);
+
+    xPredInterLumaBlk  ( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
+    xPredInterChromaBlk( pcCU, pcYuvCurrTref, uiPartAddr, &cBaseTMV, iWidth, iHeight, pYuvCurrTRef, bi,   true);
+    xPredInterLumaBlk  ( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true); 
+    xPredInterChromaBlk( pcCU, pcYuvBaseTref, uiPartAddr, &cTempMv,  iWidth, iHeight, pYuvBaseTRef, bi,   true); 
+
+    pYuvCurrTRef->subtractARP( pYuvCurrTRef , pYuvBaseTRef , uiPartAddr , iWidth , iHeight );  
+    if(dW == 2)
+    {
+      pYuvCurrTRef->multiplyARP( uiPartAddr , iWidth , iHeight , dW );
+    }
+    rpcYuvPred->addARP( rpcYuvPred , pYuvCurrTRef , uiPartAddr , iWidth , iHeight , !bi ); 
+  }
+}
+#endif
+
 #endif
 
@@ -1499,5 +1799,9 @@
 #if H_3D_VSP
 // not fully support iRatioTxtPerDepth* != 1
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
+#else
 Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
+#endif
 {
   Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;
@@ -1527,4 +1831,5 @@
   Pel *depth = yuvDepth->getLumaAddr();
 
+#if !SHARP_VSP_BLOCK_IN_AMP_F0102
   if( width<8 || height<8 )
   { // no split
@@ -1546,4 +1851,10 @@
       depth += depStrideBlock;
     }
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  if(width==4)
+    vspSize=0;
+  else
+    vspSize=1;
+#endif
   }
   else
@@ -1558,5 +1869,16 @@
     Pel repDepth4x8[2] = {0, 0};
     Pel repDepth8x4[2] = {0, 0};
-
+#endif
+
+#if !MTK_F0109_LG_F0120_VSP_BLOCK
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int blocksize    = 8;
+    Int subblocksize = 4;
+    Int depStrideBlock = depStride * blocksize;
+    Pel *depthTmp = NULL;
+    Int depStrideTmp = depStride * nTxtPerDepthY;
+    Int offset[4] = { 0, subblocksize-1, subblocksize, blocksize-1 };
+    Pel *refDepthTmp[4] = { NULL, NULL, NULL, NULL };
+#endif
     Int refDepStrideBlock    = refDepStride * blocksize;
     Int refDepStrideSubBlock = refDepStride * subblocksize;
@@ -1567,4 +1889,76 @@
     refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
 
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int subBlockW, subBlockH;
+    Int blockW, blockH;
+    subBlockW = subBlockH = 8;
+    if (height % 8)
+    {
+      subBlockW = 8;
+      subBlockH = 4;
+      blockW = width;  // no further split
+      blockH = height; // no further split
+    }
+    else if (width % 8)
+    {
+      subBlockW = 4;
+      subBlockH = 8;
+      blockW = width;  // no further split
+      blockH = height; // no further split
+    }
+    else
+    {
+      blockW = blockH = 8;
+    }
+    for( Int y=0; y<height; y+=blockH )
+    {
+      for( Int x=0; x<width; x+=blockW )
+      {
+        if (blockW == 8 && blockH == 8)
+        {
+          Bool ULvsBR = false, URvsBL = false;
+          ULvsBR = refDepthTmp[0][x+offset[0]] < refDepthTmp[3][x+offset[3]];
+          URvsBL = refDepthTmp[0][x+offset[3]] < refDepthTmp[3][x+offset[0]];
+          if( ULvsBR ^ URvsBL )
+          { // 4x8
+            subBlockW = 4;
+            subBlockH = 8;
+          }
+          else
+          {
+            subBlockW = 8;
+            subBlockH = 4;
+          }
+        }
+        for( Int yy=0; yy<blockH; yy+=subBlockH )
+        {
+          for( Int xx=0; xx<blockW; xx+=subBlockW )
+          {
+            Pel  maxDepthVal = 0;
+            Int xP0, xP1, yP0, yP1;
+            xP0 = x+xx;
+            xP1 = x+xx+subBlockW-1;
+            yP0 = yy;
+            yP1 = yy+subBlockH-1;
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP0*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP0*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP0+yP1*refDepStride]);
+            maxDepthVal = std::max( maxDepthVal, refDepthTmp[0][xP1+yP1*refDepStride]);
+            depthTmp = &depth[x+xx+yy*depStride];
+            for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY )
+            {
+              for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX )
+              {
+                depthTmp[sX] = maxDepthVal;
+              }
+              depthTmp += depStrideTmp;
+            }
+          }
+        }
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+#else // SHARP_VSP_BLOCK_IN_AMP_F0102
     for( Int y=0; y<height; y+=blocksize )
     {
@@ -1662,14 +2056,203 @@
       depth       += depStrideBlock;
     }
-  }
-
-
-}
-
+#endif // SHARP_VSP_BLOCK_IN_AMP_F0102
+#else
+#if SHARP_VSP_BLOCK_IN_AMP_F0102
+  if ((height % 8))
+  {
+    vspSize = 1; // 8x4
+  }
+  else if ((width % 8))
+  {
+    vspSize = 0; // 4x8
+  }
+  else
+  {
+    Bool ULvsBR, URvsBL;
+    ULvsBR = refDepth[0]       < refDepth[refDepStride * (height-1) + width-1];
+    URvsBL = refDepth[width-1] < refDepth[refDepStride * (height-1)];
+    vspSize = ( ULvsBR ^ URvsBL ) ? 0 : 1;
+  }
+  Int subBlockW, subBlockH;
+  Int depStrideTmp = depStride * nTxtPerDepthY;
+  if (vspSize)
+  {
+    subBlockW = 8;
+    subBlockH = 4;
+  }
+  else
+  {
+    subBlockW = 4;
+    subBlockH = 8;
+  }
+  for( Int y=0; y<height; y+=subBlockH )
+  {
+    Pel *refDepthTmp[4];
+    refDepthTmp[0] = refDepth + refDepStride * y;
+    refDepthTmp[1] = refDepthTmp[0] + subBlockW - 1;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStride * (subBlockH - 1);
+    refDepthTmp[3] = refDepthTmp[2] + subBlockW - 1;
+    for( Int x=0; x<width; x+=subBlockW )
+    {
+      Pel  maxDepthVal;
+      maxDepthVal = refDepthTmp[0][x];
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[1][x]);
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[2][x]);
+      maxDepthVal = std::max( maxDepthVal, refDepthTmp[3][x]);
+      Pel *depthTmp = &depth[x+y*depStride];
+      for( Int sY=0; sY<subBlockH; sY+=nTxtPerDepthY )
+      {
+        for( Int sX=0; sX<subBlockW; sX+=nTxtPerDepthX )
+        {
+          depthTmp[sX] = maxDepthVal;
+        }
+        depthTmp += depStrideTmp;
+      }
+    }
+  }
+#else // SHARP_VSP_BLOCK_IN_AMP_F0102
+    Int refDepStrideBlock    = refDepStride * height;
+    Int refDepStrideSubBlock = refDepStride * height/2;
+    refDepthTmp[0] = refDepth;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock;
+    refDepthTmp[1] = refDepthTmp[2] - refDepStride;
+    refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
+    offset[3] = width-1;
+    Bool ULvsBR = false, URvsBL = false;
+    ULvsBR = refDepthTmp[0][0+offset[0]] < refDepthTmp[3][0+offset[3]];
+    URvsBL = refDepthTmp[0][0+offset[3]] < refDepthTmp[3][0+offset[0]];
+    refDepStrideBlock    = refDepStride * blocksize;
+    refDepStrideSubBlock = refDepStride * subblocksize;
+    refDepthTmp[0] = refDepth;
+    refDepthTmp[2] = refDepthTmp[0] + refDepStrideSubBlock;
+    refDepthTmp[1] = refDepthTmp[2] - refDepStride;
+    refDepthTmp[3] = refDepthTmp[1] + refDepStrideSubBlock;
+    offset[3] = blocksize-1;
+    if( ULvsBR ^ URvsBL )
+    {
+    vspSize = 0;//4x8
+    for( Int y=0; y<height; y+=blocksize )
+    {
+      for( Int x=0; x<width; x+=blocksize )
+      {
+        { // 4x8
+          repDepth4x8[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[1]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[1]];
+          if( repDepth4x8[0] < refDepthTmp[3][x+offset[0]] )
+          {
+            repDepth4x8[0] = refDepthTmp[3][x+offset[0]];
+          }
+          if( repDepth4x8[0] < refDepthTmp[3][x+offset[1]] )
+          {
+            repDepth4x8[0] = refDepthTmp[3][x+offset[1]];
+          }
+          repDepth4x8[1] = refDepthTmp[0][x+offset[2]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[2]] : refDepthTmp[0][x+offset[3]];
+          if( repDepth4x8[1] < refDepthTmp[3][x+offset[2]] )
+          {
+            repDepth4x8[1] = refDepthTmp[3][x+offset[2]];
+          }
+          if( repDepth4x8[1] < refDepthTmp[3][x+offset[3]] )
+          {
+            repDepth4x8[1] = refDepthTmp[3][x+offset[3]];
+  }
+
+          depthTmp = &depth[x];
+          for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY )
+          {
+            for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX )
+            {
+              depthTmp[sX] = repDepth4x8[0];
+            }
+            depthTmp += depStrideTmp;
+          }
+          depthTmp = &depth[x+subblocksize];
+          for( Int sY=0; sY<blocksize; sY+=nTxtPerDepthY )
+          {
+            for( Int sX=0; sX<subblocksize; sX+=nTxtPerDepthX )
+            {
+              depthTmp[sX] = repDepth4x8[1];
+            }
+            depthTmp += depStrideTmp;
+          }
+        }
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      refDepthTmp[1] += refDepStrideBlock;
+      refDepthTmp[2] += refDepStrideBlock;
+      refDepthTmp[3] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+  }
+  else
+  { // 8x4
+    vspSize = 1;
+    for( Int y=0; y<height; y+=blocksize )
+    {
+      for( Int x=0; x<width; x+=blocksize )
+      {
+        repDepth8x4[0] = refDepthTmp[0][x+offset[0]] > refDepthTmp[0][x+offset[3]] ? refDepthTmp[0][x+offset[0]] : refDepthTmp[0][x+offset[3]];
+        if( repDepth8x4[0] < refDepthTmp[1][x+offset[0]] )
+        {
+          repDepth8x4[0] = refDepthTmp[1][x+offset[0]];
+        }
+        if( repDepth8x4[0] < refDepthTmp[1][x+offset[3]] )
+        {
+          repDepth8x4[0] = refDepthTmp[1][x+offset[3]];
+        }
+        repDepth8x4[1] = refDepthTmp[2][x+offset[0]] > refDepthTmp[2][x+offset[3]] ? refDepthTmp[2][x+offset[0]] : refDepthTmp[2][x+offset[3]];
+        if( repDepth8x4[1] < refDepthTmp[3][x+offset[0]] )
+        {
+          repDepth8x4[1] = refDepthTmp[3][x+offset[0]];
+        }
+        if( repDepth8x4[1] < refDepthTmp[3][x+offset[3]] )
+        {
+          repDepth8x4[1] = refDepthTmp[3][x+offset[3]];
+        }
+
+        depthTmp = &depth[x];
+        for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY )
+        {
+          for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX )
+          {
+            depthTmp[sX] = repDepth8x4[0];
+          }
+          depthTmp += depStrideTmp;
+        }
+        for( Int sY=0; sY<subblocksize; sY+=nTxtPerDepthY )
+        {
+          for( Int sX=0; sX<blocksize; sX+=nTxtPerDepthX )
+          {
+            depthTmp[sX] = repDepth8x4[1];
+          }
+          depthTmp += depStrideTmp;
+}
+      }
+      refDepthTmp[0] += refDepStrideBlock;
+      refDepthTmp[1] += refDepStrideBlock;
+      refDepthTmp[2] += refDepStrideBlock;
+      refDepthTmp[3] += refDepStrideBlock;
+      depth       += depStrideBlock;
+    }
+  }
+#endif    
+#endif
+#if !SHARP_VSP_BLOCK_IN_AMP_F0102
+  }
+#endif
+
+
+}
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)
+#else
 Void TComPrediction::xPredInterLumaBlkFromDM( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi )
+#endif
 {
   Int nTxtPerDepthX = H_3D_VSP_BLOCKSIZE;
   Int nTxtPerDepthY = H_3D_VSP_BLOCKSIZE;
   
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  nTxtPerDepthX = nTxtPerDepthX << vspSize;
+  nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);
+#endif
   Int refStride = picRef->getStride();
   Int dstStride = yuvDst->getStride();
@@ -1777,5 +2360,9 @@
 }
 
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+Void TComPrediction::xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi, Int vspSize)
+#else
 Void TComPrediction::xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&yuvDst, Bool isBi )
+#endif
 {
 #if (H_3D_VSP_BLOCKSIZE==1)
@@ -1787,4 +2374,8 @@
 #endif
 
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  nTxtPerDepthX = nTxtPerDepthX << vspSize;
+  nTxtPerDepthY = nTxtPerDepthY << (1-vspSize);
+#endif
   Int refStride = picRef->getCStride();
   Int dstStride = yuvDst->getCStride();
@@ -1968,4 +2559,5 @@
 
 #if H_3D_DIM_DMM
+#if !SEC_DMM3_RBC_F0147
 UInt TComPrediction::xPredWedgeFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt intraTabIdx )
 {
@@ -1979,4 +2571,5 @@
   return g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]][uiColTexIntraDir-2].at(intraTabIdx);
 }
+#endif
 
 Void TComPrediction::xPredContourFromTex( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, TComWedgelet* pcContourWedge )
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 724)
@@ -93,4 +93,7 @@
 #if H_3D_ARP
   Void xPredInterUniARP         ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false, TComMvField * pNewMvFiled = NULL );
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  Void xPredInterUniARPviewRef( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, TComMvField * pNewMvFiled = NULL );
+#endif
 #endif
   Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi=false          );
@@ -120,8 +123,14 @@
 
 #if H_3D_VSP
+#if MTK_F0109_LG_F0120_VSP_BLOCK
+  Void xGetVirtualDepth           ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int txtPerDepthX=1, Int txtPerDepthY=1 );
+  Void xPredInterLumaBlkFromDM    ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi, Int vspSize);
+  Void xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi, Int vspSize);
+#else
   Void xGetVirtualDepth           ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int txtPerDepthX=1, Int txtPerDepthY=1 );
   Void xPredInterLumaBlkFromDM    ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi );
   Void xPredInterChromaBlkFromDM  ( TComDataCU *cu, TComPicYuv *picRef, TComYuv *yuvDepth, Int* shiftLUT, TComMv *mv, UInt partAddr, Int width, Int height, Bool isDepth, TComYuv *&pcYuvDst, Bool isBi );
 #endif
+#endif
 
   Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst );
@@ -133,5 +142,8 @@
   Void xDCPredFiltering( Int* pSrc, Int iSrcStride, Pel*& rpDst, Int iDstStride, Int iWidth, Int iHeight );
   Bool xCheckIdenticalMotion    ( TComDataCU* pcCU, UInt PartAddr);
-
+#if MTK_SPIVMP_F0110
+  Bool xCheckTwoSPMotion ( TComDataCU* pcCU, UInt PartAddr0, UInt PartAddr1 );
+  Void xGetSubPUAddrAndMerge(TComDataCU* pcCU, UInt uiPartAddr, Int iSPWidth, Int iSPHeight, Int iNumSPInOneLine, Int iNumSP, UInt* uiMergedSPW, UInt* uiMergedSPH, UInt* uiSPAddr );
+#endif
 #if H_3D_DIM
   // depth intra functions
Index: trunk/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComRom.cpp	(revision 724)
@@ -604,5 +604,7 @@
 std::vector< std::vector<TComWedgeRef>  > g_dmmWedgeRefLists;
 std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists;
+#if !SEC_DMM3_RBC_F0147
 std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
+#endif
 
 Void initWedgeLists( Bool initNodeList )
@@ -723,4 +725,5 @@
   }
 
+#if !SEC_DMM3_RBC_F0147
   UInt uiThrSz = DMM3_SIMPLIFY_TR;
   std::vector< std::vector<UInt> > auiWdgListSz;
@@ -739,4 +742,5 @@
   }
   g_aauiWdgLstM3.push_back(auiWdgListSz);
+#endif
 }
 
Index: trunk/source/Lib/TLibCommon/TComRom.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRom.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComRom.h	(revision 724)
@@ -172,5 +172,7 @@
 extern       std::vector< std::vector<TComWedgeRef> >        g_dmmWedgeRefLists;
 extern       std::vector< std::vector<TComWedgeNode> >       g_dmmWedgeNodeLists;
+#if !SEC_DMM3_RBC_F0147
 extern       std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
+#endif
 
 Void initWedgeLists( Bool initNodeList = false );
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 724)
@@ -751,5 +751,17 @@
     if ( this->getNumRefIdx( RefPicList( uiRefListIdx ) ) == 0)
         continue;
-
+#if !SHARP_ARP_REF_CHECK_F0105
+// move the following to setARPStepNum() to define ARP related thing in ARP function.
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+     for(Int i = 0; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
+       {
+       if ( this->getRefPic(RefPicList(uiRefListIdx), i)->getPOC() != getPOC() )
+       {
+         this->setFirstTRefIdx (RefPicList(uiRefListIdx), i);
+         break;
+       }
+     }
+#endif
+#endif
     Bool bZeroIdxLtFlag = this->getRefPic(RefPicList(uiRefListIdx), 0)->getIsLongTerm();
     for(Int i = 1; i < this->getNumRefIdx(RefPicList(uiRefListIdx)); i++ )
@@ -1826,4 +1838,7 @@
 #if H_3D_IV_MERGE
     m_ivMvPredFlag         [ i ] = false;
+#if MTK_SPIVMP_F0110
+    m_iSubPULog2Size       [ i ] = 0;
+#endif
 #endif
 #if H_3D_VSP
@@ -1835,4 +1850,7 @@
 #if H_3D_INTER_SDC
     m_bInterSDCFlag        [ i ] = false;
+#endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+    m_bMPIFlag             [ i ] = false;
 #endif
   }  
@@ -2831,9 +2849,20 @@
 
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+Void TComSlice::setARPStepNum( TComPicLists*ivPicLists )
+#else
 Void TComSlice::setARPStepNum()                                  
-{
+#endif
+{
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool tempRefPicInListsFlag = false;
+#else
   Bool bAllIvRef = true;
-
+#endif
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  if(!getVPS()->getUseAdvRP(getLayerId()) || this->isIRAP())
+#else
   if(!getVPS()->getUseAdvRP(getLayerId()))
+#endif
   {
     m_nARPStepNum = 0;
@@ -2841,4 +2870,21 @@
   else
   {
+#if SHARP_ARP_REF_CHECK_F0105
+    setFirstTRefIdx (REF_PIC_LIST_0, -1);
+    setFirstTRefIdx (REF_PIC_LIST_1, -1);
+    for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
+    {
+      for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ )
+      {
+        if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() )
+        {
+          setFirstTRefIdx (RefPicList(refListIdx), i);
+          break;
+        }
+      }
+    }
+    tempRefPicInListsFlag = getFirstTRefIdx(REF_PIC_LIST_0) >= 0 || getFirstTRefIdx(REF_PIC_LIST_1) >= 0;
+    m_nARPStepNum = tempRefPicInListsFlag ? getVPS()->getARPStepNum(getLayerId()) : 0;
+#else
     for( Int iRefListId = 0; iRefListId < 2; iRefListId++ )
     {
@@ -2863,5 +2909,30 @@
     }
     m_nARPStepNum = !bAllIvRef ? getVPS()->getARPStepNum(getLayerId()) : 0;
-  }
+#endif
+  }
+#if SHARP_ARP_REF_CHECK_F0105
+  if (tempRefPicInListsFlag)
+  {
+    for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
+    {
+      RefPicList eRefPicList = RefPicList( refListIdx );
+      Int prevPOC = getRefPic(eRefPicList, getFirstTRefIdx(eRefPicList) )->getPOC();
+      for( Int i = 0; i < getNumActiveRefLayerPics(); i++ )
+      {
+        Int layerIdInNuh = getRefPicLayerId( i );
+        Int viewIdx = getVPS()->getViewId( layerIdInNuh );
+        TComPic*pcPicPrev = ivPicLists->getPic(viewIdx, 0, prevPOC);
+        if (getFirstTRefIdx(eRefPicList) >= 0 && pcPicPrev && pcPicPrev->getSlice( 0 )->isReferenced())
+        {
+          m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = true;
+        }
+        else
+        {
+          m_arpRefPicAvailable[eRefPicList][layerIdInNuh] = false;
+        }
+      }
+  }
+}
+#endif
 }
 #endif
@@ -2967,4 +3038,8 @@
   setupLUT = setupLUT || getVPS()->getDepthRefinementFlag( layerIdInVPS );
 #endif 
+
+#if QC_DEPTH_IV_MRG_F0125
+  setupLUT = setupLUT || ( getVPS()->getIvMvPredFlag(layerIdInVPS ) && getIsDepth() );
+#endif
 
   if( !setupLUT )
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 724)
@@ -597,4 +597,7 @@
 #if H_3D_IV_MERGE
   Bool        m_ivMvPredFlag             [ MAX_NUM_LAYERS ]; 
+#if MTK_SPIVMP_F0110
+  Int         m_iSubPULog2Size           [MAX_NUM_LAYERS   ];
+#endif
 #endif
 #if H_3D_VSP
@@ -618,4 +621,7 @@
 #if H_3D_INTER_SDC
   Bool        m_bInterSDCFlag[MAX_NUM_LAYERS   ];
+#endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Bool        m_bMPIFlag[MAX_NUM_LAYERS   ];
 #endif
 
@@ -826,4 +832,8 @@
   Void    setIvMvPredFlag     ( Int layerIdInVps, Bool val )  { m_ivMvPredFlag[ layerIdInVps ] = val; }
   Bool    getIvMvPredFlag     ( Int layerIdInVps )            { return m_ivMvPredFlag[ layerIdInVps ]; }; 
+#if MTK_SPIVMP_F0110
+  Int     getSubPULog2Size(Int layerIdInVps)           { return m_iSubPULog2Size[layerIdInVps]; }
+  Void    setSubPULog2Size(Int layerIdInVps, Int u)    { m_iSubPULog2Size[layerIdInVps] = u;}
+#endif
 #endif
 #if H_3D_VSP
@@ -854,5 +864,8 @@
   Void    setInterSDCFlag      ( Int layerIdInVps, Bool bval ){ m_bInterSDCFlag[layerIdInVps] = bval; }
 #endif
-
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Bool    getMPIFlag      ( Int layerIdInVps )           { return m_bMPIFlag[layerIdInVps]; }
+  Void    setMPIFlag      ( Int layerIdInVps, Bool bval ){ m_bMPIFlag[layerIdInVps] = bval; }
+#endif
 #endif  
 #endif
@@ -1338,4 +1351,7 @@
   UInt getCamParPrecision    ()  { return m_uiCamParPrecision; }
   Bool hasCamParInSliceHeader()  { return m_bCamParInSliceHeader; }
+#if QC_DEPTH_IV_MRG_F0125
+  Void setHasCamParInSliceHeader( Bool b )  { m_bCamParInSliceHeader = b; }
+#endif
   Int* getCodedScale         ()  { return m_aaiCodedScale [0]; }
   Int* getCodedOffset        ()  { return m_aaiCodedOffset[0]; }
@@ -1730,6 +1746,12 @@
 #endif
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool m_arpRefPicAvailable[2][MAX_NUM_LAYERS];
+#endif
   TComList<TComPic*> * m_pBaseViewRefPicList[MAX_NUM_LAYERS];
   UInt                 m_nARPStepNum; 
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  Int         m_aiFirstTRefIdx    [2]; 
+#endif
 #endif
 #if H_3D_IC
@@ -1818,5 +1840,9 @@
 #if H_3D_ARP
   Void      setBaseViewRefPicList( TComList<TComPic*> *pListPic, Int iViewIdx )      { m_pBaseViewRefPicList[iViewIdx] = pListPic;                   }
+#if SHARP_ARP_REF_CHECK_F0105
+  Void      setARPStepNum( TComPicLists*ivPicLists );
+#else
   Void      setARPStepNum();                                 
+#endif
   TComPic*  getBaseViewRefPic    ( UInt uiPOC , Int iViewIdx )                       { return xGetRefPic( *m_pBaseViewRefPicList[iViewIdx], uiPOC ); }
   UInt      getARPStepNum( )                                                         { return m_nARPStepNum;                                         }  
@@ -2019,4 +2045,11 @@
   Int       getAlterRefIdx          ( RefPicList e )        { return  m_aiAlterRefIdx[e];     }
 #endif
+#if QC_MTK_INTERVIEW_ARP_F0123_F0108
+  Int       getFirstTRefIdx        ( RefPicList e )                { return  m_aiFirstTRefIdx[e];     }
+  Void      setFirstTRefIdx        ( RefPicList e, Int i )         { m_aiFirstTRefIdx[e]    = i;      }
+#endif
+#if SHARP_ARP_REF_CHECK_F0105
+  Bool      getArpRefPicAvailable( RefPicList e, Int viewIdx) {return m_arpRefPicAvailable[e][getVPS()->getLayerIdInNuh(viewIdx, 0)]; }
+#endif
   Void      setIsDepth            ( Bool isDepth )   { m_isDepth = isDepth; }
   Bool      getIsDepth            ()                 { return m_isDepth; }
Index: trunk/source/Lib/TLibCommon/TComWedgelet.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComWedgelet.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TComWedgelet.h	(revision 724)
@@ -50,13 +50,23 @@
 enum DIM_IDX
 {
+#if SEC_DMM3_RBC_F0147
+  DMM1_IDX = 0,
+  DMM4_IDX = 1,
+#else
   DMM1_IDX = 0,
   DMM3_IDX = 1,
   DMM4_IDX = 2,
   RBC_IDX  = 3
+#endif
 };
 
+#if SEC_DMM3_RBC_F0147
+#define DMM_NUM_TYPE   2
+#define DIM_NUM_TYPE   (DMM_NUM_TYPE)
+#else
 #define DMM_NUM_TYPE   3
 #define RBC_NUM_TYPE   1
 #define DIM_NUM_TYPE   (DMM_NUM_TYPE+RBC_NUM_TYPE)
+#endif
 #define DIM_NO_IDX     MAX_UINT
 
@@ -75,5 +85,7 @@
 #define DMM_NO_WEDGEINDEX       MAX_UINT
 #define DMM_NUM_WEDGE_REFINES   8
+#if !SEC_DMM3_RBC_F0147
 #define DMM3_SIMPLIFY_TR        1
+#endif
 
 enum WedgeResolution
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 656)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 724)
@@ -65,4 +65,5 @@
 #define H_3D          ( HEVC_EXT == 2)
 
+
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   MAJOR DEFINES   ///////////////////////////////////  
@@ -131,5 +132,7 @@
                                               // QC_AMVP_MRG_UNIFY_IVCAN_C0051     
                                               // TEXTURE MERGING CANDIDATE     , JCT3V-C0137
-                                              // QC_INRIA_MTK_MRG_E0126            
+                                              // QC_INRIA_MTK_MRG_E0126 
+
+
 #define H_3D_TMVP                         1   // QC_TMVP_C0047 
                                               // Sony_M23639
@@ -162,5 +165,4 @@
 
 
-
 // OTHERS
                                               // MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170 // Progressive MV Compression, JCT3V-E0170
@@ -173,5 +175,4 @@
 #endif
 
-
 // Rate Control
 #define KWU_FIX_URQ                       1
@@ -212,5 +213,4 @@
 #if H_3D_DIM
 #define H_3D_DIM_DMM                      1   // Depth Modeling Modes
-#define H_3D_DIM_RBC                      1   // Region Boundary Chain mode
 #define H_3D_DIM_SDC                      1   // Simplified Depth Coding method
 #define H_3D_DIM_DLT                      1   // Depth Lookup Table
@@ -227,5 +227,4 @@
 #define H_3D_VSP_CONSTRAINED              0
 #endif
-
 #endif
 
@@ -243,4 +242,52 @@
 #define H_3D_FCO_VSP_DONBDV_E0163               0   // Adaptive depth reference for flexible coding order
 #endif
+
+
+/////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////   HTM-9.0 Integrations //////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#if H_3D
+
+#define FIX_MISSING_MACRO_R690                  1 // Missing macro in integration to revision 690
+
+#define SEC_MPI_ENABLING_MERGE_F0150            1 // MPI flag in VPS and enabling in Merge mode
+#define ETRIKHU_MERGE_REUSE_F0093               1 // Reuse HEVC merge candidate list construction for base candidates, JCT3V-F0093 
+
+#if H_3D_ARP
+#define QC_MTK_INTERVIEW_ARP_F0123_F0108        1 //JCT3V-F0123; JCT3V-F0108
+#define SHARP_ARP_REF_CHECK_F0105               1 // ARP reference picture selection and DPB check
+#define LGE_ARP_CTX_F0161                       1 //JCT3V-F0161
+#endif
+
+#if H_3D_IV_MERGE
+#define QC_DEPTH_IV_MRG_F0125                   1 // JCT3V-F0125: Depth oriented Inter-view MV candidate
+#define MTK_SPIVMP_F0110                        1 // JCT3V-F0110: Sub-PU level inter-view motion prediction
+#define BUGFIX_F0093                            1 // bug fix for F0093 for depth IvMC pruning
+#define BUGFIX_2_F0093                          1 // bug fix for VSP inheritance
+#endif
+
+#if H_3D_VSP
+#define MTK_F0109_LG_F0120_VSP_BLOCK            1 // MTK_LG_SIMPLIFY_VSP_BLOCK_PARTITION_F0109_F0120  
+#define SHARP_VSP_BLOCK_IN_AMP_F0102            1 // VSP partitioning for AMP
+#define MTK_VSP_SIMPLIFICATION_F0111            1 // 1. Inherited VSP also use NBDV of current CU, 2. VSP cannot be inherited from above LCU rowss
+#define LGE_SHARP_VSP_INHERIT_F0104             1
+#endif
+
+#define LGE_BUGFIX_F0158                        1 //JCT3V-F0158
+#define LGE_IC_CTX_F0160                        1 //JCT3V-F0160
+#define SEC_ONLY_TEXTURE_IC_F0151               1
+
+#if H_3D_DIM
+#define SEC_DMM3_RBC_F0147                      1 // Removal of DMM3 and RBC from DMMs
+#if !SEC_DMM3_RBC_F0147
+#define H_3D_DIM_RBC                            1 // Region Boundary Chain mode
+#endif
+#define QC_DIM_DELTADC_UNIFY_F0132              1 // Unify delta DC coding in depth intra modes
+#define HHI_DIM_PREDSAMP_FIX_F0171              1
+#define LGE_PRED_RES_CODING_DLT_DOMAIN_F0159    1 //JCT3V-F0159
+#endif
+#endif
+
 
 /////////////////////////////////////////////////////////////////////////////////////////
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 724)
@@ -1245,4 +1245,7 @@
     pcVPS->setARPStepNum( i, 1 );
 #endif  
+#if MTK_SPIVMP_F0110
+    pcVPS->setSubPULog2Size(i, 0);
+#endif
     if ( i != 0 )
     {
@@ -1251,4 +1254,7 @@
 #if H_3D_IV_MERGE
         READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
+#if MTK_SPIVMP_F0110
+        READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+#endif
 #endif
 #if H_3D_ARP
@@ -1265,5 +1271,19 @@
       else
       {
-
+#if QC_DEPTH_IV_MRG_F0125 && H_3D_IV_MERGE
+        if(i!=1)
+        {
+          READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
+        }
+#endif
+#if MTK_SPIVMP_F0110
+        if (i!=1)
+        {
+          READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+        }
+#endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+        READ_FLAG( uiCode, "mpi_flag[i]" );             pcVPS->setMPIFlag( i, uiCode == 1 ? true : false );
+#endif
         READ_FLAG( uiCode, "vps_depth_modes_flag[i]" );             pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false );
         //          READ_FLAG( uiCode, "lim_qt_pred_flag[i]");                  pcVPS->setLimQtPreFlag     ( i, uiCode == 1 ? true : false ); 
@@ -1795,5 +1815,9 @@
     }
 #if H_3D_IC
+#if SEC_ONLY_TEXTURE_IC_F0151
+    else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth())
+#else
     else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) )
+#endif
     {
       UInt uiCodeTmp = 0;
@@ -1813,6 +1837,20 @@
       READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
 #if H_3D_IV_MERGE
+#if SEC_MPI_ENABLING_MERGE_F0150
+      if(rpcSlice->getIsDepth())
+      {
+        Bool bMPIFlag = rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) ;
+        Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
+        rpcSlice->setMaxNumMergeCand(( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
+      }
+      else
+      {
+        Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
+        rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
+      }
+#else
       Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ;
       rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode);
+#endif
 #else
       rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 724)
@@ -135,5 +135,7 @@
 Void TDecCu::decompressCU( TComDataCU* pcCU )
 {
+#if !QC_DEPTH_IV_MRG_F0125
   xDecompressCU( pcCU, 0,  0 );
+#endif
 }
 
@@ -313,4 +315,12 @@
       m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth)  );
       m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
+#if QC_DEPTH_IV_MRG_F0125
+      if( pcCU->getSlice()->getIsDepth())
+      {
+        DvInfo.bDV = m_ppcCU[uiDepth]->getDispNeighBlocks(0, 0, &DvInfo);
+      }
+      else
+      {
+#endif
 #if H_3D_NBDV_REF
       if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() ))  //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done.
@@ -323,5 +333,7 @@
         DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo);
       }
-
+#if QC_DEPTH_IV_MRG_F0125
+      }
+#endif
 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
       if ( g_decTraceDispDer )
@@ -378,12 +390,45 @@
     UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
 
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#if H_3D_ARP
+    m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
+#endif
+#endif
+
 #if H_3D_VSP
     Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
     InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
+#if MTK_SPIVMP_F0110
+    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
+    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+    TComMvField*  pcMvFieldSP;
+    UChar* puhInterDirSP;
+    pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
+    puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+    m_ppcCU[uiDepth]->initAvailableFlags();
+    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+#if MTK_SPIVMP_F0110
+      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+      , numValidMergeCand, uiMergeIndex );
+#else
     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand, uiMergeIndex );
+#endif
     pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
 #else
+#if ETRIKHU_MERGE_REUSE_F0093
+    m_ppcCU[uiDepth]->initAvailableFlags();
     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+    m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#else
+    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#endif
 #endif
 #if H_3D_VSP
@@ -423,4 +468,28 @@
       }
     }
+#if MTK_SPIVMP_F0110
+    pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); 
+    if (bSPIVMPFlag[uiMergeIndex])
+    {
+      UInt uiSPAddr;
+      Int iWidth = pcCU->getWidth(uiAbsPartIdx);
+      Int iHeight = pcCU->getHeight(uiAbsPartIdx);
+
+      Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+      pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+      for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+      {
+        pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+        pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+        pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+        pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+      }
+    }
+    delete pcMvFieldSP;
+    delete puhInterDirSP;
+#endif
+#if !LGE_SHARP_VSP_INHERIT_F0104
 #if H_3D_IC
     m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
@@ -429,5 +498,10 @@
     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
 #endif
+#endif
+
     xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
+#if QC_DEPTH_IV_MRG_F0125
+    xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
+#endif
     return;
   }
@@ -443,4 +517,7 @@
     {
       xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
+#if QC_DEPTH_IV_MRG_F0125
+      xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
+#endif
       return;
     }
@@ -452,4 +529,5 @@
   // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
+#if !LGE_SHARP_VSP_INHERIT_F0104
 #if H_3D_IC
   m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
@@ -458,4 +536,5 @@
   m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth );  
 #endif  
+#endif
 #if H_3D_INTER_SDC
   m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
@@ -466,4 +545,7 @@
   setdQPFlag( bCodeDQP );
   xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast );
+#if QC_DEPTH_IV_MRG_F0125
+  xDecompressCU(pcCU, uiAbsPartIdx, uiDepth );
+#endif
 }
 
@@ -481,5 +563,5 @@
 {
   TComPic* pcPic = pcCU->getPic();
-  
+#if !QC_DEPTH_IV_MRG_F0125  
   Bool bBoundary = false;
   UInt uiLPelX   = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
@@ -516,5 +598,5 @@
     return;
   }
-  
+#endif  
   // Residual reconstruction
   m_ppcYuvResi[uiDepth]->clear();
@@ -693,5 +775,16 @@
     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     {
+#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
+        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
+        {
+            pReco    [ uiX ] = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
+        }
+        else
+        {
       pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
+        }
+#else
+      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
+#endif
       pRecIPred[ uiX ] = pReco[ uiX ];
     }
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 724)
@@ -111,5 +111,9 @@
   pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
 
+#if SEC_ONLY_TEXTURE_IC_F0151
+  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
+#else
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) )
+#endif
   {
     return;
@@ -209,5 +213,11 @@
   UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
 #endif
-
+#if MTK_SPIVMP_F0110
+  Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
+  TComMvField*  pcMvFieldSP;
+  UChar* puhInterDirSP;
+  pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
+  puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
+#endif
   for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ )
   {
@@ -235,4 +245,12 @@
       decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
       UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#if H_3D_ARP
+      decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#endif
       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
       {
@@ -244,5 +262,18 @@
           memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
           InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
+#if MTK_SPIVMP_F0110
+          memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+          pcSubCU->initAvailableFlags();
+          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
+          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+#if MTK_SPIVMP_F0110
+            , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+            , numValidMergeCand );
+#else
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
+#endif
           pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
 
@@ -252,5 +283,12 @@
           }
 #else
+#if ETRIKHU_MERGE_REUSE_F0093
+          pcSubCU->initAvailableFlags();
+          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
+          pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+
+#else
           pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+#endif
 #endif
           isMerged = true;
@@ -265,5 +303,18 @@
         memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
         InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
+#if MTK_SPIVMP_F0110
+        memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+        pcSubCU->initAvailableFlags();
+        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo
+#if MTK_SPIVMP_F0110
+          , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+          ,numValidMergeCand, uiMergeIndex );
+#else
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo,numValidMergeCand, uiMergeIndex );
+#endif
         pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
         if(vspFlag[uiMergeIndex])
@@ -272,5 +323,11 @@
         }
 #else
+#if ETRIKHU_MERGE_REUSE_F0093
+        pcSubCU->initAvailableFlags();
         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+        pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#else
+        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
+#endif
 #endif
       }
@@ -288,4 +345,27 @@
         }
       }
+#if MTK_SPIVMP_F0110
+      pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );  
+      if (bSPIVMPFlag[uiMergeIndex] != 0)
+      {
+        Int iWidth, iHeight;
+        UInt uiIdx;
+        pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true );
+
+        UInt uiSPAddr;
+
+        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+        {
+          pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+          pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+        }
+      }
+#endif
     }
     else
@@ -301,4 +381,12 @@
         }
       }
+#if LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_IC
+      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#if H_3D_ARP
+      decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#endif
     }
 #if H_3D_VSP
@@ -313,4 +401,8 @@
     }
   }
+#if MTK_SPIVMP_F0110
+  delete pcMvFieldSP;
+  delete puhInterDirSP;
+#endif
   return;
 }
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 724)
@@ -89,5 +89,7 @@
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#if !SEC_DMM3_RBC_F0147
 , m_cDmm3DataSCModel          ( 1,             1,               NUM_DMM3_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -176,5 +178,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM3_RBC_F0147
   m_cDmm3DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM3_DATA );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -249,5 +253,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM3_RBC_F0147
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -408,4 +414,22 @@
 }
 
+#if QC_DIM_DELTADC_UNIFY_F0132
+Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt uiNumSeg )
+{
+  UInt absValDeltaDC = 0;
+  xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, 0) );
+  rValDeltaDC = (Pel)absValDeltaDC + ( uiNumSeg > 1 ? 0 : 1 );
+
+  if( rValDeltaDC != 0 )
+  {
+    UInt uiSign;
+    m_pcTDecBinIf->decodeBinEP( uiSign );
+    if ( uiSign )
+    {
+      rValDeltaDC = -rValDeltaDC;
+    }
+  }
+}
+#else
 Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt dimType )
 {
@@ -424,4 +448,6 @@
   }
 }
+#endif
+
 #if H_3D_DIM_DMM
 Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit )
@@ -435,5 +461,5 @@
   ruiTabIdx = uiIdx;
 }
-
+#if !SEC_DMM3_RBC_F0147
 Void TDecSbac::xParseDmm3WedgeIdx( UInt& ruiIntraIdx, Int iNumBit )
 {
@@ -446,4 +472,5 @@
   ruiIntraIdx = uiIdx;
 }
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -1140,4 +1167,5 @@
       pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth );
     } break;
+#if !SEC_DMM3_RBC_F0147
   case( DMM3_IDX ):
     {
@@ -1146,4 +1174,5 @@
       pcCU->setDmm3IntraTabIdxSubParts( uiIntraIdx, absPartIdx, depth );
     } break;
+#endif
   case( DMM4_IDX ): break;
 #endif
@@ -1157,5 +1186,5 @@
   }
 
-#if H_3D_DIM_SDC
+#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
   if( pcCU->getSDCFlag(absPartIdx) )
   {
@@ -1173,7 +1202,48 @@
   {
 #endif
+#if QC_DIM_DELTADC_UNIFY_F0132
+    if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
+#else
     if( dimType < DIM_NUM_TYPE )
+#endif
     {
       UInt symbol;
+#if QC_DIM_DELTADC_UNIFY_F0132
+      UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
+
+      if( pcCU->getSDCFlag( absPartIdx ) )
+      {
+        assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N);
+        pcCU->setTrIdxSubParts(0, absPartIdx, depth);
+        pcCU->setCbfSubParts(1, 1, 1, absPartIdx, depth);
+      }
+
+      m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) );
+
+      if( symbol )
+      {
+        if( !pcCU->getSDCFlag( absPartIdx ) )
+        {
+          dir += symbol;
+        }
+      }
+      for( UInt segment = 0; segment < uiNumSegments; segment++ )
+      {
+        Pel valDeltaDC = 0;
+        if( symbol )
+        {
+          xParseDimDeltaDC( valDeltaDC, uiNumSegments );
+        }
+
+        if( pcCU->getSDCFlag( absPartIdx ) )
+        {
+          pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
+        }
+        else
+        {
+          pcCU->setDimDeltaDC( dimType, segment, absPartIdx, valDeltaDC );
+        }
+      }
+#else
       m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
       if( symbol )
@@ -1187,6 +1257,7 @@
         }
       }
-    }
-#if H_3D_DIM_SDC
+#endif
+    }
+#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
   }
 #endif
@@ -1218,5 +1289,9 @@
   else if( puIdx == 0 )
   {
+#if SEC_DMM3_RBC_F0147
+    while( binNum < 1 && symbol )
+#else
     while( binNum < 3 && symbol )
+#endif
     {
       ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum);
@@ -1225,11 +1300,30 @@
       binNum++;
     }
+#if SEC_DMM3_RBC_F0147
+    if( modeCode == 0 ) { dir = 0;                       sdcFlag = 0;}
+    else if( modeCode == 1 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+#else
          if( modeCode == 0 ) { dir = 0;                       sdcFlag = 0;}
     else if( modeCode == 2 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
     else if( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
     else if( modeCode == 7 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+#endif
   }
   else
   {
+#if SEC_DMM3_RBC_F0147
+    while( binNum < 4 && symbol )
+    {
+      ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum);
+      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+      modeCode = (modeCode<<1) + symbol;
+      binNum++;
+    }
+    if ( modeCode == 0 )        { dir =  PLANAR_IDX;             sdcFlag = 1;}
+    else if ( modeCode == 2 )   { dir = 5;                       sdcFlag = 0;}
+    else if ( modeCode == 6 )   { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
+    else if ( modeCode == 14 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if ( modeCode == 15 )  { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
+#else
     UInt maxBinNum = 0;
     m_pcTDecBinIf->decodeBinEP(symbol);
@@ -1263,4 +1357,5 @@
       else if ( modeCode == 3 )  { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
     }
+#endif
   }
   pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 724)
@@ -99,8 +99,14 @@
 #if H_3D_DIM
   Void  xReadExGolombLevel   ( UInt& ruiSymbol, ContextModel& rcSCModel  );
+#if QC_DIM_DELTADC_UNIFY_F0132
+  Void  xParseDimDeltaDC     ( Pel& rValDeltaDC, UInt uiNumSeg );
+#else
   Void  xParseDimDeltaDC     ( Pel& rValDeltaDC, UInt dimType );
+#endif
 #if H_3D_DIM_DMM
   Void  xParseDmm1WedgeIdx   ( UInt& ruiTabIdx, Int iNumBit );
+#if !SEC_DMM3_RBC_F0147
   Void  xParseDmm3WedgeIdx   ( UInt& ruiIntraIdx, Int iNumBit );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -213,5 +219,7 @@
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
+#if !SEC_DMM3_RBC_F0147
   ContextModel3DBuffer m_cDmm3DataSCModel;
+#endif
 #endif
 #if H_3D_DIM_RBC
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 724)
@@ -282,4 +282,19 @@
 }
 
+#if QC_DEPTH_IV_MRG_F0125
+Void
+CamParsCollector::copyCamParamForSlice( TComSlice* pcSlice )
+{
+  UInt uiViewIndex = pcSlice->getViewIndex();
+
+  pcSlice->getSPS()->initCamParaSPS( uiViewIndex, m_uiCamParsCodedPrecision, m_bCamParsVaryOverTime, m_aaiCodedScale, m_aaiCodedOffset );
+
+  if( m_bCamParsVaryOverTime )
+  {
+    pcSlice->setCamparaSlice( m_aaiCodedScale, m_aaiCodedOffset );
+  }
+}
+#endif
+
 Bool
 CamParsCollector::xIsComplete()
@@ -951,5 +966,9 @@
     pcSlice->setRefPicList     ( tempRefPicLists, usedAsLongTerm, numPocTotalCurr, true ); 
 #if H_3D_ARP
+#if SHARP_ARP_REF_CHECK_F0105
+    pcSlice->setARPStepNum(m_ivPicLists);
+#else
     pcSlice->setARPStepNum();
+#endif
     if( pcSlice->getARPStepNum() > 1 )
     {
@@ -1053,4 +1072,11 @@
   }
 
+#if QC_DEPTH_IV_MRG_F0125
+  if( pcSlice->getIsDepth() && m_pcCamParsCollector )
+  {
+    m_pcCamParsCollector->copyCamParamForSlice( pcSlice );
+  }
+#endif
+
   //  Decode a picture
   m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
@@ -1060,4 +1086,10 @@
     m_pcCamParsCollector->setSlice( pcSlice );
   }
+#if QC_DEPTH_IV_MRG_F0125
+  if( pcSlice->getIsDepth() )
+  {
+    pcSlice->getSPS()->setHasCamParInSliceHeader( false );
+  }
+#endif
 #endif
   m_bFirstSliceInPicture = false;
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 656)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 724)
@@ -77,4 +77,8 @@
   Bool  isInitialized() const     { return m_bInitialized; }
   Int**** getBaseViewShiftLUTI()  { return m_aiBaseViewShiftLUT;   }
+
+#if QC_DEPTH_IV_MRG_F0125
+  Void  copyCamParamForSlice( TComSlice* pcSlice );
+#endif
 
 private:
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 724)
@@ -1006,4 +1006,7 @@
 #if H_3D_IV_MERGE
         WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
+#if MTK_SPIVMP_F0110
+        WRITE_UVLC( pcVPS->getSubPULog2Size(i)-2, "log2_sub_PU_size_minus2[i]");
+#endif
 #endif
 #if H_3D_ARP
@@ -1019,4 +1022,19 @@
       else
       {
+#if QC_DEPTH_IV_MRG_F0125
+        if(i!=1)
+        {
+          WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
+        }
+#endif
+#if MTK_SPIVMP_F0110
+        if (i!=1)
+        {
+          WRITE_UVLC( pcVPS->getSubPULog2Size(i)-2, "log2_sub_PU_size_minus2[i]");
+        }
+#endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+        WRITE_FLAG( pcVPS->getMPIFlag( i ) ? 1 : 0 ,          "mpi_flag[i]" );
+#endif
         WRITE_FLAG( pcVPS->getVpsDepthModesFlag( i ) ? 1 : 0 ,          "vps_depth_modes_flag[i]" );
         //WRITE_FLAG( pcVPS->getLimQtPredFlag    ( i ) ? 1 : 0 ,          "lim_qt_pred_flag[i]"     ); 
@@ -1387,5 +1405,9 @@
     }
 #if H_3D_IC
+#if SEC_ONLY_TEXTURE_IC_F0151
+    else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) && !pcSlice->getIsDepth())
+#else
     else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) )
+#endif
     {
       WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" );
@@ -1405,6 +1427,20 @@
     {
 #if H_3D_IV_MERGE
+#if SEC_MPI_ENABLING_MERGE_F0150
+      if(pcSlice->getIsDepth())
+      {
+        Bool bMPIFlag = pcSlice->getVPS()->getMPIFlag( pcSlice->getLayerIdInVps() ) ;
+        Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
+        WRITE_UVLC( ( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
+      }
+      else
+      {
+        Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
+        WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
+      }
+#else
       Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
       WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
+#endif
 #else
       WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
@@ -1452,5 +1488,9 @@
     WRITE_UVLC(0,"slice_header_extension_length"); //<- this element needs to be set to the correct value!!
 
+#if QC_DEPTH_IV_MRG_F0125
+    if( pcSlice->getSPS()->hasCamParInSliceHeader() && !pcSlice->getIsDepth() )
+#else
     if( pcSlice->getSPS()->hasCamParInSliceHeader() )
+#endif
     {
       for( UInt uiId = 0; uiId < pcSlice->getViewIndex(); uiId++ )
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 724)
@@ -403,4 +403,7 @@
   UInt      m_uiARPStepNum;
 #endif
+#if MTK_SPIVMP_F0110
+  Int      m_iSubPULog2Size;
+#endif
 #if H_3D_IC
   Bool      m_bUseIC;
@@ -412,7 +415,12 @@
 #if H_3D_DIM
   Bool      m_useDMM;
+#if !SEC_DMM3_RBC_F0147
   Bool      m_useRBC;
+#endif
   Bool      m_useSDC;
   Bool      m_useDLT;
+#endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Bool      m_useMPI;
 #endif
 #if H_3D_QTLPC
@@ -500,4 +508,8 @@
   UInt       getARPStepNum                  ()               { return m_uiARPStepNum;    }
   Void       setARPStepNum                  ( UInt  u )      { m_uiARPStepNum = u;       }
+#endif
+#if MTK_SPIVMP_F0110
+  Int        getSubPULog2Size                   ()                   { return m_iSubPULog2Size;}
+  Void       setSubPULog2Size                   (Int u)              { m_iSubPULog2Size = u; }     
 #endif
 
@@ -980,6 +992,8 @@
   Bool      getUseDMM                       ()        { return m_useDMM; }
   Void      setUseDMM                       ( Bool b) { m_useDMM = b;    }
+#if !SEC_DMM3_RBC_F0147
   Bool      getUseRBC                       ()        { return m_useRBC; }
   Void      setUseRBC                       ( Bool b) { m_useRBC = b;    }
+#endif
   Bool      getUseSDC                       ()        { return m_useSDC; }
   Void      setUseSDC                       ( Bool b) { m_useSDC = b;    }
@@ -993,4 +1007,8 @@
   Bool      getUsePC                        ()         { return m_bUsePC;  }
 #endif
+#if SEC_MPI_ENABLING_MERGE_F0150
+  Void      setUseMPI                       ( Bool b ) { m_useMPI = b;    }
+  Bool      getUseMPI                       ()         { return m_useMPI; }
+#endif
 #endif // H_3D
 };
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 724)
@@ -497,5 +497,9 @@
 #endif
 #if H_3D_IC
+#if SEC_ONLY_TEXTURE_IC_F0151
+  Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth();
+#else
   Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE );
+#endif
   bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC();
 #endif
@@ -567,4 +571,12 @@
           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
           rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
+#if QC_DEPTH_IV_MRG_F0125
+          if (rpcTempCU->getSlice()->getIsDepth() )
+          {
+            DvInfo.bDV = rpcTempCU->getDispNeighBlocks(0, 0, &DvInfo);
+          }
+          else
+          {
+#endif 
 #if H_3D_NBDV_REF
           if(rpcTempCU->getSlice()->getVPS()->getDepthRefinementFlag( rpcTempCU->getSlice()->getLayerIdInVps()))
@@ -574,4 +586,7 @@
             DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo);
 
+#if QC_DEPTH_IV_MRG_F0125
+          }
+#endif
           rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
           rpcBestCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
@@ -1764,14 +1779,40 @@
 #endif
 
+#if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104 
+  DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
+#else
   rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
   rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
+#endif
 
 #if H_3D_VSP
+#if !(H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104)
   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
   InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
-  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand );
+#if ETRIKHU_MERGE_REUSE_F0093
+  rpcTempCU->m_bAvailableFlagA1 = 0;
+  rpcTempCU->m_bAvailableFlagB1 = 0;
+  rpcTempCU->m_bAvailableFlagB0 = 0;
+  rpcTempCU->m_bAvailableFlagA0 = 0;
+  rpcTempCU->m_bAvailableFlagB2 = 0;
+  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand );
+#else
+  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
+#endif
+#endif
+#else
+#if ETRIKHU_MERGE_REUSE_F0093
+  rpcTempCU->m_bAvailableFlagA1 = 0;
+  rpcTempCU->m_bAvailableFlagB1 = 0;
+  rpcTempCU->m_bAvailableFlagB0 = 0;
+  rpcTempCU->m_bAvailableFlagA0 = 0;
+  rpcTempCU->m_bAvailableFlagB2 = 0;
+  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+  rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
 #else
   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
+#endif
 #endif
 
@@ -1781,5 +1822,9 @@
   Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
 #endif
+#if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104
+for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
+#else
 for( UInt ui = 0; ui < numValidMergeCand; ++ui )
+#endif
   {
     mergeCandBuffer[ui] = 0;
@@ -1806,5 +1851,42 @@
   for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
   {
+#if FIX_MISSING_MACRO_R690
+    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
+#else
     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS*sizeof(Int) );
+#endif
+#if LGE_SHARP_VSP_INHERIT_F0104
+    rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
+    rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
+    rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
+#if H_3D_IC
+    rpcTempCU->setICFlagSubParts( bICFlag, 0, 0, uhDepth );
+#endif
+    rpcTempCU->getDvInfo(0) = cOrigDisInfo;
+    rpcTempCU->setDvInfoSubParts(cOrigDisInfo, 0, 0, uhDepth );
+    Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
+    memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
+    InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
+#if MTK_SPIVMP_F0110
+    Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
+    memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+    TComMvField*  pcMvFieldSP;
+    UChar* puhInterDirSP;
+    pcMvFieldSP = new TComMvField[rpcTempCU->getPic()->getPicSym()->getNumPartition()*2]; 
+    puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; 
+#endif
+#if ETRIKHU_MERGE_REUSE_F0093
+    rpcTempCU->initAvailableFlags();
+    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
+    rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo
+#if MTK_SPIVMP_F0110
+      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+      , numValidMergeCand 
+      );
+#else
+    rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
+#endif
+#endif
 #endif
   for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
@@ -1841,9 +1923,34 @@
           rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
 #endif
-          rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
-          rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-          rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-
-#if H_3D_ARP
+#if MTK_SPIVMP_F0110
+          rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
+          if (bSPIVMPFlag[uiMergeCand])
+          {
+            UInt uiSPAddr;
+            Int iWidth = rpcTempCU->getWidth(0);
+            Int iHeight = rpcTempCU->getHeight(0);
+
+            Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+            rpcTempCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+            for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+            {
+              rpcTempCU->getSPAbsPartIdx(0, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+              rpcTempCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+              rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(rpcTempCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+            }
+          }
+          else
+          {
+#endif
+            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
+            rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+            rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+#if MTK_SPIVMP_F0110
+          }
+#endif
+#if H_3D_ARP && !QC_MTK_INTERVIEW_ARP_F0123_F0108
           if( nARPW )
           {
@@ -1860,5 +1967,9 @@
             if( !bSignalflag[0] && !bSignalflag[1] )
             {
+#if LGE_SHARP_VSP_INHERIT_F0104
+              continue;
+#else
               rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
+#endif
             }
           }
@@ -1982,4 +2093,8 @@
   }
  }
+#if MTK_SPIVMP_F0110
+ delete pcMvFieldSP;
+ delete puhInterDirSP;
+#endif
 #if H_3D_ARP
  }
@@ -2051,4 +2166,5 @@
     m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
 
+#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
     if(rpcTempCU->getPartitionSize(0)==SIZE_2Nx2N)
     {
@@ -2068,4 +2184,5 @@
       }
     }
+#endif
   }
   else
@@ -2088,4 +2205,5 @@
      m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
 
+#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
      Bool bSignalflag[2] = { true, true };
      for(UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )
@@ -2102,4 +2220,5 @@
        rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
      }
+#endif
    }
   }
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 724)
@@ -160,5 +160,9 @@
 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
+#if SEC_ONLY_TEXTURE_IC_F0151
+  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
+#else
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) )
+#endif
   {
     return;
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 724)
@@ -724,5 +724,9 @@
 #if H_3D_ARP
     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
+#if SHARP_ARP_REF_CHECK_F0105
+    pcSlice->setARPStepNum(m_ivPicLists);
+#else
     pcSlice->setARPStepNum();
+#endif
     if(pcSlice->getARPStepNum() > 1)
     {
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 724)
@@ -95,5 +95,7 @@
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#if !SEC_DMM3_RBC_F0147
 , m_cDmm3DataSCModel          ( 1,             1,               NUM_DMM3_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -174,5 +176,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM3_RBC_F0147
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -262,5 +266,7 @@
 #if H_3D_DIM_DMM
       curCost += m_cDmm1DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM3_RBC_F0147
       curCost += m_cDmm3DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM3_DATA );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -331,5 +337,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM3_RBC_F0147
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -518,4 +526,15 @@
 }
 
+#if QC_DIM_DELTADC_UNIFY_F0132
+Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg )
+{
+  xWriteExGolombLevel( UInt( abs( valDeltaDC ) - ( uiNumSeg > 1 ? 0 : 1 ) ), m_cDdcDataSCModel.get(0, 0, 0) );
+  if( valDeltaDC != 0 )
+  {
+    UInt uiSign = valDeltaDC > 0 ? 0 : 1;
+    m_pcBinIf->encodeBinEP( uiSign );
+  }
+}
+#else
 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt dimType )
 {
@@ -527,4 +546,5 @@
   }
 }
+#endif
 
 #if H_3D_DIM_DMM
@@ -537,4 +557,5 @@
 }
 
+#if !SEC_DMM3_RBC_F0147
 Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit )
 {
@@ -544,4 +565,5 @@
   }
 }
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -1209,8 +1231,10 @@
       xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
     } break;
+#if !SEC_DMM3_RBC_F0147
   case( DMM3_IDX ):
     {
       xCodeDmm3WedgeIdx( pcCU->getDmm3IntraTabIdx( absPartIdx ), g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
     } break;
+#endif
   case( DMM4_IDX ): break;
 #endif
@@ -1225,5 +1249,5 @@
   }
 
-#if H_3D_DIM_SDC
+#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
   if( pcCU->getSDCFlag( absPartIdx ) )
   {
@@ -1238,6 +1262,41 @@
   {
 #endif
+#if QC_DIM_DELTADC_UNIFY_F0132
+    if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
+#else
     if( dimType < DIM_NUM_TYPE )
-    {
+#endif
+    {
+#if QC_DIM_DELTADC_UNIFY_F0132
+      UInt dimDeltaDC;
+      Pel  deltaDC;
+      UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
+      if( pcCU->getSDCFlag( absPartIdx ) )
+    {
+        if( uiNumSegments==1 )
+        {
+          dimDeltaDC = pcCU->getSDCSegmentDCOffset(0, absPartIdx) ? 1 : 0;
+        }
+        else
+        {
+          dimDeltaDC = ( pcCU->getSDCSegmentDCOffset(0, absPartIdx) || pcCU->getSDCSegmentDCOffset(1, absPartIdx) ) ? 1 : 0;
+        }
+      }
+      else
+      {
+        dimDeltaDC = isDimDeltaDC( dir );
+      }
+
+      m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) );
+
+      if( dimDeltaDC ) 
+      {
+        for( UInt segment = 0; segment < uiNumSegments; segment++ )
+        {
+          deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset(segment, absPartIdx) : pcCU->getDimDeltaDC( dimType, segment, absPartIdx );
+          xCodeDimDeltaDC( deltaDC, uiNumSegments );
+        }
+      }
+#else
       UInt dimDeltaDC = isDimDeltaDC( dir );
       m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
@@ -1249,6 +1308,7 @@
         }
       }
-    }
-#if H_3D_DIM_SDC
+#endif
+    }
+#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
   }
 #endif
@@ -1257,6 +1317,11 @@
 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
 {
+#if SEC_DMM3_RBC_F0147
+  UInt codeWordTable[3][7] =    {{0, 0, 0, 1, 0, 0, 0},{0, 2, 6, 14, 15, 0, 0},{0, 1, 0, 0, 0, 0, 0}};
+  UInt codeWordLenTable[3][7] = {{0, 1, 0, 1, 0, 0, 0},{1, 2, 3,  4,  4, 0, 0},{1, 1, 0, 0, 0, 0, 0}};
+#else
     UInt codeWordTable[3][7] =    {{0, 0, 0, 2, 0,6, 7},{0, 0, 2, 7, 3, 6, 2},{0, 1, 0, 0, 0, 0, 0}};
     UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{1, 1, 2, 3, 2, 3, 2},{1, 1, 0, 0, 0, 0, 0}};
+#endif
   UInt dir = pcCU->getLumaIntraDir( absPartIdx );
   UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 );
@@ -1273,6 +1338,8 @@
     case DMM1_IDX: codeIdx = 3; break;
     case DMM4_IDX: codeIdx = 4; break;
+#if !SEC_DMM3_RBC_F0147
     case DMM3_IDX: codeIdx = 5; break;
     case  RBC_IDX: codeIdx = 6; break;
+#endif
     default:                    break;
     }
@@ -1289,4 +1356,5 @@
   }
 #endif
+#if !SEC_DMM3_RBC_F0147 
   if( puIdx==1 )
   {
@@ -1300,4 +1368,5 @@
       }
   }
+#endif
   //mode coding
   for( UInt i = 0; i < codeWordLenTable[puIdx][codeIdx]; i++ )
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 724)
@@ -118,8 +118,14 @@
   #if H_3D_DIM
   Void  xWriteExGolombLevel  ( UInt uiSymbol, ContextModel& rcSCModel  );
+#if QC_DIM_DELTADC_UNIFY_F0132
+  Void  xCodeDimDeltaDC      ( Pel valDeltaDC, UInt uiNumSeg );
+#else
   Void  xCodeDimDeltaDC      ( Pel valDeltaDC, UInt dimType );
+#endif
 #if H_3D_DIM_DMM
   Void  xCodeDmm1WedgeIdx    ( UInt uiTabIdx, Int iNumBit );
+#if !SEC_DMM3_RBC_F0147
   Void  xCodeDmm3WedgeIdx    ( UInt uiIntraIdx, Int iNumBit );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -253,5 +259,7 @@
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
+#if !SEC_DMM3_RBC_F0147
   ContextModel3DBuffer m_cDmm3DataSCModel;
+#endif
 #endif
 #if H_3D_DIM_RBC
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 724)
@@ -1126,5 +1126,16 @@
       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
       {
+#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
+          if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
+          {
+              pResi[ uiX ] = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] );
+          }
+          else
+          {
+              pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
+          }
+#else
         pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
+#endif
       }
       pOrg  += uiStride;
@@ -1190,5 +1201,16 @@
       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
       {
+#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
+          if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
+          {
+              pReco    [ uiX ] = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
+          }
+          else
+          {
+              pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
+          }
+#else
         pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
+#endif
         pRecQt   [ uiX ] = pReco[ uiX ];
         pRecIPred[ uiX ] = pReco[ uiX ];
@@ -2876,4 +2898,5 @@
               biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
             } break;
+#if !SEC_DMM3_RBC_F0147
           case( DMM3_IDX ):
             {
@@ -2893,4 +2916,5 @@
               }
             } break;
+#endif
           case( DMM4_IDX ):
             {
@@ -2928,5 +2952,9 @@
         {
           Pel deltaDC1 = 0; Pel deltaDC2 = 0;
+#if QC_DIM_DELTADC_UNIFY_F0132
+          xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
+#else
           xSearchRbcDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
+#endif
           pcCU->setDimDeltaDC( RBC_IDX, 0, uiPartOffset, deltaDC1 );
           pcCU->setDimDeltaDC( RBC_IDX, 1, uiPartOffset, deltaDC2 );
@@ -2975,5 +3003,9 @@
       Bool bTestZeroResi = false;
 #if H_3D_DIM_ENC
+#if LGE_BUGFIX_F0158
+      bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP();
+#else
       bTestZeroResi |= pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->isIRAP();
+#endif
 #endif
 #if H_3D_DIM_SDC
@@ -3584,4 +3616,7 @@
                                  , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
+#if MTK_SPIVMP_F0110
+                                 , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
                                  , Int& numValidMergeCand
                                  )
@@ -3599,4 +3634,18 @@
     if ( iPUIdx == 0 )
     {
+#if ETRIKHU_MERGE_REUSE_F0093
+      pcCU->initAvailableFlags();
+      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
+      pcCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
+#if H_3D_VSP
+                                        , vspFlag
+                                        , inheritedVSPDisInfo
+#endif
+#if MTK_SPIVMP_F0110
+                                        , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+                                        , numValidMergeCand
+        );
+#else
       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
 #if H_3D_VSP
@@ -3606,4 +3655,5 @@
                                    , numValidMergeCand
                                    );
+#endif
     }
     pcCU->setPartSizeSubParts( partSize, 0, uiDepth );
@@ -3611,4 +3661,18 @@
   else
   {
+#if ETRIKHU_MERGE_REUSE_F0093
+    pcCU->initAvailableFlags();
+    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
+    pcCU->xGetInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
+#if H_3D_VSP
+                                      , vspFlag
+                                      , inheritedVSPDisInfo
+#endif
+#if MTK_SPIVMP_F0110
+                                      , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif
+                                      , numValidMergeCand
+      );
+#else
     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
@@ -3618,4 +3682,5 @@
                                  , numValidMergeCand
                                  );
+#endif
   }
 #if H_3D_VSP
@@ -3635,6 +3700,29 @@
       PartSize ePartSize = pcCU->getPartitionSize( 0 );
 
-      pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
-      pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+#if MTK_SPIVMP_F0110
+      pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx )); 
+      if (pbSPIVMPFlag[uiMergeCand])
+      {
+        UInt uiSPAddr;
+
+        Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+        pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+        for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+        {
+          pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+          pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+          pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+        }
+      }
+      else
+      {
+#endif
+        pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+        pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+#if MTK_SPIVMP_F0110
+      }
+#endif
 
 #if H_3D_VSP
@@ -4313,5 +4401,12 @@
       DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
 #endif
-
+#if MTK_SPIVMP_F0110
+      Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
+      memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
+      TComMvField*  pcMvFieldSP;
+      UChar* puhInterDirSP;
+      pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; 
+      puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; 
+#endif
       xMergeEstimation( pcCU, pcOrgYuv, iPartIdx, uiMRGInterDir, cMRGMvField, uiMRGIndex, uiMRGCost, cMvFieldNeighbours, uhInterDirNeighbours
 #if H_3D_VSP
@@ -4319,4 +4414,7 @@
                       , inheritedVSPDisInfo
 #endif
+#if MTK_SPIVMP_F0110
+                      , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
+#endif 
                       , numValidMergeCand
                       );
@@ -4330,9 +4428,41 @@
         pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMRGIndex].m_acDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
-        pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
-        {
-          pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
-          pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
-        }
+#if MTK_SPIVMP_F0110
+        pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );  
+        if (bSPIVMPFlag[uiMRGIndex]!=0)
+        {
+          UInt uiSPAddr;
+
+          Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
+
+          pcCU->getSPPara(iRoiWidth, iRoiHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
+
+          for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++)
+          {
+            pcCU->getSPAbsPartIdx(uiPartAddr, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr);
+            pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight);
+            pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight);
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight);
+          }
+
+          if ( pcCU->getInterDir(uiPartAddr) == 3 && pcCU->isBipredRestriction(iPartIdx) )
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiPartAddr, 0, iPartIdx);
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiPartAddr, 0, iPartIdx);
+            pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ));
+          }
+
+        }
+        else
+        {
+#endif
+          pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
+          }
+#if MTK_SPIVMP_F0110
+        }
+#endif
 
         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
@@ -4346,4 +4476,7 @@
       else
       {
+#if MTK_SPIVMP_F0110        
+        pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
+#endif
         // set ME result
         pcCU->setMergeFlagSubParts( false,        uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
@@ -4358,4 +4491,8 @@
         }
       }
+#if MTK_SPIVMP_F0110
+      delete pcMvFieldSP;
+      delete puhInterDirSP;
+#endif
     }
 
@@ -5270,5 +5407,9 @@
       dZeroCost = dCost + 1;
     }
+#if MTK_SPIVMP_F0110
+    if ( dZeroCost < dCost || pcCU->getQtRootCbf(0)==0)
+#else
     if ( dZeroCost < dCost )
+#endif
     {
       dCost        = dZeroCost;
@@ -7300,4 +7441,5 @@
 }
 
+#if !SEC_DMM3_RBC_F0147
 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir )
 {
@@ -7336,5 +7478,5 @@
   cPredYuv.destroy();
 }
-
+#endif
 #endif
 #if H_3D_DIM_RBC
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 724)
@@ -351,5 +351,7 @@
   Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
   Void xSearchDmm1Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx );
+#if !SEC_DMM3_RBC_F0147
   Void xSearchDmm3Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir );
+#endif
 #endif
 #if H_3D_DIM_RBC
@@ -425,4 +427,7 @@
                                   , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
+#if MTK_SPIVMP_F0110
+                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
+#endif
                                   , Int& numValidMergeCand
                                    );
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 724)
@@ -556,5 +556,16 @@
   rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
 #if H_3D_IV_MERGE
+#if SEC_MPI_ENABLING_MERGE_F0150
+  if(rpcSlice->getIsDepth())
+  {
+    rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( ( rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) || rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ) ? 1 : 0 ) );
+  }
+  else
+  {
+    rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
+  }
+#else
    rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
+#endif
 #else
   rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 656)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 724)
@@ -835,5 +835,7 @@
   }
 #if H_3D
+#if !QC_DEPTH_IV_MRG_F0125
   if ( !m_isDepth )
+#endif
   {
     m_cSPS.initCamParaSPS           ( m_viewIndex, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
