Index: branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 599)
+++ branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 601)
@@ -95,5 +95,7 @@
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#if !SEC_DMM2_E0146
 , m_cDmm2DataSCModel          ( 1,             1,               NUM_DMM2_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
 , m_cDmm3DataSCModel          ( 1,             1,               NUM_DMM3_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
@@ -175,5 +177,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM2_E0146
   m_cDmm2DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA );
+#endif
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
 #endif
@@ -264,5 +268,7 @@
 #if H_3D_DIM_DMM
       curCost += m_cDmm1DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM2_E0146
       curCost += m_cDmm2DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM2_DATA );
+#endif
       curCost += m_cDmm3DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM3_DATA );
 #endif
@@ -334,5 +340,7 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM2_E0146
   m_cDmm2DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA );
+#endif
   m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
 #endif
@@ -541,4 +549,5 @@
 }
 
+#if !SEC_DMM2_E0146
 Void TEncSbac::xCodeDmm2Offset( Int iOffset )
 {
@@ -557,4 +566,5 @@
   }
 }
+#endif
 
 Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit )
@@ -1216,8 +1226,10 @@
       xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
     } break;
+#if !SEC_DMM2_E0146
   case( DMM2_IDX ):
     {
       xCodeDmm2Offset( pcCU->getDmm2DeltaEnd( absPartIdx ) );
     } break;
+#endif
   case( DMM3_IDX ):
     {
@@ -1268,6 +1280,26 @@
 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
 {
+#if ZJU_DEPTH_INTRA_MODE_E0204
+    UInt codeWordTable[3][7] =    {{0, 0, 0, 2, 0,6, 7},{0, 0, 2, 7, 3, 6, 2},{0, 1, 0, 0, 0, 0, 0}};
+    UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{1, 1, 2, 3, 2, 3, 2},{1, 1, 0, 0, 0, 0, 0}};
+#else
+#if LGE_SDC_REMOVE_DC_E0158
+#if SEC_DMM2_E0146
+  UInt codeWordTable[3][7] =    {{0, 0, 0, 2, 0,6, 7},{0, 2, 3, 4, 5, 6, 7},{0, 1, 0, 0, 0, 0, 0}};
+  UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{2, 3, 3, 3, 3, 3, 3},{1, 1, 0, 0, 0, 0, 0}};
+#else
+  UInt codeWordTable[3][8] =    { { 0, 0, 0, 2, 0, 6, 0, 7 }, { 0, 2, 3, 4, 5, 6, 15, 14 }, { 0, 1, 0, 0, 0, 0, 0, 0 } };
+  UInt codeWordLenTable[3][8] = { { 0, 1, 0, 2, 0, 3, 0, 3 }, { 2, 3, 3, 3, 3, 3,  4,  4 }, { 1, 1, 0, 0, 0, 0, 0, 0 } };
+#endif
+#else
+#if SEC_DMM2_E0146
+  UInt codeWordTable[3][8] =    {{0, 0, 0, 2, 0,6, 0, 7},{0, 2, 3, 4, 5, 6, 14, 15},{0, 2, 0, 0, 0, 0, 3, 0}};
+  UInt codeWordLenTable[3][8] = {{0, 1, 0, 2, 0,3, 0, 3},{2, 3, 3, 3, 3, 3,  4,  4},{1, 2, 0, 0, 0, 0, 2, 0}};
+#else
   UInt codeWordTable[3][9] =    {{0, 0, 0, 2, 0,6, 0, 0, 7},{0, 2, 3, 4, 5, 6, 14, 31, 30},{0, 2, 0, 0, 0, 0, 3, 0, 0}};
   UInt codeWordLenTable[3][9] = {{0, 1, 0, 2, 0,3, 0, 0, 3},{2, 3, 3, 3, 3, 3,  4,  5,  5},{1, 2, 0, 0, 0, 0, 2, 0, 0}};
+#endif
+#endif
+#endif
   UInt dir = pcCU->getLumaIntraDir( absPartIdx );
   UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 );
@@ -1285,6 +1317,19 @@
     case DMM4_IDX: codeIdx = 4; break;
     case DMM3_IDX: codeIdx = 5; break;
+#if LGE_SDC_REMOVE_DC_E0158
+#if SEC_DMM2_E0146
+    case  RBC_IDX: codeIdx = 6; break;
+#else
+    case DMM2_IDX: codeIdx = 6; break;
+    case  RBC_IDX: codeIdx = 7; break;
+#endif
+#else
+#if SEC_DMM2_E0146
+    case  RBC_IDX: codeIdx = 7; break;
+#else
     case DMM2_IDX: codeIdx = 7; break;
     case  RBC_IDX: codeIdx = 8; break;
+#endif
+#endif
     default:                    break;
     }
@@ -1297,7 +1342,22 @@
     {
       case PLANAR_IDX:  codeIdx = 0; break;
+#if !LGE_SDC_REMOVE_DC_E0158
       case DC_IDX:      codeIdx = 6; break;
+#endif
       default:          codeIdx = 2; break;
     }
+  }
+#endif
+#if ZJU_DEPTH_INTRA_MODE_E0204
+  if( puIdx==1 )
+  {
+      if( codeIdx==1 || codeIdx==2 || codeIdx==4 )
+      {
+          m_pcBinIf->encodeBinEP( 0 );
+      }
+      else
+      {
+          m_pcBinIf->encodeBinEP( 1 );
+      }
   }
 #endif
Index: branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.h	(revision 599)
+++ branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSbac.h	(revision 601)
@@ -121,5 +121,7 @@
 #if H_3D_DIM_DMM
   Void  xCodeDmm1WedgeIdx    ( UInt uiTabIdx, Int iNumBit );
+#if !SEC_DMM2_E0146
   Void  xCodeDmm2Offset      ( Int iOffset );
+#endif
   Void  xCodeDmm3WedgeIdx    ( UInt uiIntraIdx, Int iNumBit );
 #endif
@@ -254,5 +256,7 @@
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
+#if !SEC_DMM2_E0146
   ContextModel3DBuffer m_cDmm2DataSCModel;
+#endif
   ContextModel3DBuffer m_cDmm3DataSCModel;
 #endif
Index: branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 599)
+++ branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 601)
@@ -1900,9 +1900,17 @@
   // get DC prediction for each segment
   Pel apDCPredValues[2];
+#if KWU_SDC_SIMPLE_DC_E0117
+  analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode );
+#else
   analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride );
+#endif
   
   // get original DC for each segment
   Pel apDCOrigValues[2];
+#if KWU_SDC_SIMPLE_DC_E0117
+  analyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode, true );
+#else
   analyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride );
+#endif
   
   for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ )
@@ -2842,6 +2850,18 @@
     if( m_pcEncCfg->getIsDepth() && uiWidth >= DIM_MIN_SIZE && uiWidth <= DIM_MAX_SIZE && uiWidth == uiHeight )
     {
+
+#if SCU_HS_FAST_DEPTH_INTRA_E0238
+      Int  threshold    = max(((pcCU->getQP(0))>>3)-1,3);
+      Int  varThreshold = (Int)( threshold * threshold - 8 );
+      UInt varCU      = m_pcRdCost->calcVAR(piOrg, uiStride, uiWidth,uiHeight,pcCU->getDepth(0));
+#endif
+
+
 #if H_3D_DIM_DMM
-      if( m_pcEncCfg->getUseDMM() )
+      if( m_pcEncCfg->getUseDMM()
+#if SCU_HS_FAST_DEPTH_INTRA_E0238
+         && (uiRdModeList[0] != 0 || varCU >= varThreshold)
+#endif
+        )
       {
         for( UInt dmmType = 0; dmmType < DMM_NUM_TYPE; dmmType++ )
@@ -2858,4 +2878,5 @@
               biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
             } break;
+#if !SEC_DMM2_E0146
           case( DMM2_IDX ):
             {
@@ -2869,6 +2890,16 @@
               }
             } break;
+#endif
           case( DMM3_IDX ):
             {
+#if LGE_PKU_DMM3_OVERLAP_E0159
+              TComPic*      pcPicTex = pcCU->getSlice()->getTexturePic();
+              TComDataCU* pcColTexCU = pcPicTex->getCU( pcCU->getAddr() );
+              UInt      uiTexPartIdx = pcCU->getZorderIdxInCU() + uiPartOffset;
+              Int   uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
+
+              if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 )
+              {
+#endif
               UInt uiIntraTabIdx = 0;
               xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx );
@@ -2876,4 +2907,7 @@
               pcCU->setDmm3IntraTabIdxSubParts( uiIntraTabIdx, uiPartOffset, uiDepth + uiInitTrDepth );
               biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
+#if LGE_PKU_DMM3_OVERLAP_E0159
+              }
+#endif
             } break;
           case( DMM4_IDX ):
@@ -2903,5 +2937,9 @@
 #endif
 #if H_3D_DIM_RBC
-      if( m_pcEncCfg->getUseRBC() )
+      if( m_pcEncCfg->getUseRBC()
+#if SCU_HS_FAST_DEPTH_INTRA_E0238
+          && (uiRdModeList[0] != 0 || varCU >= varThreshold)
+#endif
+        )
       {
         if( xSearchRbcEdge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight ) )
@@ -7323,4 +7361,5 @@
 }
 
+#if !SEC_DMM2_E0146
 Void TEncSearch::xSearchDmm2Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd )
 {
@@ -7388,4 +7427,5 @@
   return;
 }
+#endif
 
 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx )
Index: branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.h	(revision 599)
+++ branches/HTM-DEV-2.0-dev0/source/Lib/TLibEncoder/TEncSearch.h	(revision 601)
@@ -352,5 +352,7 @@
   Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
   Void xSearchDmm1Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx );
+#if !SEC_DMM2_E0146
   Void xSearchDmm2Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd );
+#endif
   Void xSearchDmm3Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx );
 #endif
