Index: /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_2view+depth.cfg
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 571)
@@ -209,4 +209,5 @@
 QTL                                : 1
 PC                                 : 1
+InterSDC                           : 1                             # use of inter sdc
 
 #========== view synthesis optimization (VSO) ==========
Index: /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_3view+depth.cfg
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 571)
@@ -241,4 +241,5 @@
 QTL                                : 1
 PC                                 : 1
+InterSDC                           : 1                             # use of inter sdc
 
 #========== view synthesis optimization (VSO) ==========
Index: /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/fullCfg.cfg
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/fullCfg.cfg	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/cfg/3D-HEVC/fullCfg.cfg	(revision 571)
@@ -245,4 +245,5 @@
 QTL                                : 1
 PC                                 : 1
+InterSDC                           : 1                             # use of inter sdc
 
 #========== view synthesis optimization (VSO) ==========
Index: /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 571)
@@ -505,4 +505,7 @@
 #if H_3D_IC
   ("IlluCompEnable",           m_abUseIC, std::vector<Bool>(2, true), "Enable illumination compensation")
+#endif
+#if LGE_INTER_SDC_E0156
+  ("InterSDC",                 m_bDepthInterSDCFlag,        true, "Enable depth inter SDC")
 #endif
   // Coding tools
@@ -2289,4 +2292,7 @@
   printf("DLT:%d ", m_useDLT );
 #endif
+#if LGE_INTER_SDC_E0156
+  printf( "interSDC: %d ", m_bDepthInterSDCFlag ? 1 : 0 );
+#endif
   printf("\n\n");  
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncCfg.h	(revision 571)
@@ -432,4 +432,7 @@
   Bool      m_bUsePC;                                         ///< flag for using Predictive Coding with QTL
 #endif
+#if LGE_INTER_SDC_E0156
+  Bool m_bDepthInterSDCFlag;                                ///< flag for inter SDC of depth map coding
+#endif
 #endif
   // internal member functions
Index: /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncTop.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/App/TAppEncoder/TAppEncTop.cpp	(revision 571)
@@ -187,4 +187,8 @@
     m_cTEncTop.setUseQTL                       ( isDepth ? m_bUseQTL               : false );
     m_cTEncTop.setUsePC                        ( isDepth ? m_bUsePC                : false );
+#endif
+    //====== Depth Inter SDC =========
+#if LGE_INTER_SDC_E0156
+    m_cTEncTop.setInterSDCEnable               ( isDepth ? m_bDepthInterSDCFlag    : false );
 #endif
 #endif // H_3D
@@ -1224,5 +1228,8 @@
 #if H_3D_VSP
     vps.setViewSynthesisPredFlag( layer, !isLayerZero && !isDepth && m_viewSynthesisPredFlag );         
-#endif      
+#endif   
+#if LGE_INTER_SDC_E0156
+    vps.setInterSDCFlag( layer, !isLayerZero && isDepth && m_bDepthInterSDCFlag );
+#endif
   }  
 #if H_3D_TMVP
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/ContextTables.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/ContextTables.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/ContextTables.h	(revision 571)
@@ -124,4 +124,10 @@
 #define SDC_NUM_RESIDUAL_CTX             1
 #endif
+
+#if LGE_INTER_SDC_E0156
+#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
 // ====================================================================================================================
 // Tables
@@ -453,4 +459,29 @@
 #endif
 
+#if LGE_INTER_SDC_E0156
+static const UChar 
+INIT_INTER_SDC_FLAG[3][NUM_INTER_SDC_FLAG_CTX] =
+{
+  { CNU },  
+  { 154 },
+  { 154 },
+};
+
+static const UChar 
+INIT_INTER_SDC_SIGN_FLAG[3][NUM_INTER_SDC_SIGN_FLAG_CTX] =
+{
+  { CNU },  
+  { 154 },
+  { 154 },
+};
+
+static const UChar 
+INIT_INTER_SDC_RESIDUAL[3][NUM_INTER_SDC_RESIDUAL_CTX] =
+{
+  { CNU },  
+  { 154 },
+  { 154 },
+};
+#endif
 //! \}
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.cpp	(revision 571)
@@ -151,4 +151,12 @@
   m_pbICFlag             = NULL;
 #endif
+#if LGE_INTER_SDC_E0156
+  m_pbInterSDCFlag       = NULL;
+  for( Int i = 0; i < 4; i++ )
+  {
+    m_apSegmentInterDCOffset[i] = NULL;
+  }
+  m_pucInterSDCMask       = NULL;
+#endif
 }
 
@@ -280,4 +288,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+    m_pbInterSDCFlag     = (Bool*  )xMalloc(Bool,   uiNumPartition);
+    for( Int i = 0; i < 4; i++ )
+      m_apSegmentInterDCOffset[i] = (Int*)xMalloc(Int, uiNumPartition);
+#endif
   }
   else
@@ -286,5 +299,7 @@
     m_acCUMvField[1].setNumPartition(uiNumPartition );
   }
-  
+#if LGE_INTER_SDC_E0156
+  m_pucInterSDCMask     = (UChar*  )xMalloc(UChar,    g_uiMaxCUHeight*g_uiMaxCUWidth);
+#endif
   m_sliceStartCU        = (UInt*  )xMalloc(UInt, uiNumPartition);
   m_sliceSegmentStartCU = (UInt*  )xMalloc(UInt, uiNumPartition);
@@ -405,6 +420,15 @@
 #endif
 #endif    
-  }
-  
+#if LGE_INTER_SDC_E0156
+    if ( m_pbInterSDCFlag     ) { xFree(m_pbInterSDCFlag);      m_pbInterSDCFlag    = NULL; }
+    for(Int i = 0; i < 4; i++ )
+    {
+      if ( m_apSegmentInterDCOffset[i] ) { xFree( m_apSegmentInterDCOffset[i] ); m_apSegmentInterDCOffset[i] = NULL; }
+    }
+#endif
+  }
+#if LGE_INTER_SDC_E0156
+  if ( m_pucInterSDCMask     ) { xFree(m_pucInterSDCMask);      m_pucInterSDCMask    = NULL; }
+#endif
   m_pcCUAboveLeft       = NULL;
   m_pcCUAboveRight      = NULL;
@@ -542,4 +566,7 @@
 #if H_3D_DIM_SDC
     m_pbSDCFlag[ui] = pcFrom->m_pbSDCFlag[ui];
+#endif
+#if LGE_INTER_SDC_E0156
+    m_pbInterSDCFlag[ui] = pcFrom->m_pbInterSDCFlag[ui];
 #endif
   }
@@ -611,4 +638,11 @@
     memset( m_apSegmentDCOffset[1]  + firstElement,     0,                numElements * sizeof( *m_apSegmentDCOffset[1] ) );
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+    memset( m_pbInterSDCFlag   + firstElement,     0,                    numElements * sizeof( *m_pbInterSDCFlag ) );
+    for( Int i = 0; i < 4; i++ )
+    {
+      memset( m_apSegmentInterDCOffset[i] + firstElement,     0,         numElements * sizeof( *m_apSegmentInterDCOffset[i] ) );
+    }
 #endif
   }
@@ -776,4 +810,11 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+      m_pbInterSDCFlag[ui] = false;
+      for( Int i = 0; i < 4; i++ )
+      {
+        m_apSegmentInterDCOffset[i][ui] = 0;
+      }
+#endif
     }
   }
@@ -887,4 +928,11 @@
   memset( m_apSegmentDCOffset[1], 0, sizeof(Pel) * m_uiNumPartition   );
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+  memset( m_pbInterSDCFlag,           0, sizeof( Bool ) * m_uiNumPartition );
+  for( Int i = 0; i < 4; i++ )
+  {
+    memset( m_apSegmentInterDCOffset[i], 0, sizeof( Int ) * m_uiNumPartition );
+  }
 #endif
 
@@ -956,4 +1004,11 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+      m_pbInterSDCFlag      [ui] = pcCU->m_pbInterSDCFlag    [ uiPartOffset + ui ];
+      for( Int i = 0; i < 4; i++ )
+      {
+        m_apSegmentInterDCOffset[i][ui] = pcCU->m_apSegmentInterDCOffset[i][ uiPartOffset + ui ];
+      }
+#endif
     }
   }
@@ -1111,4 +1166,11 @@
 #endif
 #endif  
+#if LGE_INTER_SDC_E0156
+  m_pbInterSDCFlag          = pcCU->getInterSDCFlag()       + uiPart;
+  for( Int i = 0; i < 4; i++ )
+  {
+    m_apSegmentInterDCOffset[i] = pcCU->getInterSDCSegmentDCOffset( i ) + uiPart;
+  }
+#endif
   m_puhDepth=pcCU->getDepth()                     + uiPart;
   m_puhWidth=pcCU->getWidth()                     + uiPart;
@@ -1298,4 +1360,11 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  memcpy( m_pbInterSDCFlag  + uiOffset, pcCU->getInterSDCFlag(),      iSizeInBool  );
+  for( Int i = 0; i < 4; i++ )
+  {
+    memcpy( m_apSegmentInterDCOffset[i] + uiOffset, pcCU->getInterSDCSegmentDCOffset( i ), sizeof( Int ) * uiNumPartition);
+  }
+#endif
 
   memcpy( m_puhDepth  + uiOffset, pcCU->getDepth(),  iSizeInUchar );
@@ -1417,4 +1486,11 @@
   memcpy( rpcCU->getSDCSegmentDCOffset(1) + m_uiAbsIdxInLCU, m_apSegmentDCOffset[1], sizeof( Pel ) * m_uiNumPartition);
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+  memcpy( rpcCU->getInterSDCFlag() + m_uiAbsIdxInLCU, m_pbInterSDCFlag,      iSizeInBool  );
+  for( Int i = 0;i < 4; i++ )
+  {
+    memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + m_uiAbsIdxInLCU, m_apSegmentInterDCOffset[i], sizeof( Int ) * m_uiNumPartition);
+  }
 #endif
   memcpy( rpcCU->getDepth()  + m_uiAbsIdxInLCU, m_puhDepth,  iSizeInUchar );
@@ -1525,4 +1601,11 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  memcpy( rpcCU->getInterSDCFlag() + uiPartOffset, m_pbInterSDCFlag,      iSizeInBool  );
+  for( Int i = 0; i < 4; i++ )
+  {
+    memcpy( rpcCU->getInterSDCSegmentDCOffset( i ) + uiPartOffset, m_apSegmentInterDCOffset[i], sizeof( Int ) * uiQNumPart);
+  }
+#endif
   memcpy( rpcCU->getDepth()  + uiPartOffset, m_puhDepth,  iSizeInUchar );
   memcpy( rpcCU->getWidth()  + uiPartOffset, m_puhWidth,  iSizeInUchar );
@@ -2238,4 +2321,114 @@
 }
 #endif
+
+#if LGE_INTER_SDC_E0156
+Void TComDataCU::setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
+{
+  setSubPart( bInterSDCFlag, m_pbInterSDCFlag, uiAbsPartIdx, uiDepth, uiPartIdx );
+}
+
+UInt TComDataCU::getCtxInterSDCFlag( UInt uiAbsPartIdx )
+{
+  return 0;
+}
+
+Void TComDataCU::xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask )
+{
+  UInt  uiWidth      = pcCU->getWidth ( 0 );
+  UInt  uiHeight     = pcCU->getHeight( 0 );
+  UInt  uiPartitionSize = pcCU->getPartitionSize( 0 );
+  UInt  uiXOffset = 0, uiYOffset = 0;
+
+  switch( uiPartitionSize )
+  {
+  case SIZE_2NxN:
+    uiXOffset = uiWidth;      uiYOffset = uiHeight >> 1;   break;
+  case SIZE_2NxnU:
+    uiXOffset = uiWidth;      uiYOffset = uiHeight >> 2;   break;
+  case SIZE_2NxnD: 
+    uiXOffset = uiWidth;      uiYOffset = ( uiHeight >> 1 ) + ( uiHeight >> 2 );   break;
+  case SIZE_Nx2N:
+    uiXOffset = uiWidth >> 1; uiYOffset = uiHeight; break;
+  case SIZE_nLx2N:
+    uiXOffset = uiWidth >> 2; uiYOffset = uiHeight; break;
+  case SIZE_nRx2N:
+    uiXOffset = ( uiWidth >> 1 ) + ( uiWidth >> 2 ); uiYOffset = uiHeight; break;
+  case SIZE_NxN:
+    uiXOffset = uiWidth >> 1; uiYOffset = uiHeight >> 1;  break;
+  default:
+    assert( uiPartitionSize == SIZE_2Nx2N );
+    uiXOffset = uiWidth;     uiYOffset = uiHeight;    break;
+  }
+
+  UInt uiPelX, uiPelY;
+
+  memset( pMask, 0, uiWidth*uiHeight );
+
+  //mask
+  if( uiPartitionSize == SIZE_2NxN || uiPartitionSize == SIZE_2NxnD || uiPartitionSize == SIZE_2NxnU )
+  {
+    for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ )
+    {
+      for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 0;
+      }
+    }
+
+    for( ; uiPelY < uiHeight; uiPelY++ )
+    {
+      for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 1;
+      }
+    }
+  }
+  else if( uiPartitionSize == SIZE_Nx2N || uiPartitionSize == SIZE_nLx2N || uiPartitionSize == SIZE_nRx2N )
+  {
+    for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
+    {
+      for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 0;
+      }
+
+      for( ; uiPelX < uiWidth; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 1;
+      }
+    }
+  }
+  else if( uiPartitionSize == SIZE_NxN )
+  {
+    for( uiPelY = 0; uiPelY < uiYOffset; uiPelY++ )
+    {
+      for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 0;
+      }
+
+      for( ; uiPelX < uiWidth; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 1;
+      }
+    }
+
+    for( ; uiPelY < uiHeight; uiPelY++ )
+    {
+      for( uiPelX = 0; uiPelX < uiXOffset; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 2;
+      }
+
+      for( ; uiPelX < uiWidth; uiPelX++ )
+      {
+        pMask[uiPelX + uiPelY*uiWidth] = 3;
+      }
+    }
+  }
+
+}
+#endif
+
 UInt TComDataCU::getCtxInterDir( UInt uiAbsPartIdx )
 {
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComDataCU.h	(revision 571)
@@ -223,4 +223,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  Bool*         m_pbInterSDCFlag;
+  Int*          m_apSegmentInterDCOffset[4];
+  UChar*        m_pucInterSDCMask;
+#endif
 
   // -------------------------------------------------------------------------------------------------------------------
@@ -565,4 +570,17 @@
   Void          setSDCSegmentDCOffset( Pel pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentDCOffset[uiSeg][uiPartIdx] = pOffset; }
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+  Bool*         getInterSDCFlag     ()                        { return m_pbInterSDCFlag;               }
+  Bool          getInterSDCFlag     ( UInt uiIdx )            { return m_pbInterSDCFlag[uiIdx];        }
+  Void          setInterSDCFlagSubParts ( Bool bInterSDCFlag, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
+  UInt          getCtxInterSDCFlag  ( UInt uiAbsPartIdx );
+  Int*          getInterSDCSegmentDCOffset( UInt uiSeg ) { return m_apSegmentInterDCOffset[uiSeg]; }
+  Int           getInterSDCSegmentDCOffset( UInt uiSeg, UInt uiPartIdx ) { return m_apSegmentInterDCOffset[uiSeg][uiPartIdx]; }
+  Void          setInterSDCSegmentDCOffset( Int pOffset, UInt uiSeg, UInt uiPartIdx) { m_apSegmentInterDCOffset[uiSeg][uiPartIdx] = pOffset; }
+
+  Void          xSetInterSDCCUMask( TComDataCU *pcCU, UChar *pMask );
+
+  UChar*        getInterSDCMask     ()                        { return m_pucInterSDCMask;              }
 #endif
   
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComPattern.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComPattern.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComPattern.h	(revision 571)
@@ -102,4 +102,7 @@
   Bool              m_bICFlag;
 #endif
+#if LGE_INTER_SDC_E0156
+  Bool              m_bSDCMRSADFlag;
+#endif
   static const UChar m_aucIntraFilter[5];
   
@@ -115,4 +118,8 @@
   Bool  getICFlag()               { return m_bICFlag; }
   Void  setICFlag( Bool bICFlag ) { m_bICFlag = bICFlag; }
+#endif
+#if LGE_INTER_SDC_E0156
+  Bool  getSDCMRSADFlag()         { return m_bSDCMRSADFlag; }
+  Void  setSDCMRSADFlag( Bool bSDCMRSADFlag )    { m_bSDCMRSADFlag = bSDCMRSADFlag; }
 #endif
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.cpp	(revision 571)
@@ -505,4 +505,7 @@
   cDtParam.bUseIC       = false;
 #endif
+#if LGE_INTER_SDC_E0156
+  cDtParam.bUseSDCMRSAD = false;
+#endif
 #if WEIGHTED_CHROMA_DISTORTION
   if (eText == TEXT_CHROMA_U)
@@ -608,4 +611,10 @@
   }
 #endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
+  {
+    return xGetSADic( pcDtParam );
+  }
+#endif
   Pel* piOrg   = pcDtParam->pOrg;
   Pel* piCur   = pcDtParam->pCur;
@@ -638,4 +647,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD4ic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD4ic( pcDtParam );
@@ -675,4 +690,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD8ic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD8ic( pcDtParam );
@@ -716,4 +737,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD16ic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD16ic( pcDtParam );
@@ -770,4 +797,10 @@
   }
 #endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
+  {
+    return xGetSAD12ic( pcDtParam );
+  }
+#endif
   Pel* piOrg   = pcDtParam->pOrg;
   Pel* piCur   = pcDtParam->pCur;
@@ -808,4 +841,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD16Nic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD16Nic( pcDtParam );
@@ -860,4 +899,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD32ic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD32ic( pcDtParam );
@@ -930,4 +975,10 @@
   }
 #endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
+  {
+    return xGetSAD24ic( pcDtParam );
+  }
+#endif
   Pel* piOrg   = pcDtParam->pOrg;
   Pel* piCur   = pcDtParam->pCur;
@@ -985,4 +1036,10 @@
 #if H_3D_IC
   if( pcDtParam->bUseIC )
+  {
+    return xGetSAD64ic( pcDtParam );
+  }
+#endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
   {
     return xGetSAD64ic( pcDtParam );
@@ -1087,4 +1144,10 @@
   }
 #endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
+  {
+    return xGetSAD48ic( pcDtParam );
+  }
+#endif
   Pel* piOrg   = pcDtParam->pOrg;
   Pel* piCur   = pcDtParam->pCur;
@@ -3409,4 +3472,10 @@
   }
 #endif
+#if LGE_INTER_SDC_E0156
+  if( pcDtParam->bUseSDCMRSAD )
+  {
+    return xGetHADsic( pcDtParam );
+  }
+#endif
   Pel* piOrg   = pcDtParam->pOrg;
   Pel* piCur   = pcDtParam->pCur;
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComRdCost.h	(revision 571)
@@ -94,4 +94,7 @@
   Bool  bUseIC;
 #endif
+#if LGE_INTER_SDC_E0156
+  Bool  bUseSDCMRSAD;
+#endif
   Int   iRows;
   Int   iCols;
@@ -132,4 +135,7 @@
     pVirOrg = NULL;
     iStrideVir = 0;
+#endif
+#if LGE_INTER_SDC_E0156
+    bUseSDCMRSAD = false;
 #endif
   }
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.cpp	(revision 571)
@@ -1540,4 +1540,7 @@
 #if H_3D_NBDV_REF
     m_depthRefinementFlag  [ i ] = false;
+#endif
+#if LGE_INTER_SDC_E0156
+    m_bInterSDCFlag        [ i ] = false;
 #endif
   }  
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TComSlice.h	(revision 571)
@@ -507,4 +507,7 @@
   Bool        m_ivMvScalingFlag; 
 #endif
+#if LGE_INTER_SDC_E0156
+  Bool        m_bInterSDCFlag[MAX_NUM_LAYERS   ];
+#endif
 
 #endif
@@ -716,4 +719,8 @@
   Bool    getIvMvScalingFlag   (  )                       { return m_ivMvScalingFlag; }
   Void    setIvMvScalingFlag   ( Bool b )                 { m_ivMvScalingFlag = b;    }  
+#endif
+#if LGE_INTER_SDC_E0156
+  Bool    getInterSDCFlag      ( Int layerIdInVps )           { return m_bInterSDCFlag[layerIdInVps]; }
+  Void    setInterSDCFlag      ( Int layerIdInVps, Bool bval ){ m_bInterSDCFlag[layerIdInVps] = bval; }
 #endif
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TypeDef.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibCommon/TypeDef.h	(revision 571)
@@ -100,4 +100,5 @@
 #define MTK_CLIPPING_ALIGN_IC_E0168       1   // To support simplify bi-prediction PU with identical motion checking, JCT3V-E0168
 #define MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170            1   // Progressive MV Compression, JCT3V-E0170
+#define LGE_INTER_SDC_E0156               1   // Enable inter SDC for depth coding
 
 #if H_3D_NBDV
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 571)
@@ -1073,4 +1073,7 @@
             }
 #endif
+#if LGE_INTER_SDC_E0156
+            READ_FLAG( uiCode, "depth_inter_SDC_flag" );              pcVPS->setInterSDCFlag( i, uiCode ? true : false );
+#endif
           }
         }
@@ -2033,4 +2036,15 @@
 }
 #endif
+#if LGE_INTER_SDC_E0156
+Void TDecCavlc::parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  assert(0);
+}
+
+Void TDecCavlc::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart )
+{
+  assert(0);
+}
+#endif
 // ====================================================================================================================
 // Protected member functions
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 571)
@@ -102,4 +102,8 @@
   Void  parseICFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
+#if LGE_INTER_SDC_E0156
+  Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
   Void parseSplitFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void parsePartSize        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.cpp	(revision 571)
@@ -421,4 +421,7 @@
   m_pcEntropyDecoder->decodeARPW    ( pcCU , uiAbsPartIdx , uiDepth );  
 #endif  
+#if LGE_INTER_SDC_E0156
+  m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
+#endif
   // Coefficient decoding
   Bool bCodeDQP = getdQPFlag();
@@ -485,4 +488,9 @@
   {
     case MODE_INTER:
+#if LGE_INTER_SDC_E0156
+      if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) )
+        xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
+      else
+#endif
       xReconInter( m_ppcCU[uiDepth], uiDepth );
       break;
@@ -526,4 +534,54 @@
   }
 }
+
+#if LGE_INTER_SDC_E0156
+Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  // inter prediction
+  m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
+
+  UInt  uiWidth      = pcCU->getWidth ( 0 );
+  UInt  uiHeight     = pcCU->getHeight( 0 );
+  UChar* pMask       = pcCU->getInterSDCMask();
+
+  memset( pMask, 0, uiWidth*uiHeight );
+  pcCU->xSetInterSDCCUMask( pcCU, pMask );
+
+  Pel  *pResi;
+  UInt uiPelX, uiPelY;
+  UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride();
+
+  pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 );
+  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
+  {
+    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
+    {
+      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
+
+      pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );;
+    }
+    pResi += uiResiStride;
+  }
+
+  m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
+
+  // clear UV
+  UInt  uiStrideC     = m_ppcYuvReco[uiDepth]->getCStride();
+  Pel   *pRecCb       = m_ppcYuvReco[uiDepth]->getCbAddr();
+  Pel   *pRecCr       = m_ppcYuvReco[uiDepth]->getCrAddr();
+
+  for (Int y = 0; y < uiHeight/2; y++)
+  {
+    for (Int x = 0; x < uiWidth/2; x++)
+    {
+      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
+      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
+    }
+
+    pRecCb += uiStrideC;
+    pRecCr += uiStrideC;
+  }
+}
+#endif
 
 Void
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecCu.h	(revision 571)
@@ -118,4 +118,7 @@
   Void xReconIntraSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
+#if LGE_INTER_SDC_E0156
+  Void xReconInterSDC           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
 };
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.cpp	(revision 571)
@@ -635,4 +635,16 @@
 #endif
   
+#if LGE_INTER_SDC_E0156
+  if( pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+  {
+    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
+    assert( !pcCU->isIntra( uiAbsPartIdx) );
+    assert( pcCU->getSlice()->getIsDepth() );
+
+    decodeInterSDCResidualData( pcCU, uiAbsPartIdx, uiDepth );
+    return;
+  }
+#endif
+
   if( pcCU->isIntra(uiAbsPartIdx) )
   {
@@ -656,3 +668,33 @@
 }
 
+#if LGE_INTER_SDC_E0156
+Void TDecEntropy::decodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  pcCU->setInterSDCFlagSubParts( false, uiAbsPartIdx, 0, uiDepth);
+
+  if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
+    return;
+
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || pcCU->isSkipped( uiAbsPartIdx ) )
+    return;
+
+  m_pcEntropyDecoderIf->parseInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth );
+}
+
+Void TDecEntropy::decodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
+    return;
+
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || !pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+    return;
+
+  UInt uiNumSegments = ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ? 1 : ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 );
+
+  // decode residual data for each segment
+  for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ )
+    m_pcEntropyDecoderIf->parseInterSDCResidualData( pcCU, uiAbsPartIdx, uiDepth, uiSeg );
+}
+#endif
+
 //! \}
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecEntropy.h	(revision 571)
@@ -91,4 +91,8 @@
   virtual Void parseICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
 #endif
+#if LGE_INTER_SDC_E0156
+  virtual Void parseInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
+  virtual Void parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) = 0;
+#endif
   virtual Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
   virtual Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
@@ -166,5 +170,8 @@
   Void decodeICFlag            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 #endif
-
+#if LGE_INTER_SDC_E0156
+  Void decodeInterSDCFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void decodeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+#endif
   Void decodeIPCMInfo          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 571)
@@ -100,4 +100,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+, 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
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -182,4 +187,9 @@
   m_cSDCResidualSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL );
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+  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
   m_uiLastDQpNonZero  = 0;
@@ -251,4 +261,9 @@
   m_cSDCResidualSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
 #endif
+#endif
+#if LGE_INTER_SDC_E0156
+  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
   m_pcTDecBinIf->start();
@@ -2237,3 +2252,37 @@
 #endif
 
+#if LGE_INTER_SDC_E0156
+Void TDecSbac::parseInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiSymbol = 0;
+  UInt uiCtxInterSDCFlag = pcCU->getCtxInterSDCFlag( uiAbsPartIdx );
+
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cInterSDCFlagSCModel.get( 0, 0, uiCtxInterSDCFlag ) );
+
+  if( uiSymbol )
+  {
+    pcCU->setInterSDCFlagSubParts( true, uiAbsPartIdx, 0, uiDepth );
+    pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
+    pcCU->setCbfSubParts( 1, 1, 1, uiAbsPartIdx, uiDepth );
+  }
+  else
+    pcCU->setInterSDCFlagSubParts( false, uiAbsPartIdx, 0, uiDepth);
+}
+
+Void TDecSbac::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment )
+{
+  UInt uiAbsIdx   = 0;
+  UInt uiSign     = 0;
+  Int  iIdx       = 0;
+
+  xReadExGolombLevel( uiAbsIdx, m_cInterSDCResidualSCModel.get( 0, 0, 0 ) );
+
+  uiAbsIdx++;
+  m_pcTDecBinIf->decodeBin( uiSign, m_cInterSDCResidualSignFlagSCModel.get( 0, 0, 0 ) );
+  iIdx = (Int)( uiSign ? -1 : 1 ) * uiAbsIdx;
+
+  pcCU->setInterSDCSegmentDCOffset( iIdx, uiSegment, uiAbsPartIdx );
+}
+#endif
+
 //! \}
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibDecoder/TDecSbac.h	(revision 571)
@@ -112,4 +112,8 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  Void  parseInterSDCFlag    ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
+  Void  parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart );
+#endif
 private:
   TComInputBitstream* m_pcBitstream;
@@ -221,4 +225,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  ContextModel3DBuffer m_cInterSDCFlagSCModel;
+  ContextModel3DBuffer m_cInterSDCResidualSCModel;
+  ContextModel3DBuffer m_cInterSDCResidualSignFlagSCModel;
+#endif
 };
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 571)
@@ -842,4 +842,7 @@
         }        
 #endif
+#if LGE_INTER_SDC_E0156
+        WRITE_FLAG( pcVPS->getInterSDCFlag( i ) ? 1 : 0, "depth_inter_SDC_flag" );
+#endif
       }
     }  
@@ -1776,3 +1779,15 @@
   return true;
 }
+
+#if LGE_INTER_SDC_E0156
+Void TEncCavlc::codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  assert(0);
+}
+
+Void TEncCavlc::codeInterSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
+{
+  assert(0);
+}
+#endif
 //! \}
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCavlc.h	(revision 571)
@@ -117,4 +117,8 @@
   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
+#if LGE_INTER_SDC_E0156
+  Void codeInterSDCFlag          ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+  Void codeInterSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+#endif
 
   Void codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode );
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCfg.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCfg.h	(revision 571)
@@ -394,4 +394,7 @@
   Bool      m_bUseIC;
 #endif
+#if LGE_INTER_SDC_E0156
+  bool      m_bInterSDC;
+#endif
   //====== Depth Intra Modes ======
 #if H_3D_DIM
@@ -490,4 +493,8 @@
   Void       setUseIC                       ( Bool bVal )    { m_bUseIC = bVal; }
   Bool       getUseIC                       ()               { return m_bUseIC; }
+#endif
+#if LGE_INTER_SDC_E0156
+  Void       setInterSDCEnable              ( Bool bVal )    { m_bInterSDC = bVal; }
+  Bool       getInterSDCEnable              ()               { return m_bInterSDC; }
 #endif
   //======== Transform =============
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCu.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncCu.cpp	(revision 571)
@@ -1527,4 +1527,7 @@
   m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx );
 #endif
+#if LGE_INTER_SDC_E0156
+  m_pcEntropyCoder->encodeInterSDCFlag( pcCU, uiAbsPartIdx, false );
+#endif
 
   // Encode Coefficients
@@ -1817,11 +1820,51 @@
 
           rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth );
+#if LGE_INTER_SDC_E0156
+          TComDataCU *rpcTempCUPre = rpcTempCU;
+#endif
           Int orgQP = rpcTempCU->getQP( 0 );
           xCheckDQP( rpcTempCU );
           xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+#if LGE_INTER_SDC_E0156
+          if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual )
+          {
+            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], 
+              uhDepth );
+
+            xCheckDQP( rpcTempCU );
+            xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
+          }
+#endif
           rpcTempCU->initEstData( uhDepth, orgQP );
 
       if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
       {
+#if LGE_INTER_SDC_E0156
+        if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) )
+          bestIsSkip = !rpcBestCU->getSDCFlag( 0 ) && ( rpcBestCU->getQtRootCbf(0) == 0 );
+        else
+#endif
         bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0;
       }
@@ -2017,7 +2060,43 @@
 #endif
   rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
-
+#if LGE_INTER_SDC_E0156
+  TComDataCU *rpcTempCUPre = rpcTempCU;
+#endif
   xCheckDQP( rpcTempCU );
   xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth);
+#if LGE_INTER_SDC_E0156
+  if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() )
+  {
+    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],
+      uhDepth );
+
+    xCheckDQP( rpcTempCU );
+    xCheckBestMode( rpcBestCU, rpcTempCU, uhDepth );
+  }
+#endif
 #if H_3D_ARP
   }
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 571)
@@ -662,4 +662,16 @@
 #endif
 
+#if LGE_INTER_SDC_E0156
+  if( pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+  {
+    assert( !pcCU->isSkipped( uiAbsPartIdx ) );
+    assert( !pcCU->isIntra( uiAbsPartIdx) );
+    assert( pcCU->getSlice()->getIsDepth() );
+
+    encodeInterSDCResidualData( pcCU, uiAbsPartIdx, false );
+    return;
+  }
+#endif
+
   if( pcCU->isIntra(uiAbsPartIdx) )
   {
@@ -812,3 +824,38 @@
 }
 
+#if LGE_INTER_SDC_E0156
+Void TEncEntropy::encodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
+    return;
+
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || pcCU->isSkipped( uiAbsPartIdx ) )
+    return;
+
+  if( bRD )
+    uiAbsPartIdx = 0;
+
+  m_pcEntropyCoderIf->codeInterSDCFlag( pcCU, uiAbsPartIdx );
+}
+
+Void TEncEntropy::encodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
+{
+  if( !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
+    return;
+
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( uiAbsPartIdx ) || !pcCU->getInterSDCFlag( uiAbsPartIdx ) )
+    return;
+
+  if( bRD )
+    uiAbsPartIdx = 0;
+
+  // number of segments depends on prediction mode for INTRA
+  UInt uiNumSegments = ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) ? 1 : ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 4 : 2 );
+
+  // encode residual data for each segment
+  for( UInt uiSeg = 0; uiSeg < uiNumSegments; uiSeg++ )
+    m_pcEntropyCoderIf->codeInterSDCResidualData( pcCU, uiAbsPartIdx, uiSeg );
+}
+#endif
+
 //! \}
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncEntropy.h	(revision 571)
@@ -93,4 +93,8 @@
 #if H_3D_IC
   virtual Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+#endif
+#if LGE_INTER_SDC_E0156
+  virtual Void codeInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0;
+  virtual Void codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) = 0;
 #endif
   virtual Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
@@ -181,4 +185,8 @@
   Void encodeICFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
 #endif
+#if LGE_INTER_SDC_E0156
+  Void encodeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
+  Void encodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD );
+#endif
   Void encodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
   Void encodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 571)
@@ -106,4 +106,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+, 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
 {
   assert( m_numContextModels <= MAX_NUM_CTX_MOD );
@@ -181,4 +186,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  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
   // new structure
   m_uiLastQp = iQp;
@@ -217,4 +227,9 @@
 #if H_3D_IC
       curCost += m_cCUICFlagSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_IC_FLAG );
+#endif
+#if LGE_INTER_SDC_E0156
+      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
       curCost += m_cCUPartSizeSCModel.calcCost        ( curSliceType, qp, (UChar*)INIT_PART_SIZE );
@@ -330,4 +345,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  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
   m_pcBinIf->start();
 }
@@ -2209,3 +2229,26 @@
   this->xCopyContextsFrom(pScr);
 }
+
+#if LGE_INTER_SDC_E0156
+Void TEncSbac::codeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )
+{
+  UInt uiSymbol = pcCU->getInterSDCFlag( uiAbsPartIdx ) ? 1 : 0;
+  UInt uiCtxInterSDCFlag = pcCU->getCtxInterSDCFlag( uiAbsPartIdx );
+
+  m_pcBinIf->encodeBin( uiSymbol, m_cInterSDCFlagSCModel.get( 0, 0, uiCtxInterSDCFlag ) );
+}
+
+Void TEncSbac::codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
+{
+  Pel segmentDCOffset = pcCU->getInterSDCSegmentDCOffset( uiSegment, uiAbsPartIdx );
+
+  UInt uiSign     = segmentDCOffset < 0 ? 1 : 0;
+  UInt uiAbsIdx   = abs( segmentDCOffset );
+
+  assert( uiAbsIdx > 0 );
+  uiAbsIdx--;
+  xWriteExGolombLevel( uiAbsIdx, m_cInterSDCResidualSCModel.get( 0, 0, 0 ) );
+  m_pcBinIf->encodeBin( uiSign, m_cInterSDCResidualSignFlagSCModel.get( 0, 0, 0 ) );
+}
+#endif
 //! \}
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSbac.h	(revision 571)
@@ -158,4 +158,8 @@
   Void codeICFlag        ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
+#if LGE_INTER_SDC_E0156
+  Void codeInterSDCFlag  ( TComDataCU* pcCU, UInt uiAbsPartIdx );
+  Void codeInterSDCResidualData  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment );
+#endif
   Void codeSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
   Void codeMVPIdx        ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
@@ -261,4 +265,9 @@
 #endif
 #endif
+#if LGE_INTER_SDC_E0156
+  ContextModel3DBuffer m_cInterSDCFlagSCModel;
+  ContextModel3DBuffer m_cInterSDCResidualSCModel;
+  ContextModel3DBuffer m_cInterSDCResidualSignFlagSCModel;
+#endif
 };
 
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 571)
@@ -41,4 +41,7 @@
 #include "TEncSearch.h"
 #include <math.h>
+#if LGE_INTER_SDC_E0156
+#include <memory.h>
+#endif
 
 //! \ingroup TLibEncoder
@@ -319,4 +322,7 @@
 #if H_3D_IC
   m_cDistParam.bUseIC = pcPatternKey->getICFlag();
+#endif
+#if LGE_INTER_SDC_E0156
+  m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
 #endif
   //-- jclee for using the SAD function pointer
@@ -748,4 +754,7 @@
 #if H_3D_IC
     m_cDistParam.bUseIC = pcPatternKey->getICFlag();
+#endif
+#if LGE_INTER_SDC_E0156
+    m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
 #endif
     m_cDistParam.pCur = piRefPos;
@@ -3531,4 +3540,7 @@
   cDistParam.bUseIC = false;
 #endif
+#if LGE_INTER_SDC_E0156
+  cDistParam.bUseSDCMRSAD = false;
+#endif
   ruiErr = cDistParam.DistFunc( &cDistParam );
 }
@@ -4627,4 +4639,14 @@
   pcPatternKey->setICFlag( bICFlag );
 #endif
+#if LGE_INTER_SDC_E0156
+  if ( pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) )
+  {
+    pcPatternKey->setSDCMRSADFlag( true );
+  } 
+  else
+  {
+    pcPatternKey->setSDCMRSADFlag( false );
+  }
+#endif
 
   if ( bBi )
@@ -4772,4 +4794,7 @@
 #if H_3D_IC
       m_cDistParam.bUseIC = pcPatternKey->getICFlag();
+#endif
+#if LGE_INTER_SDC_E0156
+      m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag();
 #endif
       m_cDistParam.bitDepth = g_bitDepthY;
@@ -5378,4 +5403,161 @@
 #endif
 }
+
+#if LGE_INTER_SDC_E0156
+Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, const UInt uiDepth )
+{
+  if( !pcCU->getSlice()->getIsDepth() || pcCU->isIntra( 0 ) )
+  {
+    return;
+  }
+
+  pcCU->setInterSDCFlagSubParts( true, 0, 0, uiDepth );
+
+  UInt  uiWidth      = pcCU->getWidth ( 0 );
+  UInt  uiHeight     = pcCU->getHeight( 0 );
+  UChar* pMask       = pcCU->getInterSDCMask();
+  memset( pMask, 0, uiWidth*uiHeight );
+
+  pcCU->xSetInterSDCCUMask( pcCU, pMask );
+
+  UInt uiSegSize[4] = { 0, 0, 0, 0 };
+  Pel *pPred, *pOrg;
+  UInt uiPredStride = pcPred->getStride();
+  UInt uiOrgStride  = pcOrg->getStride();
+  UInt uiPelX, uiPelY;
+  UInt uiPartitionSize = pcCU->getPartitionSize( 0 );
+  UInt uiSegmentNum = ( uiPartitionSize == SIZE_2Nx2N ) ? 1 : ( uiPartitionSize == SIZE_NxN ? 4 : 2 );
+
+  pPred = pcPred->getLumaAddr( 0 );
+  pOrg  = pcOrg->getLumaAddr( 0 );
+  Int pResDC[4] = { 0, 0, 0, 0};
+
+  //calculate dc value for prediction and original signal, and calculate residual and reconstruction
+  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
+  {
+    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
+    {
+      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
+      pResDC[uiSeg] += (Int)( pOrg [uiPelX] - pPred[uiPelX] );
+      uiSegSize[uiSeg]++;
+    }
+    pOrg  += uiOrgStride;
+    pPred += uiPredStride;
+  }
+
+  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];
+
+    pcCU->setInterSDCSegmentDCOffset( pResDC[uiSeg], uiSeg, 0 );
+  }
+
+  Pel *pRec;
+  UInt uiRecStride  = pcRec->getStride();
+  pPred = pcPred->getLumaAddr( 0 );
+  pRec  = pcRec->getLumaAddr( 0 );
+
+  for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ )
+  {
+    for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ )
+    {
+      UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ];
+      assert( uiSeg < uiSegmentNum );
+
+      pRec[ uiPelX ] = Clip3( 0, ( 1 << g_bitDepthY ) - 1, pPred[uiPelX] + pResDC[uiSeg] );
+    }
+    pPred     += uiPredStride;
+    pRec      += uiRecStride;
+  }
+
+  // clear UV
+  UInt  uiStrideC     = pcRec->getCStride();
+  Pel   *pRecCb       = pcRec->getCbAddr();
+  Pel   *pRecCr       = pcRec->getCrAddr();
+
+  for (Int y=0; y < uiHeight/2; y++)
+  {
+    for (Int x=0; x < uiWidth/2; x++)
+    {
+      pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
+      pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) );
+    }
+
+    pRecCb += uiStrideC;
+    pRecCr += uiStrideC;
+  }
+
+  Dist ruiDist;
+  Double rdCost;
+#if H_3D_VSO // M13
+  if ( m_pcRdCost->getUseVSO() )
+  {
+    ruiDist = m_pcRdCost->getDistPartVSO( pcCU, 0, pcRec->getLumaAddr(), pcRec->getStride(),  pcOrg->getLumaAddr(), pcOrg->getStride(),  uiWidth,      uiHeight     , false );
+  }
+  else    
+  {
+#endif
+    {
+      ruiDist = m_pcRdCost->getDistPart( g_bitDepthY, pcRec->getLumaAddr( 0 ), uiRecStride, pcOrg->getLumaAddr( 0 ), uiOrgStride, uiWidth, uiHeight );
+    }
+#if H_3D_VSO
+  }
+#endif
+
+  Bool bNonSkip = true;
+  for( UInt uiSeg = 0; uiSeg < uiSegmentNum; uiSeg++ )
+  {
+    bNonSkip &= ( pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 ) != 0 ) ? 1 : 0;
+  }
+
+  if( !bNonSkip )
+  {
+    pcCU->getTotalBits()       = MAX_INT;
+    pcCU->getTotalDistortion() = MAX_INT;
+    pcCU->getTotalCost()       = MAX_DOUBLE;
+  }
+  else
+  {
+    //----- determine rate and r-d cost -----
+    UInt uiBits = 0;
+    TComYuv *pDummy = NULL;
+    if( m_bUseSBACRD )
+    {
+      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
+    }
+
+    xAddSymbolBitsInter( pcCU, 0, 0, uiBits, pDummy, NULL, pDummy );
+
+#if H_3D_VSO //M 14
+    if ( m_pcRdCost->getUseLambdaScaleVSO() )    
+      rdCost = m_pcRdCost->calcRdCostVSO( uiBits, ruiDist );    
+    else
+#endif
+    {
+      rdCost = m_pcRdCost->calcRdCost( uiBits, ruiDist );
+    }
+
+    pcCU->getTotalBits()       = m_pcEntropyCoder->getNumberOfWrittenBits();
+    pcCU->getTotalDistortion() = ruiDist;
+    pcCU->getTotalCost()       = rdCost;
+
+    if( m_bUseSBACRD )
+    {
+      m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
+    }
+  }
+
+#if H_3D_VSO // necessary? // M15
+  // set Model
+  if( !m_pcRdCost->getUseEstimatedVSD() && m_pcRdCost->getUseRenModel() )
+  {
+    Pel*  piSrc       = pcRec->getLumaAddr();
+    UInt  uiSrcStride = pcRec->getStride();
+    m_pcRdCost->setRenModelData( pcCU, 0, piSrc, uiSrcStride, uiWidth, uiHeight );
+  }
+#endif
+}
+#endif
 
 #if H_3D_VSO // M25
@@ -6543,4 +6725,7 @@
     m_pcEntropyCoder->encodeARPW( pcCU , 0 );
 #endif
+#if LGE_INTER_SDC_E0156
+    m_pcEntropyCoder->encodeInterSDCFlag( pcCU, 0, true );
+#endif
     Bool bDummy = false;
     m_pcEntropyCoder->encodeCoeff   ( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0), bDummy );
Index: /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.h	(revision 570)
+++ /branches/HTM-DEV-2.0-dev2-LG/source/Lib/TLibEncoder/TEncSearch.h	(revision 571)
@@ -213,5 +213,12 @@
                                   TComYuv*&   rpcYuvRec,
                                   Bool        bSkipRes );
-  
+#if LGE_INTER_SDC_E0156
+  Void encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU,
+    TComYuv* pcOrg, 
+    TComYuv* pcPred, 
+    TComYuv* pcResi, 
+    TComYuv* pcRec, 
+    const UInt uiDepth );
+#endif
   /// set ME search range
   Void setAdaptiveSearchRange   ( Int iDir, Int iRefIdx, Int iSearchRange) { m_aaiAdaptSR[iDir][iRefIdx] = iSearchRange; }
