Index: /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 177)
@@ -476,4 +476,8 @@
 #if HHI_MPI
   ("MVI", m_bUseMVI, false, "use motion vector inheritance for depth map coding")
+#endif
+#if RWTH_SDC_DLT_B0036
+  ("DLT", m_bUseDLT, true, "Enables Depth Lookup Table")
+  ("SDC", m_bUseSDC, true, "Enabled Simplified Depth Coding")
 #endif
   ;
@@ -1746,4 +1750,8 @@
   printf("MVI:%d ", m_bUseMVI ? 1 : 0 );
 #endif
+#if RWTH_SDC_DLT_B0036
+  printf("SDC:%d ", m_bUseSDC ? 1 : 0 );
+  printf("DLT:%d ", m_bUseDLT ? 1 : 0 );
+#endif
 #if LGE_WVSO_A0119
   if ( m_bUseWVSO )
Index: /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncCfg.h	(revision 177)
@@ -269,4 +269,8 @@
   Bool      m_bUseMVI;  ///< flag for using Motion Vector Inheritance for depth map coding
 #endif
+#if RWTH_SDC_DLT_B0036
+  Bool      m_bUseDLT;
+  Bool      m_bUseSDC;
+#endif
 
   Int       m_useScalingListId;                               ///< using quantization matrix
Index: /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.cpp	(revision 177)
@@ -373,4 +373,8 @@
     m_acTEncTopList[iViewIdx]->setUseMVI( false );
 #endif
+#if RWTH_SDC_DLT_B0036
+    m_acTEncTopList[iViewIdx]->setUseDLT                      ( false );
+    m_acTEncTopList[iViewIdx]->setUseSDC                      ( false );
+#endif
   }
   if( m_bUsingDepthMaps )
@@ -655,4 +659,8 @@
      m_acTEncDepthTopList[iViewIdx]->setUseMVI( m_bUseMVI );
 #endif
+#if RWTH_SDC_DLT_B0036
+      m_acTEncDepthTopList[iViewIdx]->setUseDLT                   ( m_bUseDLT );
+      m_acTEncDepthTopList[iViewIdx]->setUseSDC                   ( m_bUseSDC );
+#endif
     }
   }
@@ -873,4 +881,9 @@
     eos.push_back( false );
     depthEos.push_back( false );
+    
+#if RWTH_SDC_DLT_B0036
+    if( m_bUsingDepthMaps && m_bUseDLT )
+      xAnalyzeInputBaseDepth(iViewIdx, m_iIntraPeriod);
+#endif
   }
 
@@ -1421,4 +1434,80 @@
   return pcPic;
 };
+  
+#if RWTH_SDC_DLT_B0036
+Void TAppEncTop::xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames)
+{
+  TComPicYuv*       pcDepthPicYuvOrg = new TComPicYuv;
+  // allocate original YUV buffer
+  pcDepthPicYuvOrg->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth );
+  
+  TVideoIOYuv* depthVideoFile = new TVideoIOYuv;
+  
+  UInt uiMaxDepthValue = g_uiIBDI_MAX;
+  
+  Bool abValidDepths[uiMaxDepthValue+1];
+  
+  depthVideoFile->open( m_pchDepthInputFileList[iViewIdx], false, m_uiInputBitDepth, m_uiInternalBitDepth );  // read  mode
+  
+  // initialize boolean array
+  for(Int p=0; p<=uiMaxDepthValue; p++)
+    abValidDepths[p] = false;
+  
+  Int iHeight   = pcDepthPicYuvOrg->getHeight();
+  Int iWidth    = pcDepthPicYuvOrg->getWidth();
+  Int iStride   = pcDepthPicYuvOrg->getStride();
+  
+  Pel* pInDM    = pcDepthPicYuvOrg->getLumaAddr();
+  
+  for(Int uiFrame=0; uiFrame < uiNumFrames; uiFrame++ )
+  {
+    depthVideoFile->read( pcDepthPicYuvOrg, m_aiPad, false );
+    
+    // check all pixel values
+    for (Int i=0; i<iHeight; i++)
+    {
+      Int rowOffset = i*iStride;
+      
+      for (Int j=0; j<iWidth; j++)
+      {
+        Pel depthValue = pInDM[rowOffset+j];
+        abValidDepths[depthValue] = true;
+      }
+    }
+  }
+  
+  depthVideoFile->close();
+  
+  pcDepthPicYuvOrg->destroy();
+  delete pcDepthPicYuvOrg;
+  
+  // convert boolean array to idx2Depth LUT
+  UInt* auiIdx2DepthValue = (UInt*) calloc(uiMaxDepthValue, sizeof(UInt));
+  UInt uiNumDepthValues = 0;
+  for(UInt p=0; p<=uiMaxDepthValue; p++)
+  {
+    if( abValidDepths[p] == true)
+    {
+      auiIdx2DepthValue[uiNumDepthValues++] = p;
+    }
+  }
+  
+  if( uiNumFrames == 0 || ceil(Log2(uiNumDepthValues)) == ceil(Log2(g_uiIBDI_MAX)) )
+  {
+    // don't use DLT
+    m_acTEncDepthTopList[iViewIdx]->setUseDLT(false);
+    m_acTEncDepthTopList[iViewIdx]->getSPS()->setUseDLT(false);
+  }
+  
+  // assign LUT
+  if( m_acTEncDepthTopList[iViewIdx]->getUseDLT() )
+    m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues);
+  else
+    m_acTEncDepthTopList[iViewIdx]->getSPS()->setDepthLUTs();
+  
+  // free temporary memory
+  free(auiIdx2DepthValue);
+}
+#endif
 
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/App/TAppEncoder/TAppEncTop.h	(revision 177)
@@ -161,4 +161,8 @@
   Void  xStoreVSORefPicsInBuffer();                                                   ///< read in External Ref pic from file and store in buffer
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Void  xAnalyzeInputBaseDepth(Int iViewIdx, UInt uiNumFrames);
+#endif
 
 };// END CLASS DEFINITION TAppEncTop
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/ContextTables.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/ContextTables.h	(revision 177)
@@ -163,4 +163,13 @@
 #endif
 
+#if RWTH_SDC_DLT_B0036
+#define SDC_NUM_FLAG_CTX                 3
+#define SDC_NUM_RESIDUAL_FLAG_CTX        1
+#define SDC_NUM_SIGN_FLAG_CTX            1
+#define SDC_NUM_RESIDUAL_CTX             10
+
+#define SDC_NUM_PRED_MODE_CTX            5
+#endif
+
 // ====================================================================================================================
 // Tables
@@ -1328,4 +1337,96 @@
 #endif
 
+#if RWTH_SDC_DLT_B0036
+static const Short INIT_SDC_FLAG[3][SDC_NUM_FLAG_CTX][2] =
+{
+  {
+    {    0,   64 }, {    0,   64 }, {    0,   64 }
+  },
+  {
+    {    0,   64 }, {    0,   64 }, {    0,   64 }
+  },
+  {
+    {    0,   64 }, {    0,   64 }, {    0,   64 }
+  }
+};
+
+static const Short INIT_SDC_RESIDUAL_FLAG[3][3*SDC_NUM_RESIDUAL_FLAG_CTX][2] =
+{
+  {
+    { -5, 35 },
+    { -0, 56 },
+    { -0, 56 }
+    
+  },
+  {
+    { -5, 35 },
+    { -0, 56 },
+    { -0, 56 }
+  },
+  {
+    { -5, 35 },
+    { -0, 56 },
+    { -0, 56 }
+  }
+};
+
+static const Short INIT_SDC_SIGN_FLAG[3][3*SDC_NUM_SIGN_FLAG_CTX][2] =
+{
+  {
+    { -1, 56 },
+    { -4, 55 },
+    { -4, 55 }
+  },
+  {
+    { -1, 56 },
+    { -4, 55 },
+    { -4, 55 }
+  },
+  {
+    { -1, 56 },
+    { -4, 55 },
+    { -4, 55 }
+  }
+};
+
+static const Short INIT_SDC_RESIDUAL[3][3*SDC_NUM_RESIDUAL_CTX][2] =
+{
+  {
+    { -1, 64 }, {  2, 64 }, {  6, 67 }, {  8, 61 }, {  7, 47 }, { 10, 33 }, { 12, 14 }, { 33, -13 }, { 12, 14 }, { 33, -13 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 }
+  },
+  {
+    { -1, 64 }, {  2, 64 }, {  6, 67 }, {  8, 61 }, {  7, 47 }, { 10, 33 }, { 12, 14 }, { 33, -13 }, { 12, 14 }, { 33, -13 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 }
+  },
+  {
+    { -1, 64 }, {  2, 64 }, {  6, 67 }, {  8, 61 }, {  7, 47 }, { 10, 33 }, { 12, 14 }, { 33, -13 }, { 12, 14 }, { 33, -13 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 },
+    {  2, 66 }, { -0, 63 }, {  1, 64 }, {  6, 65 }, {  7, 59 }, { 12, 50 }, { 14, 27 }, { -0, -17 }, { 14, 27 }, { -0, -17 }
+  }
+};
+
+static const Short INIT_SDC_PRED_MODE[3][3*SDC_NUM_PRED_MODE_CTX][2] =
+{
+  {
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 }
+  },
+  {
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 }
+  },
+  {
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 },
+    {  9, 85 }, { -4, 60 }, {  4, 70 }, {  4, 70 }, {  4, 70 }
+  }
+};
+#endif
+
 //! \}
 
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.cpp	(revision 177)
@@ -158,4 +158,9 @@
 #endif
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_pbSDCFlag           = NULL;
+  m_apSegmentDCOffset[0] = NULL;
+  m_apSegmentDCOffset[1] = NULL;
+#endif
 #if OL_DEPTHLIMIT_A0044
   //add a variable to store the partition information
@@ -208,4 +213,10 @@
     memset( m_pePartSize, SIZE_NONE,uiNumPartition * sizeof( *m_pePartSize ) );
     m_pePredMode         = new Char[ uiNumPartition ];
+    
+#if RWTH_SDC_DLT_B0036
+    m_pbSDCFlag          = (Bool*  )xMalloc(Bool,   uiNumPartition);
+    m_apSegmentDCOffset[0] = (Pel*)xMalloc(Pel, uiNumPartition);
+    m_apSegmentDCOffset[1] = (Pel*)xMalloc(Pel, uiNumPartition);
+#endif
     
     m_puiAlfCtrlFlag     = new Bool[ uiNumPartition ];
@@ -355,4 +366,9 @@
 #endif
     if ( m_pePredMode         ) { delete[] m_pePredMode;        m_pePredMode        = NULL; }
+#if RWTH_SDC_DLT_B0036
+    if ( m_pbSDCFlag          ) { xFree(m_pbSDCFlag);      m_pbSDCFlag    = NULL; }
+    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
     if ( m_puhCbf[0]          ) { xFree(m_puhCbf[0]);           m_puhCbf[0]         = NULL; }
     if ( m_puhCbf[1]          ) { xFree(m_puhCbf[1]);           m_puhCbf[1]         = NULL; }
@@ -546,4 +562,7 @@
     m_piTextureModeDepth[ui] = pcFrom->getTextureModeDepth(ui);
 #endif
+#if RWTH_SDC_DLT_B0036
+    m_pbSDCFlag[ui] = pcFrom->getSDCFlag(ui);
+#endif
     m_puhWidth  [ui] = pcFrom->getWidth(ui);
     m_puhHeight [ui] = pcFrom->getHeight(ui);
@@ -581,4 +600,9 @@
     memset( m_piTextureModeDepth+ firstElement,-1,                        numElements * sizeof( *m_piTextureModeDepth ) );
 #endif
+#if RWTH_SDC_DLT_B0036
+    memset( m_pbSDCFlag        + firstElement,     0,                     numElements * sizeof( *m_pbSDCFlag ) );
+    memset( m_apSegmentDCOffset[0]        + firstElement,     0,                     numElements * sizeof( *m_apSegmentDCOffset[0] ) );
+    memset( m_apSegmentDCOffset[1]        + firstElement,     0,                     numElements * sizeof( *m_apSegmentDCOffset[1] ) );
+#endif
     memset( m_puhTrIdx          + firstElement, 0,                        numElements * sizeof( *m_puhTrIdx ) );
     memset( m_nsqtPartIdx       + firstElement, 0,                        numElements * sizeof( *m_nsqtPartIdx) );
@@ -810,4 +834,9 @@
     m_piContourPredTexDeltaDC2[ui] = 0;
 #endif 
+#if RWTH_SDC_DLT_B0036
+    m_pbSDCFlag[ui] = false;
+    m_apSegmentDCOffset[0][ui] = 0;
+    m_apSegmentDCOffset[1][ui] = 0;
+#endif
     }
   }
@@ -922,5 +951,10 @@
   memset( m_piContourPredTexDeltaDC1, 0, sizeof( Int  ) * m_uiNumPartition );
   memset( m_piContourPredTexDeltaDC2, 0, sizeof( Int  ) * m_uiNumPartition );
-#endif    
+#endif   
+#if RWTH_SDC_DLT_B0036
+  memset( m_pbSDCFlag,     0, sizeof(Bool) * m_uiNumPartition  );
+  memset( m_apSegmentDCOffset[0],     0, sizeof(Pel) * m_uiNumPartition);
+  memset( m_apSegmentDCOffset[1],     0, sizeof(Pel) * m_uiNumPartition);
+#endif
 
   UChar uhWidth  = g_uiMaxCUWidth  >> uiDepth;
@@ -993,4 +1027,9 @@
       m_pbResPredFlag     [ui] = pcCU->m_pbResPredFlag     [ uiPartOffset + ui ];
 #endif
+#if RWTH_SDC_DLT_B0036
+      m_pbSDCFlag         [ui] = pcCU->m_pbSDCFlag         [ uiPartOffset + ui ];
+      m_apSegmentDCOffset[0][ui] = pcCU->m_apSegmentDCOffset[0][ uiPartOffset + ui ];
+      m_apSegmentDCOffset[1][ui] = pcCU->m_apSegmentDCOffset[1][ uiPartOffset + ui ];
+#endif
     }
   }
@@ -1202,4 +1241,9 @@
   }
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_pbSDCFlag               = pcCU->getSDCFlag()            + uiPart;
+  m_apSegmentDCOffset[0]    = pcCU->getSDCSegmentDCOffset(0) + uiPart;
+  m_apSegmentDCOffset[1]    = pcCU->getSDCSegmentDCOffset(1) + uiPart;
+#endif
 }
 
@@ -1384,4 +1428,9 @@
   memcpy( m_piTextureModeDepth + uiOffset, pcCU->getTextureModeDepth(), sizeof( Int ) * uiNumPartition );
 #endif
+#if RWTH_SDC_DLT_B0036
+  memcpy( m_pbSDCFlag     + uiOffset, pcCU->getSDCFlag(),      iSizeInBool  );
+  memcpy( m_apSegmentDCOffset[0]     + uiOffset, pcCU->getSDCSegmentDCOffset(0), sizeof( Pel ) * uiNumPartition);
+  memcpy( m_apSegmentDCOffset[1]     + uiOffset, pcCU->getSDCSegmentDCOffset(1), sizeof( Pel ) * uiNumPartition);
+#endif
 }
 
@@ -1505,4 +1554,9 @@
   memcpy( rpcCU->getTextureModeDepth() + m_uiAbsIdxInLCU, m_piTextureModeDepth, sizeof( Int ) * m_uiNumPartition );
 #endif
+#if RWTH_SDC_DLT_B0036
+  memcpy( rpcCU->getSDCFlag() + m_uiAbsIdxInLCU, m_pbSDCFlag,      iSizeInBool  );
+  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
 }
 
@@ -1626,4 +1680,9 @@
 #if HHI_MPI
   memcpy( rpcCU->getTextureModeDepth() + uiPartOffset, m_piTextureModeDepth, sizeof( Int ) * uiQNumPart  );
+#endif
+#if RWTH_SDC_DLT_B0036
+  memcpy( rpcCU->getSDCFlag() + uiPartOffset, m_pbSDCFlag,      iSizeInBool  );
+  memcpy( rpcCU->getSDCSegmentDCOffset(0) + uiPartOffset, m_apSegmentDCOffset[0], sizeof( Pel ) * uiQNumPart);
+  memcpy( rpcCU->getSDCSegmentDCOffset(1) + uiPartOffset, m_apSegmentDCOffset[1], sizeof( Pel ) * uiQNumPart);
 #endif
 }
@@ -2955,4 +3014,47 @@
   setSubPart( bMergeFlag, m_pbMergeFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
 }
+
+#if RWTH_SDC_DLT_B0036
+Void TComDataCU::setSDCFlagSubParts ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+  setSubPart( bSDCFlag, m_pbSDCFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+UInt TComDataCU::getCtxSDCFlag( UInt uiAbsPartIdx )
+{
+  TComDataCU* pcTempCU;
+  UInt        uiTempPartIdx;
+  UInt        uiCtx = 0;
+  
+  // left PU
+  pcTempCU = getPULeft( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false );
+  uiCtx    = ( pcTempCU ) ? pcTempCU->getSDCFlag( uiTempPartIdx ) : 0;
+  
+  // above PU
+  pcTempCU = getPUAbove( uiTempPartIdx, m_uiAbsIdxInLCU + uiAbsPartIdx, true, false );
+  uiCtx   += ( pcTempCU ) ? pcTempCU->getSDCFlag( uiTempPartIdx ) : 0;
+  
+  return uiCtx;
+}
+
+Bool TComDataCU::getSDCAvailable( UInt uiAbsPartIdx )
+{
+  if( !getSlice()->getSPS()->isDepth() || getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N )
+    return false;
+  
+  UInt uiLumaPredMode = getLumaIntraDir( uiAbsPartIdx );
+  
+  if(!isIntra(uiAbsPartIdx))
+    return false;
+  
+  for(UInt ui=0; ui<RWTH_SDC_NUM_PRED_MODES; ui++)
+  {
+    if( g_auiSDCPredModes[ui] == uiLumaPredMode )
+      return true;
+  }
+  // else
+  return false;
+}
+#endif
 
 Void TComDataCU::setMergeIndexSubParts ( UInt uiMergeIndex, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComDataCU.h	(revision 177)
@@ -274,4 +274,9 @@
   Int*          m_piContourPredTexDeltaDC2;
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Bool*         m_pbSDCFlag;
+  Pel*          m_apSegmentDCOffset[2];
+#endif
 
 protected:
@@ -823,4 +828,18 @@
 #endif
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Bool*         getSDCFlag          ()                        { return m_pbSDCFlag;               }
+  Bool          getSDCFlag          ( UInt uiIdx )            { return m_pbSDCFlag[uiIdx];        }
+  Void          setSDCFlagSubParts  ( Bool bSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  
+  UInt          getCtxSDCFlag              ( UInt uiAbsPartIdx );
+  
+  Bool          getSDCAvailable             ( UInt uiAbsPartIdx );
+  
+  Pel*          getSDCSegmentDCOffset( UInt uiSeg ) { return m_apSegmentDCOffset[uiSeg]; }
+  Pel           getSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentDCOffset[uiSeg][uiPartIdx]; }
+  Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
+#endif
 };
 
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.cpp	(revision 177)
@@ -305,4 +305,7 @@
 };
 
+#if RWTH_SDC_DLT_B0036
+UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES] = { DC_IDX, DMM_WEDGE_FULL_IDX, DMM_WEDGE_PREDDIR_IDX, PLANAR_IDX };
+#endif
 
 Int g_quantScales[6] =
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComRom.h	(revision 177)
@@ -198,4 +198,9 @@
 #endif
 
+#if RWTH_SDC_DLT_B0036
+#define RWTH_SDC_NUM_PRED_MODES 4
+extern      UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES];
+#endif
+
 Void initWedgeLists();
 Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.cpp	(revision 177)
@@ -1557,4 +1557,13 @@
 
   ::memset( m_aiUsableInterViewRefs, 0, sizeof( m_aiUsableInterViewRefs ) );
+  
+#if RWTH_SDC_DLT_B0036
+  m_bUseDLT = false;
+  
+  m_uiBitsPerDepthValue = g_uiBitDepth;
+  m_uiNumDepthmapValues = 0;
+  m_uiDepthValue2Idx    = NULL;
+  m_uiIdx2DepthValue    = NULL;
+#endif
 }
 
@@ -1572,4 +1581,85 @@
   }
 }
+
+#if RWTH_SDC_DLT_B0036
+Void TComSPS::setDepthLUTs(UInt* uidx2DepthValue, UInt uiNumDepthValues)
+{
+  UInt uiMaxDepthValue = g_uiIBDI_MAX;
+  
+  // allocate some memory
+  if( m_uiNumDepthmapValues == 0 )
+  {
+    m_uiNumDepthmapValues = uiMaxDepthValue+1;
+    m_uiBitsPerDepthValue = (UInt)ceil(log2f(m_uiNumDepthmapValues));
+    
+    m_uiDepthValue2Idx    = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues);
+    m_uiIdx2DepthValue    = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues);
+    
+    //default mapping
+    for (Int i=0; i<m_uiNumDepthmapValues; i++)
+    {
+      m_uiDepthValue2Idx[i] = i;
+      m_uiIdx2DepthValue[i] = i;
+    }
+  }
+  
+  if( uidx2DepthValue == NULL || uiNumDepthValues == 0 ) // default mapping only
+    return;
+  
+  // copy idx2DepthValue to internal array
+  memcpy(m_uiIdx2DepthValue, uidx2DepthValue, uiNumDepthValues*sizeof(UInt));
+  
+  for(Int p=0; p<=uiMaxDepthValue; p++)
+  {
+    Int iIdxDown    = 0;
+    Int iIdxUp      = uiNumDepthValues-1;
+    Bool bFound     = false;
+    
+    // iterate over indices to find lower closest depth
+    Int i = 1;
+    while(!bFound && i<uiNumDepthValues)
+    {
+      if( m_uiIdx2DepthValue[i] > p )
+      {
+        iIdxDown  = i-1;
+        bFound    = true;
+      }
+      
+      i++;
+    }
+    // iterate over indices to find upper closest depth
+    i = uiNumDepthValues-2;
+    bFound = false;
+    while(!bFound && i>=0)
+    {
+      if( m_uiIdx2DepthValue[i] < p )
+      {
+        iIdxUp  = i+1;
+        bFound    = true;
+      }
+      
+      i--;
+    }
+    
+    // assert monotony
+    assert(iIdxDown<=iIdxUp);
+    
+    // assign closer depth value/idx
+    if( abs(p-(Int)m_uiIdx2DepthValue[iIdxDown]) < abs(p-(Int)m_uiIdx2DepthValue[iIdxUp]) )
+    {
+      m_uiDepthValue2Idx[p] = iIdxDown;
+    }
+    else
+    {
+      m_uiDepthValue2Idx[p] = iIdxUp;
+    }
+    
+  }
+  
+  // update globals
+  m_uiNumDepthmapValues = uiNumDepthValues;
+  m_uiBitsPerDepthValue = (UInt)ceil(Log2(m_uiNumDepthmapValues));
+}
+#endif
 
 TComPPS::TComPPS()
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TComSlice.h	(revision 177)
@@ -323,4 +323,13 @@
   Bool        m_bUseMVI;
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Bool        m_bUseDLT;
+  
+  UInt        m_uiBitsPerDepthValue;
+  UInt        m_uiNumDepthmapValues;
+  UInt*       m_uiDepthValue2Idx;
+  UInt*       m_uiIdx2DepthValue;
+#endif
 
   Bool     m_bLFCrossTileBoundaryFlag;
@@ -547,4 +556,15 @@
   Bool getUseMVI                  ()           {return m_bUseMVI;}
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Bool getUseDLT      ()          { return m_bUseDLT; }
+  Void setUseDLT      ( Bool b ) { m_bUseDLT  = b;          }
+  
+  UInt getBitsPerDepthValue()       { return m_bUseDLT?m_uiBitsPerDepthValue:g_uiBitDepth; }
+  UInt getNumDepthValues()          { return m_bUseDLT?m_uiNumDepthmapValues:g_uiIBDI_MAX; }
+  UInt depthValue2idx(Pel uiValue)  { return m_bUseDLT?m_uiDepthValue2Idx[uiValue]:uiValue; }
+  Pel  idx2DepthValue(UInt uiIdx)   { return m_bUseDLT?m_uiIdx2DepthValue[uiIdx]:uiIdx; }
+  Void setDepthLUTs   (UInt* uidx2DepthValue = NULL, UInt uiNumDepthValues = 0);
+#endif
 
   UInt      getMaxTLayers()                           { return m_uiMaxTLayers; }
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TypeDef.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibCommon/TypeDef.h	(revision 177)
@@ -134,4 +134,9 @@
 #endif
 
+#define RWTH_SDC_DLT_B0036                1   // JCT3V-B0036: Simplified Depth Coding + Depth Lookup Table
+#if RWTH_SDC_DLT_B0036
+#define Log2( n ) ( log((double)n) / log(2.0) )
+#endif
+
 #define HHI_MPI                           1   // motion parameter inheritance from texture picture for depth map coding
 #define HHI_MPI_MERGE_POS                 0
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 177)
@@ -1674,6 +1674,36 @@
     }
 #endif
-
-    READ_FLAG( uiCode, "base_view_flag" ); 
+    
+#if RWTH_SDC_DLT_B0036
+    if( bIsDepth )
+    {
+      READ_FLAG( uiCode, "use_dlt_flag" );
+      pcSPS->setUseDLT( uiCode );
+      if( pcSPS->getUseDLT() )
+      {
+        // decode mapping
+        UInt uiNumDepthValues;
+        // parse number of values in DLT
+        xReadUvlc( uiNumDepthValues );
+        
+        // parse actual DLT values
+        UInt* auiIdx2DepthValue = (UInt*) calloc(uiNumDepthValues, sizeof(UInt));
+        for(UInt d=0; d<uiNumDepthValues; d++)
+        {
+          xReadUvlc( uiCode );
+          auiIdx2DepthValue[d] = uiCode;
+        }
+        
+        pcSPS->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues);
+        
+        // clean memory
+        free(auiIdx2DepthValue);
+      }
+      else
+        pcSPS->setDepthLUTs();
+    }
+#endif
+
+    READ_FLAG( uiCode, "base_view_flag" );
     if( uiCode )
     { // baseview SPS -> set standard values
@@ -2827,4 +2857,19 @@
 #endif
 
+#if RWTH_SDC_DLT_B0036
+Void TDecCavlc::parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert(0);
+}
+Void TDecCavlc::parseSDCPredMode    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert(0);
+}
+Void TDecCavlc::parseSDCResidualData     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart )
+{
+  assert(0);
+}
+#endif
+
 // ====================================================================================================================
 // Protected member functions
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 177)
@@ -178,4 +178,9 @@
   Void parseDFFlag         ( UInt& ruiVal, const Char *pSymbolName );
   Void parseDFSvlc         ( Int&  riVal,  const Char *pSymbolName  );
+#if RWTH_SDC_DLT_B0036
+  Void parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void parseSDCPredMode    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
 protected:
 #if DBL_CONTROL
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.cpp	(revision 177)
@@ -37,4 +37,9 @@
 
 #include "TDecCu.h"
+
+#if RWTH_SDC_DLT_B0036
+#define GetDepthValue2Idx(val)     (pcCU->getSlice()->getSPS()->depthValue2idx(val))
+#define GetIdx2DepthValue(val)     (pcCU->getSlice()->getSPS()->idx2DepthValue(val))
+#endif
 
 //! \ingroup TLibDecoder
@@ -608,4 +613,9 @@
       break;
     case MODE_INTRA:
+#if RWTH_SDC_DLT_B0036
+      if( m_ppcCU[uiDepth]->getSDCFlag(0) )
+        xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth );
+      else
+#endif
       xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
       break;
@@ -951,4 +961,131 @@
 
 }
+
+#if RWTH_SDC_DLT_B0036
+Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiWidth        = pcCU->getWidth  ( 0 );
+  UInt uiHeight       = pcCU->getHeight ( 0 );
+  
+  TComYuv* pcRecoYuv  = m_ppcYuvReco[uiDepth];
+  TComYuv* pcPredYuv  = m_ppcYuvReco[uiDepth];
+  TComYuv* pcResiYuv  = m_ppcYuvResi[uiDepth];
+  
+  UInt    uiStride    = pcRecoYuv->getStride  ();
+  Pel*    piReco      = pcRecoYuv->getLumaAddr( uiAbsPartIdx );
+  Pel*    piPred      = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  Pel*    piResi      = pcResiYuv->getLumaAddr( uiAbsPartIdx );
+  
+  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+  
+  UInt    uiLumaPredMode    = pcCU->getLumaIntraDir     ( uiAbsPartIdx );
+  
+  AOF( uiWidth == uiHeight );
+  AOF( uiAbsPartIdx == 0 );
+  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
+  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
+  
+  //===== init availability pattern =====
+  Bool  bAboveAvail = false;
+  Bool  bLeftAvail  = false;
+  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
+  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail );
+  
+  //===== get prediction signal =====
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+  if( uiLumaPredMode >= NUM_INTRA_MODE )
+  {
+    m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false );
+  }
+  else
+  {
+#endif
+    m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+  }
+#endif
+  
+  // number of segments depends on prediction mode
+  UInt uiNumSegments = 1;  
+  Bool* pbMask = NULL;
+  UInt uiMaskStride = 0;
+  
+  //if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX )
+  if( 0 )
+  {
+    Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx);
+    
+    WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
+    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
+    
+    uiNumSegments = 2;
+    pbMask = pcWedgelet->getPattern();
+    uiMaskStride = pcWedgelet->getStride();
+  }
+  
+  // get DC prediction for each segment
+  Pel apDCPredValues[2];
+  xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride);
+  
+  // reconstruct residual based on mask + DC residuals
+  Pel apDCResiValues[2];
+  Pel apDCRecoValues[2];
+  for( UInt ui = 0; ui < uiNumSegments; ui++ )
+  {
+    Pel   pPredIdx    = GetDepthValue2Idx( apDCPredValues[ui] );
+    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(ui, uiAbsPartIdx);
+    Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
+    
+    apDCRecoValues[ui]  = pRecoValue;
+    apDCResiValues[ui]  = pRecoValue - apDCPredValues[ui];
+  }
+  
+  //===== reconstruction =====
+  Bool*pMask      = pbMask;
+  Pel* pPred      = piPred;
+  Pel* pResi      = piResi;
+  Pel* pReco      = piReco;
+  Pel* pRecIPred  = piRecIPred;
+  
+  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
+  {
+    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
+    {
+      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
+      assert( ucSegment < uiNumSegments );
+      
+      Pel pPredVal= apDCPredValues[ucSegment];
+      Pel pResiDC = apDCResiValues[ucSegment];
+      
+      pReco    [ uiX ] = Clip( pPredVal + pResiDC );
+      pRecIPred[ uiX ] = pReco[ uiX ];
+    }
+    pPred     += uiStride;
+    pResi     += uiStride;
+    pReco     += uiStride;
+    pRecIPred += uiRecIPredStride;
+    pMask     += uiMaskStride;
+  }
+  
+  // clear UV
+  UInt  uiStrideC     = pcPredYuv->getCStride();
+  Pel   *pRecCb       = pcPredYuv->getCbAddr();
+  Pel   *pRecCr       = pcPredYuv->getCrAddr();
+  
+  for (Int y=0; y<uiHeight/2; y++)
+  {
+    for (Int x=0; x<uiWidth/2; x++)
+    {
+      pRecCb[x] = (Pel)(128<<g_uiBitIncrement);
+      pRecCr[x] = (Pel)(128<<g_uiBitIncrement);
+    }
+    
+    pRecCb += uiStrideC;
+    pRecCr += uiStrideC;
+  }
+}
+#endif
 
 /** Function for deriving recontructed PU/CU Luma sample with QTree structure
@@ -1216,3 +1353,37 @@
 #endif
 
+#if RWTH_SDC_DLT_B0036
+Void TDecCu::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride )
+{
+  Int iSumDepth[uiNumSegments];
+  memset(iSumDepth, 0, sizeof(Int)*uiNumSegments);
+  Int iSumPix[uiNumSegments];
+  memset(iSumPix, 0, sizeof(Int)*uiNumSegments);
+  
+  for (Int y=0; y<uiSize; y++)
+  {
+    for (Int x=0; x<uiSize; x++)
+    {
+      UChar ucSegment = pMask?(UChar)pMask[x]:0;
+      assert( ucSegment < uiNumSegments );
+      
+      iSumDepth[ucSegment] += pOrig[x];
+      iSumPix[ucSegment]   += 1;
+    }
+    
+    pOrig  += uiStride;
+    pMask  += uiMaskStride;
+  }
+  
+  // compute mean for each segment
+  for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
+  {
+    if( iSumPix[ucSeg] > 0 )
+      rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
+    else
+      rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
+  }
+}
+#endif
+
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecCu.h	(revision 177)
@@ -121,4 +121,15 @@
   Void xFillPCMBuffer           (TComDataCU* pCU, UInt absPartIdx, UInt depth);
 #endif
+#if RWTH_SDC_DLT_B0036
+  Void  xAnalyzeSegmentsSDC       ( Pel* pOrig,
+                                   UInt uiStride,
+                                   UInt uiSize,
+                                   Pel* rpSegMeans,
+                                   UInt uiNumSegments,
+                                   Bool* pMask,
+                                   UInt uiMaskStride );
+  
+  Void xReconIntraSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
 };
 
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 177)
@@ -147,13 +147,54 @@
 {
   m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth );
+  
+#if RWTH_SDC_DLT_B0036
+  // if B-Slice, code SDC flag later
+  if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    // decode SDC flag
+    decodeSDCFlag(pcCU, uiAbsPartIdx, uiDepth);
+  }
+#endif
 }
 
 Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
 {
+#if RWTH_SDC_DLT_B0036
+  if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx)  )
+  {
+    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
+    pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
+    return;
+  }
+#endif
+  
   m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth );
+  
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSlice()->isInterB() && pcCU->getSlice()->getSPS()->isDepth() && pcCU->isIntra(uiAbsPartIdx) )
+  {
+    // decode SDC flag
+    decodeSDCFlag(pcCU, uiAbsPartIdx, uiDepth);
+    
+    if( pcCU->getSDCFlag(uiAbsPartIdx) )
+    {
+      // part size is also known for SDC intra
+      pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
+      pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
+    }
+  }
+#endif
 }
 
 Void TDecEntropy::decodePredInfo    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU )
 {
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSDCFlag(uiAbsPartIdx) )
+  {
+    decodeSDCPredMode(pcCU, uiAbsPartIdx, uiDepth);
+    return;
+  }
+#endif
+  
   PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx );
   
@@ -196,4 +237,11 @@
     return;
   }
+  
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSDCFlag(uiAbsPartIdx) )
+  {
+    return;
+  }
+#endif
   
   m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth );
@@ -912,4 +960,18 @@
 #endif
   
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSDCAvailable(uiAbsPartIdx) && 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 );
+    
+    decodeSDCResidualData(pcCU, uiAbsPartIdx, uiDepth);
+    return;
+  }
+#endif
+  
   if( pcCU->isIntra(uiAbsPartIdx) )
   {
@@ -954,3 +1016,36 @@
 }
 
+#if RWTH_SDC_DLT_B0036
+Void TDecEntropy::decodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+  
+  m_pcEntropyDecoderIf->parseSDCPredMode(pcCU, uiAbsPartIdx, uiDepth );
+}
+
+Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  
+  m_pcEntropyDecoderIf->parseSDCFlag(pcCU, uiAbsPartIdx, uiDepth );
+}
+
+Void TDecEntropy::decodeSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  
+  // number of segments depends on prediction mode for INTRA
+  UInt uiNumSegments = 2;
+  UInt uiLumaPredMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
+  if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && (uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX) )
+    uiNumSegments = 1;
+  
+  // decode residual data for each segment
+  for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ )
+    m_pcEntropyDecoderIf->parseSDCResidualData(pcCU, uiAbsPartIdx, uiDepth, uiSeg);
+}
+#endif
+
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecEntropy.h	(revision 177)
@@ -142,4 +142,10 @@
   virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0;
   
+#if RWTH_SDC_DLT_B0036
+  virtual Void parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
+  virtual Void parseSDCPredMode     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
+  virtual Void parseSDCResidualData     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) = 0;
+#endif
+  
   virtual ~TDecEntropyIf() {}
 };
@@ -256,4 +262,10 @@
   Void decodeFlush() { m_pcEntropyDecoderIf->decodeFlush(); }
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Void decodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void decodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
 
 };// END CLASS DEFINITION TDecEntropy
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 177)
@@ -38,4 +38,9 @@
 #include "TDecSbac.h"
 
+#if RWTH_SDC_DLT_B0036
+#define GetNumDepthValues()     (pcCU->getSlice()->getSPS()->getNumDepthValues())
+#define GetBitsPerDepthValue()  (pcCU->getSlice()->getSPS()->getBitsPerDepthValue())
+#endif
+
 //! \ingroup TLibDecoder
 //! \{
@@ -106,4 +111,11 @@
 , m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
+#endif
+#if RWTH_SDC_DLT_B0036
+, m_cSDCFlagSCModel             ( 1,             1,                 SDC_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualFlagSCModel     ( 1,             2,  SDC_NUM_RESIDUAL_FLAG_CTX  , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualSignFlagSCModel ( 1,             2,  SDC_NUM_SIGN_FLAG_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualSCModel         ( 1,             2,  SDC_NUM_RESIDUAL_CTX       , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCPredModeSCModel             ( 1,             3,                 SDC_NUM_PRED_MODE_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 {
@@ -206,4 +218,11 @@
   m_cDmmDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_DATA );
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_cSDCFlagSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
+  m_cSDCResidualFlagSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  m_cSDCResidualSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL );
+  m_cSDCResidualSignFlagSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_SDC_SIGN_FLAG );
+  m_cSDCPredModeSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_SDC_PRED_MODE );
+#endif
   
   // new structure
@@ -285,4 +304,11 @@
   m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+  m_cSDCResidualFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  m_cSDCResidualSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
+  m_cSDCResidualSignFlagSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG );
+  m_cSDCPredModeSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE );
+#endif
 
   m_pcTDecBinIf->start();
@@ -2486,4 +2512,93 @@
 }
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+Void TDecSbac::parseSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  
+  UInt uiSymbol = 0;
+  UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
+  
+  if( uiSymbol == 1 )
+  {
+    pcCU->setPartSizeSubParts(SIZE_2Nx2N, uiAbsPartIdx, uiDepth);
+    
+    pcCU->setSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth);
+    pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth);
+    pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth);
+  }
+}
+
+Void TDecSbac::parseSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+  
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  
+  UInt uiCtx            = 0;
+  
+  UInt uiMPModeIdx      = 0;
+  
+  for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++)
+  {
+    UInt uiIsMostProb = 0;
+    m_pcTDecBinIf->decodeBin( uiIsMostProb, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) );
+    
+    if ( uiIsMostProb == 1 )
+      break;
+    
+    // else: get next most probable pred mode
+    uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES;
+  }
+  
+  Int intraPredMode = g_auiSDCPredModes[uiMPModeIdx];
+  
+#if HHI_DMM_WEDGE_INTRA
+  if( intraPredMode == DMM_WEDGE_FULL_IDX )          { xParseWedgeFullInfo          ( pcCU, uiAbsPartIdx, uiDepth ); }
+  if( intraPredMode == DMM_WEDGE_PREDDIR_IDX )       { xParseWedgePredDirInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
+#endif
+  
+  pcCU->setLumaIntraDirSubParts((UChar)intraPredMode, uiAbsPartIdx, uiDepth);
+}
+
+Void TDecSbac::parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  assert( uiSegment < 2 );
+  
+  UInt uiResidual = 0;
+  UInt uiBit      = 0;
+  UInt uiAbsIdx   = 0;
+  UInt uiSign     = 0;
+  Int  iIdx       = 0;
+  
+  UInt uiMaxResidualBits  = GetBitsPerDepthValue();
+  assert( uiMaxResidualBits <= g_uiBitDepth );
+  
+  m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) );
+  
+  if (uiResidual)
+  {
+    // decode residual sign bit
+    m_pcTDecBinIf->decodeBin(uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) );
+    
+    // decode residual magnitude
+    for (Int i=0; i<uiMaxResidualBits; i++)
+    {
+      m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) );
+      uiAbsIdx |= uiBit << i;
+    }
+    
+    uiAbsIdx += 1;
+    iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx;
+  }
+  
+  pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx);
+}
+#endif
 
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibDecoder/TDecSbac.h	(revision 177)
@@ -126,4 +126,10 @@
   Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam);
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Void parseSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void parseSDCPredMode    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void parseSDCResidualData     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
 private:
   Void  xReadUnarySymbol    ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset );
@@ -269,4 +275,14 @@
 #endif
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  ContextModel3DBuffer m_cSDCFlagSCModel;
+  
+  ContextModel3DBuffer m_cSDCResidualFlagSCModel;
+  ContextModel3DBuffer m_cSDCResidualSignFlagSCModel;
+  ContextModel3DBuffer m_cSDCResidualSCModel;
+  
+  ContextModel3DBuffer m_cSDCPredModeSCModel;
+#endif
 };
 
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 177)
@@ -644,4 +644,20 @@
   }
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  if( bIsDepth )
+  {
+    WRITE_FLAG( pcSPS->getUseDLT() ? 1 : 0, "use_dlt_flag" );
+    if( pcSPS->getUseDLT() )
+    {
+      // code mapping
+      xWriteUvlc  ( pcSPS->getNumDepthValues() );
+      for(UInt i=0; i<pcSPS->getNumDepthValues(); i++)
+      {
+        xWriteUvlc( pcSPS->idx2DepthValue(i) );
+      }
+    }
+  }
+#endif
 
   if( pcSPS->getViewId() || pcSPS->isDepth() )
@@ -2066,3 +2082,20 @@
   return true;
 }
+
+#if RWTH_SDC_DLT_B0036
+Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+
+Void TEncCavlc::codeSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
+{
+  assert(0);
+}
+
+Void TEncCavlc::codeSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+#endif
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCavlc.h	(revision 177)
@@ -223,4 +223,10 @@
   Void codeDFFlag       ( UInt uiCode, const Char *pSymbolName );
   Void codeDFSvlc       ( Int   iCode, const Char *pSymbolName );
+  
+#if RWTH_SDC_DLT_B0036
+  Void codeSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+  Void codeSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+  Void codeSDCPredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+#endif
 
 };
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCfg.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCfg.h	(revision 177)
@@ -250,4 +250,8 @@
   Bool      m_bUseMVI;
 #endif
+#if RWTH_SDC_DLT_B0036
+  Bool      m_bUseDLT;
+  Bool      m_bUseSDC;
+#endif
 
   Int*      m_aidQP;
@@ -690,4 +694,8 @@
 #if HHI_MPI
   Void  setUseMVI                      ( Bool bVal )   {m_bUseMVI = bVal;}
+#endif
+#if RWTH_SDC_DLT_B0036
+  Void  setUseDLT                       ( Bool  b )     { m_bUseDLT   = b; }
+  Void  setUseSDC                       ( Bool  b )     { m_bUseSDC   = b; }
 #endif
   Void  setUseSAO                      ( Bool bVal )   {m_bUseSAO = bVal;}
@@ -830,4 +838,9 @@
   Bool      getUseDMM()        { return m_bUseDMM; }
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  Bool      getUseDLT()      { return m_bUseDLT;     }
+  Bool      getUseSDC()      { return m_bUseSDC;     }
+#endif
 
 #if OL_DEPTHLIMIT_A0044
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCu.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncCu.cpp	(revision 177)
@@ -2308,8 +2308,9 @@
           // do MC
 #if HHI_INTERVIEW_SKIP
-      if ( (uiNoResidual == 0) || bSkipRes ){
-#else
-      if ( uiNoResidual == 0 ){
-#endif
+      if ( (uiNoResidual == 0) || bSkipRes )
+#else
+      if ( uiNoResidual == 0 )
+#endif
+        {
             m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
             // save pred adress
@@ -2541,4 +2542,7 @@
   m_ppcRecoYuvTemp[uiDepth]->copyToPicLuma(rpcTempCU->getPic()->getPicYuvRec(), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU() );
   
+#if RWTH_SDC_DLT_B0036
+  if( !rpcTempCU->getSDCFlag( 0 ) )
+#endif
   m_pcPredSearch  ->estIntraPredChromaQT( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcRecoYuvTemp[uiDepth], uiPreCalcDistC );
   
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 177)
@@ -905,10 +905,21 @@
 #endif
 
+#if !RWTH_SDC_DLT_B0036
   if ( pcCU->getSlice()->isIntra() )
   {
     return;
   }
+#endif
 
   m_pcEntropyCoderIf->codePredMode( pcCU, uiAbsPartIdx );
+  
+#if RWTH_SDC_DLT_B0036
+  // if B-Slice, code SDC flag later
+  if( !pcCU->getSlice()->isInterB() && pcCU->getSlice()->getSPS()->isDepth() && pcCU->isIntra(uiAbsPartIdx) )
+  {
+    // encode SDC flag
+    encodeSDCFlag(pcCU, uiAbsPartIdx, bRD);
+  }
+#endif
 }
 
@@ -955,5 +966,28 @@
   }
 #endif  
+#if RWTH_SDC_DLT_B0036
+  if( !pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx)  )
+  {
+    assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+    return;
+  }
+#endif
+  
   m_pcEntropyCoderIf->codePartSize( pcCU, uiAbsPartIdx, uiDepth );
+  
+#if RWTH_SDC_DLT_B0036
+  // code SDC flag now!
+  if( pcCU->getSlice()->isInterB() && pcCU->isIntra(uiAbsPartIdx) && pcCU->getSlice()->getSPS()->isDepth() )
+  {
+    // encode SDC flag
+    encodeSDCFlag(pcCU, uiAbsPartIdx, bRD);
+    
+    if( pcCU->getSDCFlag(uiAbsPartIdx) )
+    {
+      // part size is also known for SDC intra
+      assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+    }
+  }
+#endif
 }
 
@@ -972,4 +1006,11 @@
     return;
   }
+  
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSDCFlag(uiAbsPartIdx) )
+  {
+    return;
+  }
+#endif
   
   if( bRD )
@@ -1307,4 +1348,12 @@
   }
   
+#if RWTH_SDC_DLT_B0036
+  if( pcCU->getSDCFlag(uiAbsPartIdx) )
+  {
+    encodeSDCPredMode(pcCU, uiAbsPartIdx, bRD);
+    return;
+  }
+#endif
+  
   PartSize eSize = pcCU->getPartitionSize( uiAbsPartIdx );
   
@@ -1636,4 +1685,18 @@
   UInt uiLumaTrMode, uiChromaTrMode;
   pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode );
+  
+#if RWTH_SDC_DLT_B0036
+  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 );
+    
+    encodeSDCResidualData(pcCU, uiAbsPartIdx);
+    return;
+  }
+#endif
   
   if( pcCU->isIntra(uiAbsPartIdx) )
@@ -2009,3 +2072,47 @@
 }
 
+#if RWTH_SDC_DLT_B0036
+Void TEncEntropy::encodeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  
+  if( bRD )
+    uiAbsPartIdx = 0;
+  
+  m_pcEntropyCoderIf->codeSDCPredMode(pcCU, uiAbsPartIdx);
+}
+
+Void TEncEntropy::encodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  
+  if( bRD )
+    uiAbsPartIdx = 0;
+  
+  m_pcEntropyCoderIf->codeSDCFlag(pcCU, uiAbsPartIdx);
+}
+
+Void TEncEntropy::encodeSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 );
+  assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 );
+  assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 );
+  assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 );
+  
+  if( bRD )
+    uiAbsPartIdx = 0;
+  
+  // number of segments depends on prediction mode for INTRA
+  UInt uiNumSegments = 2;
+  UInt uiLumaPredMode = pcCU->getLumaIntraDir( uiAbsPartIdx );
+  if( uiLumaPredMode == DC_IDX || uiLumaPredMode == PLANAR_IDX )
+    uiNumSegments = 1;
+  
+  // encode residual data for each segment
+  for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ )
+    m_pcEntropyCoderIf->codeSDCResidualData(pcCU, uiAbsPartIdx, uiSeg);
+}
+#endif
+
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncEntropy.h	(revision 177)
@@ -128,4 +128,10 @@
   virtual Void codePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
   
+#if RWTH_SDC_DLT_B0036
+  virtual Void codeSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+  virtual Void codeSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) = 0;
+  virtual Void codeSDCPredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+#endif
+  
 #if BURST_IPCM
   virtual Void codeIPCMInfo      ( TComDataCU* pcCU, UInt uiAbsPartIdx, Int numIPCM, Bool firstIPCMFlag) = 0;
@@ -302,4 +308,10 @@
   Void encodeScalingList       ( TComScalingList* scalingList );
   Void encodeDFParams          (TComAPS* pcAPS);
+  
+#if RWTH_SDC_DLT_B0036
+  Void encodeSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
+  Void encodeSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
+  Void encodeSDCPredMode   ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
+#endif
 
 private:
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 177)
@@ -42,4 +42,9 @@
 #include <algorithm>
 
+#if RWTH_SDC_DLT_B0036
+#define GetNumDepthValues()     (pcCU->getSlice()->getSPS()->getNumDepthValues())
+#define GetBitsPerDepthValue()  (pcCU->getSlice()->getSPS()->getBitsPerDepthValue())
+#endif
+
 //! \ingroup TLibEncoder
 //! \{
@@ -114,4 +119,11 @@
 , m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
+#endif
+#if RWTH_SDC_DLT_B0036
+, m_cSDCFlagSCModel             ( 1,             1,                 SDC_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualFlagSCModel     ( 1,             2,  SDC_NUM_RESIDUAL_FLAG_CTX  , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualSignFlagSCModel ( 1,             2,  SDC_NUM_SIGN_FLAG_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualSCModel         ( 1,             2,  SDC_NUM_RESIDUAL_CTX       , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCPredModeSCModel             ( 1,             3,                 SDC_NUM_PRED_MODE_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 {
@@ -199,4 +211,11 @@
 #endif
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+  m_cSDCResidualFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  m_cSDCResidualSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
+  m_cSDCResidualSignFlagSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG );
+  m_cSDCPredModeSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE );
+#endif
 
   // new structure
@@ -353,4 +372,11 @@
   m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
 #endif
+#if RWTH_SDC_DLT_B0036
+  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
+  m_cSDCResidualFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  m_cSDCResidualSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
+  m_cSDCResidualSignFlagSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG );
+  m_cSDCPredModeSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE );
+#endif
   
   m_pcBinIf->start();
@@ -750,4 +776,12 @@
 Void TEncSbac::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx )
 {
+#if RWTH_SDC_DLT_B0036
+  if ( pcCU->getSlice()->isIntra() )
+  {
+    assert( pcCU->isIntra(uiAbsPartIdx) );
+    return;
+  }
+#endif
+  
   // get context function is here
   Int iPredMode = pcCU->getPredictionMode( uiAbsPartIdx );
@@ -2678,3 +2712,85 @@
 }
 #endif
+
+#if RWTH_SDC_DLT_B0036
+Void TEncSbac::codeSDCPredMode( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  
+  UInt uiPredMode     = pcCU->getLumaIntraDir(uiAbsPartIdx);
+  UInt uiCtx          = 0;
+  
+  UInt uiMPModeIdx    = 0;
+  
+  for(Int i=0; i<RWTH_SDC_NUM_PRED_MODES-1; i++)
+  {
+    UInt uiBit = (uiPredMode == g_auiSDCPredModes[uiMPModeIdx]) ? 1 : 0;
+    m_pcBinIf->encodeBin( uiBit, m_cSDCPredModeSCModel.get( 0, i, uiCtx ) );
+    
+    // if mode is most probable mode, we are done here
+    if ( uiBit == 1 )
+      break;
+    
+    // else: get next most probable pred mode
+    uiMPModeIdx = (uiMPModeIdx+1)%RWTH_SDC_NUM_PRED_MODES;
+  }
+  
+#if HHI_DMM_WEDGE_INTRA
+  if( uiPredMode == DMM_WEDGE_FULL_IDX )          { xCodeWedgeFullInfo          ( pcCU, uiAbsPartIdx ); }
+  if( uiPredMode == DMM_WEDGE_PREDDIR_IDX )       { xCodeWedgePredDirInfo       ( pcCU, uiAbsPartIdx ); }
+#endif
+  
+  AOF(uiPredMode == g_auiSDCPredModes[uiMPModeIdx]);
+}
+
+Void TEncSbac::codeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  // get context function is here
+  UInt uiSymbol = pcCU->getSDCFlag( uiAbsPartIdx ) ? 1 : 0;
+  UInt uiCtxSDCFlag = pcCU->getCtxSDCFlag( uiAbsPartIdx );
+  m_pcBinIf->encodeBin( uiSymbol, m_cSDCFlagSCModel.get( 0, 0, uiCtxSDCFlag ) );
+  
+}
+
+Void TEncSbac::codeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
+{
+  assert( pcCU->getSlice()->getSPS()->isDepth() );
+  assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  assert( uiSegment < 2 );
+  
+  Pel segmentDCOffset = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
+  
+  UInt uiResidual = segmentDCOffset == 0 ? 0 : 1;
+  UInt uiSign     = segmentDCOffset < 0 ? 1 : 0;
+  UInt uiAbsIdx   = abs(segmentDCOffset);
+  UInt uiBit = 0;
+  
+  UInt uiMaxResidualBits  = GetBitsPerDepthValue();
+  assert( uiMaxResidualBits <= g_uiBitDepth );
+  
+  // residual flag
+  m_pcBinIf->encodeBin( uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection
+  
+  if (uiResidual)
+  {
+    // encode sign bit of residual
+    m_pcBinIf->encodeBin( uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) ); //TODO depthmap: more sophisticated context selection
+        
+    assert(uiAbsIdx < GetNumDepthValues());
+    
+    // encode residual magnitude
+    uiAbsIdx -= 1;
+    for (Int i=0; i<uiMaxResidualBits; i++)
+    {
+      uiBit = (uiAbsIdx & (1<<i))>>i;
+      
+      m_pcBinIf->encodeBin( uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) ); //TODO depthmap: more sophisticated context selection
+    }
+    
+  }
+}
+#endif
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSbac.h	(revision 177)
@@ -145,4 +145,10 @@
 #endif
   Void  codeScalingList      ( TComScalingList* scalingList     ){ assert (0);  return;};
+  
+#if RWTH_SDC_DLT_B0036
+  Void codeSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+  Void codeSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+  Void codeSDCPredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+#endif
 
 private:
@@ -322,4 +328,14 @@
 #endif
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+  ContextModel3DBuffer m_cSDCFlagSCModel;
+  
+  ContextModel3DBuffer m_cSDCResidualFlagSCModel;
+  ContextModel3DBuffer m_cSDCResidualSignFlagSCModel;
+  ContextModel3DBuffer m_cSDCResidualSCModel;
+  
+  ContextModel3DBuffer m_cSDCPredModeSCModel;
+#endif
 };
 
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 177)
@@ -42,4 +42,9 @@
 #include <math.h>
 
+#if RWTH_SDC_DLT_B0036
+#define GetDepthValue2Idx(val)     (pcCU->getSlice()->getSPS()->depthValue2idx(val))
+#define GetIdx2DepthValue(val)     (pcCU->getSlice()->getSPS()->idx2DepthValue(val))
+#endif
+
 //! \ingroup TLibEncoder
 //! \{
@@ -195,9 +200,7 @@
   const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + 1;
   for( Int iNum = 0; iNum < iNumAMVPCands+1; iNum++)
-  {
     for( Int iIdx = 0; iIdx < iNumAMVPCands; iIdx++)
 #else
   for( Int iNum = 0; iNum < AMVP_MAX_NUM_CANDS+1; iNum++)
-  {
     for( Int iIdx = 0; iIdx < AMVP_MAX_NUM_CANDS; iIdx++)
 #endif
@@ -208,5 +211,4 @@
         m_auiMVPIdxCost[iIdx][iNum] = MAX_INT;
     }
-  }
   
   initTempBuff();
@@ -1599,4 +1601,173 @@
 }
 
+#if RWTH_SDC_DLT_B0036
+Void TEncSearch::xIntraCodingSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual )
+{
+  UInt    uiLumaPredMode    = pcCU     ->getLumaIntraDir( uiAbsPartIdx );
+  UInt    uiWidth           = pcCU     ->getWidth   ( 0 );
+  UInt    uiHeight          = pcCU     ->getHeight  ( 0 );
+  UInt    uiStride          = pcOrgYuv ->getStride  ();
+  Pel*    piOrg             = pcOrgYuv ->getLumaAddr( uiAbsPartIdx );
+  Pel*    piPred            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  Pel*    piReco            = pcPredYuv->getLumaAddr( uiAbsPartIdx );
+  
+  UInt    uiZOrder          = pcCU->getZorderIdxInCU() + uiAbsPartIdx;
+  Pel*    piRecIPred        = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder );
+  UInt    uiRecIPredStride  = pcCU->getPic()->getPicYuvRec()->getStride  ();
+  
+  AOF( uiWidth == uiHeight );
+  AOF( uiAbsPartIdx == 0 );
+  AOF( pcCU->getSDCAvailable(uiAbsPartIdx) );
+  AOF( pcCU->getSDCFlag(uiAbsPartIdx) );
+  
+  //===== init availability pattern =====
+  Bool  bAboveAvail = false;
+  Bool  bLeftAvail  = false;
+  pcCU->getPattern()->initPattern   ( pcCU, 0, uiAbsPartIdx );
+  pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_piYuvExt, m_iYuvExtStride, m_iYuvExtHeight, bAboveAvail, bLeftAvail );
+  
+  //===== get prediction signal =====
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+  if( uiLumaPredMode >= NUM_INTRA_MODE )
+  {
+    predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, true );
+  }
+  else
+  {
+#endif
+    predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
+#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
+  }
+#endif
+  
+  // number of segments depends on prediction mode
+  UInt uiNumSegments = 1;  
+  Bool* pbMask = NULL;
+  UInt uiMaskStride = 0;
+  
+  //if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX )
+  if( 0 )
+  {
+    Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx);
+    
+    WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])];
+    TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx ));
+    
+    uiNumSegments = 2;
+    pbMask = pcWedgelet->getPattern();
+    uiMaskStride = pcWedgelet->getStride();
+  }
+  
+  // get DC prediction for each segment
+  Pel apDCPredValues[2];
+  xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride );
+  
+  // get original DC for each segment
+  Pel apDCOrigValues[2];
+  xAnalyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride );
+  
+  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
+  {
+    // remap reconstructed value to valid depth values
+    Pel pDCRec = bResidual?apDCOrigValues[uiSegment]:apDCPredValues[uiSegment];
+    
+    // get residual (idx)
+    Pel pResidualIdx = GetDepthValue2Idx( pDCRec ) - GetDepthValue2Idx( apDCPredValues[uiSegment] );
+    
+    // save SDC DC offset
+    pcCU->setSDCSegmentDCOffset(pResidualIdx, uiSegment, uiAbsPartIdx);
+  }
+  
+  // reconstruct residual based on mask + DC residuals
+  Pel apDCResiValues[2];
+  Pel apDCRecoValues[2];
+  for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
+  {
+    Pel   pPredIdx    = GetDepthValue2Idx( apDCPredValues[uiSegment] );
+    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
+    Pel   pRecoValue  = GetIdx2DepthValue( pPredIdx + pResiIdx );
+    
+    apDCRecoValues[uiSegment]  = pRecoValue;
+    apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
+  }
+  
+  //===== reconstruction =====
+  Bool* pMask     = pbMask;
+  Pel* pPred      = piPred;
+  Pel* pReco      = piReco;
+  Pel* pRecIPred  = piRecIPred;
+  
+  for( UInt uiY = 0; uiY < uiHeight; uiY++ )
+  {
+    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
+    {
+      UChar ucSegment = pMask?(UChar)pMask[uiX]:0;
+      assert( ucSegment < uiNumSegments );
+      
+      Pel pPredVal= apDCPredValues[ucSegment];
+      Pel pResiDC = apDCResiValues[ucSegment];
+      
+      pReco    [ uiX ] = Clip( pPredVal + pResiDC );
+      pRecIPred[ uiX ] = pReco[ uiX ];
+    }
+    pPred     += uiStride;
+    pReco     += uiStride;
+    pRecIPred += uiRecIPredStride;
+    pMask     += uiMaskStride;
+  }
+  
+  // clear UV
+  UInt  uiStrideC     = pcPredYuv->getCStride();
+  Pel   *pRecCb       = pcPredYuv->getCbAddr();
+  Pel   *pRecCr       = pcPredYuv->getCrAddr();
+  
+  for (Int y=0; y<uiHeight/2; y++)
+  {
+    for (Int x=0; x<uiWidth/2; x++)
+    {
+      pRecCb[x] = (Pel)(128<<g_uiBitIncrement);
+      pRecCr[x] = (Pel)(128<<g_uiBitIncrement);
+    }
+    
+    pRecCb += uiStrideC;
+    pRecCr += uiStrideC;
+  }
+  
+  //===== determine distortion =====
+#if HHI_VSO
+  if ( m_pcRdCost->getUseVSO() )
+  {
+    ruiDist = m_pcRdCost->getDistVS  ( pcCU, uiAbsPartIdx, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, false, 0 );
+  }
+  else
+#endif
+  {
+    ruiDist = m_pcRdCost->getDistPart( piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight );
+  }
+  
+  //----- determine rate and r-d cost -----
+  m_pcEntropyCoder->resetBits();
+
+  // encode reduced intra header
+  m_pcEntropyCoder->encodeSkipFlag( pcCU, 0, true );
+  m_pcEntropyCoder->encodePredMode( pcCU, 0, true );
+  
+  // encode pred direction + residual data
+  m_pcEntropyCoder->encodePredInfo( pcCU, 0, true );
+  
+  UInt   uiBits = m_pcEntropyCoder->getNumberOfWrittenBits();
+  
+#if HHI_VSO
+  if ( m_pcRdCost->getUseLambdaScaleVSO())
+  {
+    dRDCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );
+  }
+  else
+#endif
+  {
+    dRDCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
+  }
+}
+#endif
 
 Void
@@ -2107,4 +2278,8 @@
     UInt    uiBestPUDistC = 0;
     Double  dBestPUCost   = MAX_DOUBLE;
+#if RWTH_SDC_DLT_B0036
+    Bool    bBestUseSDC   = false;
+    Pel     apBestDCOffsets[2] = {0,0};
+#endif
     for( UInt uiMode = 0; uiMode < numModesForFullRD; uiMode++ )
     {
@@ -2127,4 +2302,13 @@
         continue;
       }
+#endif
+      
+#if RWTH_SDC_DLT_B0036
+      UInt uiUseSDC = ( m_pcEncCfg->getUseSDC() && pcCU->getPartitionSize(uiPartOffset) == SIZE_2Nx2N )?1:0;
+      
+      for( UInt uiSDC=0; uiSDC<=uiUseSDC; uiSDC++ )
+      {
+        for( UInt uiRes = 0; uiRes<=uiUseSDC; uiRes++ )
+        {
 #endif
 
@@ -2150,5 +2334,22 @@
       }
 #endif
-
+#if RWTH_SDC_DLT_B0036
+          // last check: if not available for current intra prediction mode, don't try
+          if( uiSDC == 1 && !pcCU->getSDCAvailable(uiPartOffset) )
+            continue;
+          
+          pcCU->setSDCFlagSubParts( uiSDC == 1, uiPartOffset, 0, uiDepth + uiInitTrDepth );
+          
+          if(uiSDC == 1)
+          {
+            pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
+            pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
+            
+            // start encoding with SDC
+            xIntraCodingSDC(pcCU, uiPartOffset, pcOrgYuv, pcPredYuv, uiPUDistY, dPUCost, (uiRes==1));
+          }
+          else
+          {
+#endif
 #if HHI_RQT_INTRA_SPEEDUP
 #if LG_ZEROINTRADEPTHRESI_M26039
@@ -2159,4 +2360,7 @@
 #else
       xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, dPUCost );
+#endif
+#if RWTH_SDC_DLT_B0036
+          }
 #endif
       
@@ -2172,4 +2376,97 @@
         uiBestPUDistC = uiPUDistC;
         dBestPUCost   = dPUCost;
+        
+#if RWTH_SDC_DLT_B0036
+        if( uiSDC == 1 )
+        {
+          bBestUseSDC = true;
+          
+          // copy reconstruction
+          pcPredYuv->copyPartToPartYuv(pcRecoYuv, uiPartOffset, uiWidth, uiHeight);
+          
+          // copy DC values
+          apBestDCOffsets[0] = pcCU->getSDCSegmentDCOffset(0, uiPartOffset);
+          apBestDCOffsets[1] = pcCU->getSDCSegmentDCOffset(1, uiPartOffset);
+        }
+        else
+        {
+          bBestUseSDC = false;
+#endif
+        
+        xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
+        
+        UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
+        ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+        ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+        ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+        ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
+#if RWTH_SDC_DLT_B0036
+        }
+#endif
+      }
+#if HHI_RQT_INTRA_SPEEDUP_MOD
+      else if( dPUCost < dSecondBestPUCost )
+      {
+        uiSecondBestMode  = uiOrgMode;
+        dSecondBestPUCost = dPUCost;
+      }
+#endif
+#if LG_ZEROINTRADEPTHRESI_M26039
+    }
+#endif
+#if RWTH_SDC_DLT_B0036
+      } // SDC residual loop
+    } // SDC loop
+#endif
+    } // Mode loop
+    
+#if HHI_RQT_INTRA_SPEEDUP
+#if HHI_RQT_INTRA_SPEEDUP_MOD
+    for( UInt ui =0; ui < 2; ++ui )
+#endif
+    {
+#if HHI_RQT_INTRA_SPEEDUP_MOD
+      UInt uiOrgMode   = ui ? uiSecondBestMode  : uiBestPUMode;
+      if( uiOrgMode == MAX_UINT )
+      {
+        break;
+      }
+#else
+      UInt uiOrgMode = uiBestPUMode;
+#endif
+      
+      pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
+      
+      // set context models
+      if( m_bUseSBACRD )
+      {
+        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
+      }
+      
+      // determine residual for partition
+      Dist   uiPUDistY = 0;
+      Dist   uiPUDistC = 0;
+      Double dPUCost   = 0.0;
+
+#if HHI_VSO
+      // reset Model
+      if( m_pcRdCost->getUseRenModel() )
+      {
+        m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
+      }
+#endif
+
+      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost );
+      
+      // check r-d cost
+      if( dPUCost < dBestPUCost )
+      {
+        uiBestPUMode  = uiOrgMode;
+        uiBestPUDistY = uiPUDistY;
+        uiBestPUDistC = uiPUDistC;
+        dBestPUCost   = dPUCost;
+#if RWTH_SDC_DLT_B0036
+        bBestUseSDC   = false;
+#endif
         
         xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
@@ -2182,71 +2479,4 @@
         
       }
-#if HHI_RQT_INTRA_SPEEDUP_MOD
-      else if( dPUCost < dSecondBestPUCost )
-      {
-        uiSecondBestMode  = uiOrgMode;
-        dSecondBestPUCost = dPUCost;
-      }
-#endif
-#if LG_ZEROINTRADEPTHRESI_M26039
-    }
-#endif
-    } // Mode loop
-    
-#if HHI_RQT_INTRA_SPEEDUP
-#if HHI_RQT_INTRA_SPEEDUP_MOD
-    for( UInt ui =0; ui < 2; ++ui )
-#endif
-    {
-#if HHI_RQT_INTRA_SPEEDUP_MOD
-      UInt uiOrgMode   = ui ? uiSecondBestMode  : uiBestPUMode;
-      if( uiOrgMode == MAX_UINT )
-      {
-        break;
-      }
-#else
-      UInt uiOrgMode = uiBestPUMode;
-#endif
-      
-      pcCU->setLumaIntraDirSubParts ( uiOrgMode, uiPartOffset, uiDepth + uiInitTrDepth );
-      
-      // set context models
-      if( m_bUseSBACRD )
-      {
-        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[uiDepth][CI_CURR_BEST] );
-      }
-      
-      // determine residual for partition
-      Dist   uiPUDistY = 0;
-      Dist   uiPUDistC = 0;
-      Double dPUCost   = 0.0;
-
-#if HHI_VSO
-      // reset Model
-      if( m_pcRdCost->getUseRenModel() )
-      {
-        m_pcRdCost->setRenModelData( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight );
-      }
-#endif
-
-      xRecurIntraCodingQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcOrgYuv, pcPredYuv, pcResiYuv, uiPUDistY, uiPUDistC, false, dPUCost );
-      
-      // check r-d cost
-      if( dPUCost < dBestPUCost )
-      {
-        uiBestPUMode  = uiOrgMode;
-        uiBestPUDistY = uiPUDistY;
-        uiBestPUDistC = uiPUDistC;
-        dBestPUCost   = dPUCost;
-        
-        xSetIntraResultQT( pcCU, uiInitTrDepth, uiPartOffset, bLumaOnly, pcRecoYuv );
-        
-        UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth(0) + uiInitTrDepth ) << 1 );
-        ::memcpy( m_puhQTTempTrIdx,  pcCU->getTransformIdx()       + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-        ::memcpy( m_puhQTTempCbf[0], pcCU->getCbf( TEXT_LUMA     ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-        ::memcpy( m_puhQTTempCbf[1], pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-        ::memcpy( m_puhQTTempCbf[2], pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, uiQPartNum * sizeof( UChar ) );
-        
-      }
     } // Mode loop
 #endif
@@ -2255,4 +2485,18 @@
     uiOverallDistY += uiBestPUDistY;
     uiOverallDistC += uiBestPUDistC;
+    
+#if RWTH_SDC_DLT_B0036
+    if( bBestUseSDC )
+    {
+      pcCU->setTrIdxSubParts(0, uiPartOffset, uiDepth + uiInitTrDepth);
+      pcCU->setCbfSubParts(1, 1, 1, uiPartOffset, uiDepth + uiInitTrDepth);
+      
+      //=== copy best DC segment values back to CU ====
+      pcCU->setSDCSegmentDCOffset(apBestDCOffsets[0], 0, uiPartOffset);
+      pcCU->setSDCSegmentDCOffset(apBestDCOffsets[1], 1, uiPartOffset);
+    }
+    else
+    {
+#endif
     
     //--- update transform index and cbf ---
@@ -2262,4 +2506,7 @@
     ::memcpy( pcCU->getCbf( TEXT_CHROMA_U ) + uiPartOffset, m_puhQTTempCbf[1], uiQPartNum * sizeof( UChar ) );
     ::memcpy( pcCU->getCbf( TEXT_CHROMA_V ) + uiPartOffset, m_puhQTTempCbf[2], uiQPartNum * sizeof( UChar ) );
+#if RWTH_SDC_DLT_B0036
+    }
+#endif
     
     //--- set reconstruction for next intra prediction blocks ---
@@ -2332,4 +2579,7 @@
     //=== update PU data ====
     pcCU->setLumaIntraDirSubParts     ( uiBestPUMode, uiPartOffset, uiDepth + uiInitTrDepth );
+#if RWTH_SDC_DLT_B0036
+    pcCU->setSDCFlagSubParts          ( bBestUseSDC, uiPartOffset, 0, uiDepth + uiInitTrDepth );
+#endif
     pcCU->copyToPic                   ( uiDepth, uiPU, uiInitTrDepth );
   } // PU loop
@@ -7817,4 +8067,38 @@
 #endif
 #endif
+  
+#if RWTH_SDC_DLT_B0036
+Void TEncSearch::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride )
+{
+  Int iSumDepth[uiNumSegments];
+  memset(iSumDepth, 0, sizeof(Int)*uiNumSegments);
+  Int iSumPix[uiNumSegments];
+  memset(iSumPix, 0, sizeof(Int)*uiNumSegments);
+  
+  for (Int y=0; y<uiSize; y++)
+  {
+    for (Int x=0; x<uiSize; x++)
+    {
+      UChar ucSegment = pMask?(UChar)pMask[x]:0;
+      assert( ucSegment < uiNumSegments );
+      
+      iSumDepth[ucSegment] += pOrig[x];
+      iSumPix[ucSegment]   += 1;
+    }
+    
+    pOrig  += uiStride;
+    pMask  += uiMaskStride;
+  }
+  
+  // compute mean for each segment
+  for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ )
+  {
+    if( iSumPix[ucSeg] > 0 )
+      rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg];
+    else
+      rpSegMeans[ucSeg] = 0;  // this happens for zero-segments
+  }
+}
+#endif
 
 //! \}
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.h	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncSearch.h	(revision 177)
@@ -307,4 +307,16 @@
                                     UInt         uiAbsPartIdx,
                                     TComYuv*     pcRecoYuv );
+  
+#if RWTH_SDC_DLT_B0036
+  Void  xAnalyzeSegmentsSDC       ( Pel* pOrig,
+                                   UInt uiStride,
+                                   UInt uiSize,
+                                   Pel* rpSegMeans,
+                                   UInt uiNumSegments,
+                                   Bool* pMask,
+                                   UInt uiMaskStride );
+  
+  Void  xIntraCodingSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, Dist& ruiDist, Double& dRDCost, Bool bResidual );
+#endif
   
   // -------------------------------------------------------------------------------------------------------------------
Index: /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncTop.cpp	(revision 176)
+++ /branches/HTM-4.1-dev2-RWTH/source/Lib/TLibEncoder/TEncTop.cpp	(revision 177)
@@ -648,4 +648,8 @@
 #endif
   
+#if RWTH_SDC_DLT_B0036
+  m_cSPS.setUseDLT        ( m_bUseDLT );
+#endif
+  
   m_cSPS.setQuadtreeTULog2MaxSize( m_uiQuadtreeTULog2MaxSize );
   m_cSPS.setQuadtreeTULog2MinSize( m_uiQuadtreeTULog2MinSize );
