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 ////////////////////////////////
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 833)
@@ -1697,5 +1697,9 @@
         READ_FLAG( uiCode, "iv_mv_pred_flag[i]");          pcVPS->setIvMvPredFlag         ( i, uiCode == 1 ? true : false );
 #if H_3D_SPIVMP
+#if SEC_SPIVMP_MCP_SIZE_G0077
+        READ_UVLC (uiCode, "log2_sub_PU_size_minus3");     pcVPS->setSubPULog2Size(i, uiCode+3); 
+#else
         READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+#endif
 #endif
 #endif
@@ -1710,4 +1714,7 @@
         READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false );
 #endif
+#if H_3D_DBBP
+          READ_FLAG( uiCode, "use_dbbp_flag[i]" ); pcVPS->setUseDBBP( i, uiCode == 1 ? true : false );
+#endif
       }
       else
@@ -1722,5 +1729,9 @@
         if (i!=1)
         {
+#if SEC_SPIVMP_MCP_SIZE_G0077
+          READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3); 
+#else
           READ_UVLC (uiCode, "log2_sub_PU_size_minus2[i]");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+#endif
         }
 #endif
@@ -1762,5 +1773,7 @@
     }
   }
-
+#if QC_SPIVMP_MPI_G0119
+  READ_UVLC (uiCode, "log2_sub_PU_MPI_size_minus3");              pcVPS->setSubPUMPILog2Size( uiCode + 3 ); 
+#endif
   READ_FLAG( uiCode, "iv_mv_scaling_flag");                       pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); 
 }
@@ -2774,4 +2787,15 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TDecCavlc::parseDeltaDC( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
+{ 
+  assert(0);
+}
+
+Void TDecCavlc::parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert(0);
+}
+#else
 Void TDecCavlc::parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -2783,4 +2807,11 @@
   assert(0);
 }
+#endif
+#endif
+#if H_3D_DBBP
+  Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+  {
+    assert(0);
+  }
 #endif
 // ====================================================================================================================
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 833)
@@ -124,6 +124,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void  parseDeltaDC        ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
+  Void  parseSDCFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#else
   Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
+#endif
+#if H_3D_DBBP
+  Void  parseDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
   Void parseSplitFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 833)
@@ -50,4 +50,7 @@
   m_ppcYuvReco = NULL;
   m_ppcCU      = NULL;
+#if H_3D_DBBP
+  m_ppcYuvRecoDBBP = NULL;
+#endif
 }
 
@@ -75,4 +78,7 @@
   m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1];
   m_ppcCU      = new TComDataCU*[m_uiMaxDepth-1];
+#if H_3D_DBBP
+  m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1];
+#endif
   
   UInt uiNumPartitions;
@@ -86,4 +92,7 @@
     m_ppcYuvReco[ui] = new TComYuv;    m_ppcYuvReco[ui]->create( uiWidth, uiHeight );
     m_ppcCU     [ui] = new TComDataCU; m_ppcCU     [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) );
+#if H_3D_DBBP
+    m_ppcYuvRecoDBBP[ui] = new TComYuv;    m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight );
+#endif
   }
   
@@ -106,4 +115,7 @@
     m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;
     m_ppcCU     [ui]->destroy(); delete m_ppcCU     [ui]; m_ppcCU     [ui] = NULL;
+#if H_3D_DBBP
+    m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL;
+#endif
   }
   
@@ -111,4 +123,7 @@
   delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;
   delete [] m_ppcCU     ; m_ppcCU      = NULL;
+#if H_3D_DBBP
+  delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL;
+#endif
 }
 
@@ -213,4 +228,5 @@
   DTRACE_CU("cqtDepth"  , uiDepth)
 #endif
+
   TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
@@ -276,4 +292,9 @@
 #endif
 
+
+#if MTK_DDD_G0063
+      pcCU->setUseDDD( false, uiAbsPartIdx, uiDepth );
+#endif
+
   if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP())
   {
@@ -318,5 +339,9 @@
       if( pcCU->getSlice()->getIsDepth())
       {
+#if SEC_DEPTH_DV_DERIVAITON_G0074
+        DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo);
+#else
         DvInfo.bDV = m_ppcCU[uiDepth]->getDispNeighBlocks(0, 0, &DvInfo);
+#endif
       }
       else
@@ -390,9 +415,16 @@
     UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
 
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
     m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
 #endif
+#endif
 #if H_3D_ARP
     m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth );
+#endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+    m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
 #endif
 
@@ -434,4 +466,13 @@
     pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
 
+#if MTK_DDD_G0063
+    if( uiMergeIndex == m_ppcCU[uiDepth]->getUseDDDCandIdx() )
+    {
+        assert( pcCU->getSlice()->getViewIndex() != 0 );
+        pcCU->setUseDDD( true, uiAbsPartIdx, 0, uiDepth );
+        pcCU->setDDDepthSubParts( m_ppcCU[uiDepth]->getDDTmpDepth(),uiAbsPartIdx, 0, uiDepth );
+    }
+#endif
+
     TComMv cTmpMv( 0, 0 );
     for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
@@ -443,4 +484,18 @@
         pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
         pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
+#if NTT_STORE_SPDV_VSP_G0148
+        if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 )
+        {
+          if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
+          {
+            UInt dummy;
+            Int vspSize;
+            Int width, height;
+            m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height );
+            m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
+            pcCU->setVSPFlag( uiAbsPartIdx, vspSize );
+          }
+        }
+#endif
 #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC   
         if ( g_decTraceMvFromMerge )
@@ -496,4 +551,7 @@
   m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
 
+#if QC_SDC_UNIFY_G0130
+  m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
   if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
   {
@@ -515,5 +573,5 @@
   // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]);
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
 #endif
@@ -585,6 +643,18 @@
   {
     case MODE_INTER:
+#if H_3D_DBBP
+      if( m_ppcCU[uiDepth]->getDBBPFlag(0) )
+      {
+        xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
+      }
+      else
+      {
+#endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+      if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) )
+#else
       if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
+#endif
       {
         xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
@@ -595,4 +665,7 @@
       xReconInter( m_ppcCU[uiDepth], uiDepth );
 #if H_3D_INTER_SDC
+      }
+#endif
+#if H_3D_DBBP
       }
 #endif
@@ -646,8 +719,10 @@
   UInt  uiWidth      = pcCU->getWidth ( 0 );
   UInt  uiHeight     = pcCU->getHeight( 0 );
+#if !SEC_INTER_SDC_G0101
   UChar* pMask       = pcCU->getInterSDCMask();
 
   memset( pMask, 0, uiWidth*uiHeight );
   pcCU->xSetInterSDCCUMask( pcCU, pMask );
+#endif
 
   Pel  *pResi;
@@ -660,7 +735,14 @@
     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
     {
+#if SEC_INTER_SDC_G0101
+      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 );
+#else
       UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
-
-      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );;
+#if QC_SDC_UNIFY_G0130
+      pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( uiSeg, 0 );
+#else
+      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );
+#endif
+#endif
     }
     pResi += uiResiStride;
@@ -684,4 +766,104 @@
     pRecCb += uiStrideC;
     pRecCr += uiStrideC;
+  }
+}
+#endif
+
+#if H_3D_DBBP
+Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  AOF(!pcCU->getSlice()->getIsDepth());
+  AOF(!pcCU->getSlice()->isIntra());
+  PartSize ePartSize = pcCU->getPartitionSize( 0 );
+  
+  // get collocated depth block
+  UInt uiDepthStride = 0;
+  Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride);
+  AOF( pDepthPels != NULL );
+  AOF( uiDepthStride != 0 );
+  
+  // compute mask by segmenting depth block
+  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
+  Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask);
+  AOF(bValidMask);
+  
+  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+  TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] };
+  
+  // first, extract the two sets of motion parameters
+  UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4;
+  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
+  {
+    UInt uiPartAddr = uiSegment*uiPUOffset;
+    
+    pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr);
+    
+    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+    {
+      RefPicList eRefList = (RefPicList)uiRefListIdx;
+      pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
+    }
+    
+    pDBBPTmpData->ahVSPFlag[uiSegment] = pcCU->getVSPFlag( uiPartAddr );
+    pDBBPTmpData->acDvInfo[uiSegment] = pcCU->getDvInfo( uiPartAddr );
+  }
+  
+  // do motion compensation for each segment as 2Nx2N
+  pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
+  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
+  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
+  {
+    pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth );
+    
+    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], 0, 0, uiDepth );
+    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], 0, 0, uiDepth );
+    
+    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+    {
+      RefPicList eRefList = (RefPicList)uiRefListIdx;
+
+      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 );
+    }
+    
+    // inter prediction
+    m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] );
+  }
+  
+  // restore motion information in both segments again
+  pcCU->setPartSizeSubParts( ePartSize,  0, uiDepth );
+  pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth );
+  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
+  {
+    UInt uiPartAddr = uiSegment*uiPUOffset;
+    
+    pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth);
+    
+    pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uiDepth );
+    pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uiDepth );
+    
+    pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level
+    
+    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+    {
+      RefPicList eRefList = (RefPicList)uiRefListIdx;
+
+      pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
+    }
+  }
+  
+  // reconstruct final prediction signal by combining both segments
+  m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0));
+  
+  // inter recon
+  xDecodeInterTexture( pcCU, 0, uiDepth );
+  
+  // clip for only non-zero cbp case
+  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
+  {
+    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
+  }
+  else
+  {
+    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
   }
 }
@@ -906,5 +1088,65 @@
   UInt uiWidth        = pcCU->getWidth  ( 0 );
   UInt uiHeight       = pcCU->getHeight ( 0 );
-  
+#if QC_PKU_SDC_SPLIT_G0123
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#else
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#endif
+#endif
+#if QC_PKU_SDC_SPLIT_G0123
+  UInt numParts = 1;
+  UInt i = 0;
+  UInt sdcDepth    = 0;
+  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
+  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
+  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
+
+  UInt    uiStride = 0;
+  Pel*    piReco;
+  Pel*    piPred;
+  Pel*    piResi;
+
+  UInt    uiZOrder;        
+  Pel*    piRecIPred;      
+  UInt    uiRecIPredStride;
+
+  UInt    uiLumaPredMode = 0;  
+
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+  if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1)
+  {
+    numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
+    sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
+    uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize());
+  }
+#else
+  if (uiWidth == 64)
+  {
+    numParts = 4;
+    sdcDepth = 1;
+    uiWidth = uiHeight = 32;
+  }
+#endif
+
+  for ( i = 0; i < numParts; i++ )
+  {
+    uiStride    = pcRecoYuv->getStride  ();
+    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
+    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
+  
+    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+
+    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
+
+    AOF( uiWidth == uiHeight );
+#else
   TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
   TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
@@ -926,16 +1168,41 @@
   AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
   AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
+#endif
   
   //===== init availability pattern =====
   Bool  bAboveAvail = false;
   Bool  bLeftAvail  = false;
+#if QC_PKU_SDC_SPLIT_G0123
+  pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
+  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
+#else
   pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
-  
+#endif
+#if !QC_PKU_SDC_SPLIT_G0123
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#endif
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
   //===== get prediction signal =====
 #if H_3D_DIM
   if( isDimMode( uiLumaPredMode ) )
   {
-    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight );
+    m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight 
+#if QC_GENERIC_SDC_G0122
+      , false, dmm4Segmentation
+#endif
+      );
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
+    Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
+    for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 
+    { 
+      dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
+    }
+#endif
   }
   else
@@ -946,5 +1213,38 @@
   }
 #endif
-  
+#if QC_PKU_SDC_SPLIT_G0123 
+    if ( numParts > 1 )
+    {
+      for( UInt uiY = 0; uiY < uiHeight; uiY++ )
+      {
+        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
+        {
+          piReco        [ uiX ] = ClipY( piPred[ uiX ] );
+          piRecIPred    [ uiX ] = piReco[ uiX ];
+        }
+        piPred     += uiStride;
+        piReco     += uiStride;
+        piRecIPred += uiRecIPredStride;
+      }
+    }
+    uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 );
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    dmm4Segmentation->destroy(); delete dmm4Segmentation;
+#endif
+  }
+  uiAbsPartIdx = 0;
+  
+  if ( numParts > 1 )
+  {
+    uiWidth = pcCU->getWidth( 0 );
+    uiHeight = pcCU->getHeight( 0 );
+  }
+  piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
+  piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
+  uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+  piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+  uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+#endif
   // number of segments depends on prediction mode
   UInt uiNumSegments = 1;
@@ -963,5 +1263,17 @@
     uiMaskStride = pcWedgelet->getStride();
   }
-  
+#if QC_GENERIC_SDC_G0122
+  if( getDimType( uiLumaPredMode ) == DMM4_IDX )
+  {
+    uiNumSegments = 2;
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    pbMask  = dmm4SegmentationOrg->getPattern();
+    uiMaskStride = dmm4SegmentationOrg->getStride();
+#else
+    pbMask  = dmm4Segmentation->getPattern();
+    uiMaskStride = dmm4Segmentation->getStride();
+#endif
+  }
+#endif
   // get DC prediction for each segment
   Pel apDCPredValues[2];
@@ -1025,4 +1337,11 @@
     pRecCr += uiStrideC;
   }
+#if QC_GENERIC_SDC_G0122
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+  dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
+#else
+  dmm4Segmentation->destroy(); delete dmm4Segmentation;
+#endif
+#endif
 }
 #endif
Index: trunk/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecCu.h	(revision 833)
@@ -63,4 +63,8 @@
   TComDataCU**        m_ppcCU;            ///< CU data array
   
+#if H_3D_DBBP
+  TComYuv**           m_ppcYuvRecoDBBP;
+#endif
+  
   // access channel
   TComTrQuant*        m_pcTrQuant;
@@ -98,4 +102,8 @@
   Void xReconInter              ( TComDataCU* pcCU, UInt uiDepth );
   
+#if H_3D_DBBP
+  Void xReconInterDBBP          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
+  
   Void  xReconIntraQT           ( TComDataCU* pcCU, UInt uiDepth );
   Void  xIntraRecLumaBlk        ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 833)
@@ -111,5 +111,9 @@
   pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth );
 
+#if SEC_IC_ARP_SIG_G0072
+  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
+#else
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
+#endif
   {
     return;
@@ -137,4 +141,31 @@
 {
   m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
+  
+#if H_3D_DBBP
+  if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE )
+  {
+    decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth);
+    
+    if( pcCU->getDBBPFlag(uiAbsPartIdx) )
+    {
+      AOF( pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE );
+      
+      // get collocated depth block
+      UInt uiDepthStride = 0;
+      Pel* pDepthPels = NULL;
+      pDepthPels = pcCU->getVirtualDepthBlock(uiAbsPartIdx, pcCU->getWidth(uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), uiDepthStride);
+      
+      AOF( pDepthPels != NULL );
+      AOF( uiDepthStride != 0 );
+      
+      // derive true partitioning for this CU based on depth
+      // (needs to be done in parsing process as motion vector predictors are also derived during parsing)
+      PartSize eVirtualPartSize = m_pcPrediction->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(uiAbsPartIdx));
+      AOF( eVirtualPartSize != SIZE_NONE );
+      
+      pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
+    }
+  }
+#endif
 }
 
@@ -241,11 +272,22 @@
       decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
       UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
 #endif
+#endif
 #if H_3D_ARP
       decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
 #endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#endif
+#if H_3D_DBBP
+      if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false )
+#else
       if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) 
+#endif
       {
         pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
@@ -320,4 +362,17 @@
       pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
 
+#if MTK_DDD_G0063
+      if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() )
+      {
+          assert( pcCU->getSlice()->getViewIndex() != 0 );
+          pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth );
+          pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth );
+      }
+      else
+      {
+          pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth );
+      }
+#endif
+
       TComMv cTmpMv( 0, 0 );
       for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
@@ -329,4 +384,22 @@
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
           pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx );
+#if NTT_STORE_SPDV_VSP_G0148
+#if H_3D_DBBP
+          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) )
+#else
+          if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 )
+#endif
+          {
+            if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) )
+            {
+              UInt dummy;
+              Int vspSize;
+              Int width, height;
+              pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 );
+              pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize );
+              pcCU->setVSPFlag( uiSubPartIdx, vspSize );
+            }
+          }
+#endif
         }
       }
@@ -367,13 +440,24 @@
         }
       }
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
       decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
 #endif
+#endif
 #if H_3D_ARP
       decodeARPW  ( pcCU, uiAbsPartIdx, uiDepth );
 #endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+      decodeICFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
+#endif
     }
 #if H_3D_VSP
+#if NTT_STORE_SPDV_VSP_G0148
+    if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == 0))
+#else
     if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == false))
+#endif
 #else
     if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) )
@@ -713,7 +797,7 @@
   UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
   UInt uiChromaOffset = uiLumaOffset>>2;
-  
+#if QC_SDC_UNIFY_G0130
 #if H_3D_DIM_SDC
-  if( pcCU->getSDCFlag( uiAbsPartIdx ) )
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) )
   {
     assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
@@ -722,4 +806,49 @@
     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
+  }
+#endif
+
+#if H_3D_INTER_SDC
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) )
+  {
+    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
+    assert( !pcCU->isIntra( uiAbsPartIdx) );
+    assert( pcCU->getSlice()->getIsDepth() );
+  }
+#endif
+#if QC_SDC_UNIFY_G0130_FIX
+  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
+#else
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) )
+#endif
+  {
+    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
+    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
+  
+    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
+    {
+      for( Int iPart = 0; iPart < iPartNum; iPart++ )
+      {
+        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
+        {
+          m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) );
+        }
+      }
+    }
+    else
+    {
+      m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth );
+      return;
+    }
+  }
+#else
+#if H_3D_DIM_SDC
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) )
+  {
+    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
     return;
   }
@@ -737,4 +866,5 @@
   }
 #endif
+#endif
 
   if( pcCU->isIntra(uiAbsPartIdx) )
@@ -760,4 +890,34 @@
 
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
+
+  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || 
+    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
+  {
+    return;
+  }
+
+#if SEC_INTER_SDC_G0101
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
+#else
+  if( !pcCU->getSlice()->getIsDepth() || ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N ) || pcCU->isSkipped( uiAbsPartIdx ) )
+#endif
+  {
+    return;
+  }
+
+#if SEC_INTER_SDC_G0101
+  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
+#else
+  assert( ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
+#endif
+
+  m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
+}
+
+#else
 Void TDecEntropy::decodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -798,4 +958,11 @@
 }
 #endif
+#endif
+#if H_3D_DBBP
+Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth );
+}
+#endif
 
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 833)
@@ -96,6 +96,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  virtual Void parseDeltaDC       ( TComDataCU* pcCU, UInt absPartIdx, UInt depth ) = 0;
+  virtual Void parseSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
+#else
   virtual Void parseInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
   virtual Void parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) = 0;
+#endif
+#endif
+#if H_3D_DBBP
+  virtual Void parseDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
   virtual Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
@@ -179,7 +187,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void decodeSDCFlag           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#else
   Void decodeInterSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void decodeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
+#endif
+#if H_3D_DBBP
+  Void decodeDBBPFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
   Void decodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 833)
@@ -87,4 +87,10 @@
 , m_cDdcFlagSCModel           ( 1,             1,               NUM_DDC_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
+#if QC_GENERIC_SDC_G0122
+, m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
+#if !QC_SDC_UNIFY_G0130
+, m_cIntraSdcFlagSCModel      ( 1,             1,               NUM_INTRASDC_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#endif
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
@@ -95,8 +101,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
 , m_cInterSDCFlagSCModel             ( 1,             1,  NUM_INTER_SDC_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cInterSDCResidualSCModel         ( 1,             1,  NUM_INTER_SDC_RESIDUAL_CTX       , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cInterSDCResidualSignFlagSCModel ( 1,             1,  NUM_INTER_SDC_SIGN_FLAG_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if QC_SDC_UNIFY_G0130
+, m_cSDCFlagSCModel                  ( 1,             1,  NUM_SDC_FLAG_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if H_3D_DBBP
+, m_cDBBPFlagSCModel             ( 1,             1,                 DBBP_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 {
@@ -170,4 +182,10 @@
   m_cDdcFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_FLAG );
   m_cDdcDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_DATA );
+#if QC_GENERIC_SDC_G0122
+  m_cAngleFlagSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_ANGLE_FLAG );
+#if !QC_SDC_UNIFY_G0130
+  m_cIntraSdcFlagSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_INTRASDC_FLAG );
+#endif
+#endif
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM1_DATA );
@@ -178,8 +196,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_cInterSDCFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer   ( sliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL );
   m_cInterSDCResidualSignFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_INTER_SDC_SIGN_FLAG );
+#endif
+#if QC_SDC_UNIFY_G0130
+  m_cSDCFlagSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
+#endif
+#if H_3D_DBBP
+  m_cDBBPFlagSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_DBBP_FLAG );
 #endif
   m_uiLastDQpNonZero  = 0;
@@ -239,4 +263,10 @@
   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
+#if QC_GENERIC_SDC_G0122
+  m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
+#if !QC_SDC_UNIFY_G0130
+  m_cIntraSdcFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_INTRASDC_FLAG );
+#endif
+#endif
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
@@ -247,8 +277,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_cInterSDCFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer   ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL );
   m_cInterSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_SIGN_FLAG );
+#endif
+#if QC_SDC_UNIFY_G0130
+  m_cSDCFlagSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+#endif
+#if H_3D_DBBP
+  m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
   m_pcTDecBinIf->start();
@@ -784,9 +820,22 @@
   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
 
+#if MTK_TEX_DEP_PAR_G0055
+  Bool depthDependent = false;
+  UInt uiTexturePart = uiMode;
+#endif
   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC())
   {
     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
     assert(pcTextureCU->getDepth(uiAbsPartIdx) >= uiDepth);
+#if !MTK_TEX_DEP_PAR_G0055
     if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN)
+#else
+    if(pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth )
+    {
+      depthDependent = true;
+      uiTexturePart = pcTextureCU->getPartitionSize( uiAbsPartIdx );
+    }
+    if (pcTextureCU->getDepth(uiAbsPartIdx) == uiDepth && pcTextureCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N)
+#endif
     {
       bParsePartSize = false;
@@ -833,4 +882,8 @@
     if(bParsePartSize)
     {
+#endif
+#if MTK_TEX_DEP_PAR_G0055
+      if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
+      {
 #endif
       UInt uiMaxNumBits = 2;
@@ -870,4 +923,71 @@
         }
       }
+#if MTK_TEX_DEP_PAR_G0055
+      }
+      else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
+      {
+        UInt uiMaxNumBits = 1;
+        if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+        {
+          uiMaxNumBits ++;
+        }
+        for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
+        {
+          m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
+          if ( uiSymbol )
+          {
+            break;
+          }
+          uiMode++;
+        }
+        eMode = (PartSize) uiMode;
+        if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 )
+        {
+          eMode = SIZE_2NxN;
+        }
+        else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0  && uiSymbol==0)
+        {
+          eMode = SIZE_2NxN;
+        }
+        else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0)
+        {
+          m_pcTDecBinIf->decodeBinEP(uiSymbol);
+          eMode = (uiSymbol == 0? SIZE_2NxnU : SIZE_2NxnD);
+        }
+      }
+      else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
+      {
+        UInt uiMaxNumBits = 1;
+        if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+        {
+          uiMaxNumBits ++;
+        }
+        for ( UInt ui = 0; ui < uiMaxNumBits; ui++ )
+        {
+          m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) );
+          if ( uiSymbol )
+          {
+            break;
+          }
+          uiMode++;
+        }
+        eMode = (PartSize) uiMode;
+        if(uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==1 )
+        {
+          eMode = SIZE_Nx2N;
+        }
+        else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth )==0  && uiSymbol==0)
+        {
+          eMode = SIZE_Nx2N;
+        }
+        else if (uiMode && pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) && uiSymbol==0)
+        {
+          m_pcTDecBinIf->decodeBinEP(uiSymbol);
+          eMode = (uiSymbol == 0? SIZE_nLx2N : SIZE_nRx2N);
+        }
+      }
+      else
+        assert(0);
+#endif
 #if H_MV_ENC_DEC_TRAC          
       DTRACE_CU("part_mode", eMode )
@@ -925,5 +1045,9 @@
     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
 #if H_3D_DIM_SDC
+#if QC_GENERIC_SDC_G0122
+      if( 1 ) // This should be cleaned up. 
+#else
       if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
 #endif
     {
@@ -943,5 +1067,9 @@
     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
 #if H_3D_DIM_SDC
+#if QC_GENERIC_SDC_G0122
+      if( 1 )  // This should be cleaned up. 
+#else
       if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
 #endif
     {
@@ -1046,8 +1174,13 @@
   }
 
+#if !QC_SDC_UNIFY_G0130
   if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
   {
     UInt symbol;
+#if QC_GENERIC_SDC_G0122
+    UInt uiNumSegments = isDimMode( dir ) ? 2 : 1;
+#else
     UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
+#endif
 
     if( pcCU->getSDCFlag( absPartIdx ) )
@@ -1085,8 +1218,50 @@
     }
   }
-
+#endif
   pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
 }
 
+#if QC_GENERIC_SDC_G0122
+Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
+{
+  UInt uiSymbol, uiIsDimMode;
+
+  if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) );
+  }
+  else
+  {
+    uiSymbol = 1;
+  }
+  uiIsDimMode = uiSymbol ? 0 : 1;
+  pcCU->setLumaIntraDirSubParts( 0, absPartIdx, depth );
+#if !QC_SDC_UNIFY_G0130
+  if( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ) //SDC is allowed only in this case
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraSdcFlagSCModel.get( 0, 0, pcCU->getCtxSDCFlag( absPartIdx ) ) );
+  }
+  else
+  {
+    uiSymbol = 0;
+  }
+
+  pcCU->setSDCFlagSubParts( uiSymbol, absPartIdx, depth );
+#endif
+  //decode DMM index
+  if( uiIsDimMode )
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
+    if( !uiSymbol )
+    {
+      pcCU->setLumaIntraDirSubParts( ( 2 * DMM1_IDX + DIM_OFFSET ), absPartIdx, depth );
+    }
+    else
+    {
+      pcCU->setLumaIntraDirSubParts( ( 2 * DMM4_IDX + DIM_OFFSET ), absPartIdx, depth );
+    }
+  }
+}
+#else
 Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
 {
@@ -1151,4 +1326,5 @@
 #endif
 }
+#endif
 #endif
 
@@ -2058,5 +2234,9 @@
   if( 1 == uiW )   
   {
+#if MTK_ARP_FLAG_CABAC_SIMP_G0061
+    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
+#else
     m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 3 ) );
+#endif
     uiW += ( 1 == uiCode ? 1 : 0 );
   }
@@ -2078,6 +2258,10 @@
 { 
   UInt uiSymbol = 0;
+#if MTK_IC_FLAG_CABAC_SIMP_G0061
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) );
+#else
   UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx );
   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) );
+#endif
 #if !H_MV_ENC_DEC_TRAC 
   DTRACE_CABAC_VL( g_nSymbolCounter++ );
@@ -2097,4 +2281,92 @@
 
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TDecSbac::parseDeltaDC( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
+{
+  if( ! ( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) )
+  {
+    assert( 0 );
+  }
+
+  UInt symbol = 0;
+  UInt uiNumSegments = 0;
+
+  if( pcCU->isIntra( absPartIdx ) )
+  {
+    UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
+    uiNumSegments = isDimMode( dir ) ? 2 : 1;
+
+    m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get( 0, 0, uiNumSegments-1 ) );
+
+    if( pcCU->getSDCFlag( absPartIdx ) )
+    {
+      assert( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N );
+      pcCU->setTrIdxSubParts( 0, absPartIdx, depth );
+      pcCU->setCbfSubParts( 1, 1, 1, absPartIdx, depth );
+    }
+    else
+    {
+      pcCU->setLumaIntraDirSubParts( dir + symbol, absPartIdx, depth );
+    }
+  }
+  else
+  {
+#if SEC_INTER_SDC_G0101
+    uiNumSegments = 1;
+#else
+    PartSize cPartSize = pcCU->getPartitionSize( absPartIdx );
+    uiNumSegments = ( cPartSize == SIZE_2Nx2N ) ? 1 : ( cPartSize == SIZE_NxN ? 4 : 2 );
+#endif
+    symbol = 1;
+  }
+
+
+  for( UInt segment = 0; segment < uiNumSegments; segment++ )
+  {
+    Pel valDeltaDC = 0;
+    if( symbol )
+    {
+      xParseDimDeltaDC( valDeltaDC, uiNumSegments );
+    }
+
+    if( pcCU->isIntra( absPartIdx ) )
+    {
+      UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
+
+      if( pcCU->getSDCFlag( absPartIdx ) )
+      {
+        pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
+      }
+      else
+      {
+        pcCU->setDimDeltaDC( getDimType( dir ), segment, absPartIdx, valDeltaDC );
+      }
+    }
+    else
+    {
+      pcCU->setSDCSegmentDCOffset( valDeltaDC, segment, absPartIdx );
+    }
+  }
+}
+
+Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiSymbol = 0;
+  UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
+
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
+
+  if( uiSymbol )
+  {
+    pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, uiDepth );
+    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
+    pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth );
+  }
+  else
+  {
+    pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth );
+  }
+}
+#else
 Void TDecSbac::parseInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
@@ -2131,4 +2403,24 @@
 }
 #endif
+#endif
+
+#if H_3D_DBBP
+Void TDecSbac::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
+  AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
+  AOF( !pcCU->getSlice()->getIsDepth() );
+  AOF( ePartSize == RWTH_DBBP_PACK_MODE );
+  
+  UInt uiSymbol = 0;
+  
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
+  
+  if( uiSymbol )
+  {
+    pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth);
+  }
+}
+#endif
 
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 833)
@@ -112,6 +112,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void  parseDeltaDC         ( TComDataCU* pcCU, UInt absPartIdx, UInt depth );
+  Void  parseSDCFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#else
   Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
+#endif
+#if H_3D_DBBP
+  Void parseDBBPFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
 private:
@@ -211,4 +219,10 @@
   ContextModel3DBuffer m_cDdcFlagSCModel;
   ContextModel3DBuffer m_cDdcDataSCModel;
+#if QC_GENERIC_SDC_G0122
+  ContextModel3DBuffer m_cAngleFlagSCModel;
+#if !QC_SDC_UNIFY_G0130
+  ContextModel3DBuffer m_cIntraSdcFlagSCModel;
+#endif
+#endif
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
@@ -219,9 +233,15 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   ContextModel3DBuffer m_cInterSDCFlagSCModel;
   ContextModel3DBuffer m_cInterSDCResidualSCModel;
   ContextModel3DBuffer m_cInterSDCResidualSignFlagSCModel;
 #endif
+#if QC_SDC_UNIFY_G0130
+  ContextModel3DBuffer m_cSDCFlagSCModel;
+#endif
+#if H_3D_DBBP
+  ContextModel3DBuffer m_cDBBPFlagSCModel;
+#endif
 };
 
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 774)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 833)
@@ -82,4 +82,10 @@
 #endif
 
+#if MTK_DDD_G0063
+  Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];}
+  Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];}
+  UInt getCamParsCodedPrecision(){ return m_uiCamParsCodedPrecision; }
+#endif
+
 private:
   Bool  xIsComplete ();
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 833)
@@ -1500,5 +1500,9 @@
         WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
 #if H_3D_SPIVMP
+#if SEC_SPIVMP_MCP_SIZE_G0077
+        WRITE_UVLC( pcVPS->getSubPULog2Size(i)-3, "log2_sub_PU_size_minus3[i]");
+#else
         WRITE_UVLC( pcVPS->getSubPULog2Size(i)-2, "log2_sub_PU_size_minus2[i]");
+#endif
 #endif
 #endif
@@ -1512,4 +1516,7 @@
         WRITE_FLAG( pcVPS->getViewSynthesisPredFlag( i ) ? 1 : 0 , "view_synthesis_pred_flag[i]");
 #endif
+#if H_3D_DBBP
+        WRITE_FLAG( pcVPS->getUseDBBP( i ) ? 1 : 0, "use_dbbp_flag[i]" );
+#endif
       }          
       else
@@ -1522,5 +1529,9 @@
         if (i!=1)
         {
+#if SEC_SPIVMP_MCP_SIZE_G0077
+          WRITE_UVLC( pcVPS->getSubPULog2Size(i)-3, "log2_sub_PU_size_minus3[i]");
+#else
           WRITE_UVLC( pcVPS->getSubPULog2Size(i)-2, "log2_sub_PU_size_minus2[i]");
+#endif
         }
 #endif
@@ -1555,4 +1566,7 @@
     }
   }
+#if QC_SPIVMP_MPI_G0119
+  WRITE_UVLC( pcVPS->getSubPUMPILog2Size( ) - 3, "log2_sub_PU_MPI_size_minus3");
+#endif
 #if H_3D_TMVP
   WRITE_FLAG( pcVPS->getIvMvScalingFlag( ) ? 1 : 0 ,          "iv_mv_scaling_flag" );
@@ -2513,4 +2527,15 @@
 
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TEncCavlc::codeDeltaDC( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+
+Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+#else
 Void TEncCavlc::codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -2523,3 +2548,11 @@
 }
 #endif
+#endif
+    
+#if H_3D_DBBP
+Void TEncCavlc::codeDBBPFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+#endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 833)
@@ -138,6 +138,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+  Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+#else
   Void codeInterSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeInterSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+#endif
+#endif
+#if H_3D_DBBP
+  Void codeDBBPFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
 
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 833)
@@ -411,4 +411,7 @@
   Int      m_iSubPULog2Size;
 #endif
+#if QC_SPIVMP_MPI_G0119
+  Int      m_iSubPUMPILog2Size;
+#endif
 #if H_3D_IC
   Bool      m_bUseIC;
@@ -416,4 +419,7 @@
 #if H_3D_INTER_SDC
   bool      m_bInterSDC;
+#endif
+#if H_3D_DBBP
+  Bool      m_bUseDBBP;
 #endif
   //====== Depth Intra Modes ======
@@ -515,5 +521,8 @@
   Void       setSubPULog2Size                   (Int u)              { m_iSubPULog2Size = u; }     
 #endif
-
+#if QC_SPIVMP_MPI_G0119
+  Int        getSubPUMPILog2Size            ()               { return m_iSubPUMPILog2Size;}
+  Void       setSubPUMPILog2Size            (Int u)          { m_iSubPUMPILog2Size = u;   }     
+#endif
 #if H_3D_IC
   Void       setUseIC                       ( Bool bVal )    { m_bUseIC = bVal; }
@@ -523,4 +532,8 @@
   Void       setInterSDCEnable              ( Bool bVal )    { m_bInterSDC = bVal; }
   Bool       getInterSDCEnable              ()               { return m_bInterSDC; }
+#endif
+#if H_3D_DBBP
+  Void       setUseDBBP                     ( Bool  b )      { m_bUseDBBP   = b; }
+  Bool       getUseDBBP()                                    { return m_bUseDBBP;     }
 #endif
   //======== Transform =============
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 833)
@@ -76,4 +76,7 @@
   m_ppcRecoYuvTemp = new TComYuv*[m_uhTotalDepth-1];
   m_ppcOrigYuv     = new TComYuv*[m_uhTotalDepth-1];
+#if H_3D_DBBP
+  m_ppcOrigYuvDBBP = new TComYuv*[m_uhTotalDepth-1];
+#endif
   
   UInt uiNumPartitions;
@@ -100,4 +103,7 @@
     
     m_ppcOrigYuv    [i] = new TComYuv; m_ppcOrigYuv    [i]->create(uiWidth, uiHeight);
+#if H_3D_DBBP
+    m_ppcOrigYuvDBBP[i] = new TComYuv; m_ppcOrigYuvDBBP[i]->create(uiWidth, uiHeight);
+#endif
   }
   
@@ -180,4 +186,10 @@
       m_ppcOrigYuv[i]->destroy();     delete m_ppcOrigYuv[i];     m_ppcOrigYuv[i] = NULL;
     }
+#if H_3D_DBBP
+    if(m_ppcOrigYuvDBBP[i])
+    {
+      m_ppcOrigYuvDBBP[i]->destroy(); delete m_ppcOrigYuvDBBP[i]; m_ppcOrigYuvDBBP[i] = NULL;
+    }
+#endif
   }
   if(m_ppcBestCU)
@@ -234,4 +246,11 @@
     m_ppcOrigYuv = NULL;
   }
+#if H_3D_DBBP
+  if(m_ppcOrigYuvDBBP)
+  {
+    delete [] m_ppcOrigYuvDBBP;
+    m_ppcOrigYuvDBBP = NULL;
+  }
+#endif
 }
 
@@ -544,4 +563,13 @@
           bTryNx2N  = false;
           bTry2NxN  = false;
+#if MTK_TEX_DEP_PAR_G0055
+          if( pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize(uiCUIdx) != SIZE_2Nx2N)
+          {
+            if(pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxN || pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnU|| pcTextureCU->getPartitionSize(uiCUIdx)==SIZE_2NxnD)
+              bTry2NxN  = true;
+            else
+              bTryNx2N  = true;
+          }
+#endif
         }
       }
@@ -570,5 +598,9 @@
           if (rpcTempCU->getSlice()->getIsDepth() )
           {
+#if SEC_DEPTH_DV_DERIVAITON_G0074
+            DvInfo.bDV = rpcTempCU->getDispforDepth(0, 0, &DvInfo);
+#else
             DvInfo.bDV = rpcTempCU->getDispNeighBlocks(0, 0, &DvInfo);
+#endif
           }
           else
@@ -650,4 +682,16 @@
             rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
 #endif
+          
+#if H_3D_DBBP
+          if( m_pcEncCfg->getUseDBBP() )
+          {
+            xCheckRDCostInterDBBP( rpcBestCU, rpcTempCU, false );
+            rpcTempCU->initEstData( uiDepth, iQP );
+#if H_3D_VSP
+            rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth);
+#endif
+          }
+#endif
+          
             if(m_pcEncCfg->getUseCbfFastMode())
             {
@@ -1576,10 +1620,17 @@
 #endif
     m_pcEntropyCoder->encodeMergeIndex( pcCU, uiAbsPartIdx );
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
     m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
 #endif
+#endif
 #if H_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+    m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
+#endif
+#endif
     finishCU(pcCU,uiAbsPartIdx,uiDepth);
     return;
@@ -1589,4 +1640,7 @@
   m_pcEntropyCoder->encodePartSize( pcCU, uiAbsPartIdx, uiDepth );
   
+#if QC_SDC_UNIFY_G0130
+  m_pcEntropyCoder->encodeSDCFlag( pcCU, uiAbsPartIdx, false );
+#endif
   if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
   {
@@ -1603,11 +1657,18 @@
   // prediction Info ( Intra : direction mode, Inter : Mv, reference idx )
   m_pcEntropyCoder->encodePredInfo( pcCU, uiAbsPartIdx );
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
   m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
 #endif
+#endif
 #if H_3D_ARP
   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
-#if H_3D_INTER_SDC
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+  m_pcEntropyCoder->encodeICFlag  ( pcCU, uiAbsPartIdx );
+#endif
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_pcEntropyCoder->encodeInterSDCFlag( pcCU, uiAbsPartIdx, false );
 #endif
@@ -1837,5 +1898,9 @@
 #if H_3D_ARP
   Int nARPWMax = rpcTempCU->getSlice()->getARPStepNum() - 1;
+#if SEC_IC_ARP_SIG_G0072
+  if( nARPWMax < 0 || !rpcTempCU->getDvInfo(0).bDV || bICFlag )
+#else
   if( nARPWMax < 0 || !rpcTempCU->getDvInfo(0).bDV )
+#endif
   {
     nARPWMax = 0;
@@ -1877,4 +1942,11 @@
 
 #endif
+
+#if MTK_DDD_G0063
+    Int iDDDCand = rpcTempCU->getUseDDDCandIdx(); 
+    UChar ucDDDepth = rpcTempCU->getDDTmpDepth();
+    rpcTempCU->setUseDDD( false, 0, uhDepth );
+#endif
+
   for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
   {
@@ -1910,4 +1982,17 @@
           rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
 #endif
+
+#if MTK_DDD_G0063
+          if( rpcTempCU->getSlice()->getIsDepth() && rpcTempCU->getSlice()->getViewIndex() != 0 && iDDDCand == uiMergeCand )
+          {
+              rpcTempCU->setUseDDD( true, 0, 0, uhDepth );
+              rpcTempCU->setDDDepthSubParts( ucDDDepth, 0, 0, uhDepth );
+          }
+          else
+          {
+              rpcTempCU->setUseDDD( false, 0, 0, uhDepth );
+          }
+#endif
+
 #if H_3D_SPIVMP
           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
@@ -1931,12 +2016,41 @@
           }
           else
+#endif
+#if NTT_STORE_SPDV_VSP_G0148
+          if ( vspFlag[uiMergeCand] )
           {
-#endif
+            UInt partAddr;
+            Int vspSize;
+            Int width, height;
+            rpcTempCU->getPartIndexAndSize( 0, partAddr, width, height );
+
+            if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
+            {
+              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
+              rpcTempCU->setVSPFlag( partAddr, vspSize );
+            }
+            else
+            {
+              rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+            }
+            if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
+            {
+              rpcTempCU->setMvFieldPUForVSP( rpcTempCU, partAddr, width, height, REF_PIC_LIST_1 , cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
+              rpcTempCU->setVSPFlag( partAddr, vspSize );
+            }
+            else
+            {
+              rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
+            }
+
+            rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
+          }
+          else
+#endif
+          {
             rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], 0, 0, uhDepth ); // interprets depth relative to LCU level
             rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
             rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-#if H_3D_SPIVMP
           }
-#endif
        // do MC
        m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
@@ -1968,4 +2082,10 @@
 
           rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
+#if NTT_STORE_SPDV_VSP_G0148 // possible bug fix
+          if( rpcTempCU->getSkipFlag(0) )
+          {
+            rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
+          }
+#endif
 #if H_3D_INTER_SDC
           TComDataCU *rpcTempCUPre = rpcTempCU;
@@ -1977,4 +2097,37 @@
           if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual )
           {
+#if SEC_INTER_SDC_G0101
+            for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
+            {
+              if( rpcTempCU != rpcTempCUPre )
+              {
+                rpcTempCU->initEstData( uhDepth, orgQP );
+                rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
+              }
+              rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
+              rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
+              rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
+#if H_3D_VSO //M2
+              if( m_pcRdCost->getUseRenModel() )
+              { //Reset
+                UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth    ();
+                UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight   ();
+                Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr ();
+                UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride   ();
+                m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+              }
+#endif
+              m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
+                m_ppcOrigYuv[uhDepth], 
+                ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth], 
+                m_ppcResiYuvTemp[uhDepth], 
+                m_ppcRecoYuvTemp[uhDepth],
+                uiOffest,
+                uhDepth );
+
+              xCheckDQP( rpcTempCU );
+              xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
+            }
+#else
             if( rpcTempCU != rpcTempCUPre )
             {
@@ -2004,4 +2157,5 @@
             xCheckDQP( rpcTempCU );
             xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
+#endif
           }
 #endif
@@ -2087,5 +2241,9 @@
   Int nARPWMax    = rpcTempCU->getSlice()->getARPStepNum() - 1;
 
+#if SEC_IC_ARP_SIG_G0072
+  if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || !rpcTempCU->getDvInfo(0).bDV || rpcTempCU->getICFlag(0) )
+#else
   if( nARPWMax < 0 || ePartSize != SIZE_2Nx2N || !rpcTempCU->getDvInfo(0).bDV  )
+#endif
   {
     nARPWMax = 0;
@@ -2118,4 +2276,8 @@
   rpcTempCU->setCUTransquantBypassSubParts  ( m_pcEncCfg->getCUTransquantBypassFlagValue(),      0, uhDepth );
   
+#if MTK_DDD_G0063
+  rpcTempCU->setUseDDD( false, 0, uhDepth );
+#endif
+
 #if H_3D_ARP
   rpcTempCU->setARPWSubParts( (UChar)nARPW , 0 , uhDepth );
@@ -2186,5 +2348,11 @@
 
   m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
-
+  
+#if NTT_STORE_SPDV_VSP_G0148 // possible bug fix
+  if( rpcTempCU->getQtRootCbf(0)==0 )
+  {
+    rpcTempCU->setTrIdxSubParts(0, 0, uhDepth);
+  }
+#endif
 
 #if H_3D_VSO // M4
@@ -2200,6 +2368,45 @@
   xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
 #if H_3D_INTER_SDC
+#if SEC_INTER_SDC_G0101 // ONLY_2NX2N_SDC
+  if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && ePartSize == SIZE_2Nx2N)
+#else
   if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() )
-  {
+#endif
+  {
+#if SEC_INTER_SDC_G0101
+    for( Int uiOffest = -2 ; uiOffest <= 2 ; uiOffest++ )
+    {
+      if( rpcTempCU != rpcTempCUPre )
+      {
+        Int orgQP = rpcBestCU->getQP( 0 );
+        rpcTempCU->initEstData( uhDepth, orgQP );
+        rpcTempCU->copyPartFrom( rpcBestCU, 0, uhDepth );
+      }
+      rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth );
+      rpcTempCU->setTrIdxSubParts( 0, 0, uhDepth );
+      rpcTempCU->setCbfSubParts( 1, 1, 1, 0, uhDepth );
+#if H_3D_VSO // M3
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
+        UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
+        Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
+        UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
+        m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+      }
+#endif
+
+      m_pcPredSearch->encodeResAndCalcRdInterSDCCU( rpcTempCU, 
+        m_ppcOrigYuv[uhDepth],
+        ( rpcTempCU != rpcTempCUPre ) ? m_ppcPredYuvBest[uhDepth] : m_ppcPredYuvTemp[uhDepth],
+        m_ppcResiYuvTemp[uhDepth],
+        m_ppcRecoYuvTemp[uhDepth],
+        uiOffest,
+        uhDepth );
+
+      xCheckDQP( rpcTempCU );
+      xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+    }
+#else
     if( rpcTempCU != rpcTempCUPre )
     {
@@ -2231,4 +2438,5 @@
   xCheckDQP( rpcTempCU );
   xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+#endif
   }
 #endif
@@ -2240,4 +2448,193 @@
 #endif
 }
+
+#if H_3D_DBBP
+Void TEncCu::xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment )
+{
+  UInt  uiWidth     = pOrigYuv->getWidth ( );
+  UInt  uiHeight    = pOrigYuv->getHeight( );
+  Pel*  piSrc       = pOrigYuv->getLumaAddr( );
+  UInt  uiSrcStride = pOrigYuv->getStride();
+  Pel*  piDst       = pOrigYuvTemp->getLumaAddr( );
+  UInt  uiDstStride = pOrigYuvTemp->getStride();
+  
+  UInt  uiMaskStride= MAX_CU_SIZE;
+  
+  AOF( uiWidth == uiHeight );
+  
+  // backup pointer
+  Bool* pMaskStart = pMask;
+  
+  for (Int y=0; y<uiHeight; y++)
+  {
+    for (Int x=0; x<uiWidth; x++)
+    {
+      UChar ucSegment = (UChar)pMask[x];
+      AOF( ucSegment < 2 );
+      
+      piDst[x] = (ucSegment==uiValidSegment)?piSrc[x]:DBBP_INVALID_SHORT;
+    }
+    
+    piSrc  += uiSrcStride;
+    piDst  += uiDstStride;
+    pMask  += uiMaskStride;
+  }
+  
+  // now invalidate chroma
+  Pel*  piSrcU       = pOrigYuv->getCbAddr();
+  Pel*  piSrcV       = pOrigYuv->getCrAddr();
+  UInt  uiSrcStrideC = pOrigYuv->getCStride();
+  Pel*  piDstU       = pOrigYuvTemp->getCbAddr( );
+  Pel*  piDstV       = pOrigYuvTemp->getCrAddr( );
+  UInt  uiDstStrideC = pOrigYuvTemp->getCStride();
+  pMask = pMaskStart;
+  
+  for (Int y=0; y<uiHeight/2; y++)
+  {
+    for (Int x=0; x<uiWidth/2; x++)
+    {
+      UChar ucSegment = (UChar)pMask[x*2];
+      AOF( ucSegment < 2 );
+      
+      piDstU[x] = (ucSegment==uiValidSegment)?piSrcU[x]:DBBP_INVALID_SHORT;
+      piDstV[x] = (ucSegment==uiValidSegment)?piSrcV[x]:DBBP_INVALID_SHORT;
+    }
+    
+    piSrcU  += uiSrcStrideC;
+    piSrcV  += uiSrcStrideC;
+    piDstU  += uiDstStrideC;
+    piDstV  += uiDstStrideC;
+    pMask   += 2*uiMaskStride;
+  }
+}
+
+Void TEncCu::xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG )
+{
+  AOF( !rpcTempCU->getSlice()->getIsDepth() );
+  
+  UChar uhDepth = rpcTempCU->getDepth( 0 );
+  
+#if H_3D_VSO
+  if( m_pcRdCost->getUseRenModel() )
+  {
+    UInt  uiWidth     = m_ppcOrigYuv[uhDepth]->getWidth ( );
+    UInt  uiHeight    = m_ppcOrigYuv[uhDepth]->getHeight( );
+    Pel*  piSrc       = m_ppcOrigYuv[uhDepth]->getLumaAddr( );
+    UInt  uiSrcStride = m_ppcOrigYuv[uhDepth]->getStride();
+    m_pcRdCost->setRenModelData( rpcTempCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+  }
+#endif
+  
+  UInt uiWidth  = rpcTempCU->getWidth(0);
+  UInt uiHeight = rpcTempCU->getHeight(0);
+  AOF( uiWidth == uiHeight );
+  
+  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
+  
+  // fetch virtual depth block
+  UInt uiDepthStride = 0;
+  Pel* pDepthPels = rpcTempCU->getVirtualDepthBlock(0, uiWidth, uiHeight, uiDepthStride);
+  AOF( pDepthPels != NULL );
+  AOF( uiDepthStride != 0 );
+  
+  // derive partitioning from depth
+  PartSize eVirtualPartSize = m_pcPredSearch->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, uiWidth);
+  
+  // derive segmentation mask from depth
+  Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE];
+  Bool bValidMask = m_pcPredSearch->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, uiWidth, uiHeight, pMask);
+  
+  if( !bValidMask )
+  {
+    return;
+  }
+  
+  // find optimal motion/disparity vector for each segment
+  DisInfo originalDvInfo = rpcTempCU->getDvInfo(0);
+  DBBPTmpData* pDBBPTmpData = rpcTempCU->getDBBPTmpData();
+  TComYuv* apPredYuv[2] = { m_ppcRecoYuvTemp[uhDepth], m_ppcPredYuvTemp[uhDepth] };
+  
+  // find optimal motion vector fields for both segments (as 2Nx2N)
+  rpcTempCU->setDepthSubParts( uhDepth, 0 );
+  rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N,  0, uhDepth );
+  rpcTempCU->setPredModeSubParts( MODE_INTER, 0, uhDepth );
+  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
+  {
+    rpcTempCU->setDBBPFlagSubParts(true, 0, 0, uhDepth);
+    rpcTempCU->setDvInfoSubParts(originalDvInfo, 0, uhDepth);
+    
+    // invalidate all other segments in original YUV
+    xInvalidateOriginalSegments(m_ppcOrigYuv[uhDepth], m_ppcOrigYuvDBBP[uhDepth], pMask, uiSegment);
+    
+    // do motion estimation for this segment
+    m_pcRdCost->setUseMask(true);
+    rpcTempCU->getDBBPTmpData()->eVirtualPartSize = eVirtualPartSize;
+    rpcTempCU->getDBBPTmpData()->uiVirtualPartIndex = uiSegment;
+    m_pcPredSearch->predInterSearch( rpcTempCU, m_ppcOrigYuvDBBP[uhDepth], apPredYuv[uiSegment], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], false, false, bUseMRG );
+    m_pcRdCost->setUseMask(false);
+    
+    // extract motion parameters of full block for this segment
+    pDBBPTmpData->auhInterDir[uiSegment] = rpcTempCU->getInterDir(0);
+    
+    pDBBPTmpData->abMergeFlag[uiSegment] = rpcTempCU->getMergeFlag(0);
+    pDBBPTmpData->auhMergeIndex[uiSegment] = rpcTempCU->getMergeIndex(0);
+    
+    pDBBPTmpData->ahVSPFlag[uiSegment] = rpcTempCU->getVSPFlag(0);
+    pDBBPTmpData->acDvInfo[uiSegment] = rpcTempCU->getDvInfo(0);
+    
+    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+    {
+      RefPicList eRefList = (RefPicList)uiRefListIdx;
+      
+      pDBBPTmpData->acMvd[uiSegment][eRefList] = rpcTempCU->getCUMvField(eRefList)->getMvd(0);
+      pDBBPTmpData->aiMvpNum[uiSegment][eRefList] = rpcTempCU->getMVPNum(eRefList, 0);
+      pDBBPTmpData->aiMvpIdx[uiSegment][eRefList] = rpcTempCU->getMVPIdx(eRefList, 0);
+      
+      rpcTempCU->getMvField(rpcTempCU, 0, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]);
+    }
+  }
+  
+  // store final motion/disparity information in each PU using derived partitioning
+  rpcTempCU->setDepthSubParts( uhDepth, 0 );
+  rpcTempCU->setPartSizeSubParts  ( eVirtualPartSize,  0, uhDepth );
+  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
+  
+  UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( rpcTempCU->getSlice()->getSPS()->getMaxCUDepth() - uhDepth ) << 1 ) ) >> 4;
+  for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ )
+  {
+    UInt uiPartAddr = uiSegment*uiPUOffset;
+    
+    rpcTempCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uhDepth);
+    
+    // now set stored information from 2Nx2N motion search to each partition
+    rpcTempCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uhDepth); // interprets depth relative to LCU level
+    
+    rpcTempCU->setMergeFlagSubParts(pDBBPTmpData->abMergeFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
+    rpcTempCU->setMergeIndexSubParts(pDBBPTmpData->auhMergeIndex[uiSegment], uiPartAddr, uiSegment, uhDepth);
+    
+    rpcTempCU->setVSPFlagSubParts(pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uhDepth);
+    rpcTempCU->setDvInfoSubParts(pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uhDepth);
+    
+    for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+    {
+      RefPicList eRefList = (RefPicList)uiRefListIdx;
+      
+      rpcTempCU->getCUMvField( eRefList )->setAllMvd(pDBBPTmpData->acMvd[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment);
+      rpcTempCU->setMVPNum(eRefList, uiPartAddr, pDBBPTmpData->aiMvpNum[uiSegment][eRefList]);
+      rpcTempCU->setMVPIdx(eRefList, uiPartAddr, pDBBPTmpData->aiMvpIdx[uiSegment][eRefList]);
+      
+      rpcTempCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], eVirtualPartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level
+    }
+  }
+  
+  // reconstruct final prediction signal by combining both segments
+  m_pcPredSearch->combineSegmentsWithMask(apPredYuv, m_ppcPredYuvTemp[uhDepth], pMask, uiWidth, uiHeight);
+  
+  m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false );
+  
+  xCheckDQP( rpcTempCU );
+  xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+}
+#endif
 
 Void TEncCu::xCheckRDCostIntra( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize eSize )
@@ -2285,4 +2682,7 @@
   m_pcEntropyCoder->encodePredMode( rpcTempCU, 0,          true );
   m_pcEntropyCoder->encodePartSize( rpcTempCU, 0, uiDepth, true );
+#if QC_SDC_UNIFY_G0130
+  m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
+#endif
   m_pcEntropyCoder->encodePredInfo( rpcTempCU, 0,          true );
   m_pcEntropyCoder->encodeIPCMInfo(rpcTempCU, 0, true );
@@ -2374,4 +2774,7 @@
   m_pcEntropyCoder->encodePredMode ( rpcTempCU, 0,          true );
   m_pcEntropyCoder->encodePartSize ( rpcTempCU, 0, uiDepth, true );
+#if QC_SDC_UNIFY_G0130
+  m_pcEntropyCoder->encodeSDCFlag( rpcTempCU, 0, true );
+#endif
   m_pcEntropyCoder->encodeIPCMInfo ( rpcTempCU, 0, true );
 
Index: trunk/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncCu.h	(revision 833)
@@ -82,4 +82,8 @@
   TComYuv**               m_ppcOrigYuv;     ///< Original Yuv for each depth
   
+#if H_3D_DBBP
+  TComYuv**               m_ppcOrigYuvDBBP;
+#endif
+  
   //  Data : encoder control
   Bool                    m_bEncodeDQP;
@@ -168,4 +172,8 @@
   Void  xCheckRDCostInter   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
 #endif
+#if H_3D_DBBP
+  Void  xInvalidateOriginalSegments( TComYuv* pOrigYuv, TComYuv* pOrigYuvTemp, Bool* pMask, UInt uiValidSegment );
+  Void  xCheckRDCostInterDBBP( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, Bool bUseMRG = false );
+#endif
   Void  xCheckRDCostIntra   ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize  );
   Void  xCheckDQP           ( TComDataCU*  pcCU );
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 833)
@@ -160,5 +160,9 @@
 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
+#if SEC_IC_ARP_SIG_G0072
+  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 )
+#else
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
+#endif
   {
     return;
@@ -240,5 +244,31 @@
     uiAbsPartIdx = 0;
   }
+  
+#if H_3D_DBBP
+  PartSize eVirtualPartSize = pcCU->getPartitionSize(uiAbsPartIdx);
+  if( pcCU->getDBBPFlag(uiAbsPartIdx) )
+  {
+    AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
+    
+    // temporarily change partition size for DBBP blocks
+    pcCU->setPartSizeSubParts(RWTH_DBBP_PACK_MODE, uiAbsPartIdx, uiDepth);
+  }
+#endif
+  
   m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth );
+  
+#if H_3D_DBBP
+  if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE )
+  {
+    encodeDBBPFlag(pcCU, uiAbsPartIdx, bRD);
+    
+    if( pcCU->getDBBPFlag(uiAbsPartIdx) )
+    {
+      AOF( pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE );
+      // restore virtual partition size for DBBP blocks
+      pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth);
+    }
+  }
+#endif
 }
 
@@ -649,7 +679,7 @@
   UInt uiLumaOffset   = uiMinCoeffSize*uiAbsPartIdx;
   UInt uiChromaOffset = uiLumaOffset>>2;
-    
+#if QC_SDC_UNIFY_G0130
 #if H_3D_DIM_SDC
-  if( pcCU->getSDCFlag( uiAbsPartIdx ) )
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx ) )
   {
     assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
@@ -658,18 +688,64 @@
     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
     assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
-    return;
   }
 #endif
 
 #if H_3D_INTER_SDC
-  if( pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx ) )
   {
     assert( !pcCU->isSkipped( uiAbsPartIdx ) );
     assert( !pcCU->isIntra( uiAbsPartIdx) );
     assert( pcCU->getSlice()->getIsDepth() );
+  }
+#endif
+#if QC_SDC_UNIFY_G0130_FIX
+  if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) )
+#else
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) )
+#endif
+  {
+    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
+    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
+    
+    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
+    {
+      for( Int iPart = 0; iPart < iPartNum; iPart++ )
+      {
+        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
+        {
+          m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart );
+        }
+      }
+    }
+    else
+    {
+      m_pcEntropyCoderIf->codeDeltaDC( pcCU, uiAbsPartIdx );
+      return;
+    }
+  }
+#else
+#if H_3D_DIM_SDC
+  if( pcCU->getSDCFlag( uiAbsPartIdx ) )
+  {
+    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+    assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
+    assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
+    return;
+  }
+#endif
+
+#if H_3D_INTER_SDC
+  if( pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+  {
+    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
+    assert( !pcCU->isIntra( uiAbsPartIdx) );
+    assert( pcCU->getSlice()->getIsDepth() );
 
     encodeInterSDCResidualData( pcCU, uiAbsPartIdx, false );
     return;
   }
+#endif
 #endif
 
@@ -825,4 +901,41 @@
 
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TEncEntropy::encodeDeltaDC  ( TComDataCU* pcCU, UInt absPartIdx )
+{
+  m_pcEntropyCoderIf->codeDeltaDC( pcCU, absPartIdx );
+}
+
+Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || 
+    ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) )
+  {
+    return;
+  }
+
+#if SEC_INTER_SDC_G0101
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) )
+#else
+  if( !pcCU->getSlice()->getIsDepth() || ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N ) || pcCU->isSkipped( uiAbsPartIdx ) )
+#endif
+  {
+    return;
+  }
+
+#if SEC_INTER_SDC_G0101
+  assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
+#else
+  assert( ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) );
+#endif
+
+  if( bRD )
+  {
+    uiAbsPartIdx = 0;
+  }
+
+  m_pcEntropyCoderIf->codeSDCFlag( pcCU, uiAbsPartIdx );
+}
+#else
 Void TEncEntropy::encodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
@@ -872,4 +985,15 @@
 }
 #endif
+#endif
+#if H_3D_DBBP
+Void TEncEntropy::encodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  if( bRD )
+  {
+    uiAbsPartIdx = 0;
+  }
+  m_pcEntropyCoderIf->codeDBBPFlag( pcCU, uiAbsPartIdx );
+}
+#endif
 
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.h	(revision 833)
@@ -95,6 +95,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  virtual Void codeDeltaDC       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+  virtual Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+#else
   virtual Void codeInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   virtual Void codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) = 0;
+#endif
+#endif
+#if H_3D_DBBP
+  virtual Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
 #endif
   virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
@@ -186,6 +194,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void encodeDeltaDC      ( TComDataCU* pcCU, UInt absPartIdx );
+  Void encodeSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
+#else
   Void encodeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
   Void encodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD );
+#endif
+#endif
+#if H_3D_DBBP
+  Void encodeDBBPFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
 #endif
   Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 833)
@@ -93,4 +93,10 @@
 , m_cDdcFlagSCModel           ( 1,             1,               NUM_DDC_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
+#if QC_GENERIC_SDC_G0122
+, m_cAngleFlagSCModel         ( 1,             1,               NUM_ANGLE_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
+#if !QC_SDC_UNIFY_G0130
+, m_cIntraSdcFlagSCModel      ( 1,             1,               NUM_INTRASDC_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#endif
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
@@ -101,8 +107,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
 , m_cInterSDCFlagSCModel             ( 1,             1,  NUM_INTER_SDC_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cInterSDCResidualSCModel         ( 1,             1,  NUM_INTER_SDC_RESIDUAL_CTX       , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cInterSDCResidualSignFlagSCModel ( 1,             1,  NUM_INTER_SDC_SIGN_FLAG_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if QC_SDC_UNIFY_G0130
+, m_cSDCFlagSCModel                  ( 1,             1,  NUM_SDC_FLAG_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if H_3D_DBBP
+, m_cDBBPFlagSCModel             ( 1,             1,                 DBBP_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 {
@@ -168,4 +180,10 @@
   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
+#if QC_GENERIC_SDC_G0122
+  m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
+#if !QC_SDC_UNIFY_G0130
+  m_cIntraSdcFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_INTRASDC_FLAG );
+#endif
+#endif
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
@@ -176,8 +194,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_cInterSDCFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL );
   m_cInterSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_SIGN_FLAG );
+#endif
+#if QC_SDC_UNIFY_G0130
+  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+#endif
+#if H_3D_DBBP
+  m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
   // new structure
@@ -218,8 +242,14 @@
       curCost += m_cCUICFlagSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_IC_FLAG );
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
       curCost += m_cInterSDCFlagSCModel.calcCost      ( curSliceType, qp, (UChar*)INIT_INTER_SDC_FLAG );
       curCost += m_cInterSDCResidualSCModel.calcCost  ( curSliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL );
       curCost += m_cInterSDCResidualSignFlagSCModel.calcCost( curSliceType, qp, (UChar*)INIT_INTER_SDC_SIGN_FLAG );
+#endif
+#if QC_SDC_UNIFY_G0130
+      curCost += m_cSDCFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_SDC_FLAG );
+#endif
+#if H_3D_DBBP
+      curCost += m_cDBBPFlagSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DBBP_FLAG );
 #endif
       curCost += m_cCUPartSizeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
@@ -252,4 +282,10 @@
       curCost += m_cDdcFlagSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_FLAG );
       curCost += m_cDdcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_DDC_DATA );
+#if QC_GENERIC_SDC_G0122
+      curCost += m_cAngleFlagSCModel.calcCost         ( curSliceType, qp, (UChar*)INIT_ANGLE_FLAG );  
+#if !QC_SDC_UNIFY_G0130
+      curCost += m_cIntraSdcFlagSCModel.calcCost      ( curSliceType, qp, (UChar*)INIT_INTRASDC_FLAG );  
+#endif
+#endif
 #if H_3D_DIM_DMM
       curCost += m_cDmm1DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM1_DATA );
@@ -317,4 +353,10 @@
   m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
   m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
+#if QC_GENERIC_SDC_G0122
+  m_cAngleFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_ANGLE_FLAG );
+#if !QC_SDC_UNIFY_G0130
+  m_cIntraSdcFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_INTRASDC_FLAG );
+#endif
+#endif
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
@@ -325,8 +367,14 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   m_cInterSDCFlagSCModel.initBuffer         ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG );
   m_cInterSDCResidualSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL );
   m_cInterSDCResidualSignFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_SIGN_FLAG );
+#endif
+#if QC_SDC_UNIFY_G0130
+  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+#endif
+#if H_3D_DBBP
+  m_cDBBPFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DBBP_FLAG );
 #endif
   m_pcBinIf->start();
@@ -629,4 +677,10 @@
   this->m_cDepthIntraModeSCModel .copyFrom( &pSrc->m_cDepthIntraModeSCModel );
   this->m_cDdcFlagSCModel        .copyFrom( &pSrc->m_cDdcFlagSCModel );
+#if QC_GENERIC_SDC_G0122
+  this->m_cAngleFlagSCModel      .copyFrom( &pSrc->m_cAngleFlagSCModel );
+#if !QC_SDC_UNIFY_G0130
+  this->m_cIntraSdcFlagSCModel   .copyFrom( &pSrc->m_cIntraSdcFlagSCModel );
+#endif
+#endif
 }
 #endif
@@ -679,4 +733,8 @@
   Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
 
+#if MTK_TEX_DEP_PAR_G0055
+  Bool depthDependent = false;
+  UInt uiTexturePart = eSize;
+#endif
   if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && pcCU->getPic()->getReduceBitsFlag() && sps->getUseQTL() && sps->getUsePC() )
   {
@@ -684,5 +742,14 @@
     UInt uiCUIdx            = (pcCU->getZorderIdxInCU() == 0) ? uiAbsPartIdx : pcCU->getZorderIdxInCU();
     assert(pcTextureCU->getDepth(uiCUIdx) >= uiDepth);
+#if !MTK_TEX_DEP_PAR_G0055
     if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) != SIZE_NxN)
+#else
+    if(pcTextureCU->getDepth(uiCUIdx) == uiDepth )
+    {
+      depthDependent = true;
+      uiTexturePart = pcTextureCU->getPartitionSize( uiCUIdx );
+    }
+    if (pcTextureCU->getDepth(uiCUIdx) == uiDepth && pcTextureCU->getPartitionSize( uiCUIdx ) == SIZE_2Nx2N)
+#endif
     {
       assert( eSize == SIZE_2Nx2N );
@@ -706,4 +773,8 @@
   DTRACE_CU("part_mode", eSize )
 #endif        
+#if MTK_TEX_DEP_PAR_G0055
+    if (depthDependent==false || uiTexturePart == SIZE_NxN|| uiTexturePart == SIZE_2Nx2N)
+    {
+#endif
   switch(eSize)
   {
@@ -772,4 +843,82 @@
     }
   }
+#if MTK_TEX_DEP_PAR_G0055
+    }
+    else if(uiTexturePart == SIZE_2NxN || uiTexturePart == SIZE_2NxnU || uiTexturePart == SIZE_2NxnD)
+    {
+      //assert(eSize!=SIZE_NxN);
+      //assert(eSize!=SIZE_Nx2N);
+      //assert(eSize==SIZE_2Nx2N || eSize==SIZE_2NxN || eSize==SIZE_2NxnU || eSize==SIZE_2NxnD);
+      switch(eSize)
+      {
+      case SIZE_2Nx2N:
+        {
+          m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          break;
+        }
+      case SIZE_2NxN:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+          {     
+            m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          }
+          break;
+        }
+      case SIZE_2NxnU:
+      case SIZE_2NxnD:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          m_pcBinIf->encodeBinEP((eSize == SIZE_2NxnU? 0: 1));
+          break;
+        }
+      default:
+        {
+          assert(0);
+        }
+      }
+    }
+    else if(uiTexturePart == SIZE_Nx2N|| uiTexturePart==SIZE_nLx2N || uiTexturePart==SIZE_nRx2N)
+    {
+      //assert(eSize!=SIZE_NxN);
+      //assert(eSize!=SIZE_2NxN);
+      //assert(eSize==SIZE_2Nx2N ||eSize==SIZE_Nx2N || eSize==SIZE_nLx2N || eSize==SIZE_nRx2N);
+      switch(eSize)
+      {
+      case SIZE_2Nx2N:
+        {
+          m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          break;
+        }
+      case SIZE_Nx2N:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          if ( pcCU->getSlice()->getSPS()->getAMPAcc( uiDepth ) )
+          {     
+            m_pcBinIf->encodeBin( 1, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          }
+          break;
+        }
+      case SIZE_nLx2N:
+      case SIZE_nRx2N:
+        {
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+          m_pcBinIf->encodeBin( 0, m_cCUPartSizeSCModel.get( 0, 0, 1) );
+          m_pcBinIf->encodeBinEP((eSize == SIZE_nLx2N? 0: 1));
+          break;
+        }
+      default:
+        {
+          assert(0);
+        }
+      }
+    }
+    else
+    {
+      printf("uiTexturePart=%d",uiTexturePart);
+      assert(0);
+    }
+#endif
 }
 
@@ -906,5 +1055,9 @@
   if( nBinNum > 1 )
   {
+#if MTK_ARP_FLAG_CABAC_SIMP_G0061
+     m_pcBinIf->encodeBin( ( iW == iMaxW ) ? 1 : 0, m_cCUPUARPWSCModel.get( 0, 0, 2 ) );
+#else
      m_pcBinIf->encodeBin( ( iW == iMaxW ) ? 1 : 0, m_cCUPUARPWSCModel.get( 0, 0, 3 ) );
+#endif
   }
 #if H_MV_ENC_DEC_TRAC
@@ -924,6 +1077,10 @@
   // get context function is here
   UInt uiSymbol = pcCU->getICFlag( uiAbsPartIdx ) ? 1 : 0;
+#if MTK_IC_FLAG_CABAC_SIMP_G0061
+  m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, 0 ) );
+#else
   UInt uiCtxIC  = pcCU->getCtxICFlag( uiAbsPartIdx ) ;
   m_pcBinIf->encodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) );
+#endif
 #if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ );
@@ -1016,5 +1173,9 @@
     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
 #if H_3D_DIM_SDC
+#if QC_GENERIC_SDC_G0122
+      if( 1 )
+#else
       if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
 #endif
     {
@@ -1042,5 +1203,9 @@
     if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
 #if H_3D_DIM_SDC
+#if QC_GENERIC_SDC_G0122
+      if( 1 )
+#else
       if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
 #endif
     {
@@ -1141,10 +1306,14 @@
   default: break;
   }
-
+#if !QC_SDC_UNIFY_G0130
   if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
   {
     UInt dimDeltaDC;
     Pel  deltaDC;
+#if QC_GENERIC_SDC_G0122
+    UInt uiNumSegments = isDimMode( dir ) ? 2 : 1;
+#else
     UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
+#endif
     if( pcCU->getSDCFlag( absPartIdx ) )
     {
@@ -1174,6 +1343,37 @@
     }
   }
-}
-
+#endif
+}
+
+#if QC_GENERIC_SDC_G0122
+Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
+{
+  UInt dir = pcCU->getLumaIntraDir( absPartIdx );
+
+  if( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() >> pcCU->getDepth( absPartIdx ) ) < 64 ) //DMM and HEVC intra modes are both allowed
+  {
+    m_pcBinIf->encodeBin( isDimMode( dir ) ? 0 : 1, m_cAngleFlagSCModel.get( 0, 0, pcCU->getCtxAngleFlag( absPartIdx ) ) );
+  }
+#if !QC_SDC_UNIFY_G0130
+  if( pcCU->getPartitionSize( absPartIdx ) == SIZE_2Nx2N ) //SDC is allowed only in this case
+  {
+    m_pcBinIf->encodeBin( pcCU->getSDCFlag( absPartIdx ) ? 1 : 0, m_cIntraSdcFlagSCModel.get( 0, 0, pcCU->getCtxSDCFlag( absPartIdx ) ) );
+}
+#endif
+  if( isDimMode( dir ) )
+  {
+    UInt uiCodeIdx = 0;
+
+    switch( getDimType( dir ) )
+    {
+    case DMM1_IDX: uiCodeIdx = 0; break;
+    case DMM4_IDX: uiCodeIdx = 1; break;
+    default:                      break;
+    }
+    //mode coding
+    m_pcBinIf->encodeBin( uiCodeIdx == 0 ? 0 : 1, m_cDepthIntraModeSCModel.get( 0, 0, 0 ) );
+  }
+}
+#else
 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
 {
@@ -1216,4 +1416,5 @@
   }
 }
+#endif
 #endif
 
@@ -2137,4 +2338,78 @@
 
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+Void TEncSbac::codeDeltaDC( TComDataCU* pcCU, UInt absPartIdx )
+{
+  if( !( pcCU->getSDCFlag( absPartIdx ) || ( pcCU->isIntra( absPartIdx ) && getDimType( pcCU->getLumaIntraDir( absPartIdx ) ) < DIM_NUM_TYPE ) ) )
+  {
+    assert( 0 );
+  }
+
+  UInt uiNumSegments = 0;
+  UInt dimDeltaDC = 0;
+
+  if( pcCU->isIntra( absPartIdx ) )
+  {
+    UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
+    uiNumSegments = isDimMode( dir ) ? 2 : 1;
+
+    if( pcCU->getSDCFlag( absPartIdx ) )
+    {
+      if( uiNumSegments == 1 )
+      {
+        dimDeltaDC = pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) ? 1 : 0;
+      }
+      else
+      {
+        dimDeltaDC = ( pcCU->getSDCSegmentDCOffset( 0, absPartIdx ) || pcCU->getSDCSegmentDCOffset( 1, absPartIdx ) ) ? 1 : 0;
+      }
+    }
+    else
+    {
+      dimDeltaDC = isDimDeltaDC( dir );
+    }
+
+    m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get( 0, 0, uiNumSegments-1 ) );
+  }
+  else //all-zero inter SDC is not allowed
+  {
+#if SEC_INTER_SDC_G0101
+    uiNumSegments = 1;
+#else
+    PartSize cPartSize = pcCU->getPartitionSize( absPartIdx );
+    uiNumSegments = ( cPartSize == SIZE_2Nx2N ) ? 1 : ( cPartSize == SIZE_NxN ? 4 : 2 );
+#endif
+    dimDeltaDC = 1;
+  }
+
+  if( dimDeltaDC )
+  {
+    for( UInt segment = 0; segment < uiNumSegments; segment++ )
+    {
+      Pel deltaDC = 0;
+
+      if( pcCU->isIntra( absPartIdx ) )
+      {
+        UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
+        deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset( segment, absPartIdx ) : pcCU->getDimDeltaDC( getDimType( dir ), segment, absPartIdx );
+      }
+      else
+      {
+        deltaDC = pcCU->getSDCSegmentDCOffset( segment, absPartIdx );
+      }
+
+      xCodeDimDeltaDC( deltaDC, uiNumSegments );
+    }
+  }
+}
+
+Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0;
+  UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
+
+  m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
+}
+#else
 Void TEncSbac::codeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
@@ -2158,3 +2433,18 @@
 }
 #endif
+#endif
+
+#if H_3D_DBBP
+Void TEncSbac::codeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx );
+  AOF( ePartSize == RWTH_DBBP_PACK_MODE );
+  AOF( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) );
+  AOF( !pcCU->getSlice()->getIsDepth() );
+  
+  UInt uiSymbol = pcCU->getDBBPFlag( uiAbsPartIdx ) ? 1 : 0;
+  m_pcBinIf->encodeBin( uiSymbol, m_cDBBPFlagSCModel.get( 0, 0, 0 ) );
+}
+#endif
+
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 833)
@@ -154,6 +154,14 @@
 #endif
 #if H_3D_INTER_SDC
+#if QC_SDC_UNIFY_G0130
+  Void codeDeltaDC       ( TComDataCU* pcCU, UInt absPartIdx );
+  Void codeSDCFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+#else
   Void codeInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
   Void codeInterSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+#endif
+#endif
+#if H_3D_DBBP
+  Void codeDBBPFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
   Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
@@ -247,4 +255,10 @@
   ContextModel3DBuffer m_cDdcFlagSCModel;
   ContextModel3DBuffer m_cDdcDataSCModel;
+#if QC_GENERIC_SDC_G0122
+  ContextModel3DBuffer m_cAngleFlagSCModel;
+#if !QC_SDC_UNIFY_G0130
+  ContextModel3DBuffer m_cIntraSdcFlagSCModel;
+#endif
+#endif
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
@@ -255,9 +269,15 @@
 #endif
 #endif
-#if H_3D_INTER_SDC
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
   ContextModel3DBuffer m_cInterSDCFlagSCModel;
   ContextModel3DBuffer m_cInterSDCResidualSCModel;
   ContextModel3DBuffer m_cInterSDCResidualSignFlagSCModel;
 #endif
+#if QC_SDC_UNIFY_G0130
+  ContextModel3DBuffer m_cSDCFlagSCModel;
+#endif
+#if H_3D_DBBP
+  ContextModel3DBuffer m_cDBBPFlagSCModel;
+#endif
 };
 
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 833)
@@ -922,4 +922,7 @@
       m_pcEntropyCoder  ->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
 
+#if QC_SDC_UNIFY_G0130
+      m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
+#endif
       if (pcCU->isIntra(0) && pcCU->getPartitionSize(0) == SIZE_2Nx2N )
       {
@@ -938,4 +941,10 @@
       {
         m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, 0 );
+#if QC_SDC_UNIFY_G0130_FIX
+        if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( 0 ) ) && getDimType( pcCU->getLumaIntraDir( 0 ) ) < DIM_NUM_TYPE ) 
+        {
+          m_pcEntropyCoder->encodeDeltaDC( pcCU, 0 );
+        }
+#endif
       }
     }
@@ -949,4 +958,10 @@
         {
           m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiPart * uiQNumParts );
+#if QC_SDC_UNIFY_G0130_FIX
+          if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiPart * uiQNumParts ) ) && getDimType( pcCU->getLumaIntraDir( uiPart * uiQNumParts ) ) < DIM_NUM_TYPE ) 
+          {
+            m_pcEntropyCoder->encodeDeltaDC( pcCU, uiPart * uiQNumParts );
+          }
+#endif
         }
       }
@@ -954,6 +969,27 @@
       {
         m_pcEntropyCoder->encodeIntraDirModeLuma ( pcCU, uiAbsPartIdx );
-      }
-    }
+#if QC_SDC_UNIFY_G0130_FIX
+        if( pcCU->getSlice()->getIsDepth() && ( !pcCU->getSDCFlag( uiAbsPartIdx ) ) && getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx ) ) < DIM_NUM_TYPE ) 
+        {
+          m_pcEntropyCoder->encodeDeltaDC( pcCU, uiAbsPartIdx );
+      }
+#endif
+    }
+  }
+#if QC_SDC_UNIFY_G0130 && !QC_SDC_UNIFY_G0130_FIX
+    Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1;
+    UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2;
+
+    if( !pcCU->getSDCFlag( uiAbsPartIdx ) )
+    {
+      for( Int iPart = 0; iPart < iPartNum; iPart++ )
+      {
+        if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) 
+        {
+          m_pcEntropyCoder->encodeDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart );
+        }
+      }
+    }
+#endif
   }
   if( bChroma )
@@ -1862,9 +1898,68 @@
 
 #if H_3D_DIM_SDC
-Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual )
+Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, 
+#if QC_GENERIC_SDC_G0122
+  Bool bZeroResidual, Int iSDCDeltaResi
+#else
+  Bool bResidual
+#endif
+  )
 {
   UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir( uiAbsPartIdx );
   UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
   UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
+#if QC_PKU_SDC_SPLIT_G0123
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#else
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#endif
+#endif
+#if QC_PKU_SDC_SPLIT_G0123
+  UInt numParts = 1;
+  UInt i = 0;
+  UInt sdcDepth = 0;
+  UInt uiStride;         
+  Pel* piOrg;          
+  Pel* piPred;          
+  Pel* piReco;        
+
+  UInt uiZOrder;         
+  Pel* piRecIPred;       
+  UInt uiRecIPredStride; 
+
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+  if ( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 )
+  {
+    numParts = uiWidth * uiWidth >> ( 2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() );
+    sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize();
+    uiWidth = uiHeight = ( 1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() );
+  }
+#else
+  if (uiWidth == 64)
+  {
+    numParts = 4;
+    sdcDepth = 1;
+    uiWidth = uiHeight = 32;
+  }
+#endif
+
+  for ( i = 0; i < numParts; i++ )
+  {
+    uiStride          = pcOrgYuv ->getStride  ();
+    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
+    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+    piReco            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+
+    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+
+    AOF( uiWidth == uiHeight );
+#else
   UInt    uiStride          = pcOrgYuv ->getStride  ();
   Pel*    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
@@ -1880,18 +1975,60 @@
   AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
   AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
+#endif
+#if !QC_GENERIC_SDC_G0122
   AOF( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || ( getDimType( uiLumaPredMode ) == DMM1_IDX && !isDimDeltaDC( uiLumaPredMode ) ) );
   AOF( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX || uiWidth < 64  );
+#endif
   
   //===== init availability pattern =====
   Bool  bAboveAvail = false;
   Bool  bLeftAvail  = false;
+#if QC_PKU_SDC_SPLIT_G0123
+  pcCU->getPattern()->initPattern   ( pcCU, sdcDepth, uiAbsPartIdx );
+  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
+#else
   pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
   pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
   
+#endif
+#if !QC_PKU_SDC_SPLIT_G0123
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#endif
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+#if QC_GENERIC_SDC_G0122
+  TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight );
+#endif
+#endif
   //===== get prediction signal =====
 #if H_3D_DIM
   if( isDimMode( uiLumaPredMode ) )
   {
-    predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true );
+#if HS_TSINGHUA_SDC_SPLIT_G0111  
+    UInt dimType   = getDimType  ( uiLumaPredMode );
+    UInt patternID = pcCU->getDmmWedgeTabIdx(dimType, uiAbsPartIdx);
+    if ( patternID >= g_dmmWedgeLists[g_aucConvertToBit[uiWidth]].size() && dimType == DMM1_IDX )
+    {
+      if (g_aucConvertToBit[uiWidth] == 2)  // Encoder method. Avoid DMM1 pattern list index exceeds the maximum DMM1 pattern number when SDC split is used.
+        patternID = 1349;  // Split 32x32 to 16x16. 1349: Maximum DMM1 pattern number when block size is 16x16
+      else 
+        patternID = patternID >> 1;  // Other cases
+      pcCU->setDmmWedgeTabIdx(dimType, uiAbsPartIdx, patternID);
+    }
+#endif
+    predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, true 
+#if QC_GENERIC_SDC_G0122
+      , dmm4Segmentation
+#endif
+      );
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    Bool* dmm4PatternSplit = dmm4Segmentation->getPattern();
+    Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern();
+    for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) 
+    { 
+      dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k];
+    }
+#endif
   }
   else
@@ -1902,5 +2039,39 @@
   }
 #endif
-  
+#if QC_PKU_SDC_SPLIT_G0123
+    if ( numParts > 1 )
+    {
+      for( UInt uiY = 0; uiY < uiHeight; uiY++ )
+      {
+        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
+        {
+          piPred        [ uiX ] = ClipY( piPred[ uiX ] );
+          piRecIPred    [ uiX ] = piPred[ uiX ];
+        }
+        piPred     += uiStride;
+        piRecIPred += uiRecIPredStride;
+      }
+    }
+    uiAbsPartIdx += ( ( uiWidth * uiWidth ) >> 4 );
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    dmm4Segmentation->destroy(); delete dmm4Segmentation;
+#endif
+  }
+  uiAbsPartIdx = 0;
+  uiStride          = pcOrgYuv ->getStride  ();
+  piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
+  piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  piReco            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  
+  uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+  piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+  uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+
+  if (numParts > 1)
+  {
+    uiWidth = pcCU->getWidth( 0 );
+    uiHeight = pcCU->getHeight( 0 );
+  }
+#endif
   // number of segments depends on prediction mode
   UInt uiNumSegments = 1;
@@ -1919,4 +2090,17 @@
     uiMaskStride = pcWedgelet->getStride();
   }
+#if QC_GENERIC_SDC_G0122
+  if( getDimType( uiLumaPredMode ) == DMM4_IDX )
+  {
+    uiNumSegments = 2;
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+    pbMask  = dmm4SegmentationOrg->getPattern();
+    uiMaskStride = dmm4SegmentationOrg->getStride();
+#else
+    pbMask  = dmm4Segmentation->getPattern();
+    uiMaskStride = dmm4Segmentation->getStride();
+#endif
+  }
+#endif
   
   // get DC prediction for each segment
@@ -1931,6 +2115,9 @@
   {
     // remap reconstructed value to valid depth values
+#if QC_GENERIC_SDC_G0122
+    Pel pDCRec = ( !bZeroResidual ) ? apDCOrigValues[uiSegment] : apDCPredValues[uiSegment];
+#else
     Pel pDCRec = bResidual?apDCOrigValues[uiSegment]:apDCPredValues[uiSegment];
-    
+#endif
     // get residual (idx)
 #if H_3D_DIM_DLT
@@ -1939,5 +2126,15 @@
     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
 #endif
-    
+#if QC_GENERIC_SDC_G0122
+    if( !bZeroResidual )
+    {
+      Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
+      Int   pTestIdx    = pPredIdx + pResidualIdx + iSDCDeltaResi;
+      if( pTestIdx >= 0 && pTestIdx < pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) )
+      {
+        pResidualIdx += iSDCDeltaResi;
+      }
+    }
+#endif
     // save SDC DC offset
     pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx);
@@ -2012,8 +2209,31 @@
   
   // encode reduced intra header
+#if QC_SDC_UNIFY_G0130
+  if( !pcCU->getSlice()->isIntra() )
+  {
+    if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
+    {
+      m_pcEntropyCoder->encodeCUTransquantBypassFlag( pcCU, 0, true );
+    }
+    m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
+    m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
+  }
+
+#if QC_SDC_UNIFY_G0130_FIX2
+  m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth( 0 ), true );
+#else
+  m_pcEntropyCoder->encodePartSize( pcCU, 0, true );
+#endif
+  m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
+#else
   m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
+#endif
   
   // encode pred direction + DC residual data
   m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
+#if QC_SDC_UNIFY_G0130
+  Bool bDummy = false;
+  m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth( 0 ), uiWidth, uiHeight, bDummy );
+#endif
   UInt uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
   
@@ -2024,4 +2244,11 @@
 #endif
     dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
+#if QC_GENERIC_SDC_G0122
+#if HS_TSINGHUA_SDC_SPLIT_G0111
+  dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg;
+#else
+  dmm4Segmentation->destroy(); delete dmm4Segmentation;
+#endif
+#endif
 }
 #endif
@@ -2901,5 +3128,7 @@
           case( DMM4_IDX ):
             {
+#if !QC_GENERIC_SDC_G0122
               if( uiWidth > 4 )
+#endif
               {
                 biSegmentation = new TComWedgelet( uiWidth, uiHeight );
@@ -2957,4 +3186,12 @@
       {
         pcCU->setSDCFlagSubParts( (uiSDC != 0), uiPartOffset, uiDepth + uiInitTrDepth );
+#if QC_GENERIC_SDC_G0122
+        for( Int iSDCDeltaResi = -2; iSDCDeltaResi <= 2; iSDCDeltaResi++ )
+        {
+          if( ( uiSDC == 0 ) && iSDCDeltaResi != 0 )
+          {
+            continue;
+          }
+#endif
 #endif
       
@@ -2966,4 +3203,10 @@
 #if H_3D_DIM_SDC
       bTestZeroResi |= pcCU->getSDCFlag(uiPartOffset);
+#endif
+#if QC_GENERIC_SDC_G0122
+      if( uiSDC != 0 && iSDCDeltaResi != 0 )
+      {
+        bTestZeroResi = false;
+      }
 #endif
 #endif
@@ -3000,5 +3243,9 @@
               
               // start encoding with SDC
+#if QC_GENERIC_SDC_G0122
+              xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, ( testZeroResi != 0 ), iSDCDeltaResi );
+#else
               xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, (testZeroResi!=0));
+#endif
             }
             else
@@ -3073,4 +3320,7 @@
 #if H_3D_DIM_ENC || H_3D_DIM_SDC
       }
+#endif
+#if QC_GENERIC_SDC_G0122
+        } // SDC residual loop
 #endif
 #if H_3D_DIM_SDC
@@ -3583,6 +3833,45 @@
   pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
   UInt uiDepth = pcCU->getDepth( uiAbsPartIdx );
+  
+#if H_3D_DBBP
+  DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+  if( pcCU->getDBBPFlag(0) )
+  {
+    AOF( uiAbsPartIdx == 0 );
+    AOF( iPUIdx == 0 );
+    AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
+    AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
+    
+    // temporary change of partition size for candidate derivation
+    pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
+    iPUIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
+    
+    // if this is handling the second segment, make sure that motion info of first segment is available
+    if( iPUIdx == 1 )
+    {
+      pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
+      
+      pcCU->setVSPFlagSubParts(pDBBPTmpData->ahVSPFlag[0], 0, 0, pcCU->getDepth(0));
+      pcCU->setDvInfoSubParts(pDBBPTmpData->acDvInfo[0], 0, 0, pcCU->getDepth(0));
+      
+      for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+      {
+        RefPicList eRefList = (RefPicList)uiRefListIdx;
+        
+        pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+      }
+    }
+    
+    // update these values to virtual partition size
+    pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
+  }
+#endif
+  
   PartSize partSize = pcCU->getPartitionSize( 0 );
+#if H_3D_DBBP
+  if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(0) == false )
+#else
   if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && partSize != SIZE_2Nx2N && pcCU->getWidth( 0 ) <= 8 )
+#endif
   {
     pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );
@@ -3634,4 +3923,19 @@
 #endif
 
+#if H_3D_DBBP
+  if( pcCU->getDBBPFlag(0) )
+  {
+    // reset to 2Nx2N for actual motion search
+    iPUIdx = 0;
+    AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
+    pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
+    
+    // restore values for 2Nx2N partition size
+    pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight );
+    
+    AOF( uiAbsPartIdx == 0 );
+    AOF( iWidth == iHeight );
+  }
+#endif
 
   ruiCost = MAX_UINT;
@@ -3643,4 +3947,9 @@
       
       PartSize ePartSize = pcCU->getPartitionSize( 0 );
+      
+#if H_3D_VSP && NTT_STORE_SPDV_VSP_G0148
+      pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+#endif
 
 #if H_3D_SPIVMP
@@ -3662,15 +3971,58 @@
       }
       else
-      {
-#endif
+#endif
+#if NTT_STORE_SPDV_VSP_G0148
+#if H_3D_DBBP
+      if ( vspFlag[uiMergeCand] && !pcCU->getDBBPFlag(0) )
+#else
+      if ( vspFlag[uiMergeCand] )
+#endif
+      {
+        UInt partAddr;
+        Int vspSize;
+        Int width, height;
+        pcCU->getPartIndexAndSize( iPUIdx, partAddr, width, height );
+
+        if( uhInterDirNeighbours[ uiMergeCand ] & 0x01 )
+        {
+          pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_0, cMvFieldNeighbours[ 2*uiMergeCand + 0 ].getRefIdx(), vspSize );
+          pcCU->setVSPFlag( partAddr, vspSize );
+        }
+        else
+        {
+          pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+        }
+        if( uhInterDirNeighbours[ uiMergeCand ] & 0x02 )
+        {
+          pcCU->setMvFieldPUForVSP( pcCU, partAddr, width, height, REF_PIC_LIST_1, cMvFieldNeighbours[ 2*uiMergeCand + 1 ].getRefIdx(), vspSize );
+          pcCU->setVSPFlag( partAddr, vspSize );
+        }
+        else
+        {
+          pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
+        }
+      }
+      else
+#endif
+      {
         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
-#if H_3D_SPIVMP
-      }
-#endif
-
-#if H_3D_VSP
+      }
+
+#if H_3D_VSP && !NTT_STORE_SPDV_VSP_G0148
       pcCU->setVSPFlagSubParts( vspFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
       pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+#endif
+
+#if MTK_DDD_G0063
+      if( uiMergeCand == pcCU->getUseDDDCandIdx() )
+      {
+          pcCU->setUseDDD( true, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+          pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      }
+      else
+      {
+          pcCU->setUseDDD( false, uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx ) );
+      }
 #endif
 
@@ -4302,5 +4654,10 @@
 #endif
 
+#if H_3D_DBBP
+    // test merge mode for DBBP (2Nx2N)
+    if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N || pcCU->getDBBPFlag(0) )
+#else
     if ( pcCU->getPartitionSize( uiPartAddr ) != SIZE_2Nx2N )
+#endif
     {
       UInt uiMRGInterDir = 0;     
@@ -4372,4 +4729,19 @@
         pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMRGIndex].m_acDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
+
+#if MTK_DDD_G0063
+        if( uiMRGIndex == pcCU->getUseDDDCandIdx() )
+        {
+            assert( vspFlag[uiMRGIndex]     == 0 );
+            assert( bSPIVMPFlag[uiMRGIndex] == 0 );
+            pcCU->setUseDDD( true, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+            pcCU->setDDDepthSubParts( pcCU->getDDTmpDepth(), uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+        else
+        {
+            pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+#endif
+
 #if H_3D_SPIVMP
         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );  
@@ -4399,6 +4771,40 @@
         }
         else
-        {
-#endif
+#endif
+#if NTT_STORE_SPDV_VSP_G0148
+#if H_3D_DBBP
+        if ( vspFlag[uiMRGIndex] && !pcCU->getDBBPFlag(uiPartAddr) )
+#else
+        if ( vspFlag[uiMRGIndex] )
+#endif
+        {
+          UInt partAddrTemp;
+          Int vspSize;
+          Int width, height;
+          pcCU->getPartIndexAndSize( iPartIdx, partAddrTemp, width, height ); // true or pcCU->getTotalNumPart()==256
+
+          if( uiMRGInterDir & 0x01 )
+          {
+            pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_0, cMRGMvField[0].getRefIdx(), vspSize );
+            pcCU->setVSPFlag( partAddrTemp, vspSize );
+          }
+          else
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMRGMvField[0], ePartSize, uiPartAddr, 0, iPartIdx );
+          }
+          if( uiMRGInterDir & 0x02 )
+          {
+            pcCU->setMvFieldPUForVSP( pcCU, partAddrTemp, width, height, REF_PIC_LIST_1, cMRGMvField[1].getRefIdx(), vspSize );
+            pcCU->setVSPFlag( partAddrTemp, vspSize );
+          }
+          else
+          {
+            pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
+          }
+          pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
+        }
+        else
+#endif
+        {
           pcCU->setInterDirSubParts  ( uiMRGInterDir, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
           {
@@ -4406,7 +4812,5 @@
             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
           }
-#if H_3D_SPIVMP
-        }
-#endif
+        }
 
         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( cMvZero,            ePartSize, uiPartAddr, 0, iPartIdx );
@@ -4422,4 +4826,8 @@
 #if H_3D_SPIVMP        
         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
+#endif
+
+#if MTK_DDD_G0063
+        pcCU->setUseDDD( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
         // set ME result
@@ -4473,5 +4881,50 @@
   if (!bFilled)
   {
+#if H_3D_DBBP
+    DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData();
+    if( pcCU->getDBBPFlag(0) )
+    {
+      AOF( uiPartAddr == 0 );
+      AOF( uiPartIdx == 0 );
+      AOF( pcCU->getPartitionSize(0) == SIZE_2Nx2N );
+      AOF( pDBBPTmpData->eVirtualPartSize != SIZE_NONE );
+      AOF( iRoiWidth == iRoiHeight );
+      
+      // temporary change of partition size for candidate derivation
+      pcCU->setPartSizeSubParts( pDBBPTmpData->eVirtualPartSize, 0, pcCU->getDepth(0));
+      uiPartIdx = pcCU->getDBBPTmpData()->uiVirtualPartIndex;
+      
+      // if this is handling the second segment, make sure that motion info of first segment is set to first segment
+      if( uiPartIdx == 1 )
+      {
+        pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[0], 0, 0, pcCU->getDepth(0)); // interprets depth relative to LCU level
+        
+        for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ )
+        {
+          RefPicList eRefList = (RefPicList)uiRefListIdx;
+          pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[0][eRefList], pDBBPTmpData->eVirtualPartSize, 0, 0, 0 ); // interprets depth relative to rpcTempCU level
+        }
+      }
+      
+      // update values to virtual partition size
+      pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
+    }
+#endif
+    
     pcCU->fillMvpCand( uiPartIdx, uiPartAddr, eRefPicList, iRefIdx, pcAMVPInfo );
+    
+#if H_3D_DBBP
+    if( pcCU->getDBBPFlag(0) )
+    {
+      // restore 2Nx2N partitioning for motion estimation
+      uiPartIdx = 0;
+      AOF( pcCU->getPartitionSize(0) == pDBBPTmpData->eVirtualPartSize );
+      pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, pcCU->getDepth(0));
+      
+      // restore values for 2Nx2N partition size
+      pcCU->getPartIndexAndSize( uiPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
+      AOF(uiPartAddr==0);
+    }
+#endif
   }
   
@@ -5253,9 +5706,16 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex( pcCU, 0, true );
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
 #endif
+#endif
 #if H_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
+#endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
+#endif
 #endif
     uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
@@ -5536,5 +5996,9 @@
 
 #if H_3D_INTER_SDC
+#if SEC_INTER_SDC_G0101
+Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, Int uiOffest, const UInt uiDepth )
+#else
 Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, const UInt uiDepth )
+#endif
 {
   if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( 0 ) )
@@ -5542,9 +6006,15 @@
     return;
   }
-
+#if QC_SDC_UNIFY_G0130
+  pcCU->setSDCFlagSubParts( true, 0, uiDepth );
+#else
   pcCU->setInterSDCFlagSubParts( true, 0, 0, uiDepth );
+#endif
 
   UInt  uiWidth      = pcCU->getWidth ( 0 );
   UInt  uiHeight     = pcCU->getHeight( 0 );
+#if SEC_INTER_SDC_G0101
+  UInt uiSegSize = 0;
+#else
   UChar* pMask       = pcCU->getInterSDCMask();
   memset( pMask, 0, uiWidth*uiHeight );
@@ -5553,14 +6023,21 @@
 
   UInt uiSegSize[4] = { 0, 0, 0, 0 };
+#endif
   Pel *pPred, *pOrg;
   UInt uiPredStride = pcPred->getStride();
   UInt uiOrgStride  = pcOrg->getStride();
   UInt uiPelX, uiPelY;
+#if !SEC_INTER_SDC_G0101
   UInt uiPartitionSize = pcCU->getPartitionSize( 0 );
   UInt uiSegmentNum = ( uiPartitionSize == SIZE_2Nx2N ) ? 1 : ( uiPartitionSize == SIZE_NxN ? 4 : 2 );
+#endif
 
   pPred = pcPred->getLumaAddr( 0 );
   pOrg  = pcOrg->getLumaAddr( 0 );
+#if SEC_INTER_SDC_G0101
+  Int pResDC = 0;
+#else
   Int pResDC[4] = { 0, 0, 0, 0};
+#endif
 
   //calculate dc value for prediction and original signal, and calculate residual and reconstruction
@@ -5569,7 +6046,12 @@
     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
     {
+#if SEC_INTER_SDC_G0101
+      pResDC += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
+      uiSegSize++;
+#else
       UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
       pResDC[uiSeg] += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
       uiSegSize[uiSeg]++;
+#endif
     }
     pOrg  += uiOrgStride;
@@ -5577,11 +6059,21 @@
   }
 
+#if SEC_INTER_SDC_G0101
+  Int iResiOffset = ( pResDC  > 0 ? ( uiSegSize >> 1 ) : -1*( uiSegSize >> 1 ) );
+  pResDC          = ( pResDC + iResiOffset ) / (Int) uiSegSize;
+
+  pcCU->setSDCSegmentDCOffset( pResDC + uiOffest, 0, 0 );
+#else
   for( UInt uiSeg = 0; uiSeg < uiSegmentNum; uiSeg++ )
   {
     Int iResiOffset = ( pResDC [uiSeg] > 0 ? ( uiSegSize[uiSeg] >> 1 ) : -1*( uiSegSize[uiSeg] >> 1 ) );
     pResDC [uiSeg]  = ( pResDC [uiSeg] + iResiOffset ) / (Int) uiSegSize[uiSeg];
-
+#if QC_SDC_UNIFY_G0130
+    pcCU->setSDCSegmentDCOffset( pResDC[uiSeg], uiSeg, 0 );
+#else
     pcCU->setInterSDCSegmentDCOffset( pResDC[uiSeg], uiSeg, 0 );
-  }
+#endif
+  }
+#endif
 
   Pel *pRec;
@@ -5594,8 +6086,12 @@
     for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
     {
+#if SEC_INTER_SDC_G0101
+      pRec[ uiPelX ] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, pPred[uiPelX] + pcCU->getSDCSegmentDCOffset(0, 0) );
+#else
       UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
       assert( uiSeg < uiSegmentNum );
 
       pRec[ uiPelX ] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, pPred[uiPelX] + pResDC[uiSeg] );
+#endif
     }
     pPred     += uiPredStride;
@@ -5637,9 +6133,21 @@
 #endif
 
+#if QC_SDC_UNIFY_G0130
+  Bool bNonSkip = false;
+#else
   Bool bNonSkip = true;
+#endif
+#if SEC_INTER_SDC_G0101
+  bNonSkip |= ( pcCU->getSDCSegmentDCOffset( 0, 0 ) != 0 ) ? 1 : 0;
+#else
   for( UInt uiSeg = 0; uiSeg < uiSegmentNum; uiSeg++ )
   {
+#if QC_SDC_UNIFY_G0130
+    bNonSkip |= ( pcCU->getSDCSegmentDCOffset( uiSeg, 0 ) != 0 ) ? 1 : 0;
+#else
     bNonSkip &= ( pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 ) != 0 ) ? 1 : 0;
-  }
+#endif
+  }
+#endif
 
   if( !bNonSkip )
@@ -6833,9 +7341,16 @@
     m_pcEntropyCoder->encodeSkipFlag(pcCU, 0, true);
     m_pcEntropyCoder->encodeMergeIndex(pcCU, 0, true);
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
 #endif
+#endif
 #if H_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU, 0 );
+#endif
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
+#endif
 #endif
     ruiBits += m_pcEntropyCoder->getNumberOfWrittenBits();
@@ -6851,12 +7366,22 @@
     m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
     m_pcEntropyCoder->encodePartSize( pcCU, 0, pcCU->getDepth(0), true );
+#if QC_SDC_UNIFY_G0130
+    m_pcEntropyCoder->encodeSDCFlag( pcCU, 0, true );
+#endif
     m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
+#if !SEC_IC_ARP_SIG_G0072
 #if H_3D_IC
     m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
 #endif
+#endif
 #if H_3D_ARP
     m_pcEntropyCoder->encodeARPW( pcCU , 0 );
 #endif
-#if H_3D_INTER_SDC
+#if SEC_IC_ARP_SIG_G0072
+#if H_3D_IC
+    m_pcEntropyCoder->encodeICFlag( pcCU, 0, true );
+#endif
+#endif
+#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
     m_pcEntropyCoder->encodeInterSDCFlag( pcCU, 0, true );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 833)
@@ -219,4 +219,7 @@
     TComYuv* pcResi, 
     TComYuv* pcRec, 
+#if SEC_INTER_SDC_G0101
+    Int      uiOffset,
+#endif
     const UInt uiDepth );
 #endif
@@ -353,5 +356,11 @@
 #endif
 #if H_3D_DIM_SDC
-  Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual );
+  Void xIntraCodingSDC            ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, 
+#if QC_GENERIC_SDC_G0122
+    Bool bZeroResidual, Int iSDCDeltaResi
+#else
+    Bool bResidual
+#endif
+    );
 #endif
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSlice.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.h	(revision 774)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.h	(revision 833)
@@ -107,4 +107,10 @@
   UInt                    m_uiSliceIdx;
   std::vector<TEncSbac*> CTXMem;
+
+#if MTK_DDD_G0063
+  Int          m_iDDDScale;
+  Int          m_iDDDOffset;
+  UInt         m_uiDDDPrecision;
+#endif
 public:
   TEncSlice();
@@ -147,4 +153,8 @@
   Void      setCtxMem( TEncSbac* sb, Int b )   { CTXMem[b] = sb; }
 
+#if MTK_DDD_G0063
+  Void setDDDPar( Int iScale, Int iOffset, UInt uiPrecision ){ m_iDDDScale = iScale; m_iDDDOffset = iOffset; m_uiDDDPrecision = uiPrecision; }
+#endif
+
 private:
   Double  xGetQPValueAccordingToLambda ( Double lambda );
