Index: trunk/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- trunk/source/Lib/TLibCommon/ContextTables.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/ContextTables.h	(revision 833)
@@ -97,15 +97,27 @@
 
 #if H_3D_ARP
+#if MTK_ARP_FLAG_CABAC_SIMP_G0061
+#define NUM_ARPW_CTX                  3       ///< number of context models for weighting factor index used by advanced residual prediction
+#else
 #define NUM_ARPW_CTX                  4       ///< number of context models for weighting factor index used by advanced residual prediction
 #endif
+#endif
 
 #if H_3D_IC
+#if MTK_IC_FLAG_CABAC_SIMP_G0061
+#define NUM_IC_FLAG_CTX               1       ///< number of context models for illumination compensation flag
+#else
 #define NUM_IC_FLAG_CTX               3       ///< number of context models for illumination compensation flag
 #endif
+#endif
 
 #define CNU                          154      ///< dummy initialization value for unused context models 'Context model Not Used'
 
 #if H_3D_DIM
+#if QC_GENERIC_SDC_G0122
+#define NUM_DEPTH_INTRA_MODE_CTX      1       ///< number of context models for depth intra modes
+#else
 #define NUM_DEPTH_INTRA_MODE_CTX      8       ///< number of context models for depth intra modes
+#endif
 #define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (DMM or RBC)
 #define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or RBC)
@@ -113,4 +125,10 @@
 #define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
 #endif
+#if QC_GENERIC_SDC_G0122
+#define NUM_ANGLE_FLAG_CTX            3
+#if !QC_SDC_UNIFY_G0130
+#define NUM_INTRASDC_FLAG_CTX         3
+#endif
+#endif
 #endif
 
@@ -120,8 +138,15 @@
 #endif
 
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
 #define NUM_INTER_SDC_FLAG_CTX        1      ///< number of context models for inter SDC flag
 #define NUM_INTER_SDC_SIGN_FLAG_CTX   1      ///< number of context models for sign of inter SDC residual
 #define NUM_INTER_SDC_RESIDUAL_CTX    1      ///< number of context models for abs of inter SDC residual
+#endif
+
+#if QC_SDC_UNIFY_G0130
+#define NUM_SDC_FLAG_CTX              1      ///< number of context 
+#endif
+#if H_3D_DBBP
+#define DBBP_NUM_FLAG_CTX                 1
 #endif
 // ====================================================================================================================
@@ -364,4 +389,13 @@
 
 #if H_3D_ARP
+#if MTK_ARP_FLAG_CABAC_SIMP_G0061
+static const UChar 
+INIT_ARPW[3][NUM_ARPW_CTX] = 
+{
+    { 162, 153, 162 },
+    { 162, 153, 162 },
+    { 162, 153, 162 },
+};
+#else
 static const UChar 
 INIT_ARPW[3][NUM_ARPW_CTX] = 
@@ -372,6 +406,15 @@
 };
 #endif
-
+#endif
 #if H_3D_IC
+#if MTK_IC_FLAG_CABAC_SIMP_G0061
+static const UChar 
+INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] =  
+{
+    { 154 },
+    { 154 },
+    { 154 },
+};
+#else
 static const UChar 
 INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] =  
@@ -382,5 +425,15 @@
 };
 #endif
+#endif
 #if H_3D_DIM
+#if QC_GENERIC_SDC_G0122
+static const UChar
+INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
+{
+  { 154, },
+  { 154, },
+  { 154, }
+};
+#else
 static const UChar
 INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
@@ -390,4 +443,24 @@
     {64, 0, CNU, CNU, 168, 109,   0, 0}
 };
+#endif
+
+#if QC_GENERIC_SDC_G0122
+static const UChar 
+INIT_ANGLE_FLAG[3][NUM_ANGLE_FLAG_CTX] =
+{
+  { 154, 155, 156 },
+  { 141, 185, 214 },
+  { 155, 170, 157 },
+};
+#if !QC_SDC_UNIFY_G0130
+static const UChar 
+INIT_INTRASDC_FLAG[3][NUM_INTRASDC_FLAG_CTX] =
+{
+  { 214, 229, 230 },
+  { 215, 202, 174 },
+  { 213, 201, 246 },
+};
+#endif
+#endif
 
 static const UChar 
@@ -432,5 +505,5 @@
 #endif
 
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
 static const UChar 
 INIT_INTER_SDC_FLAG[3][NUM_INTER_SDC_FLAG_CTX] =
@@ -458,5 +531,22 @@
 #endif
 //! \}
-
-
-#endif
+#if QC_SDC_UNIFY_G0130
+static const UChar 
+INIT_SDC_FLAG[3][NUM_SDC_FLAG_CTX] =
+{
+  { 154 },  
+  { 154 },
+  { 154 },
+};
+#endif
+
+#if H_3D_DBBP
+static const UChar INIT_DBBP_FLAG[3][DBBP_NUM_FLAG_CTX] =
+{
+  { CNU },
+  { CNU },
+  { CNU },
+};
+#endif
+
+#endif
Index: trunk/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComDataCU.cpp	(revision 833)
@@ -123,6 +123,13 @@
 #if H_3D_DIM_SDC
   m_pbSDCFlag             = NULL;
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    m_apSegmentDCOffset[i]  = NULL;
+  }
+#else
   m_apSegmentDCOffset[0]  = NULL;
   m_apSegmentDCOffset[1]  = NULL;
+#endif
 #endif
 #endif
@@ -146,4 +153,5 @@
 #endif
 #if H_3D_INTER_SDC
+#if !QC_SDC_UNIFY_G0130
   m_pbInterSDCFlag       = NULL;
   for( Int i = 0; i < 4; i++ )
@@ -151,5 +159,16 @@
     m_apSegmentInterDCOffset[i] = NULL;
   }
+#endif
+#if !SEC_INTER_SDC_G0101
   m_pucInterSDCMask       = NULL;
+#endif
+#endif
+#if H_3D_DBBP
+  m_pbDBBPFlag         = NULL;
+#endif
+
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth = NULL;
+  m_pbUseDDD = NULL;
 #endif
 }
@@ -272,9 +291,16 @@
 #if H_3D_DIM_SDC
     m_pbSDCFlag             = (Bool*)xMalloc(Bool, uiNumPartition);
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+    for( Int i = 0; i < 4; i++ )
+    {
+      m_apSegmentDCOffset[i]  = (Pel*)xMalloc(Pel, uiNumPartition);
+    }
+#else
     m_apSegmentDCOffset[0]  = (Pel*)xMalloc(Pel, uiNumPartition);
     m_apSegmentDCOffset[1]  = (Pel*)xMalloc(Pel, uiNumPartition);
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
     m_pbInterSDCFlag     = (Bool*  )xMalloc(Bool,   uiNumPartition);
     for( Int i = 0; i < 4; i++ )
@@ -283,4 +309,7 @@
     }
 #endif
+#if H_3D_DBBP
+    m_pbDBBPFlag         = (Bool*  )xMalloc(Bool,   uiNumPartition);
+#endif
   }
   else
@@ -289,7 +318,9 @@
     m_acCUMvField[1].setNumPartition(uiNumPartition );
   }
+#if !SEC_INTER_SDC_G0101
 #if H_3D_INTER_SDC
   m_pucInterSDCMask     = (UChar*  )xMalloc(UChar,    g_uiMaxCUHeight*g_uiMaxCUWidth);
 #endif
+#endif
   m_sliceStartCU        = (UInt*  )xMalloc(UInt, uiNumPartition);
   m_sliceSegmentStartCU = (UInt*  )xMalloc(UInt, uiNumPartition);
@@ -298,4 +329,9 @@
   m_pcPattern            = (TComPattern*)xMalloc(TComPattern, 1);
   
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth         = (UChar*  )xMalloc( UChar,  uiNumPartition);
+  m_pbUseDDD                         = (Bool*  ) xMalloc( Bool,   uiNumPartition);
+#endif 
+
   // create motion vector fields
   
@@ -377,4 +413,9 @@
 #endif
 
+#if MTK_DDD_G0063
+    if ( m_pucDisparityDerivedDepth ) { xFree(m_pucDisparityDerivedDepth);          m_pucDisparityDerivedDepth        = NULL; }
+    if ( m_pbUseDDD                 ) { xFree(m_pbUseDDD);                          m_pbUseDDD                        = NULL; }
+#endif
+
 #if H_3D_ARP
     if ( m_puhARPW            ) { delete[] m_puhARPW;           m_puhARPW           = NULL; }
@@ -400,9 +441,16 @@
 #if H_3D_DIM_SDC
     if ( m_pbSDCFlag            ) { xFree(m_pbSDCFlag);             m_pbSDCFlag             = NULL; }
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+    for( Int i = 0; i < 4; i++ )
+    {
+      if ( m_apSegmentDCOffset[i] ) { xFree(m_apSegmentDCOffset[i]);  m_apSegmentDCOffset[i]  = NULL; }
+    }
+#else
     if ( m_apSegmentDCOffset[0] ) { xFree(m_apSegmentDCOffset[0]);  m_apSegmentDCOffset[0]  = NULL; }
     if ( m_apSegmentDCOffset[1] ) { xFree(m_apSegmentDCOffset[1]);  m_apSegmentDCOffset[1]  = NULL; }
 #endif
 #endif    
-#if H_3D_INTER_SDC
+#endif    
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
     if ( m_pbInterSDCFlag     ) { xFree(m_pbInterSDCFlag);      m_pbInterSDCFlag    = NULL; }
     for(Int i = 0; i < 4; i++ )
@@ -411,7 +459,12 @@
   }
 #endif
-  }
+#if H_3D_DBBP
+    if ( m_pbDBBPFlag         ) { xFree(m_pbDBBPFlag);          m_pbDBBPFlag        = NULL; }
+#endif
+  }
+#if !SEC_INTER_SDC_G0101
 #if H_3D_INTER_SDC
   if ( m_pucInterSDCMask     ) { xFree(m_pucInterSDCMask);      m_pucInterSDCMask    = NULL; }
+#endif
 #endif
   m_pcCUAboveLeft       = NULL;
@@ -525,4 +578,10 @@
     m_pbICFlag[ui]   =  pcFrom->m_pbICFlag[ui];
 #endif
+
+#if MTK_DDD_G0063
+    m_pucDisparityDerivedDepth[ui] = pcFrom->m_pucDisparityDerivedDepth[ui];
+    m_pbUseDDD[ui] = pcFrom->m_pbUseDDD[ui];
+#endif
+
     m_puhWidth  [ui] = pcFrom->getWidth(ui);
     m_puhHeight [ui] = pcFrom->getHeight(ui);
@@ -554,6 +613,9 @@
     m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
     m_pbInterSDCFlag[ui] = pcFrom->m_pbInterSDCFlag[ui];
+#endif
+#if H_3D_DBBP
+    m_pbDBBPFlag[ui] = pcFrom->m_pbDBBPFlag[ui];
 #endif
   }
@@ -602,4 +664,10 @@
     memset( m_pbICFlag          + firstElement, false,                    numElements * sizeof( *m_pbICFlag )   );
 #endif
+
+#if MTK_DDD_G0063
+    memset( m_pucDisparityDerivedDepth        + firstElement, 0,           numElements * sizeof( *m_pucDisparityDerivedDepth ) );
+    memset( m_pbUseDDD                        + firstElement, 0,           numElements * sizeof( *m_pbUseDDD ) );
+#endif
+
 #if H_3D_DIM
     for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -616,9 +684,16 @@
 #if H_3D_DIM_SDC
     memset( m_pbSDCFlag             + firstElement,     0,                numElements * sizeof( *m_pbSDCFlag            ) );
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+    for( Int i = 0; i < 4; i++ )
+    {
+      memset( m_apSegmentDCOffset[i]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[i] ) );
+    }
+#else
     memset( m_apSegmentDCOffset[0]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[0] ) );
     memset( m_apSegmentDCOffset[1]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[1] ) );
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
     memset( m_pbInterSDCFlag   + firstElement,     0,                    numElements * sizeof( *m_pbInterSDCFlag ) );
     for( Int i = 0; i < 4; i++ )
@@ -626,4 +701,7 @@
       memset( m_apSegmentInterDCOffset[i] + firstElement,     0,         numElements * sizeof( *m_apSegmentInterDCOffset[i] ) );
     }
+#endif
+#if H_3D_DBBP
+    memset( m_pbDBBPFlag        + firstElement, false,                    numElements * sizeof( *m_pbDBBPFlag ) );
 #endif
   }
@@ -774,4 +852,10 @@
       m_pbICFlag[ui]  = false;
 #endif
+
+#if MTK_DDD_G0063
+      m_pucDisparityDerivedDepth[ui] = 0;
+      m_pbUseDDD[ui] = 0;
+#endif
+
 #if H_3D_DIM
       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -788,9 +872,16 @@
 #if H_3D_DIM_SDC
       m_pbSDCFlag           [ui] = false;
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+      for( Int i = 0; i < 4; i++ )
+      {
+        m_apSegmentDCOffset[i][ui] = 0;
+      }
+#else
       m_apSegmentDCOffset[0][ui] = 0;
       m_apSegmentDCOffset[1][ui] = 0;
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
       m_pbInterSDCFlag[ui] = false;
       for( Int i = 0; i < 4; i++ )
@@ -798,4 +889,7 @@
         m_apSegmentInterDCOffset[i][ui] = 0;
       }
+#endif
+#if H_3D_DBBP
+      m_pbDBBPFlag[ui] = false;
 #endif
     }
@@ -879,4 +973,10 @@
   memset( m_puhARPW,            0, iSizeInUchar  );
 #endif
+
+#if MTK_DDD_G0063
+  memset( m_pucDisparityDerivedDepth,         0, iSizeInUchar );
+  memset( m_pbUseDDD,                         0, iSizeInBool );
+#endif
+
   UChar uhWidth  = g_uiMaxCUWidth  >> uiDepth;
   UChar uhHeight = g_uiMaxCUHeight >> uiDepth;
@@ -901,9 +1001,16 @@
 #if H_3D_DIM_SDC
   memset( m_pbSDCFlag,            0, sizeof(Bool) * m_uiNumPartition  );
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    memset( m_apSegmentDCOffset[i], 0, sizeof(Pel) * m_uiNumPartition   );
+  }
+#else
   memset( m_apSegmentDCOffset[0], 0, sizeof(Pel) * m_uiNumPartition   );
   memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   memset( m_pbInterSDCFlag,           0, sizeof( Bool ) * m_uiNumPartition );
   for( Int i = 0; i < 4; i++ )
@@ -911,4 +1018,7 @@
     memset( m_apSegmentInterDCOffset[i], 0, sizeof( Int ) * m_uiNumPartition );
   }
+#endif
+#if H_3D_DBBP
+  memset( m_pbDBBPFlag,         0, iSizeInBool  );
 #endif
 
@@ -964,4 +1074,10 @@
       m_pbICFlag          [ui] = pcCU->m_pbICFlag[uiPartOffset+ui];
 #endif
+
+#if MTK_DDD_G0063
+      m_pucDisparityDerivedDepth[ui] = pcCU->m_pucDisparityDerivedDepth[uiPartOffset+ui];
+      m_pbUseDDD[ui]                 = pcCU->m_pbUseDDD[uiPartOffset+ui];
+#endif
+
 #if H_3D_DIM
       for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -978,9 +1094,16 @@
 #if H_3D_DIM_SDC
       m_pbSDCFlag           [ui] = pcCU->m_pbSDCFlag            [ uiPartOffset + ui ];
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+      for( Int i = 0; i < 4; i++ )
+      {
+        m_apSegmentDCOffset[i][ui] = pcCU->m_apSegmentDCOffset[i] [ uiPartOffset + ui ];
+      }
+#else
       m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0] [ uiPartOffset + ui ];
       m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1] [ uiPartOffset + ui ];
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
       m_pbInterSDCFlag      [ui] = pcCU->m_pbInterSDCFlag    [ uiPartOffset + ui ];
       for( Int i = 0; i < 4; i++ )
@@ -988,4 +1111,7 @@
         m_apSegmentInterDCOffset[i][ui] = pcCU->m_apSegmentInterDCOffset[i][ uiPartOffset + ui ];
       }
+#endif
+#if H_3D_DBBP
+      m_pbDBBPFlag[ui]=pcCU->m_pbDBBPFlag[uiPartOffset+ui];
 #endif
     }
@@ -1109,4 +1235,9 @@
 #endif
 
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth          = pcCU->getDDDepth()        + uiPart;
+  m_pbUseDDD                          = pcCU->getUseDDD()         + uiPart;
+#endif
+
   m_puhLumaIntraDir     = pcCU->getLumaIntraDir()     + uiPart;
   m_puhChromaIntraDir   = pcCU->getChromaIntraDir()   + uiPart;
@@ -1134,9 +1265,16 @@
 #if H_3D_DIM_SDC
   m_pbSDCFlag               = pcCU->getSDCFlag()              + uiPart;
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    m_apSegmentDCOffset[i]    = pcCU->getSDCSegmentDCOffset(i)  + uiPart;
+  }
+#else
   m_apSegmentDCOffset[0]    = pcCU->getSDCSegmentDCOffset(0)  + uiPart;
   m_apSegmentDCOffset[1]    = pcCU->getSDCSegmentDCOffset(1)  + uiPart;
 #endif
 #endif  
-#if H_3D_INTER_SDC
+#endif  
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_pbInterSDCFlag          = pcCU->getInterSDCFlag()       + uiPart;
   for( Int i = 0; i < 4; i++ )
@@ -1144,4 +1282,7 @@
     m_apSegmentInterDCOffset[i] = pcCU->getInterSDCSegmentDCOffset( i ) + uiPart;
   }
+#endif
+#if H_3D_DBBP
+  m_pbDBBPFlag              = pcCU->getDBBPFlag()         + uiPart;
 #endif
   m_puhDepth=pcCU->getDepth()                     + uiPart;
@@ -1256,4 +1397,13 @@
 #if H_3D_ARP
   m_puhARPW            = pcCU->getARPW()                  + uiAbsPartIdx;
+#endif
+
+#if MTK_DDD_G0063
+  m_pucDisparityDerivedDepth         = pcCU->getDDDepth()              + uiAbsPartIdx;
+  m_pbUseDDD                         = pcCU->getUseDDD()              + uiAbsPartIdx;
+#endif
+    
+#if H_3D_DBBP
+  m_pbDBBPFlag       = pcCU->getDBBPFlag()              + uiAbsPartIdx;
 #endif
 
@@ -1314,4 +1464,10 @@
   memcpy( m_puhCbf[2] + uiOffset, pcCU->getCbf(TEXT_CHROMA_V), iSizeInUchar );
   
+#if MTK_DDD_G0063
+  memcpy( m_pucDisparityDerivedDepth          + uiOffset, pcCU->getDDDepth(),         iSizeInUchar );
+  memcpy( m_pbUseDDD                          + uiOffset, pcCU->getUseDDD(),          iSizeInBool );
+#endif
+
+
 #if H_3D_DIM
   for( Int i = 0; i < DIM_NUM_TYPE; i++ )
@@ -1328,9 +1484,16 @@
 #if H_3D_DIM_SDC
   memcpy( m_pbSDCFlag             + uiOffset, pcCU->getSDCFlag(),             iSizeInBool  );
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    memcpy( m_apSegmentDCOffset[i]  + uiOffset, pcCU->getSDCSegmentDCOffset(i), sizeof( Pel ) * uiNumPartition);
+  }
+#else
   memcpy( m_apSegmentDCOffset[0]  + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition);
   memcpy( m_apSegmentDCOffset[1]  + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   memcpy( m_pbInterSDCFlag  + uiOffset, pcCU->getInterSDCFlag(),      iSizeInBool  );
   for( Int i = 0; i < 4; i++ )
@@ -1338,4 +1501,7 @@
     memcpy( m_apSegmentInterDCOffset[i] + uiOffset, pcCU->getInterSDCSegmentDCOffset( i ), sizeof( Int ) * uiNumPartition);
   }
+#endif
+#if H_3D_DBBP
+  memcpy( m_pbDBBPFlag          + uiOffset, pcCU->getDBBPFlag(),          iSizeInBool  );
 #endif
 
@@ -1410,4 +1576,9 @@
 #if H_3D_NBDV
   memcpy( rpcCU->getDvInfo()         + m_uiAbsIdxInLCU, m_pDvInfo,    sizeof(* m_pDvInfo)     * m_uiNumPartition );
+#endif
+
+#if MTK_DDD_G0063
+  memcpy( rpcCU->getDDDepth()          + m_uiAbsIdxInLCU, m_pucDisparityDerivedDepth,         iSizeInUchar  );
+  memcpy( rpcCU->getUseDDD()           + m_uiAbsIdxInLCU, m_pbUseDDD,                         iSizeInBool  );
 #endif
 
@@ -1450,9 +1621,16 @@
 #if H_3D_DIM_SDC
   memcpy( rpcCU->getSDCFlag()             + m_uiAbsIdxInLCU, m_pbSDCFlag,      iSizeInBool  );
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    memcpy( rpcCU->getSDCSegmentDCOffset(i) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[i], sizeof( Pel ) * m_uiNumPartition);
+  }
+#else
   memcpy( rpcCU->getSDCSegmentDCOffset(0) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[0], sizeof( Pel ) * m_uiNumPartition);
   memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   memcpy( rpcCU->getInterSDCFlag() + m_uiAbsIdxInLCU, m_pbInterSDCFlag,      iSizeInBool  );
   for( Int i = 0;i < 4; i++ )
@@ -1461,4 +1639,8 @@
   }
 #endif
+#if H_3D_DBBP
+  memcpy( rpcCU->getDBBPFlag()          + m_uiAbsIdxInLCU, m_pbDBBPFlag,          iSizeInBool  );
+#endif
+  
   memcpy( rpcCU->getDepth()  + m_uiAbsIdxInLCU, m_puhDepth,  iSizeInUchar );
   memcpy( rpcCU->getWidth()  + m_uiAbsIdxInLCU, m_puhWidth,  iSizeInUchar );
@@ -1544,4 +1726,9 @@
   memcpy( rpcCU->getCbf(TEXT_CHROMA_V) + uiPartOffset, m_puhCbf[2], iSizeInUchar );
   
+#if MTK_DDD_G0063
+  memcpy( rpcCU->getDDDepth()          + uiPartOffset, m_pucDisparityDerivedDepth,         iSizeInUchar );
+  memcpy( rpcCU->getUseDDD()           + uiPartOffset, m_pbUseDDD,                         iSizeInBool );
+#endif
+
 #if H_3D_DIM
   for( Int i = 0; i < DMM_NUM_TYPE; i++ )
@@ -1558,9 +1745,16 @@
 #if H_3D_DIM_SDC
   memcpy( rpcCU->getSDCFlag()             + uiPartOffset, m_pbSDCFlag,      iSizeInBool  );
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  for( Int i = 0; i < 4; i++ )
+  {
+    memcpy( rpcCU->getSDCSegmentDCOffset(i) + uiPartOffset, m_apSegmentDCOffset[i], sizeof( Pel ) * uiQNumPart);
+  }
+#else
   memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart);
   memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
 #endif
 #endif
-#if H_3D_INTER_SDC
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   memcpy( rpcCU->getInterSDCFlag() + uiPartOffset, m_pbInterSDCFlag,      iSizeInBool  );
   for( Int i = 0; i < 4; i++ )
@@ -1569,4 +1763,8 @@
   }
 #endif
+#if H_3D_DBBP
+  memcpy( rpcCU->getDBBPFlag()          + uiPartOffset, m_pbDBBPFlag,          iSizeInBool  );
+#endif
+  
   memcpy( rpcCU->getDepth()  + uiPartOffset, m_puhDepth,  iSizeInUchar );
   memcpy( rpcCU->getWidth()  + uiPartOffset, m_puhWidth,  iSizeInUchar );
@@ -1611,4 +1809,22 @@
 #endif
 }
+
+#if MTK_DDD_G0063
+Void TComDataCU::setDDDepthSubParts ( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+    setSubPart<UChar>( ucDDD, m_pucDisparityDerivedDepth, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+Void TComDataCU::setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+    setSubPart<Bool>( bUseDDD, m_pbUseDDD, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+Void TComDataCU::setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth )
+{
+    memset( m_pbUseDDD + uiAbsPartIdx, bUseDDD, (m_pcPic->getNumPartInCU() >> ( 2 * uiDepth ))*sizeof(Bool) );
+}
+
+#endif
 
 // --------------------------------------------------------------------------------------------------------------------
@@ -2267,11 +2483,12 @@
   uiCtx    = ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1) : 0;
   
+#if !MTK_ARP_FLAG_CABAC_SIMP_G0061        
   pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
   uiCtx   += ( pcTempCU ) ? ((pcTempCU->getARPW( uiTempPartIdx )==0)?0:1): 0;
-  
+#endif
   return uiCtx;
 }
 #endif
-
+#if !MTK_IC_FLAG_CABAC_SIMP_G0061
 #if H_3D_IC
 UInt TComDataCU::getCtxICFlag( UInt uiAbsPartIdx )
@@ -2291,6 +2508,86 @@
 }
 #endif
+#endif
+#if H_3D_DBBP
+Pel* TComDataCU::getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride)
+{
+  // get coded and reconstructed depth view
+  TComPicYuv* depthPicYuv = NULL;
+  Pel* pDepthPels = NULL;
+  
+  // DBBP is a texture coding tool
+  if( getSlice()->getIsDepth() )
+  {
+    return NULL;
+  }
+  
+#if H_3D_FCO
+  TComPic* depthPic = getSlice()->getIvPic(true, getSlice()->getViewIndex() );
+  
+  if( depthPic && depthPic->getPicYuvRec() != NULL && depthPic->getIsDepth() )  // depth first
+  {
+    depthPicYuv = depthPic->getPicYuvRec();
+    depthPicYuv->extendPicBorder();
+    
+    // get collocated depth block for current CU
+    uiDepthStride = depthPicYuv->getStride();
+    pDepthPels    = depthPicYuv->getLumaAddr( getAddr(), uiAbsPartIdx );
+  }
+  else  // texture first
+#else
+  {
+    DisInfo DvInfo = getDvInfo(uiAbsPartIdx);
+    
+    TComPic* baseDepthPic = getSlice()->getIvPic (true, DvInfo.m_aVIdxCan);
+    
+    if( baseDepthPic == NULL || baseDepthPic->getPicYuvRec() == NULL )
+    {
+      return NULL;
+    }
+    
+    depthPicYuv   = baseDepthPic->getPicYuvRec();
+    depthPicYuv->extendPicBorder();
+    uiDepthStride = depthPicYuv->getStride();
+    
+    Int iBlkX = ( getAddr() % baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUWidth  + g_auiRasterToPelX[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
+    Int iBlkY = ( getAddr() / baseDepthPic->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ getZorderIdxInCU()+uiAbsPartIdx ] ];
+    
+    Int iPictureWidth  = depthPicYuv->getWidth();
+    Int iPictureHeight = depthPicYuv->getHeight();
+    
+    Int iWidth  = uiWidth;
+    Int iHeight = uiHeight;
+    
+    Bool depthRefineFlag = false;
+#if H_3D_NBDV_REF
+    depthRefineFlag = m_pcSlice->getVPS()->getDepthRefinementFlag( m_pcSlice->getLayerIdInVps() );
+#endif // H_3D_NBDV_REF
+    
+    TComMv cDv = depthRefineFlag ? DvInfo.m_acDoNBDV : DvInfo.m_acNBDV;
+    
+    Int depthPosX = Clip3(0,   iPictureWidth - iWidth,  iBlkX + ((cDv.getHor()+2)>>2));
+    Int depthPosY = Clip3(0,   iPictureHeight- iHeight, iBlkY + ((cDv.getVer()+2)>>2));
+    
+    pDepthPels = depthPicYuv->getLumaAddr() + depthPosX + depthPosY * uiDepthStride;
+  }
+#endif
+  
+  AOF( depthPicYuv != NULL );
+  AOF( pDepthPels != NULL );
+  AOF( uiDepthStride != 0 );
+  
+  return pDepthPels;
+}
+#endif
+
+#if H_3D_DBBP
+Void TComDataCU::setDBBPFlagSubParts ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+  setSubPart( bDBBPFlag, m_pbDBBPFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+#endif
 
 #if H_3D_INTER_SDC
+#if !QC_SDC_UNIFY_G0130
 Void TComDataCU::setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
 {
@@ -2302,5 +2599,7 @@
   return 0;
 }
-
+#endif
+
+#if !SEC_INTER_SDC_G0101
 Void TComDataCU::xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask )
 {
@@ -2400,4 +2699,45 @@
 }
 #endif
+#endif
+
+#if QC_GENERIC_SDC_G0122
+UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx )
+{
+#if QC_SDC_UNIFY_G0130
+  return 0;
+#else
+  TComDataCU* pcTempCU;
+  UInt        uiTempPartIdx;
+  UInt        uiCtx = 0;
+
+  // Get BCBP of left PU
+  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx    = ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? pcTempCU->getSDCFlag( uiTempPartIdx ) : 0;
+
+  // Get BCBP of above PU
+  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx   += ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? pcTempCU->getSDCFlag( uiTempPartIdx ) : 0;
+
+  return uiCtx;
+#endif
+}
+
+UInt TComDataCU::getCtxAngleFlag( UInt uiAbsPartIdx )
+{
+  TComDataCU* pcTempCU;
+  UInt        uiTempPartIdx;
+  UInt        uiCtx = 0;
+
+  // Get BCBP of left PU
+  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx    = ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? ( pcTempCU->getLumaIntraDir( uiTempPartIdx ) < NUM_INTRA_MODE ? 1 : 0 ) : 0;
+
+  // Get BCBP of above PU
+  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx );
+  uiCtx   += ( pcTempCU && pcTempCU->isIntra( uiTempPartIdx ) ) ? ( pcTempCU->getLumaIntraDir( uiTempPartIdx ) < NUM_INTRA_MODE ? 1 : 0 ) : 0;
+
+  return uiCtx;
+}
+#endif
 
 UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
@@ -2627,5 +2967,17 @@
   if( !getSlice()->getIsDepth() || !isIntra(uiAbsPartIdx) || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
     return false;
-  
+#if QC_GENERIC_SDC_G0122
+  if( isDimMode( getLumaIntraDir( uiAbsPartIdx ) ) && !isDimDeltaDC( getLumaIntraDir( uiAbsPartIdx ) ) )
+  {
+    return true;
+  }
+  
+  if( getLumaIntraDir( uiAbsPartIdx ) < NUM_INTRA_MODE )
+  {
+    return true;
+  }
+
+  return false;
+#endif
   // check prediction mode
   UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx );  
@@ -3250,5 +3602,9 @@
   Bool* abCandIsInter, TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* vspFlag, Int& iCount3DV, InheritedVSPDisInfo*  inheritedVSPDisInfo  )
   {
+#if MTK_NBDV_IVREF_FIX_G0067
+  if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() || pDInfo->m_aVIdxCan == -1)
+#else
   if ( m_pcSlice->getViewIndex() == 0 || !m_pcSlice->getVPS()->getViewSynthesisPredFlag( m_pcSlice->getLayerIdInVps() ) || m_pcSlice->getIsDepth() )
+#endif
   {
     return false;
@@ -3267,7 +3623,9 @@
   
   Bool  refViewAvailFlag = false;
-  UChar predFlag[2]      = {0, 0};  
+  UChar predFlag[2]      = {0, 0};
+#if !MTK_RBIP_VSP_G0069
   Int   refListIdY       = 0;    
   Int   viewIdInRefListX = -1;
+#endif
   
   for( Int iRefListIdX = 0; iRefListIdX < 2 && !refViewAvailFlag; iRefListIdX++ )
@@ -3281,6 +3639,8 @@
         refViewAvailFlag      = true;
         predFlag[iRefListIdX] = 1;
+#if !MTK_RBIP_VSP_G0069
         viewIdInRefListX      = m_pcSlice->getRefPic(eRefPicListX, i)->getViewId();
         refListIdY            = 1 - iRefListIdX;
+#endif
         pcMvFieldNeighbours[(iCount<<1)+iRefListIdX].setMvField( pDInfo->m_acNBDV, i );
 #if H_3D_NBDV
@@ -3291,4 +3651,5 @@
   }
 
+#if !MTK_RBIP_VSP_G0069
   if (m_pcSlice->isInterB() && refViewAvailFlag)
   {
@@ -3330,4 +3691,5 @@
     }
   }
+#endif
 
   // Set values to be returned
@@ -3448,5 +3810,9 @@
   for ( Int currListPos = (ivCandDir[0] ? 1 : 0); currListPos < iCount; currListPos++ )
   {
+#if NTT_STORE_SPDV_VSP_G0148
+    if ( ( currListPos == posIvDC ) || ( vspFlag[ currListPos ] != 0 ) )
+#else
     if ( ( currListPos == posIvDC ) || ( vspFlag[ currListPos ] == 1 ) )
+#endif
     {
       continue;
@@ -3880,4 +4246,8 @@
   UChar tmpDir;
 
+#if MTK_DDD_G0063
+  m_iUseDDDCandIdx = -1;
+#endif
+
   //////////////////////////////////
   //////// GET DISPARITIES  ////////
@@ -3932,4 +4302,7 @@
   Bool bARPFlag = getARPW(uiAbsPartIdx)>0 ? true : false;
 #endif
+#if H_3D_DBBP
+  Bool bDBBPFlag = getDBBPFlag(uiAbsPartIdx);
+#endif
 
 #if H_3D
@@ -3957,5 +4330,9 @@
     iPosLeftAbove[0] = numA1B1B0;
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if (pcCULeft->getVSPFlag(uiLeftPartIdx) != 0
+#else
     if (pcCULeft->getVSPFlag(uiLeftPartIdx) == 1
+#endif
 #if H_3D_IC
       && !bICFlag
@@ -3980,5 +4357,9 @@
     iPosLeftAbove[1] = numA1B1B0;
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) != 0) 
+#else
     if ( ( ( getAddr() - pcCUAbove->getAddr() ) == 0) && (pcCUAbove->getVSPFlag(uiAbovePartIdx) == 1) 
+#endif
 #if H_3D_IC
       && !bICFlag
@@ -4003,5 +4384,9 @@
   {
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) != 0) 
+#else
     if ( ( ( getAddr() - pcCUAboveRight->getAddr() ) == 0) && (pcCUAboveRight->getVSPFlag(uiAboveRightPartIdx) == 1) 
+#endif
 #if H_3D_IC
       && !bICFlag
@@ -4024,5 +4409,9 @@
   {
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) != 0
+#else
     if (pcCULeftBottom->getVSPFlag(uiLeftBottomPartIdx) == 1
+#endif
 #if H_3D_IC
       && !bICFlag
@@ -4047,5 +4436,9 @@
   {
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) != 0) 
+#else
     if ( ( ( getAddr() - pcCUAboveLeft->getAddr() ) == 0) && (pcCUAboveLeft->getVSPFlag(uiAboveLeftPartIdx) == 1) 
+#endif
 #if H_3D_IC
       && !bICFlag
@@ -4075,4 +4468,112 @@
   if( bMPIFlag)
   {
+#if QC_SPIVMP_MPI_G0119
+    tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+    tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+    tmpDir        =  0;
+
+    TComPic * pcTexPic = m_pcSlice->getTexturePic();
+#if H_3D_FCO
+    if (pcTexturePic->getReconMark())
+    {
+#endif    
+      TComPicYuv*   pcTexRec = pcTexPic->getPicYuvRec  ();
+      UInt          uiPartAddr;
+      Int           iWidth, iHeight;
+      Int           iCurrPosX, iCurrPosY;
+
+      this->getPartIndexAndSize( uiPUIdx, uiPartAddr, iWidth, iHeight );
+      pcTexRec->getTopLeftSamplePos( this->getAddr(), this->getZorderIdxInCU() + uiPartAddr, iCurrPosX, iCurrPosY );
+
+      Int iPUWidth, iPUHeight, iNumPart, iNumPartLine;
+      this->getSPPara(iWidth, iHeight, iNumPart, iNumPartLine, iPUWidth, iPUHeight);
+
+      for (Int i=0; i<iNumPart; 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         iTexCUAddr;
+      Int         iTexAbsPartIdx;
+      TComDataCU* pcTexCU;
+      Int iPartition = 0;
+      Int iInterDirSaved = 0;
+      TComMvField cMvFieldSaved[2];
+
+      Int iOffsetX = iPUWidth/2;;
+      Int iOffsetY = iPUHeight/2;
+
+      Int         iTexPosX, iTexPosY;
+      const TComMv cMvRounding( 1 << ( 2 - 1 ), 1 << ( 2 - 1 ) );
+      for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iPUHeight)
+      {
+        for (Int j = iCurrPosX; j < iCurrPosX + iWidth; j += iPUWidth)
+        {
+          iTexPosX     = j + iOffsetX;
+          iTexPosY     = i + iOffsetY; 
+          pcTexRec->getCUAddrAndPartIdx( iTexPosX, iTexPosY, iTexCUAddr, iTexAbsPartIdx );
+          pcTexCU  = pcTexPic->getCU( iTexCUAddr );
+
+          if( pcTexCU && !pcTexCU->isIntra(iTexAbsPartIdx) )
+          {
+            for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )
+            {
+              RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+              TComMvField cTexMvField;
+              pcTexCU->getMvField( pcTexCU, iTexAbsPartIdx, eCurrRefPicList, cTexMvField );
+              Int iValidDepRef = getPic()->isTextRefValid( eCurrRefPicList, cTexMvField.getRefIdx() );
+              if( (cTexMvField.getRefIdx()>=0) && ( iValidDepRef >= 0 ) )
+              {
+                TComMv cMv = cTexMvField.getMv() + cMvRounding;
+                cMv >>=2;
+                this->clipMv( cMv );
+                pcMvFieldSP[2*iPartition + uiCurrRefListId].setMvField(cMv, iValidDepRef);
+              }
+            }
+          }
+          puhInterDirSP[iPartition] = (pcMvFieldSP[2*iPartition].getRefIdx()!=-1 ? 1: 0) + (pcMvFieldSP[2*iPartition+1].getRefIdx()!=-1 ? 2: 0);
+          if (puhInterDirSP[iPartition] == 0)
+          {
+            if (iInterDirSaved != 0)
+            {
+              puhInterDirSP[iPartition] = iInterDirSaved;
+              pcMvFieldSP[2*iPartition] = cMvFieldSaved[0];
+              pcMvFieldSP[2*iPartition + 1] = cMvFieldSaved[1];
+            }
+          }
+          else
+          {
+            if (iInterDirSaved ==0)
+            {
+              pbSPIVMPFlag[iCount] = true;
+              tmpDir = puhInterDirSP[iPartition];
+              tmpMV[0] = pcMvFieldSP[2*iPartition];
+              tmpMV[1] = pcMvFieldSP[2*iPartition+1];
+
+              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];
+                }
+              }
+            }
+            iInterDirSaved = puhInterDirSP[iPartition];
+            cMvFieldSaved[0] = pcMvFieldSP[2*iPartition];
+            cMvFieldSaved[1] = pcMvFieldSP[2*iPartition + 1];
+          }
+          iPartition ++;
+        }
+      }
+#if H_3D_FCO
+    }
+#endif
+#else
     UInt uiPartIdxCenter;
     xDeriveCenterIdx( uiPUIdx, uiPartIdxCenter );    
@@ -4131,5 +4632,5 @@
         tmpDir += ((tmpMV[1].getRefIdx()>=0)?2:0);
       }
-
+#endif
       if( tmpDir != 0 )
       {
@@ -4190,5 +4691,8 @@
           }
         }
-
+#if QC_SPIVMP_MPI_G0119
+        pcMvFieldNeighbours[iCount<<1].setMvField(tmpMV[0].getMv(), tmpMV[0].getRefIdx());
+        pcMvFieldNeighbours[(iCount<<1)+1].setMvField(tmpMV[1].getMv(), tmpMV[1].getRefIdx());
+#else
         if( (tmpMV[0].getRefIdx()>=0) && ( tRef[0] >= 0 ) )
         {
@@ -4202,4 +4706,5 @@
           }
         }
+#endif
         puhInterDirNeighbours[iCount] = tmpDir;
 
@@ -4210,7 +4715,113 @@
         iCount ++;
       }
-    }
-  }
-
+#if !QC_SPIVMP_MPI_G0119
+    }
+#endif
+  }
+#if MTK_DDD_G0063
+  if( m_pcSlice->getIsDepth() && m_pcSlice->getViewIndex() != 0  && bMPIFlag )
+  {
+      UInt uiPartIdx;
+      TComDataCU *pcTextureCU = m_pcSlice->getTexturePic()->getCU( getAddr() );
+      TComSlice *pcTextureSlice = pcTextureCU->getSlice();  
+
+
+      tmpMV[0].setMvField( cZeroMv, NOT_VALID );
+      tmpMV[1].setMvField( cZeroMv, NOT_VALID );
+      tmpDir = 0;
+
+      xDeriveCenterIdx( uiPUIdx, uiPartIdx); 
+
+      if ( pcTextureCU && !pcTextureCU->isIntra( uiPartIdx ) )
+      {
+
+          TComMvField cMVField;
+          UChar ucInterDir = pcTextureCU->getInterDir( uiPartIdx );
+
+          Int iDV = 0;
+          Int iViewIdx = 0;
+          if( ucInterDir & 1 )
+          {
+              pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_0, cMVField );
+              if( pcTextureSlice->getRefPOC( REF_PIC_LIST_0, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
+              {
+                  iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_0, cMVField.getRefIdx())->getViewIndex();
+                  iDV = cMVField.getHor();
+
+
+                  Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_0, cMVField.getRefIdx() );
+
+                  if( iValidDepRef >= 0 )
+                  {
+                      const TComMv cAdd( 2, 2 );
+                      cMVField.getMv() += cAdd;
+                      cMVField.getMv() >>= 2;
+                      clipMv( cMVField.getMv() );
+                      tmpMV[ 0 ].setMvField( cMVField.getMv(), iValidDepRef );
+                      tmpDir = 1;
+                  }
+              }
+          }
+          if( !tmpDir && ( ucInterDir & 2 ))
+          {
+              pcTextureCU->getMvField( pcTextureCU, uiPartIdx, REF_PIC_LIST_1, cMVField );
+              if( pcTextureSlice->getRefPOC( REF_PIC_LIST_1, cMVField.getRefIdx()) == pcTextureSlice->getPOC() )
+              {
+                  iViewIdx = pcTextureSlice->getRefPic( REF_PIC_LIST_1, cMVField.getRefIdx())->getViewIndex();
+                  iDV = cMVField.getHor();
+
+                  Int iValidDepRef = getPic()->isTextRefValid( REF_PIC_LIST_1, cMVField.getRefIdx() );
+
+                  if( iValidDepRef >= 0 )
+                  {
+                      const TComMv cAdd( 2, 2 );
+                      cMVField.getMv() += cAdd;
+                      cMVField.getMv() >>= 2;
+                      clipMv( cMVField.getMv() );
+                      tmpMV[ 1 ].setMvField( cMVField.getMv(), iValidDepRef );
+                      tmpDir = 2;
+                  }
+              }
+          }
+          if( tmpDir != 0 )
+          {
+              rightShiftMergeCandList( pcMvFieldNeighbours, puhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, iCount, 5-iCount, iCount3DV);
+              m_ucDDTmpDepth = m_pcSlice->getDepthFromDV( iDV,  iViewIdx );
+              m_iUseDDDCandIdx = iCount;
+
+              if( tmpDir == 1 )
+              {
+                  pcMvFieldNeighbours[ iCount << 1 ] = tmpMV[ 0 ];
+              }
+              else if( tmpDir == 2  )
+              {
+                  pcMvFieldNeighbours[( iCount << 1 ) + 1 ] = tmpMV[ 1 ];
+              }
+
+              abCandIsInter        [ iCount ] = true;
+              puhInterDirNeighbours[ iCount ] = tmpDir;
+
+              if ( mrgCandIdx == iCount )
+              {
+                  return;
+              }
+              iCount ++;
+
+              Int iLeftAboveAvail = 0;
+              if( iPosLeftAbove[ 0 ] != -1 )
+              {
+                  iPosLeftAbove[ 0 ] = iCount;
+                  iLeftAboveAvail = 1;
+              }
+              if( iPosLeftAbove[ 1 ] != -1 )
+              {
+                  iPosLeftAbove[ 1 ] = iCount + iLeftAboveAvail;
+              }
+
+          }
+      }      
+
+  }
+#endif
   /////////////////////////////////////////////////////////////////
   //////// DERIVE IvMC, IvMCShift,IvDCShift, IvDC  Candidates /////
@@ -4229,5 +4840,9 @@
   Bool ivMvPredFlag   = getSlice()->getVPS()->getIvMvPredFlag( getSlice()->getLayerIdInVps() );
 
+#if MTK_NBDV_IVREF_FIX_G0067
+  if ( ivMvPredFlag && cDisInfo.m_aVIdxCan!=-1)
+#else
   if ( ivMvPredFlag )
+#endif
   {
     getInterViewMergeCands(uiPUIdx, ivCandRefIdx, ivCandMv, &cDisInfo, ivCandDir , bIsDepth, pcMvFieldSP, puhInterDirSP );
@@ -4237,5 +4852,10 @@
   //////// INTER VIEW MOTION COMP(IvMC) /////////
   ///////////////////////////////////////////////
-
+#if QC_DEPTH_MERGE_SIMP_G0127
+  if( getSlice()->getIsDepth() )
+  {
+    ivCandDir[1] = ivCandDir[2] = ivCandDir[3] = 0;
+  }
+#endif
   if( ivCandDir[0] )
   {
@@ -4277,4 +4897,10 @@
       for(; iCnloop >= 0; iCnloop --)
       {
+#if MTK_DDD_G0063
+          if( iCnloop == m_iUseDDDCandIdx )
+          {
+              continue;
+          }
+#endif
         if(ivCandDir[0] == puhInterDirNeighbours[iCnloop] && pcMvFieldNeighbours[iCnloop<<1]==tmpMV[0] && pcMvFieldNeighbours[(iCnloop<<1)+1]==tmpMV[1])  // F0125 compatible with F0093
         {
@@ -4339,5 +4965,16 @@
     if (bIvMC)
     {
+#if QC_SPIVMP_MPI_G0119
+      if(!m_pcSlice->getIsDepth())
+#endif
+#if SEC_SPIVMP_MCP_SIZE_G0077
+        if(getPartitionSize(0) == SIZE_2Nx2N)
+          pbSPIVMPFlag[iCount] = true;
+#else
       pbSPIVMPFlag[iCount] = true;
+#endif
+#if H_3D_DBBP
+      pbSPIVMPFlag[iCount] &= !bDBBPFlag;
+#endif
       if( ( ivCandDir[0] & 1 ) == 1 )
       {
@@ -4466,4 +5103,11 @@
 #endif
 
+#if MTK_DDD_G0063
+  // early termination
+  if ( iCount >= getSlice()->getMaxNumMergeCand()) 
+  {
+      return;
+  }
+#endif
 
 #if H_3D_IV_MERGE 
@@ -4471,6 +5115,9 @@
   //////// INTER VIEW DISP COMP (IvDC) ////////
   /////////////////////////////////////////////
-
+#if QC_DEPTH_MERGE_SIMP_G0127
+  if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() )
+#else
   if( ivCandDir[1] && iCount < getSlice()->getMaxNumMergeCand())
+#endif
   {
     assert(iCount < getSlice()->getMaxNumMergeCand());
@@ -4633,5 +5280,9 @@
   //////// SHIFTED IV (IvMCShift + IvDCShift) ////////
   ////////////////////////////////////////////////////
+#if QC_DEPTH_MERGE_SIMP_G0127
+  if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() && !getSlice()->getIsDepth() ) 
+#else
   if(  ivMvPredFlag && iCount < getSlice()->getMaxNumMergeCand() ) 
+#endif
   {
     if(xAddIvMRGCand( mrgCandIdx,  iCount, abCandIsInter, pcMvFieldNeighbours, puhInterDirNeighbours, ivCandDir, ivCandMv, ivCandRefIdx, posIvDC, vspFlag, iCount3DV, inheritedVSPDisInfo ) )
@@ -5439,4 +6090,11 @@
   Int height = 0;
   UInt partAddr;
+  
+#if H_3D_DBBP
+  if( getDBBPFlag(0) )
+  {
+    return true;
+  }
+#endif
 
   getPartIndexAndSize( puIdx, partAddr, width, height );
@@ -6362,6 +7020,22 @@
 #endif
 #if H_3D_IV_MERGE
+#if SEC_DEPTH_DV_DERIVAITON_G0074
+Bool TComDataCU::getDispforDepth (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
+#else
 Bool TComDataCU::getDispNeighBlocks (UInt uiPartIdx, UInt uiPartAddr, DisInfo* pDisp)
-{
+#endif
+{
+#if SEC_DEPTH_DV_DERIVAITON_G0074
+  assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
+
+  TComMv cMv; 
+  Int iDisp     = getSlice()->getDepthToDisparityB( 0 )[ 128 ];
+  cMv.setHor(iDisp);
+  cMv.setVer(0);
+  pDisp->m_acNBDV = cMv;
+  pDisp->m_aVIdxCan = 0;
+
+  return true;
+#else
   Pel pDepPos[3] = {0, 0, 0};
   assert(getPartitionSize( uiPartAddr ) == SIZE_2Nx2N);
@@ -6409,4 +7083,5 @@
     return false;
   }
+#endif
 }
 #endif
@@ -6425,4 +7100,7 @@
   // Init disparity struct for results
   pDInfo->bDV = false;   
+#if MTK_NBDV_IVREF_FIX_G0067
+  pDInfo->m_aVIdxCan = -1;
+#endif
   // Init struct for disparities from MCP neighboring blocks
   IDVInfo cIDVInfo;
@@ -6945,4 +7623,10 @@
 {
   Int iSubPUSize = 1<<getSlice()->getVPS()->getSubPULog2Size(getSlice()->getLayerId());
+#if QC_SPIVMP_MPI_G0119
+  if( getSlice()->getIsDepth() )
+  {
+    iSubPUSize = 1 << getSlice()->getVPS()->getSubPUMPILog2Size();
+  }
+#endif
   iNumSPInOneLine = iPUWidth/iSubPUSize;
   iNumSPInOneLine = iNumSPInOneLine < 1 ? 1: iNumSPInOneLine;
@@ -7038,5 +7722,12 @@
   //////////sub-PU IvMC///////////
   ////////////////////////////////
-  
+#if QC_SPIVMP_MPI_G0119
+  if(!m_pcSlice->getIsDepth())
+  {
+#endif  
+#if SEC_SPIVMP_MCP_SIZE_G0077
+  if( getPartitionSize(0) == SIZE_2Nx2N )
+  {
+#endif
   Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight;
   getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight);
@@ -7055,10 +7746,81 @@
   TComDataCU* pcBaseCU;
   Int iPartition = 0;
+#if !KHU_SIMP_SPIVMP_G0147
   Int iInterDirLast = 0;
   TComMvField cMvFieldLast[2];
+#endif
 
   Int iDelX = iSPWidth/2;
   Int iDelY = iSPHeight/2;
 
+#if KHU_SIMP_SPIVMP_G0147
+  Int         iCenterPosX = iCurrPosX + ( ( iWidth /  iSPWidth ) >> 1 )  * iSPWidth + ( iSPWidth >> 1 );
+  Int         iCenterPosY = iCurrPosY + ( ( iHeight /  iSPHeight ) >> 1 )  * iSPHeight + (iSPHeight >> 1);
+  Int         iRefCenterCUAddr, iRefCenterAbsPartIdx;
+
+  if(iWidth == iSPWidth && iHeight == iSPHeight)
+  {
+    iCenterPosX = iCurrPosX + (iWidth >> 1);
+    iCenterPosY = iCurrPosY + (iHeight >> 1);
+  }
+
+  Int iRefCenterPosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCenterPosX + ( (cDv.getHor() + 2 ) >> 2 ) );
+  Int iRefCenterPosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCenterPosY + ( (cDv.getVer() + 2 ) >> 2 ) ); 
+
+  pcBaseRec->getCUAddrAndPartIdx( iRefCenterPosX , iRefCenterPosY , iRefCenterCUAddr, iRefCenterAbsPartIdx );
+  TComDataCU* pcDefaultCU    = pcBasePic->getCU( iRefCenterCUAddr );
+  if(!( pcDefaultCU->getPredictionMode( iRefCenterAbsPartIdx ) == MODE_INTRA ))
+  {
+    for( UInt uiCurrRefListId = 0; uiCurrRefListId < 2; uiCurrRefListId++ )       
+    {
+      RefPicList  eCurrRefPicList = RefPicList( uiCurrRefListId );
+      Bool stopLoop = false;
+      for(Int iLoop = 0; iLoop < 2 && !stopLoop; ++iLoop)
+      {
+        RefPicList eDefaultRefPicList = (iLoop ==1)? RefPicList( 1 -  uiCurrRefListId ) : RefPicList( uiCurrRefListId );
+        TComMvField cDefaultMvField;
+        pcDefaultCU->getMvField( pcDefaultCU, iRefCenterAbsPartIdx, eDefaultRefPicList, cDefaultMvField );
+        Int         iDefaultRefIdx     = cDefaultMvField.getRefIdx();
+        if (iDefaultRefIdx >= 0)
+        {
+          Int iDefaultRefPOC = pcDefaultCU->getSlice()->getRefPOC(eDefaultRefPicList, iDefaultRefIdx);
+          if (iDefaultRefPOC != pcSlice->getPOC())    
+          {
+            for (Int iPdmRefIdx = 0; iPdmRefIdx < pcSlice->getNumRefIdx( eCurrRefPicList ); iPdmRefIdx++)
+            {
+              if (iDefaultRefPOC == pcSlice->getRefPOC(eCurrRefPicList, iPdmRefIdx))
+              {
+                abPdmAvailable[ uiCurrRefListId ] = true;
+                TComMv cMv(cDefaultMvField.getHor(), cDefaultMvField.getVer());
+#if H_3D_NBDV 
+#if H_3D_IV_MERGE
+                if( !bIsDepth )
+                {
+#endif
+                  cMv.setIDVFlag   (true);
+                  cMv.setIDVHor    (cDv.getHor());                  
+                  cMv.setIDVVer    (cDv.getVer());  
+                  cMv.setIDVVId    (iViewIndex); 
+#if H_3D_IV_MERGE
+                }
+#endif
+#endif
+                clipMv( cMv );
+                paiPdmRefIdx  [ uiCurrRefListId ] = iPdmRefIdx;
+                pacPdmMv      [ uiCurrRefListId ] = cMv;
+                stopLoop = true;
+                break;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  availableMcDc[0] = ( abPdmAvailable[0]? 1 : 0) + (abPdmAvailable[1]? 2 : 0);
+
+  if(availableMcDc[0])
+  {
+#endif
   Int         iBasePosX, iBasePosY;
   for (Int i=iCurrPosY; i < iCurrPosY + iHeight; i += iSPHeight)
@@ -7119,4 +7881,9 @@
       if (puhInterDirSP[iPartition] == 0)
       {
+#if KHU_SIMP_SPIVMP_G0147
+        puhInterDirSP[iPartition] = availableMcDc[0];
+        pcMvFieldSP[2*iPartition].setMvField(pacPdmMv[0], paiPdmRefIdx[0]);
+        pcMvFieldSP[2*iPartition + 1].setMvField(pacPdmMv[1], paiPdmRefIdx[1]);
+#else
         if (iInterDirLast != 0)
         {
@@ -7125,5 +7892,7 @@
           pcMvFieldSP[2*iPartition + 1] = cMvFieldLast[1];
         }
-      }
+#endif
+      }
+#if !KHU_SIMP_SPIVMP_G0147
       else
       {
@@ -7150,12 +7919,21 @@
         cMvFieldLast[1] = pcMvFieldSP[2*iPartition + 1];
       }
-
+#endif
       iPartition ++;
 
     }
-  }  
+  }
+#if KHU_SIMP_SPIVMP_G0147
+  }
+#endif
+#if SEC_SPIVMP_MCP_SIZE_G0077
+  }
+#endif
 
   iCurrPosX  += ( iWidth  >> 1 );
   iCurrPosY  += ( iHeight >> 1 );
+#if QC_SPIVMP_MPI_G0119
+ }
+#endif
 #endif
 
@@ -7165,5 +7943,30 @@
 
 #if H_3D_SPIVMP
+#if QC_SPIVMP_MPI_G0119
+ if(m_pcSlice->getIsDepth())
+ {
+   iCurrPosX  += ( iWidth  >> 1 );
+   iCurrPosY  += ( iHeight >> 1 );
+ }
+#if QC_DEPTH_MERGE_SIMP_G0127
+#if SEC_SPIVMP_MCP_SIZE_G0077
+  for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getPartitionSize(uiPartAddr) != SIZE_2Nx2N) ? 0 : 1 ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#else
+ for(Int iLoopCan = ( 1 - m_pcSlice->getIsDepth() ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#endif
+#else
+#if SEC_SPIVMP_MCP_SIZE_G0077
+ for(Int iLoopCan = ( (m_pcSlice->getIsDepth() || getPartitionSize(uiPartAddr) != SIZE_2Nx2N) ? 0 : 1 ); iLoopCan < 2; iLoopCan ++) 
+#else
+ for(Int iLoopCan = ( 1 - m_pcSlice->getIsDepth() ); iLoopCan < 2; iLoopCan ++) 
+#endif
+#endif
+#else
+#if SEC_SPIVMP_MCP_SIZE_G0077
+ for(Int iLoopCan = (getPartitionSize(uiPartAddr) == SIZE_2Nx2N ? 1 : 0); iLoopCan < 2; iLoopCan ++) 
+#else
   for(Int iLoopCan = 1; iLoopCan < 2; iLoopCan ++) 
+#endif
+#endif
 #else
   for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
@@ -7173,5 +7976,5 @@
     // iLoopCan == 1 --> IvMCShift 
 
-#if !H_3D_SPIVMP
+#if !H_3D_SPIVMP || QC_SPIVMP_MPI_G0119
     Int         iBaseCUAddr;
     Int         iBaseAbsPartIdx;
@@ -7181,5 +7984,5 @@
     Int offsetH = (iLoopCan == 0) ? 0 : ( ((iHeight/2)*4) + 4 );
 
-#if H_3D_SPIVMP
+#if H_3D_SPIVMP && !QC_SPIVMP_MPI_G0119
     iBasePosX   = Clip3( 0, pcBaseRec->getWidth () - 1, iCurrPosX + ( (cDv.getHor() + offsetW + 2 ) >> 2 ) );
     iBasePosY   = Clip3( 0, pcBaseRec->getHeight() - 1, iCurrPosY + ( (cDv.getVer() + offsetH + 2 ) >> 2 ) ); 
@@ -7190,5 +7993,5 @@
     pcBaseRec->getCUAddrAndPartIdx( iBasePosX , iBasePosY , iBaseCUAddr, iBaseAbsPartIdx );
 
-#if H_3D_SPIVMP
+#if H_3D_SPIVMP && !QC_SPIVMP_MPI_G0119
     pcBaseCU    = pcBasePic->getCU( iBaseCUAddr );
 #else
@@ -7248,5 +8051,13 @@
   }
 #if H_3D_SPIVMP
+#if QC_SPIVMP_MPI_G0119
+#if QC_DEPTH_MERGE_SIMP_G0127
+  for(Int iLoopCan = ( 1 - m_pcSlice->getIsDepth() ); iLoopCan < ( 2 - m_pcSlice->getIsDepth() ); iLoopCan ++) 
+#else
+  for(Int iLoopCan = ( 1 - m_pcSlice->getIsDepth() ); iLoopCan < 2; iLoopCan ++) 
+#endif
+#else
   for(Int iLoopCan = 1; iLoopCan < 2; iLoopCan ++)
+#endif
 #else
   for(Int iLoopCan = 0; iLoopCan < 2; iLoopCan ++)
@@ -7260,5 +8071,8 @@
   /////// IvDC + IvDCShift ///////
   ////////////////////////////////
-  
+#if QC_DEPTH_MERGE_SIMP_G0127
+  if( !getSlice()->getIsDepth() )
+  {
+#endif
   for( Int iRefListId = 0; iRefListId < 2 ; iRefListId++ )
   {
@@ -7294,4 +8108,7 @@
     availableMcDc[1 + (iLoopCan << 1)] = ( abPdmAvailable[2 + (iLoopCan<<2)] ? 1 : 0 ) + ( abPdmAvailable[3 + (iLoopCan<<2)] ? 2 : 0 );
   }
+#if QC_DEPTH_MERGE_SIMP_G0127
+  }
+#endif
   return false;
 }
@@ -7367,4 +8184,139 @@
 #endif
 
+#if NTT_STORE_SPDV_VSP_G0148
+Void TComDataCU::setMvFieldPUForVSP( TComDataCU* pcCU, UInt partAddr, Int width, Int height, RefPicList eRefPicList, Int iRefIdx, Int &vspSize )
+{
+  // Get depth reference
+  Int depthRefViewIdx = pcCU->getDvInfo(partAddr).m_aVIdxCan;
+  
+#if H_3D_FCO_VSP_DONBDV_E0163
+  TComPic* pRefPicBaseDepth = 0;
+  Bool     bIsCurrDepthCoded = false;
+  pRefPicBaseDepth  = pcCU->getSlice()->getIvPic( true, pcCU->getSlice()->getViewIndex() );
+  if ( pRefPicBaseDepth->getPicYuvRec() != NULL  ) 
+  {
+    bIsCurrDepthCoded = true;
+  }
+  else 
+  {
+    pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
+  }
+#else
+  TComPic* pRefPicBaseDepth = pcCU->getSlice()->getIvPic (true, depthRefViewIdx );
+#endif
+  assert(pRefPicBaseDepth != NULL);
+  TComPicYuv* pcBaseViewDepthPicYuv = pRefPicBaseDepth->getPicYuvRec();
+  assert(pcBaseViewDepthPicYuv != NULL);
+  pcBaseViewDepthPicYuv->extendPicBorder();
+
+  // Get texture reference
+  assert(iRefIdx >= 0);
+  TComPic* pRefPicBaseTxt = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx );
+  TComPicYuv* pcBaseViewTxtPicYuv = pRefPicBaseTxt->getPicYuvRec();
+  assert(pcBaseViewTxtPicYuv != NULL);
+
+  // Initialize LUT according to the reference viewIdx
+  Int txtRefViewIdx = pRefPicBaseTxt->getViewIndex();
+  Int* pShiftLUT    = pcCU->getSlice()->getDepthToDisparityB( txtRefViewIdx );
+  assert( txtRefViewIdx < pcCU->getSlice()->getViewIndex() );
+
+  // prepare Dv to access depth map or reference view
+  TComMv cDv  = pcCU->getDvInfo(partAddr).m_acNBDV;
+  pcCU->clipMv(cDv);
+
+#if H_3D_FCO_VSP_DONBDV_E0163
+  if ( bIsCurrDepthCoded )
+  {
+      cDv.setZero();
+  }
+#endif
+
+  // fetch virtual depth map & convert depth to motion vector, which are stored in the motion memory
+  xSetMvFieldForVSP( pcCU, pcBaseViewDepthPicYuv, &cDv, partAddr, width, height, pShiftLUT, eRefPicList, iRefIdx, pcCU->getSlice()->getIsDepth(), vspSize );
+}
+
+Void TComDataCU::xSetMvFieldForVSP( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize )
+{
+  TComCUMvField *cuMvField = cu->getCUMvField( refPicList );
+  Int partAddrRasterSubPULine  = g_auiZscanToRaster[ partAddr ];
+  Int numPartsLine    = cu->getPic()->getNumPartInWidth();
+
+  Int nTxtPerMvInfoX = 4; // cu->getPic()->getMinCUWidth();
+  Int nTxtPerMvInfoY = 4; // cu->getPic()->getMinCUHeight();
+
+  Int refDepStride = picRefDepth->getStride();
+
+  TComMv tmpMv(0, 0);
+  tmpMv.setIDVFlag(false);
+
+  Int refDepOffset  = ( (dv->getHor()+2) >> 2 ) + ( (dv->getVer()+2) >> 2 ) * refDepStride;
+  Pel *refDepth     = picRefDepth->getLumaAddr( cu->getAddr(), cu->getZorderIdxInCU() + partAddr ) + refDepOffset;
+
+  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;
+  if (vspSize)
+  {
+    subBlockW = 8;
+    subBlockH = 4;
+  }
+  else
+  {
+    subBlockW = 4;
+    subBlockH = 8;
+  }
+  
+  Int numPartsInSubPUW = subBlockW / nTxtPerMvInfoX;
+  Int numPartsInSubPUH = subBlockH / nTxtPerMvInfoY * numPartsLine;
+
+  for( Int y=0; y<height; y+=subBlockH, partAddrRasterSubPULine+=numPartsInSubPUH )
+  {
+    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;
+
+    Int partAddrRasterSubPU = partAddrRasterSubPULine;
+    for( Int x=0; x<width; x+=subBlockW, partAddrRasterSubPU+=numPartsInSubPUW )
+    {
+      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]);
+      tmpMv.setHor( (Short) shiftLUT[ maxDepthVal ] );
+
+      Int partAddrRasterPartLine = partAddrRasterSubPU;
+      for( Int sY=0; sY<numPartsInSubPUH; sY+=numPartsLine, partAddrRasterPartLine += numPartsLine )
+      {
+        Int partAddrRasterPart = partAddrRasterPartLine;
+        for( Int sX=0; sX<numPartsInSubPUW; sX+=1, partAddrRasterPart++ )
+        {
+          cuMvField->setMv    ( g_auiRasterToZscan[ partAddrRasterPart ], tmpMv );
+          cuMvField->setRefIdx( g_auiRasterToZscan[ partAddrRasterPart ], refIdx );
+        }
+      }
+    }
+  }
+
+  vspSize = (vspSize<<2)+1;
+
+}
+#endif // NTT_STORE_SPDV_VSP_G0148
 
 //! \}
Index: trunk/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComDataCU.h	(revision 833)
@@ -97,4 +97,21 @@
 };
 
+#if H_3D_DBBP
+typedef struct _DBBPTmpData
+{
+  TComMv      acMvd[2][2];          // for two segments and two lists
+  TComMvField acMvField[2][2];      // for two segments and two lists
+  Int         aiMvpNum[2][2];       // for two segments and two lists
+  Int         aiMvpIdx[2][2];       // for two segments and two lists
+  UChar       auhInterDir[2];       // for two segments
+  Bool        abMergeFlag[2];       // for two segments
+  UChar       auhMergeIndex[2];     // for two segments
+  Char        ahVSPFlag[2];         // for two segments
+  DisInfo     acDvInfo[2];          // for two segments
+  
+  PartSize    eVirtualPartSize;
+  UInt        uiVirtualPartIndex;
+} DBBPTmpData;
+#endif
 
 // ====================================================================================================================
@@ -215,11 +232,23 @@
 #if H_3D_DIM_SDC
   Bool*         m_pbSDCFlag;
+#if QC_SDC_UNIFY_G0130 && !SEC_INTER_SDC_G0101
+  Pel*          m_apSegmentDCOffset[4];
+#else
   Pel*          m_apSegmentDCOffset[2];
 #endif
 #endif
+#endif
 #if H_3D_INTER_SDC
+#if !QC_SDC_UNIFY_G0130
   Bool*         m_pbInterSDCFlag;
   Int*          m_apSegmentInterDCOffset[4];
+#endif
+#if !SEC_INTER_SDC_G0101
   UChar*        m_pucInterSDCMask;
+#endif
+#endif
+#if H_3D_DBBP
+  Bool*         m_pbDBBPFlag;        ///< array of DBBP flags
+  DBBPTmpData   m_sDBBPTmpData;
 #endif
 #if H_3D
@@ -250,4 +279,11 @@
 #endif
 
+#if MTK_DDD_G0063
+  UChar*        m_pucDisparityDerivedDepth;
+  Bool*         m_pbUseDDD;
+  Int           m_iUseDDDCandIdx;
+  UChar         m_ucDDTmpDepth;
+#endif
+
 protected:
   
@@ -283,4 +319,8 @@
 
   Void xDeriveCenterIdx( UInt uiPartIdx, UInt& ruiPartIdxCenter );
+
+#if NTT_STORE_SPDV_VSP_G0148
+  Void xSetMvFieldForVSP  ( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *dv, UInt partAddr, Int width, Int height, Int *shiftLUT, RefPicList refPicList, Int refIdx, Bool isDepth, Int &vspSize );
+#endif
 
 public:
@@ -351,4 +391,8 @@
   Void          setCUTransquantBypassSubParts( Bool flag, UInt uiAbsPartIdx, UInt uiDepth );
   
+#if H_3D_DBBP
+  Pel*          getVirtualDepthBlock(UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt& uiDepthStride);
+#endif
+  
   Bool*        getSkipFlag            ()                        { return m_skipFlag;          }
   Bool         getSkipFlag            (UInt idx)                { return m_skipFlag[idx];     }
@@ -362,4 +406,12 @@
   Void          setPredictionMode     ( UInt uiIdx, PredMode uh){ m_pePredMode[uiIdx] = uh;   }
   Void          setPredModeSubParts   ( PredMode eMode, UInt uiAbsPartIdx, UInt uiDepth );
+  
+#if H_3D_DBBP
+  Bool*         getDBBPFlag           ()                        { return m_pbDBBPFlag;               }
+  Bool          getDBBPFlag           ( UInt uiIdx )            { return m_pbDBBPFlag[uiIdx];        }
+  Void          setDBBPFlag           ( UInt uiIdx, Bool b )    { m_pbDBBPFlag[uiIdx] = b;           }
+  Void          setDBBPFlagSubParts   ( Bool bDBBPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  DBBPTmpData*  getDBBPTmpData        () { return &m_sDBBPTmpData; }
+#endif
   
   UChar*        getWidth              ()                        { return m_puhWidth;          }
@@ -501,5 +553,9 @@
 #if H_3D
   Void          rightShiftMergeCandList( TComMvField* pcMvFieldNeighbours, UChar* puhInterDirNeighbours, Int* iVSPIndexTrue, InheritedVSPDisInfo*  inheritedVSPDisInfo, UInt start, UInt num, Int &iCount3DV);
+#if SEC_DEPTH_DV_DERIVAITON_G0074
+  Bool          getDispforDepth  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
+#else
   Bool          getDispNeighBlocks  ( UInt uiPartIdx, UInt uiPartAddr, DisInfo* cDisp);
+#endif
   Bool          getDispMvPredCan(UInt uiPartIdx, RefPicList eRefPicList, Int iRefIdx, Int* paiPdmRefIdx, TComMv* pacPdmMv, DisInfo* pDis, Int* iPdm );
 #endif
@@ -571,7 +627,12 @@
   Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
+#if QC_GENERIC_SDC_G0122
+  UInt          getCtxSDCFlag          ( UInt   uiAbsPartIdx );
+  UInt          getCtxAngleFlag        ( UInt   uiAbsPartIdx );
+#endif
 #endif
 #endif
 #if H_3D_INTER_SDC
+#if !QC_SDC_UNIFY_G0130
   Bool*         getInterSDCFlag     ()                        { return m_pbInterSDCFlag;               }
   Bool          getInterSDCFlag     ( UInt uiIdx )            { return m_pbInterSDCFlag[uiIdx];        }
@@ -582,7 +643,10 @@
   Void          setInterSDCSegmentDCOffset( Int pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentInterDCOffset[uiSeg][uiPartIdx] = pOffset; }
 
+#endif
+#if !SEC_INTER_SDC_G0101
   Void          xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask );
 
   UChar*        getInterSDCMask     ()                        { return m_pucInterSDCMask;              }
+#endif
 #endif
   
@@ -691,4 +755,7 @@
   Void          setVSPFlag        ( UInt uiIdx, Int n )     { m_piVSPFlag[uiIdx] = n;      }
   Void          setVSPFlagSubParts( Char iVSPFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+#if NTT_STORE_SPDV_VSP_G0148
+  Void          setMvFieldPUForVSP    ( TComDataCU* cu, UInt partAddr, Int width, Int height, RefPicList refPicList, Int refIdx, Int &vspSize );
+#endif
 #endif
   Void          deriveLeftRightTopIdxGeneral  ( UInt uiAbsPartIdx, UInt uiPartIdx, UInt& ruiPartIdxLT, UInt& ruiPartIdxRT );
@@ -730,6 +797,8 @@
   UInt          getCTXARPWFlag                  ( UInt   uiAbsPartIdx                                 );
 #endif  
+#if !MTK_IC_FLAG_CABAC_SIMP_G0061
 #if H_3D_IC
   UInt          getCtxICFlag                    ( UInt   uiAbsPartIdx                                 );
+#endif
 #endif
   UInt          getSliceStartCU         ( UInt pos )                  { return m_sliceStartCU[pos-m_uiAbsIdxInLCU];                                                                                          }
@@ -751,4 +820,21 @@
   UInt          getCoefScanIdx(UInt uiAbsPartIdx, UInt uiWidth, Bool bIsLuma, Bool bIsIntra);
 
+#if MTK_DDD_G0063
+  UChar*       getDDDepth        ()                        { return m_pucDisparityDerivedDepth;        }
+  UChar        getDDDepth        ( UInt uiIdx )            { return m_pucDisparityDerivedDepth[uiIdx]; }
+  Void         setDDDepth        ( UInt uiIdx, UChar n )   { m_pucDisparityDerivedDepth[uiIdx] = n;    }
+  Void         setDDDepthSubParts( UChar ucDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  Bool*        getUseDDD        ()                        { return m_pbUseDDD;        }
+  Bool         getUseDDD        ( UInt uiIdx )            { return m_pbUseDDD[uiIdx]; }
+  Void         setUseDDD        ( UInt uiIdx, Bool n )     { m_pbUseDDD[uiIdx] = n;    }
+  Void         setUseDDD( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiDepth );
+
+  Void         setUseDDD        ( Bool bUseDDD, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+
+  UChar        getDDTmpDepth(){ return m_ucDDTmpDepth; }
+  Int          getUseDDDCandIdx(){ return m_iUseDDDCandIdx;}
+
+#endif
 };
 
Index: trunk/source/Lib/TLibCommon/TComMotionInfo.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComMotionInfo.h	(revision 833)
@@ -176,4 +176,8 @@
   Void    setMvFieldSP ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComMvField cMvField, Int iWidth, Int iHeight  );
 #endif
+#if NTT_STORE_SPDV_VSP_G0148
+  Void    setMv         ( Int iIdx, TComMv const & rcMv ) { m_pcMv[iIdx] = rcMv; }
+  Void    setRefIdx     ( Int iIdx, Int iRefIdx )         { m_piRefIdx[iIdx] = iRefIdx; }
+#endif
 
   Void setNumPartition( Int iNumPart )
Index: trunk/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComPrediction.cpp	(revision 833)
@@ -416,5 +416,9 @@
 
 #if H_3D_DIM
-Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc )
+Void TComPrediction::predIntraLumaDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc
+#if QC_GENERIC_SDC_G0122
+  , TComWedgelet* dmm4Segmentation
+#endif
+  )
 {
   assert( iWidth == iHeight  );
@@ -442,6 +446,19 @@
     case( DMM4_IDX ): 
       {
+#if QC_GENERIC_SDC_G0122
+        if( dmm4Segmentation == NULL )
+        { 
+          dmmSegmentation = new TComWedgelet( iWidth, iHeight );
+          xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation );
+        }
+        else
+        {
+          xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmm4Segmentation );
+          dmmSegmentation = dmm4Segmentation;
+        }
+#else
         dmmSegmentation = new TComWedgelet( iWidth, iHeight );
         xPredContourFromTex( pcCU, uiAbsPartIdx, iWidth, iHeight, dmmSegmentation );
+#endif
       } break;
     default: assert(0);
@@ -494,5 +511,9 @@
 
 #if H_3D_DIM_DMM
+#if QC_GENERIC_SDC_G0122
+  if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; }
+#else
   if( dimType == DMM4_IDX ) { dmmSegmentation->destroy(); delete dmmSegmentation; }
+#endif
 #endif
 }
@@ -598,4 +619,302 @@
   }
   return true;
+}
+#endif
+
+#if H_3D_DBBP
+PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize)
+{
+  // find virtual partitioning for this CU based on depth block
+  // segmentation of texture block --> mask IDs
+  Pel*  pDepthBlockStart      = pDepthPels;
+  
+  // first compute average of depth block for thresholding
+  Int iSumDepth = 0;
+  Int iSubSample = 4;
+  for (Int y=0; y<uiSize; y+=iSubSample)
+  {
+    for (Int x=0; x<uiSize; x+=iSubSample)
+    {
+      Int depthPel = pDepthPels[x];
+      
+      iSumDepth += depthPel;
+    }
+    
+    // next row
+    pDepthPels += uiDepthStride*iSubSample;
+  }
+  
+  Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample];  // respect sub-sampling factor
+  Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiSize*uiSize);
+  
+  // start again for segmentation
+  pDepthPels = pDepthBlockStart;
+  
+  // start mapping process
+  Bool bAMPAvail = uiSize > 8;
+  Int matchedPartSum[6][2] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; // counter for each part size and boolean option
+  PartSize virtualPartSizes[6] = { SIZE_Nx2N, SIZE_2NxN, SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N };
+  
+  UInt uiHalfSize = uiSize>>1;
+  UInt uiQuarterSize = uiSize>>2;
+  
+  for (Int y=0; y<uiSize; y+=iSubSample)
+  {
+    for (Int x=0; x<uiSize; x+=iSubSample)
+    {
+      Int depthPel = pDepthPels[x];
+      
+      // decide which segment this pixel belongs to
+      Int ucSegment = (Int)(depthPel>iMean);
+      
+      // Matched Filter to find optimal (conventional) partitioning
+      
+      // SIZE_Nx2N
+      if(x<uiHalfSize)  // left
+      {
+        matchedPartSum[0][ucSegment]++;
+      }
+      else  // right
+      {
+        matchedPartSum[0][1-ucSegment]++;
+      }
+      
+      // SIZE_2NxN
+      if(y<uiHalfSize)  // top
+      {
+        matchedPartSum[1][ucSegment]++;
+      }
+      else  // bottom
+      {
+        matchedPartSum[1][1-ucSegment]++;
+      }
+      
+      if( bAMPAvail )
+      {
+        // SIZE_2NxnU
+        if(y<uiQuarterSize)  // top (1/4)
+        {
+          matchedPartSum[2][ucSegment]++;
+        }
+        else  // bottom (3/4)
+        {
+          matchedPartSum[2][1-ucSegment]++;
+        }
+        
+        // SIZE_2NxnD
+        if(y<(uiQuarterSize*3))  // top (3/4)
+        {
+          matchedPartSum[3][ucSegment]++;
+        }
+        else  // bottom (1/4)
+        {
+          matchedPartSum[3][1-ucSegment]++;
+        }
+        
+        // SIZE_nLx2N
+        if(x<uiQuarterSize)  // left (1/4)
+        {
+          matchedPartSum[4][ucSegment]++;
+        }
+        else  // right (3/4)
+        {
+          matchedPartSum[4][1-ucSegment]++;
+        }
+        
+        // SIZE_nRx2N
+        if(x<(uiQuarterSize*3))  // left (3/4)
+        {
+          matchedPartSum[5][ucSegment]++;
+        }
+        else  // right (1/4)
+        {
+          matchedPartSum[5][1-ucSegment]++;
+        }
+      }
+    }
+    
+    // next row
+    pDepthPels += uiDepthStride*iSubSample;
+  }
+  
+  PartSize matchedPartSize = SIZE_NONE;
+  
+  Int iMaxMatchSum = 0;
+  for(Int p=0; p<6; p++)  // loop over partition sizes
+  {
+    for( Int b=0; b<=1; b++ ) // loop over boolean options
+    {
+      if(matchedPartSum[p][b] > iMaxMatchSum)
+      {
+        iMaxMatchSum = matchedPartSum[p][b];
+        matchedPartSize = virtualPartSizes[p];
+      }
+    }
+  }
+  
+  AOF( matchedPartSize != SIZE_NONE );
+  
+  return matchedPartSize;
+}
+
+Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask )
+{
+  // segmentation of texture block --> mask IDs
+  Pel*  pDepthBlockStart      = pDepthPels;
+  
+  // first compute average of depth block for thresholding
+  Int iSumDepth = 0;
+  Int uiMinDepth = MAX_INT;
+  Int uiMaxDepth = 0;
+  for (Int y=0; y<uiHeight; y++)
+  {
+    for (Int x=0; x<uiWidth; x++)
+    {
+      Int depthPel = pDepthPels[x];
+      iSumDepth += depthPel;
+      
+      if( depthPel > uiMaxDepth )
+      {
+        uiMaxDepth = depthPel;
+      }
+      if( depthPel < uiMinDepth )
+      {
+        uiMinDepth = depthPel;
+      }
+    }
+    
+    // next row
+    pDepthPels += uiDepthStride;
+  }
+  
+  // don't generate mask for blocks with small depth range (encoder decision)
+  if( uiMaxDepth - uiMinDepth < 10 )
+  {
+    return false;
+  }
+  
+  AOF(uiWidth==uiHeight);
+  Int iSizeInBits = g_aucConvertToBit[uiWidth]+2;
+  Int iMean = iSumDepth >> iSizeInBits*2;       // iMean /= (uiWidth*uiHeight);
+  
+  // start again for segmentation
+  pDepthPels = pDepthBlockStart;
+  
+  Bool bInvertMask = pDepthPels[0]>iMean; // top-left segment needs to be mapped to partIdx 0
+  
+  // generate mask
+  UInt uiSumPix[2] = {0,0};
+  for (Int y=0; y<uiHeight; y++)
+  {
+    for (Int x=0; x<uiHeight; x++)
+    {
+      Int depthPel = pDepthPels[x];
+      
+      // decide which segment this pixel belongs to
+      Int ucSegment = (Int)(depthPel>iMean);
+      
+      if( bInvertMask )
+      {
+        ucSegment = 1-ucSegment;
+      }
+      
+      // count pixels for each segment
+      uiSumPix[ucSegment]++;
+      
+      // set mask value
+      pMask[x] = (Bool)ucSegment;
+    }
+    
+    // next row
+    pDepthPels += uiDepthStride;
+    pMask += MAX_CU_SIZE;
+  }
+  
+  // don't generate valid mask for tiny segments (encoder decision)
+  // each segment needs to cover at least 1/8th of block
+  UInt uiMinPixPerSegment = (uiWidth*uiHeight) >> 3;
+  if( !( uiSumPix[0] > uiMinPixPerSegment && uiSumPix[1] > uiMinPixPerSegment ) )
+  {
+    return false;
+  }
+  
+  // all good
+  return true;
+}
+
+Void TComPrediction::combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr )
+{
+  Pel*  piSrc[2]    = {pInYuv[0]->getLumaAddr(uiPartAddr), pInYuv[1]->getLumaAddr(uiPartAddr)};
+  UInt  uiSrcStride = pInYuv[0]->getStride();
+  Pel*  piDst       = pOutYuv->getLumaAddr(uiPartAddr);
+  UInt  uiDstStride = pOutYuv->getStride();
+  
+  UInt  uiMaskStride= MAX_CU_SIZE;
+  
+  // backup pointer
+  Bool* pMaskStart = pMask;
+  
+  // combine luma first
+  for (Int y=0; y<uiHeight; y++)
+  {
+    for (Int x=0; x<uiWidth; x++)
+    {
+      UChar ucSegment = (UChar)pMask[x];
+      AOF( ucSegment < 2 );
+      
+      // filtering
+      Bool t = (y==0)?pMaskStart[(y+1)*uiMaskStride+x]:pMaskStart[(y-1)*uiMaskStride+x];
+      Bool l = (x==0)?pMaskStart[y*uiMaskStride+x+1]:pMaskStart[y*uiMaskStride+x-1];
+      Bool b = (y==uiHeight-1)?pMaskStart[(y-1)*uiMaskStride+x]:pMaskStart[(y+1)*uiMaskStride+x];
+      Bool r = (x==uiWidth-1)?pMaskStart[y*uiMaskStride+x-1]:pMaskStart[y*uiMaskStride+x+1];
+      
+      Bool bBlend = !((t&&l&&b&&r) || (!t&&!l&&!b&&!r));
+      piDst[x] = bBlend?((piSrc[0][x]+piSrc[1][x]+1)>>1):piSrc[ucSegment][x];
+    }
+    
+    piSrc[0]  += uiSrcStride;
+    piSrc[1]  += uiSrcStride;
+    piDst     += uiDstStride;
+    pMask     += uiMaskStride;
+  }
+  
+  // now combine chroma
+  Pel*  piSrcU[2]       = { pInYuv[0]->getCbAddr(uiPartAddr), pInYuv[1]->getCbAddr(uiPartAddr) };
+  Pel*  piSrcV[2]       = { pInYuv[0]->getCrAddr(uiPartAddr), pInYuv[1]->getCrAddr(uiPartAddr) };
+  UInt  uiSrcStrideC    = pInYuv[0]->getCStride();
+  Pel*  piDstU          = pOutYuv->getCbAddr(uiPartAddr);
+  Pel*  piDstV          = pOutYuv->getCrAddr(uiPartAddr);
+  UInt  uiDstStrideC    = pOutYuv->getCStride();
+  UInt  uiWidthC        = uiWidth >> 1;
+  UInt  uiHeightC       = uiHeight >> 1;
+  pMask = pMaskStart;
+  
+  for (Int y=0; y<uiHeightC; y++)
+  {
+    for (Int x=0; x<uiWidthC; x++)
+    {
+      UChar ucSegment = (UChar)pMask[x*2];
+      AOF( ucSegment < 2 );
+      
+      // filtering
+      Bool t = (y==0)?pMaskStart[(y+1)*2*uiMaskStride+x*2]:pMaskStart[(y-1)*2*uiMaskStride+x*2];
+      Bool l = (x==0)?pMaskStart[y*2*uiMaskStride+(x+1)*2]:pMaskStart[y*2*uiMaskStride+(x-1)*2];
+      Bool b = (y==uiHeightC-1)?pMaskStart[(y-1)*2*uiMaskStride+x*2]:pMaskStart[(y+1)*2*uiMaskStride+x*2];
+      Bool r = (x==uiWidthC-1)?pMaskStart[y*2*uiMaskStride+(x-1)*2]:pMaskStart[y*2*uiMaskStride+(x+1)*2];
+      
+      Bool bBlend = !((t&&l&&b&&r) || (!t&&!l&&!b&&!r));
+      
+      piDstU[x] = bBlend?((piSrcU[0][x]+piSrcU[1][x]+1)>>1):piSrcU[ucSegment][x];
+      piDstV[x] = bBlend?((piSrcV[0][x]+piSrcV[1][x]+1)>>1):piSrcV[ucSegment][x];
+    }
+    
+    piSrcU[0]   += uiSrcStrideC;
+    piSrcU[1]   += uiSrcStrideC;
+    piSrcV[0]   += uiSrcStrideC;
+    piSrcV[1]   += uiSrcStrideC;
+    piDstU      += uiDstStrideC;
+    piDstV      += uiDstStrideC;
+    pMask       += 2*uiMaskStride;
+  }
 }
 #endif
@@ -783,4 +1102,41 @@
   TComMv      cMv         = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr );
   pcCU->clipMv(cMv);
+
+#if MTK_DDD_G0063
+  if( pcCU->getUseDDD( uiPartAddr ) )
+  {
+      assert( pcCU->getSPIVMPFlag( uiPartAddr ) == 0 );
+      assert( pcCU->getSlice()->getViewIndex() != 0 );
+
+      Int dstStride = rpcYuvPred->getStride();
+      Int dstStrideC = rpcYuvPred->getCStride();
+      Pel *dst      = rpcYuvPred->getLumaAddr( uiPartAddr );
+      Pel *dstU     = rpcYuvPred->getCbAddr( uiPartAddr );
+      Pel *dstV     = rpcYuvPred->getCrAddr( uiPartAddr );
+
+      Int iWidthC  = iWidth >> 1;
+      Int iHeightC = iHeight >> 1;
+      Int DefaultC = 1 << ( g_bitDepthY - 1);
+      for ( Int i = 0; i < iHeight; i++)
+      {
+          for ( Int j = 0; j < iWidth ; j++)
+          {
+              dst[j] = pcCU->getDDDepth( uiPartAddr );
+          }
+          dst += dstStride;
+      }
+      for ( Int i = 0; i < iHeightC; i++)
+      {
+          for ( Int j = 0; j < iWidthC; j++)
+          {
+              dstU[j] = dstV[j] = DefaultC;
+          }
+          dstU += dstStrideC;
+          dstV += dstStrideC;
+      }
+
+      //return;
+  } else
+#endif
 #if H_3D_ARP
   if(pcCU->getARPW( uiPartAddr ) > 0  && pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPOC()== pcCU->getSlice()->getPOC())
@@ -826,4 +1182,21 @@
 Void TComPrediction::xPredInterUniVSP( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi )
 {
+#if NTT_STORE_SPDV_VSP_G0148
+  Int vspSize = pcCU->getVSPFlag( uiPartAddr ) >> 1;
+
+  Int widthSubPU, heightSubPU;
+  if (vspSize)
+  {
+    widthSubPU  = 8;
+    heightSubPU = 4;
+  }
+  else
+  {
+    widthSubPU  = 4;
+    heightSubPU = 8;
+  }
+  xPredInterUniSubPU( pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, rpcYuvPred, bi, widthSubPU, heightSubPU );
+
+#else // NTT_STORE_SPDV_VSP_G0148
   // Get depth reference
   Int       depthRefViewIdx = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;
@@ -877,5 +1250,34 @@
   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);
-}
+#endif // NTT_STORE_SPDV_VSP_G0148
+}
+
+#if NTT_STORE_SPDV_VSP_G0148
+Void TComPrediction::xPredInterUniSubPU( TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU, Int heightSubPU )
+{
+  UInt numPartsInLine       = pcCU->getPic()->getNumPartInWidth();
+  UInt horiNumPartsInSubPU  = widthSubPU >> 2;
+  UInt vertNumPartsInSubPU  = (heightSubPU >> 2) * numPartsInLine;
+
+  UInt partAddrRasterLine = g_auiZscanToRaster[ uiPartAddr ];
+
+  for( Int posY=0; posY<iHeight; posY+=heightSubPU, partAddrRasterLine+=vertNumPartsInSubPU )
+  {
+    UInt partAddrRasterSubPU = partAddrRasterLine;
+    for( Int posX=0; posX<iWidth; posX+=widthSubPU, partAddrRasterSubPU+=horiNumPartsInSubPU )
+    {
+      UInt    partAddrSubPU = g_auiRasterToZscan[ partAddrRasterSubPU ];
+      Int     refIdx        = pcCU->getCUMvField( eRefPicList )->getRefIdx( partAddrSubPU );           assert (refIdx >= 0);
+      TComMv  cMv           = pcCU->getCUMvField( eRefPicList )->getMv( partAddrSubPU );
+      pcCU->clipMv(cMv);
+
+      xPredInterLumaBlk  ( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
+      xPredInterChromaBlk( pcCU, pcCU->getSlice()->getRefPic( eRefPicList, refIdx )->getPicYuvRec(), partAddrSubPU, &cMv, widthSubPU, heightSubPU, rpcYuvPred, bi );
+
+    }
+  }
+}
+#endif // NTT_STORE_SPDV_VSP_G0148
+
 #endif
 
@@ -1732,4 +2134,5 @@
 
 #if H_3D_VSP
+#if !(NTT_STORE_SPDV_VSP_G0148)
 // not fully support iRatioTxtPerDepth* != 1
 Void TComPrediction::xGetVirtualDepth( TComDataCU *cu, TComPicYuv *picRefDepth, TComMv *mv, UInt partAddr, Int width, Int height, TComYuv *yuvDepth, Int &vspSize, Int ratioTxtPerDepthX, Int ratioTxtPerDepthY )
@@ -2044,5 +2447,5 @@
   }
 }
-
+#endif
 
 #if H_3D_VSP_CONSTRAINED
@@ -2082,5 +2485,11 @@
   if( bL == bT )
   {
+#if SCU_HS_DEPTH_DC_PRED_G0143
+    const Int  iTRR = ( patternStride * 2 - 1  ) - srcStride; 
+    const Int  iLBB = ( patternStride * 2 - 1  ) * srcStride - 1;
+    refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : (abs(ptrSrc[iTRR] - ptrSrc[-(Int)srcStride]) > abs(ptrSrc[iLBB] - ptrSrc[ -1]) ? ptrSrc[iTRR] : ptrSrc[iLBB]);
+#else
     refDC1 = bL ? ( ptrSrc[iTR] + ptrSrc[iLB] )>>1 : 1<<( g_bitDepthY - 1 );
+#endif
     refDC2 =      ( ptrSrc[ -1] + ptrSrc[-(Int)srcStride] )>>1;
   }
@@ -2184,5 +2593,10 @@
   Int iSumPix[2];
   memset(iSumPix, 0, sizeof(Int)*2);
-  
+#if QC_GENERIC_SDC_G0122
+  for( Int i = 0; i < uiNumSegments; i++ )
+  {
+    rpSegMeans[i] = 0;
+  }
+#endif
   if (orgDC == false)
   {
@@ -2199,5 +2613,41 @@
       rpSegMeans[ucSegmentRB] = pOrig[uiStride * (uiSize-1) + (uiSize-1) ];
     }
+#if QC_GENERIC_SDC_G0122
+    else if( getDimType( uiIntraMode ) == DMM4_IDX )
+    {
+      Pel *ptmpOrig = pOrig;
+      Bool *ptmpMask = pMask, bBreak = false;
+      UChar ucSegment = ptmpMask? (UChar) ptmpMask[0] : 0;
+      UChar bFirstSeg = ucSegment;
+
+      rpSegMeans[ucSegment] = ptmpOrig[0];
+      for ( Int y = 0; y < uiSize; y++ )
+      {
+        for ( Int x = 0; x < uiSize; x++ )
+        {
+          ucSegment = ptmpMask[x];
+          assert( ucSegment < uiNumSegments );
+
+          if( bFirstSeg != ucSegment )
+          {
+            rpSegMeans[ucSegment] = ptmpOrig[x];
+            bBreak = true;
+            break;
+          }
+        }
+
+        if( bBreak )
+        {
+          break;
+        }
+
+        ptmpOrig  += uiStride;
+        ptmpMask  += uiMaskStride;
+      }
+    }
+    else
+#else
     else if (uiIntraMode == PLANAR_IDX)
+#endif
     {
       Pel* pLeftTop = pOrig;
Index: trunk/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComPrediction.h	(revision 833)
@@ -121,7 +121,11 @@
 
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+  Void xPredInterUniSubPU        ( TComDataCU *cu, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi, Int widthSubPU=4, Int heightSubPU=4 );
+#else
   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);
+#endif
 #endif
 
@@ -167,5 +171,9 @@
 #if H_3D_DIM
   // Depth intra
-  Void predIntraLumaDepth         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc = false );
+  Void predIntraLumaDepth         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiIntraMode, Pel* piPred, UInt uiStride, Int iWidth, Int iHeight, Bool bFastEnc = false 
+#if QC_GENERIC_SDC_G0122
+    , TComWedgelet* dmm4Segmentation = NULL
+#endif
+    );
 #if H_3D_DIM_SDC
   Void analyzeSegmentsSDC         ( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride
@@ -175,4 +183,10 @@
 #endif
 #endif
+  
+#if H_3D_DBBP
+  PartSize      getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize);
+  Bool          getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask );
+  Void          combineSegmentsWithMask( TComYuv* pInYuv[2], TComYuv* pOutYuv, Bool* pMask, UInt uiWidth, UInt uiHeight, UInt uiPartAddr = 0 );
+#endif
 
   Pel  predIntraGetPredValDC      ( Int* pSrc, Int iSrcStride, UInt iWidth, UInt iHeight, Bool bAbove, Bool bLeft );
Index: trunk/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComRdCost.cpp	(revision 833)
@@ -266,4 +266,7 @@
   m_bUseEstimatedVSD        = false; 
 #endif
+#if H_3D_DBBP
+  m_bUseMask                = false;
+#endif
 }
 
@@ -326,4 +329,30 @@
   rcDistParam.DistFunc = m_afpDistortFunc[eDFunc + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
   
+#if H_3D_DBBP
+  if( m_bUseMask )
+  {
+    if( eDFunc >= DF_SSE && eDFunc <= DF_SSE16N )
+    {
+      rcDistParam.DistFunc = TComRdCost::xGetMaskedSSE;
+    }
+    else if( eDFunc >= DF_SAD && eDFunc <= DF_SADS16N )
+    {
+      rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
+    }
+    else if( eDFunc >= DF_HADS && eDFunc <= DF_HADS16N )
+    {
+      rcDistParam.DistFunc = TComRdCost::xGetMaskedHADs;
+    }
+    else if( eDFunc >= DF_VSD && eDFunc <= DF_VSD16N )
+    {
+      rcDistParam.DistFunc = TComRdCost::xGetMaskedVSD;
+    }
+    else if( eDFunc >= DF_SAD12 && eDFunc <= DF_SADS48 )
+    {
+      rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
+    }
+  }
+#endif
+  
   // initialize
   rcDistParam.iSubShift  = 0;
@@ -357,4 +386,11 @@
   {
     rcDistParam.DistFunc = m_afpDistortFunc[45 ];
+  }
+#endif
+  
+#if H_3D_DBBP
+  if( m_bUseMask )
+  {
+    rcDistParam.DistFunc = TComRdCost::xGetMaskedSAD;
   }
 #endif
@@ -411,4 +447,11 @@
     rcDistParam.DistFunc = m_afpDistortFunc[DF_HADS + g_aucConvertToBit[ rcDistParam.iCols ] + 1 ];
   }
+  
+#if H_3D_DBBP
+  if( m_bUseMask )
+  {
+    rcDistParam.DistFunc = (bHADME)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
+  }
+#endif
   
   // initialize
@@ -433,4 +476,12 @@
   rcDP.bitDepth   = bitDepth;
   rcDP.DistFunc   = m_afpDistortFunc[ ( bHadamard ? DF_HADS : DF_SADS ) + g_aucConvertToBit[ iWidth ] + 1 ];
+  
+#if H_3D_DBBP
+  if( m_bUseMask )
+  {
+    rcDP.DistFunc = (bHadamard)?TComRdCost::xGetMaskedHADs:TComRdCost::xGetMaskedSAD;
+  }
+#endif
+  
 #if NS_HAD
   rcDP.bUseNSHAD  = bUseNSHAD;
@@ -586,4 +637,7 @@
   cDtParam.uiComp       = 255;    // just for assert: to be sure it was set before use, since only values 0,1 or 2 are allowed.
 
+#if SCU_HS_VSD_BUGFIX_IMPROV_G0163
+  cDtParam.bitDepth   = g_bitDepthY;
+#endif
   Dist dist = cDtParam.DistFunc( &cDtParam );
 
@@ -631,4 +685,227 @@
 // Distortion functions
 // ====================================================================================================================
+
+#if H_3D_DBBP
+// --------------------------------------------------------------------------------------------------------------------
+// Masked distortion functions
+// --------------------------------------------------------------------------------------------------------------------
+
+UInt TComRdCost::xGetMaskedSSE( DistParam* pcDtParam )
+{
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iCols   = pcDtParam->iCols;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  
+  UInt uiSum = 0;
+  
+  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT((pcDtParam->bitDepth-8) << 1);
+  
+  Int iTemp;
+  
+  for( ; iRows != 0; iRows-- )
+  {
+    for (Int n = 0; n < iCols; n++ )
+    {
+      if( piOrg[n] != DBBP_INVALID_SHORT )
+      {
+        iTemp = piOrg[n  ] - piCur[n  ];
+        uiSum += ( iTemp * iTemp ) >> uiShift;
+      }
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+  
+  return ( uiSum );
+}
+
+UInt TComRdCost::xGetMaskedSAD( DistParam* pcDtParam )
+{
+  
+  AOF(!pcDtParam->bApplyWeight);
+#if H_3D_IC
+  AOF(!pcDtParam->bUseIC);
+#endif
+  
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iCols   = pcDtParam->iCols;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  
+  UInt uiSum = 0;
+  
+  for( ; iRows != 0; iRows-- )
+  {
+    for (Int n = 0; n < iCols; n++ )
+    {
+      if( piOrg[n] != DBBP_INVALID_SHORT )
+      {
+        uiSum += abs( piOrg[n] - piCur[n] );
+      }
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+  
+  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
+}
+
+UInt TComRdCost::xGetMaskedHADs( DistParam* pcDtParam )
+{
+  AOF(!pcDtParam->bApplyWeight);
+#if H_3D_IC
+  AOF(!pcDtParam->bUseIC);
+#endif
+  Pel* piOrg   = pcDtParam->pOrg;
+  Pel* piCur   = pcDtParam->pCur;
+  Int  iRows   = pcDtParam->iRows;
+  Int  iCols   = pcDtParam->iCols;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStep  = pcDtParam->iStep;
+  
+  Int  x, y;
+  
+  UInt uiSum = 0;
+  
+#if NS_HAD
+  if( ( ( iRows % 8 == 0) && (iCols % 8 == 0) && ( iRows == iCols ) ) || ( ( iRows % 8 == 0 ) && (iCols % 8 == 0) && !pcDtParam->bUseNSHAD ) )
+#else
+    if( ( iRows % 8 == 0) && (iCols % 8 == 0) )
+#endif
+    {
+      Int  iOffsetOrg = iStrideOrg<<3;
+      Int  iOffsetCur = iStrideCur<<3;
+      for ( y=0; y<iRows; y+= 8 )
+      {
+        for ( x=0; x<iCols; x+= 8 )
+        {
+          if( piOrg[x] != DBBP_INVALID_SHORT )
+          {
+            uiSum += xCalcHADs8x8( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
+          }
+        }
+        piOrg += iOffsetOrg;
+        piCur += iOffsetCur;
+      }
+    }
+#if NS_HAD
+    else if ( ( iCols > 8 ) && ( iCols > iRows ) && pcDtParam->bUseNSHAD )
+    {
+      Int  iOffsetOrg = iStrideOrg<<2;
+      Int  iOffsetCur = iStrideCur<<2;
+      for ( y=0; y<iRows; y+= 4 )
+      {
+        for ( x=0; x<iCols; x+= 16 )
+        {
+          if( piOrg[x] != DBBP_INVALID_SHORT )
+          {
+            uiSum += xCalcHADs16x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
+          }
+        }
+        piOrg += iOffsetOrg;
+        piCur += iOffsetCur;
+      }
+    }
+    else if ( ( iRows > 8 ) && ( iCols < iRows ) && pcDtParam->bUseNSHAD )
+    {
+      Int  iOffsetOrg = iStrideOrg<<4;
+      Int  iOffsetCur = iStrideCur<<4;
+      for ( y=0; y<iRows; y+= 16 )
+      {
+        for ( x=0; x<iCols; x+= 4 )
+        {
+          if( piOrg[x] != DBBP_INVALID_SHORT )
+          {
+            uiSum += xCalcHADs4x16( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
+          }
+        }
+        piOrg += iOffsetOrg;
+        piCur += iOffsetCur;
+      }
+    }
+#endif
+    else if( ( iRows % 4 == 0) && (iCols % 4 == 0) )
+    {
+      Int  iOffsetOrg = iStrideOrg<<2;
+      Int  iOffsetCur = iStrideCur<<2;
+      
+      for ( y=0; y<iRows; y+= 4 )
+      {
+        for ( x=0; x<iCols; x+= 4 )
+        {
+          if( piOrg[x] != DBBP_INVALID_SHORT )
+          {
+            uiSum += xCalcHADs4x4( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
+          }
+        }
+        piOrg += iOffsetOrg;
+        piCur += iOffsetCur;
+      }
+    }
+    else if( ( iRows % 2 == 0) && (iCols % 2 == 0) )
+    {
+      Int  iOffsetOrg = iStrideOrg<<1;
+      Int  iOffsetCur = iStrideCur<<1;
+      for ( y=0; y<iRows; y+=2 )
+      {
+        for ( x=0; x<iCols; x+=2 )
+        {
+          if( piOrg[x] != DBBP_INVALID_SHORT )
+          {
+            uiSum += xCalcHADs2x2( &piOrg[x], &piCur[x*iStep], iStrideOrg, iStrideCur, iStep );
+          }
+        }
+        piOrg += iOffsetOrg;
+        piCur += iOffsetCur;
+      }
+    }
+    else
+    {
+      assert(false);
+    }
+  
+  return uiSum >> DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8);
+}
+
+UInt TComRdCost::xGetMaskedVSD( DistParam* pcDtParam )
+{
+  Pel* piOrg    = pcDtParam->pOrg;
+  Pel* piCur    = pcDtParam->pCur;
+  Pel* piVirRec = pcDtParam->pVirRec;
+  Pel* piVirOrg = pcDtParam->pVirOrg;
+  Int  iRows    = pcDtParam->iRows;
+  Int  iCols    = pcDtParam->iCols;
+  Int  iStrideOrg = pcDtParam->iStrideOrg;
+  Int  iStrideCur = pcDtParam->iStrideCur;
+  Int  iStrideVir = pcDtParam->iStrideVir;
+  
+  UInt uiSum = 0;
+  UInt uiShift = DISTORTION_PRECISION_ADJUSTMENT(pcDtParam->bitDepth-8)<<1;
+  
+  Int dDM;
+  
+  for ( Int y = 0 ; y < iRows ; y++ )
+  {
+    for (Int x = 0; x < iCols; x++ )
+    {
+      if( piOrg[x] != DBBP_INVALID_SHORT )
+      {
+        dDM = (Int) ( piOrg[x  ] - piCur[x  ] );
+        uiSum += getVSDEstimate( dDM, piOrg, iStrideOrg, piVirRec, piVirOrg, iStrideVir, x, y ) >> uiShift;
+      }
+    }
+    piOrg += iStrideOrg;
+    piCur += iStrideCur;
+  }
+  
+  return ( uiSum );
+}
+#endif
 
 // --------------------------------------------------------------------------------------------------------------------
@@ -2747,5 +3024,10 @@
   dD = ( (Double) ( dDM >> DISTORTION_PRECISION_ADJUSTMENT( g_bitDepthY - 8 ) ) ) * m_dDisparityCoeff;
 
+#if SCU_HS_VSD_BUGFIX_IMPROV_G0163
+  Double dDepthWeight = ( pOrg[x] >=  ( (1<<(g_bitDepthY - 3)) + (1<<(g_bitDepthY - 2)) ) ? 4 : pOrg[x] > ((1<<g_bitDepthY) >> 4) ? (Float)(pOrg[x] - ((1<<g_bitDepthY) >> 4))/(Float)((1<<g_bitDepthY) >> 3) + 1 : 1.0 );
+  Double dTemp = ( 0.5 * fabs(dD) * dDepthWeight * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
+#else
   Double dTemp = ( 0.5 * fabs(dD) * ( abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x-1+y*iVirStride ] ) + abs( (Int) pVirRec[ x+y*iVirStride ] - (Int) pVirRec[ x+1+y*iVirStride ] ) ) );
+#endif  
   iTemp = (Int) (((dTemp) < 0)? (Int)((dTemp) - 0.5) : (Int)((dTemp) + 0.5));
 
Index: trunk/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComRdCost.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComRdCost.h	(revision 833)
@@ -184,4 +184,8 @@
 #endif
   
+#if H_3D_DBBP
+  Bool                    m_bUseMask;
+#endif
+  
 public:
   TComRdCost();
@@ -229,4 +233,8 @@
   Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
   Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
+#endif
+  
+#if H_3D_DBBP
+  Void    setUseMask(Bool b) { m_bUseMask = b; }
 #endif
   
@@ -334,4 +342,11 @@
 #endif
   
+#if H_3D_DBBP
+  static UInt xGetMaskedSSE     ( DistParam* pcDtParam );
+  static UInt xGetMaskedSAD     ( DistParam* pcDtParam );
+  static UInt xGetMaskedHADs    ( DistParam* pcDtParam );
+  static UInt xGetMaskedVSD     ( DistParam* pcDtParam );
+#endif
+  
 public:
 #if WEIGHTED_CHROMA_DISTORTION
Index: trunk/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComSlice.cpp	(revision 833)
@@ -1827,4 +1827,7 @@
 #if H_3D_INTER_SDC
     m_bInterSDCFlag        [ i ] = false;
+#endif
+#if H_3D_DBBP
+    m_dbbpFlag             [ i ] = false;
 #endif
 #if H_3D_IV_MERGE
@@ -3129,11 +3132,29 @@
     for ( Int refListIdx = 0; refListIdx < ((m_eSliceType==B_SLICE) ? 2 : 1); refListIdx++ )
     {
+#if MTK_ARP_REF_SELECTION_G0053
+      Int diffPOC=MAX_INT;
+      Int idx=-1;
+#endif
       for(Int i = 0; i < getNumRefIdx(RefPicList(refListIdx)); i++ )
       {
         if ( getRefPic(RefPicList(refListIdx), i)->getPOC() != getPOC() )
         {
+#if MTK_ARP_REF_SELECTION_G0053
+          if( abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC()) < diffPOC)
+          {
+            diffPOC=abs(getRefPic(RefPicList(refListIdx), i)->getPOC() - getPOC());
+            idx=i;
+          }
+#else
           setFirstTRefIdx (RefPicList(refListIdx), i);
           break;
+#endif
         }
+#if MTK_ARP_REF_SELECTION_G0053
+        if(idx>=0)
+        {
+          setFirstTRefIdx (RefPicList(refListIdx), idx);
+        }
+#endif
       }
     }
@@ -3272,4 +3293,14 @@
 #endif
 
+#if MTK_DDD_G0063
+  if( getIsDepth() && getViewIndex() > 0 )
+  {
+      TComSlice *pcTextSlice = getTexturePic()->getSlice( 0 );
+      memcpy( m_aiDDDInvScale, pcTextSlice->m_aiDDDInvScale, sizeof( Int ) * getViewIndex() );
+      memcpy( m_aiDDDInvOffset, pcTextSlice->m_aiDDDInvOffset, sizeof( Int ) * getViewIndex() );
+      memcpy( m_aiDDDShift, pcTextSlice->m_aiDDDShift, sizeof( Int ) * getViewIndex() );             
+  }  
+#endif 
+
   if( !setupLUT )
     return; 
@@ -3319,8 +3350,74 @@
       m_depthToDisparityF[ i ][ d ] = ( invCodScale[ i ] * d + invOffset ) >> log2Div; 
     }
-  }
-}
-#endif
-#endif
+
+#if MTK_DDD_G0063
+    InitializeDDDPara( vps->getCamParPrecision(), codScale[ i ], codOffset[ i ], i );
+#endif
+  }
+}
+#endif
+#endif
+
+#if MTK_DDD_G0063
+Void TComSlice::InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx )
+{
+    UInt uiViewId     = getViewIndex();
+
+    if( uiViewId == 0 )
+    {
+        m_aiDDDInvScale[ iBaseViewIdx ] = m_aiDDDInvOffset[ iBaseViewIdx ] = m_aiDDDShift[ iBaseViewIdx ] = 0;
+        return;
+    }
+
+
+    Int iSign = iCodedScale >= 0 ? 1 : -1;
+    iCodedScale = abs( iCodedScale );
+
+    Int iBitWidth = 0;
+
+    const Int iInvPres = 9;
+
+    while( ((( 1 << iBitWidth ) << 1 ) <= iCodedScale ) )
+    {
+        iBitWidth ++;
+    }
+    iBitWidth += iInvPres;
+    Int iTargetValue =  1 << iBitWidth;
+
+    Int iMinError = MAX_INT;
+    Int iBestD = 1 << ( iInvPres - 1 );
+    for( Int d = 1 << ( iInvPres - 1 ); d < ( 1 << iInvPres ); d++ )
+    {
+        Int iError = abs( iCodedScale * d - iTargetValue );
+        if( iError < iMinError )
+        {
+            iMinError = iError;
+            iBestD = d;
+        }
+        if( iMinError == 0 )
+        {
+            break;
+        }
+    }
+    Int iRoundingDir = 0;
+    if( iCodedScale * iBestD > iTargetValue )
+    {
+        iRoundingDir = -1;
+    }
+    else if( iCodedScale * iBestD < iTargetValue )
+    {
+        iRoundingDir = 1;
+    }
+    Int iCamPres = uiCamParsCodedPrecision - 1;
+    m_aiDDDInvScale [ iBaseViewIdx ] = ( iBestD << ( iCamPres + g_bitDepthY )) * iSign;
+    m_aiDDDInvOffset[ iBaseViewIdx ] = -iSign * iBestD * ( iCodedOffset << g_bitDepthY );
+    m_aiDDDShift    [ iBaseViewIdx ] = iBitWidth;
+    m_aiDDDInvOffset[ iBaseViewIdx ] += 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 1 );
+    m_aiDDDInvOffset[ iBaseViewIdx ] += ( 1 << ( m_aiDDDShift[ iBaseViewIdx ] - 4 ) ) * iRoundingDir;
+
+    return;
+}
+#endif
+
 /** get scaling matrix from RefMatrixID
  * \param sizeId size index
Index: trunk/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- trunk/source/Lib/TLibCommon/TComSlice.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TComSlice.h	(revision 833)
@@ -783,4 +783,7 @@
 #endif
 #endif
+#if QC_SPIVMP_MPI_G0119
+  Int         m_iSubPUMPILog2Size;
+#endif
 #if H_3D_VSP
   Bool        m_viewSynthesisPredFlag    [ MAX_NUM_LAYERS ];
@@ -801,4 +804,7 @@
 #if H_3D_INTER_SDC
   Bool        m_bInterSDCFlag[MAX_NUM_LAYERS   ];
+#endif
+#if H_3D_DBBP
+  Bool        m_dbbpFlag[MAX_NUM_LAYERS];
 #endif
 #if H_3D_IV_MERGE
@@ -952,5 +958,5 @@
   Bool    inferOutputLayerFlag( Int layerSetIdx, Int i )                   { return ( getDefaultOneTargetOutputLayerIdc( ) == 0 || ( ( getDefaultOneTargetOutputLayerIdc( ) == 1 ) && ( i == m_layerSetLayerIdList[layerSetIdx].size() - 1  ) ));  }
 
-  Void    setProfileLevelTierIdx( Int outLayerSetIdx, Int val )            { m_profileLevelTierIdx[ outLayerSetIdx  = val ]; }
+  Void    setProfileLevelTierIdx( Int outLayerSetIdx, Int val )            { m_profileLevelTierIdx[ outLayerSetIdx ] = val; }
   Int     getProfileLevelTierIdx( Int outLayerSetIdx )                     { return m_profileLevelTierIdx[ outLayerSetIdx ]; } 
   Void    setAltOutputLayerFlag( Bool flag )                               { m_altOutputLayerFlag = flag; } 
@@ -1058,4 +1064,8 @@
 #endif
 #endif
+#if QC_SPIVMP_MPI_G0119
+  Int     getSubPUMPILog2Size( )           { return m_iSubPUMPILog2Size; }
+  Void    setSubPUMPILog2Size( Int u )     { m_iSubPUMPILog2Size = u;    }
+#endif
 #if H_3D_VSP
   Void    setViewSynthesisPredFlag  ( Int layerIdInVps, Bool val )  { m_viewSynthesisPredFlag[ layerIdInVps ] = val; }
@@ -1074,4 +1084,8 @@
   Bool    getInterSDCFlag      ( Int layerIdInVps )           { return m_bInterSDCFlag[layerIdInVps]; }
   Void    setInterSDCFlag      ( Int layerIdInVps, Bool bval ){ m_bInterSDCFlag[layerIdInVps] = bval; }
+#endif
+#if H_3D_DBBP
+  Bool getUseDBBP              ( Int layerIdInVps )         { return m_dbbpFlag[layerIdInVps]; }
+  Void setUseDBBP              ( Int layerIdInVps, Bool bval ){ m_dbbpFlag[layerIdInVps] = bval; }
 #endif
 #if H_3D_IV_MERGE
@@ -2055,4 +2069,11 @@
 #endif
 #endif
+
+#if MTK_DDD_G0063
+  Int          m_aiDDDInvScale [MAX_NUM_LAYERS];
+  Int          m_aiDDDInvOffset[MAX_NUM_LAYERS];
+  UInt         m_aiDDDShift    [MAX_NUM_LAYERS];
+#endif
+
 public:
   TComSlice();
@@ -2401,4 +2422,13 @@
   TComPic* getPicFromRefPicSetInterLayer( Int setIdc, Int layerId );
 #endif
+
+#if MTK_DDD_G0063
+  Void InitializeDDDPara( UInt uiCamParsCodedPrecision, Int  iCodedScale,Int  iCodedOffset, Int iBaseViewIdx );
+  Int  getDepthFromDV( Int iDV, Int iBaseViewIdx )
+  {
+      return ClipY(( iDV * m_aiDDDInvScale[ iBaseViewIdx ] + m_aiDDDInvOffset[ iBaseViewIdx ] ) >> m_aiDDDShift[ iBaseViewIdx ]);
+  }
+#endif
+
 protected:
   TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
Index: trunk/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- trunk/source/Lib/TLibCommon/TypeDef.h	(revision 774)
+++ trunk/source/Lib/TLibCommon/TypeDef.h	(revision 833)
@@ -235,5 +235,4 @@
 #define H_3D_DELTA_DLT                    1
 #endif
-
 #define H_3D_DIM_ENC                      1   // Depth Intra encoder optimizations, includes:
                                               // HHI_DEPTH_INTRA_SEARCH_RAU_C0160
@@ -250,4 +249,5 @@
 #endif
 
+
 ///// ***** ILLUMATION COMPENSATION *********
 #if H_3D_IC
@@ -257,4 +257,5 @@
 #endif
 
+
 ///// ***** FCO *********
 #if H_3D_FCO
@@ -272,16 +273,54 @@
 ///////////////////////////////////   HTM-10.0 Integrations //////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////
-
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-// !!! PLEASE PUT MACROS RELATED TO HTM-10.0 INTEGRATIONS HERE !!!
-
+#if H_3D
+#if  H_3D_QTLPC
+#define MTK_TEX_DEP_PAR_G0055             1   // Texture-partition-dependent depth partition. JCT3V-G0055
+#endif
+
+#define MTK_DDD_G0063                     1   // Disparity derived depth coding
+
+#if H_3D_VSP
+#define MTK_RBIP_VSP_G0069                1   // Restricted bi-prediction for VSP
+#define NTT_STORE_SPDV_VSP_G0148          1   // Storing Sub-PU based DV for VSP
+#endif
+
+#define H_3D_DBBP                         1   // DBBP: Depth-based Block Partitioning and Merging
+
+#if H_3D_DBBP
+#define DBBP_INVALID_SHORT                (-4)
+#define RWTH_DBBP_PACK_MODE               SIZE_2NxN
+#endif
+
+#if H_3D_DIM
+#define QC_PKU_SDC_SPLIT_G0123            1   // Intra SDC Split
+#if QC_PKU_SDC_SPLIT_G0123
+#define HS_TSINGHUA_SDC_SPLIT_G0111       1
+#endif
+#define SCU_HS_DEPTH_DC_PRED_G0143        1
+#define QC_GENERIC_SDC_G0122              1  // Generalize SDC to all depth intra modes
+#if H_3D_DIM_SDC && H_3D_INTER_SDC
+#define QC_SDC_UNIFY_G0130                1  // Unify intra SDC and inter SDC
+#define QC_SDC_UNIFY_G0130_FIX            1  // Fix bug of G0130
+#define QC_SDC_UNIFY_G0130_FIX2           1  // Fix bug of G0130
+#endif
+#define SEC_INTER_SDC_G0101               1  // Improved inter SDC with multiple DC candidates
+#endif
+
+#define KHU_SIMP_SPIVMP_G0147             1  // Simplification on Sub-PU level temporal interview motion prediction
+
+#if H_3D_SPIVMP
+#define QC_SPIVMP_MPI_G0119               1 // Sub-PU level MPI merge candidate
+#endif
+
+#define QC_DEPTH_MERGE_SIMP_G0127         1 // Remove DV candidate and shifting candidate for depth coding
+#define SEC_IC_ARP_SIG_G0072              1   // Disabling IC when ARP is enabled, option 1 in JCT3V-G0072, part 2 in JCT3V-G0121
+#define SCU_HS_VSD_BUGFIX_IMPROV_G0163    1
+#define SEC_SPIVMP_MCP_SIZE_G0077         1  // Apply SPIVMP only to 2Nx2N partition, JCT3V-G0077
+#define SEC_DEPTH_DV_DERIVAITON_G0074     1  // Simplification of DV derivation for depth, JCT3V-G0074
+#define MTK_ARP_REF_SELECTION_G0053       1   // ARP Reference picture selection in JCT3V-G0053 
+#define MTK_ARP_FLAG_CABAC_SIMP_G0061     1   // Use 2 context for ARP flag referring to only left neighbor block in JCT3V-G0061
+#define MTK_IC_FLAG_CABAC_SIMP_G0061      1   // Use only 1 context for IC flag in JCT3V-G0061
+#define MTK_NBDV_IVREF_FIX_G0067          1   // Disable IvMC, VSP when IVREF is not available, JCT3V-G0067
+#endif
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   HM RELATED DEFINES ////////////////////////////////
