Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 443)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 608)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -52,18 +52,14 @@
 , m_cCUSplitFlagSCModel       ( 1,             1,               NUM_SPLIT_FLAG_CTX            , m_contextModels + m_numContextModels, m_numContextModels )
 , m_cCUSkipFlagSCModel        ( 1,             1,               NUM_SKIP_FLAG_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#if LGE_ILLUCOMP_B0045
-, m_cCUICFlagSCModel          ( 1,             1,               NUM_IC_FLAG_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
 , m_cCUMergeFlagExtSCModel    ( 1,             1,               NUM_MERGE_FLAG_EXT_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUMergeIdxExtSCModel     ( 1,             1,               NUM_MERGE_IDX_EXT_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
-#if H3D_IVRP
-, m_cResPredFlagSCModel       ( 1,             1,               NUM_RES_PRED_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#if QC_ARP_D0177
-, m_cCUPUARPW                 ( 1,             1,               NUM_ARPW_CTX                 , m_contextModels + m_numContextModels, m_numContextModels)
+#if H_3D_ARP
+, m_cCUPUARPWSCModel          ( 1,             1,               NUM_ARPW_CTX                  , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if H_3D_IC
+, m_cCUICFlagSCModel          ( 1,             1,               NUM_IC_FLAG_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
 #endif
 , m_cCUPartSizeSCModel        ( 1,             1,               NUM_PART_SIZE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUPredModeSCModel        ( 1,             1,               NUM_PRED_MODE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cCUAlfCtrlFlagSCModel     ( 1,             1,               NUM_ALF_CTRL_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUIntraPredSCModel       ( 1,             1,               NUM_ADI_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUChromaPredSCModel      ( 1,             1,               NUM_CHROMA_PRED_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
@@ -82,53 +78,35 @@
 , m_cCUAbsSCModel             ( 1,             1,               NUM_ABS_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cMVPIdxSCModel            ( 1,             1,               NUM_MVP_IDX_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cALFFlagSCModel           ( 1,             1,               NUM_ALF_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cALFUvlcSCModel           ( 1,             1,               NUM_ALF_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cALFSvlcSCModel           ( 1,             1,               NUM_ALF_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
-#if LGE_SAO_MIGRATION_D0091
-, m_cSaoMergeSCModel          ( 1,             1,               NUM_SAO_MERGE_FLAG_CTX        , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSaoMergeSCModel      ( 1,             1,               NUM_SAO_MERGE_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
 , m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
-#else
-, m_cSaoFlagSCModel           ( 1,             1,               NUM_SAO_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSaoUvlcSCModel           ( 1,             1,               NUM_SAO_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSaoSvlcSCModel           ( 1,             1,               NUM_SAO_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSaoMergeLeftSCModel      ( 1,             1,               NUM_SAO_MERGE_LEFT_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSaoMergeUpSCModel        ( 1,             1,               NUM_SAO_MERGE_UP_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-, m_cDmmFlagSCModel           ( 1,             1,               NUM_DMM_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cDmmModeSCModel           ( 1,             1,               NUM_DMM_MODE_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-, m_cDmmDataSCModel           ( 1,             1,               NUM_DMM_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#if LGE_EDGE_INTRA_A0070
-, m_cEdgeIntraSCModel         ( 1,             1,               NUM_EDGE_INTRA_CTX            , m_contextModels + m_numContextModels, m_numContextModels)
-#if LGE_EDGE_INTRA_DELTA_DC
-, m_cEdgeIntraDeltaDCSCModel  ( 1,             1,               NUM_EDGE_INTRA_DELTA_DC_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#endif
-#if RWTH_SDC_DLT_B0036
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-, m_cSDCFlagSCModel             ( 1,             1,                 SDC_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
-#else
-, m_cDepthModeModel             ( 1,             1,                 DEPTH_MODE_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cDmmDeltaFlagModel             ( 1,             1,                 DMM_DELTA_NUM_FLAG_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#if RWTH_SDC_CTX_SIMPL_D0032
-, m_cSDCResidualFlagSCModel     ( 1,             1,  SDC_NUM_RESIDUAL_FLAG_CTX  , m_contextModels + m_numContextModels, m_numContextModels)
-, m_cSDCResidualSCModel         ( 1,             1,  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)
-#else
-, 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
+, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
+, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
+#if H_3D_DIM
+, m_cDepthIntraModeSCModel    ( 1,             1,               NUM_DEPTH_INTRA_MODE_CTX      , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cDdcFlagSCModel           ( 1,             1,               NUM_DDC_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cDdcDataSCModel           ( 1,             1,               NUM_DDC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
+#if 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
+#if H_3D_DIM_RBC
+, m_cRbcDataSCModel           ( 1,             1,               NUM_RBC_DATA_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
+#endif
+#if H_3D_DIM_SDC
+, m_cSDCResidualFlagSCModel     ( 1,             1,             SDC_NUM_RESIDUAL_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
+, m_cSDCResidualSCModel         ( 1,             1,             SDC_NUM_RESIDUAL_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
+#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 );
-  m_iSliceGranularity = 0;
 }
 
@@ -141,5 +119,4 @@
 // ====================================================================================================================
 
-#if CABAC_INIT_FLAG
 Void TDecSbac::resetEntropy(TComSlice* pSlice)
 {
@@ -162,24 +139,14 @@
   }
 
-#else
-Void TDecSbac::resetEntropywithQPandInitIDC (Int  qp, Int iID)
-{
-  SliceType sliceType = (SliceType)iID;
-#endif  
-
   m_cCUSplitFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_SPLIT_FLAG );
   m_cCUSkipFlagSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SKIP_FLAG );
-#if LGE_ILLUCOMP_B0045
-  m_cCUICFlagSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_IC_FLAG );
-#endif
   m_cCUMergeFlagExtSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
   m_cCUMergeIdxExtSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
-#if H3D_IVRP
-  m_cResPredFlagSCModel.initBuffer       ( sliceType, qp, (UChar*)INIT_RES_PRED_FLAG );
-#endif
-#if QC_ARP_D0177
-  m_cCUPUARPW.initBuffer                ( sliceType, qp, (UChar*)INIT_ARPW );
-#endif
-  m_cCUAlfCtrlFlagSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG );
+#if H_3D_ARP
+  m_cCUPUARPWSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_ARPW );
+#endif
+#if H_3D_IC
+  m_cCUICFlagSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_IC_FLAG );
+#endif
   m_cCUPartSizeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PART_SIZE );
   m_cCUAMPSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );
@@ -200,48 +167,35 @@
   m_cCUAbsSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_ABS_FLAG );
   m_cMVPIdxSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_MVP_IDX );
-  m_cALFFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_FLAG );
-  m_cALFUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_UVLC );
-  m_cALFSvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_SVLC );
-#if LGE_SAO_MIGRATION_D0091
-  m_cSaoMergeSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG );
+  m_cSaoMergeSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG );
   m_cSaoTypeIdxSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX );
-#else
-  m_cSaoFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_FLAG );
-  m_cSaoUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_UVLC );
-  m_cSaoSvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_SVLC );
-  m_cSaoMergeLeftSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
-  m_cSaoMergeUpSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
-  m_cSaoTypeIdxSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX );
-#endif
 
   m_cCUTransSubdivFlagSCModel.initBuffer ( sliceType, qp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
-#if LGE_EDGE_INTRA_A0070
-  m_cEdgeIntraSCModel.initBuffer         ( sliceType, qp, (UChar*)INIT_EDGE_INTRA );
-#if LGE_EDGE_INTRA_DELTA_DC
-  m_cEdgeIntraDeltaDCSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_EDGE_INTRA_DELTA_DC );
-#endif
+  m_cTransformSkipSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
+  m_CUTransquantBypassFlagSCModel.initBuffer( sliceType, qp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
+#if H_3D_DIM
+  m_cDepthIntraModeSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_DEPTH_INTRA_MODE );
+  m_cDdcFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_FLAG );
+  m_cDdcDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DDC_DATA );
+#if H_3D_DIM_DMM
+  m_cDmm1DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM1_DATA );
+#if !SEC_DMM2_E0146
+  m_cDmm2DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM2_DATA );
+#endif
+  m_cDmm3DataSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_DMM3_DATA );
+#endif
+#if H_3D_DIM_RBC
+  m_cRbcDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_RBC_DATA );
+#endif
+#if H_3D_DIM_SDC
+  m_cSDCResidualFlagSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  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;
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-  m_cDmmFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_FLAG );
-  m_cDmmModeSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_MODE );
-#endif
-  m_cDmmDataSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMM_DATA );
-#endif
-#if RWTH_SDC_DLT_B0036
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-  m_cSDCFlagSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_SDC_FLAG );
-#else
-  m_cDepthModeModel.initBuffer              ( sliceType, qp, (UChar*)INIT_DEPTHMODE_FLAG );
-  m_cDmmDeltaFlagModel.initBuffer           ( sliceType, qp, (UChar*)INIT_DMMDELTA_FLAG );
-#endif
-  m_cSDCResidualFlagSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
-  m_cSDCResidualSCModel.initBuffer          ( sliceType, qp, (UChar*)INIT_SDC_RESIDUAL );
-#if !RWTH_SDC_CTX_SIMPL_D0032
-  m_cSDCResidualSignFlagSCModel.initBuffer  ( sliceType, qp, (UChar*)INIT_SDC_SIGN_FLAG );
-#endif
-  m_cSDCPredModeSCModel.initBuffer              ( sliceType, qp, (UChar*)INIT_SDC_PRED_MODE );
-#endif
   
   // new structure
@@ -258,32 +212,17 @@
   UInt uiBit;
   m_pcTDecBinIf->decodeBinTrm(uiBit);
+  assert(uiBit); // end_of_sub_stream_one_bit must be equal to 1
   m_pcTDecBinIf->finish();  
-#if !OL_FLUSH_ALIGN
-  // Account for misaligned CABAC.
-  Int iCABACReadAhead = m_pcTDecBinIf->getBitsReadAhead();
-  iCABACReadAhead--;
-  Int iStreamBits = 8-m_pcBitstream->getNumBitsUntilByteAligned();
-  if (iCABACReadAhead >= iStreamBits)
-  {
-    // Misaligned CABAC has read into the 1st byte of the next tile.
-    // Back up a byte prior to alignment.
-    m_pcBitstream->backupByte();
-  }
-#endif
   m_pcBitstream->readOutTrailingBits();
   m_cCUSplitFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_SPLIT_FLAG );
   m_cCUSkipFlagSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SKIP_FLAG );
-#if LGE_ILLUCOMP_B0045
-  m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
-#endif
   m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );
   m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );
-#if H3D_IVRP
-  m_cResPredFlagSCModel.initBuffer       ( eSliceType, iQp, (UChar*)INIT_RES_PRED_FLAG );
-#endif
-#if QC_ARP_D0177
-  m_cCUPUARPW.initBuffer                 ( eSliceType, iQp, (UChar*)INIT_ARPW );
-#endif
-  m_cCUAlfCtrlFlagSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG );
+#if H_3D_ARP
+  m_cCUPUARPWSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_ARPW );
+#endif
+#if H_3D_IC
+  m_cCUICFlagSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_IC_FLAG );
+#endif
   m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
   m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
@@ -304,61 +243,44 @@
   m_cCUAbsSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG );
   m_cMVPIdxSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_MVP_IDX );
-  m_cALFFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_FLAG );
-  m_cALFUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC );
-  m_cALFSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC );
-#if LGE_SAO_MIGRATION_D0091
-  m_cSaoMergeSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
+  m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
   m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
-#else
-  m_cSaoFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_FLAG );
-  m_cSaoUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC );
-  m_cSaoSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_SVLC );
-  m_cSaoMergeLeftSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
-  m_cSaoMergeUpSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
-  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
-#endif
   m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-  m_cDmmFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_FLAG );
-  m_cDmmModeSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_MODE );
-#endif
-  m_cDmmDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMM_DATA );
-#endif
-#if RWTH_SDC_DLT_B0036
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-  m_cSDCFlagSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_FLAG );
-#else
-  m_cDepthModeModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_DEPTHMODE_FLAG );
-  m_cDmmDeltaFlagModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DMMDELTA_FLAG );
-#endif
-  m_cSDCResidualFlagSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
-  m_cSDCResidualSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL );
-#if !RWTH_SDC_CTX_SIMPL_D0032
-  m_cSDCResidualSignFlagSCModel.initBuffer  ( eSliceType, iQp, (UChar*)INIT_SDC_SIGN_FLAG );
-#endif
-  m_cSDCPredModeSCModel.initBuffer              ( eSliceType, iQp, (UChar*)INIT_SDC_PRED_MODE );
-#endif
-
+  m_cTransformSkipSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_TRANSFORMSKIP_FLAG );
+  m_CUTransquantBypassFlagSCModel.initBuffer( eSliceType, iQp, (UChar*)INIT_CU_TRANSQUANT_BYPASS_FLAG );
+
+#if H_3D_DIM
+  m_cDepthIntraModeSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_DEPTH_INTRA_MODE );
+  m_cDdcFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_FLAG );
+  m_cDdcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_DDC_DATA );
+#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
+#if H_3D_DIM_RBC
+  m_cRbcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_RBC_DATA );
+#endif
+#if H_3D_DIM_SDC
+  m_cSDCResidualFlagSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_SDC_RESIDUAL_FLAG );
+  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();
 }
 
-Void TDecSbac::readTileMarker( UInt& uiTileIdx, UInt uiBitsUsed )
-{
-  UInt uiSymbol;
-  uiTileIdx = 0;
-  for (Int iShift=uiBitsUsed-1; iShift>=0; iShift--)
-  {
-    m_pcTDecBinIf->decodeBinEP ( uiSymbol );
-    if (uiSymbol)
-    {
-      uiTileIdx |= (1<<iShift);
-    }
-  }
-}
-
 Void TDecSbac::parseTerminatingBit( UInt& ruiBit )
 {
   m_pcTDecBinIf->decodeBinTrm( ruiBit );
+  if ( ruiBit )
+  {
+    m_pcTDecBinIf->finish();
+  }
 }
 
@@ -440,47 +362,269 @@
 }
 
-/** Parsing of coeff_abs_level_minus3
- * \param ruiSymbol reference to coeff_abs_level_minus3
- * \param ruiGoRiceParam reference to Rice parameter
+
+/** Parsing of coeff_abs_level_remaing
+ * \param ruiSymbol reference to coeff_abs_level_remaing
+ * \param ruiParam reference to parameter
  * \returns Void
  */
-Void TDecSbac::xReadGoRiceExGolomb( UInt &ruiSymbol, UInt &ruiGoRiceParam )
-{
-  Bool bExGolomb    = false;
-  UInt uiCodeWord   = 0;
-  UInt uiQuotient   = 0;
-  UInt uiRemainder  = 0;
-  UInt uiMaxVlc     = g_auiGoRiceRange[ ruiGoRiceParam ];
-  UInt uiMaxPreLen  = g_auiGoRicePrefixLen[ ruiGoRiceParam ];
-
+Void TDecSbac::xReadCoefRemainExGolomb ( UInt &rSymbol, UInt &rParam )
+{
+
+  UInt prefix   = 0;
+  UInt codeWord = 0;
   do
   {
-    uiQuotient++;
-    m_pcTDecBinIf->decodeBinEP( uiCodeWord );
-  }
-  while( uiCodeWord && uiQuotient < uiMaxPreLen );
-
-  uiCodeWord  = 1 - uiCodeWord;
-  uiQuotient -= uiCodeWord;
-
-  if ( ruiGoRiceParam > 0 )
-  {
-    m_pcTDecBinIf->decodeBinsEP( uiRemainder, ruiGoRiceParam );    
-  }
-
-  ruiSymbol      = uiRemainder + ( uiQuotient << ruiGoRiceParam );
-  bExGolomb      = ruiSymbol == ( uiMaxVlc + 1 );
-
-  if( bExGolomb )
-  {
-    xReadEpExGolomb( uiCodeWord, 0 );
-    ruiSymbol += uiCodeWord;
-  }
-
-  ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 23 ) ];
+    prefix++;
+    m_pcTDecBinIf->decodeBinEP( codeWord );
+  }
+  while( codeWord);
+  codeWord  = 1 - codeWord;
+  prefix -= codeWord;
+  codeWord=0;
+  if (prefix < COEF_REMAIN_BIN_REDUCTION )
+  {
+    m_pcTDecBinIf->decodeBinsEP(codeWord,rParam);
+    rSymbol = (prefix<<rParam) + codeWord;
+  }
+  else
+  {
+    m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam);
+    rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord;
+  }
+}
+
+#if H_3D_DIM
+Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
+{
+  UInt uiSymbol;
+  UInt uiCount = 0;
+  do
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel );
+    uiCount++;
+  }
+  while( uiSymbol && ( uiCount != 13 ) );
+
+  ruiSymbol = uiCount - 1;
+
+  if( uiSymbol )
+  {
+    xReadEpExGolomb( uiSymbol, 0 );
+    ruiSymbol += uiSymbol + 1;
+  }
 
   return;
 }
 
+Void TDecSbac::xParseDimDeltaDC( Pel& rValDeltaDC, UInt dimType )
+{
+  UInt absValDeltaDC = 0;
+  xReadExGolombLevel( absValDeltaDC, m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
+  rValDeltaDC = (Pel)absValDeltaDC;
+
+  if( rValDeltaDC != 0 )
+  {
+    UInt uiSign;
+    m_pcTDecBinIf->decodeBinEP( uiSign );
+    if ( uiSign )
+    {
+      rValDeltaDC = -rValDeltaDC;
+    }
+  }
+}
+#if H_3D_DIM_DMM
+Void TDecSbac::xParseDmm1WedgeIdx( UInt& ruiTabIdx, Int iNumBit )
+{
+  UInt uiSymbol, uiIdx = 0;
+  for( Int i = 0; i < iNumBit; i++ )
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm1DataSCModel.get(0, 0, 0) );
+    uiIdx += uiSymbol << i;
+  }
+  ruiTabIdx = uiIdx;
+}
+#if !SEC_DMM2_E0146
+Void TDecSbac::xParseDmm2Offset( Int& riOffset )
+{
+  Int iDeltaEnd = 0;
+  if( DMM2_DELTAEND_MAX > 0 )
+  {
+    UInt uiFlag = 0;
+    m_pcTDecBinIf->decodeBin( uiFlag, m_cDmm2DataSCModel.get(0, 0, 0) );
+
+    if( uiFlag )
+    {
+      UInt uiAbsValMinus1;
+      UInt uiSymbol;
+      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1  = uiSymbol;
+      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm2DataSCModel.get(0, 0, 0) ); uiAbsValMinus1 |= uiSymbol << 1;
+      iDeltaEnd = uiAbsValMinus1 + 1;
+      UInt uiSign;
+      m_pcTDecBinIf->decodeBinEP( uiSign );
+      if( uiSign )
+      {
+        iDeltaEnd = -iDeltaEnd;
+      }
+    }
+  }
+  riOffset = iDeltaEnd;
+}
+#endif
+Void TDecSbac::xParseDmm3WedgeIdx( UInt& ruiIntraIdx, Int iNumBit )
+{
+  UInt uiSymbol, uiIdx = 0;
+  for( Int i = 0; i < iNumBit; i++ )
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmm3DataSCModel.get(0, 0, 0) );
+    uiIdx += uiSymbol << i;
+  }
+  ruiIntraIdx = uiIdx;
+}
+#endif
+#if H_3D_DIM_RBC
+Void TDecSbac::xParseRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiSymbol = 0;
+
+  // 1. Top(0) or Left(1)
+  UChar ucLeft;
+  m_pcTDecBinIf->decodeBinEP( uiSymbol );
+  ucLeft = uiSymbol;
+
+  // 2. Start position (lowest bit first)
+  UChar ucStart = 0;
+  for( UInt ui = 0; ui < 6 - uiDepth; ui++ )
+  {
+    m_pcTDecBinIf->decodeBinEP( uiSymbol );
+    ucStart |= (uiSymbol << ui);
+  }
+
+  // 3. Number of edges
+  UChar ucMax = 0;
+  for( UInt ui = 0; ui < 7 - uiDepth; ui++ )
+  {
+    m_pcTDecBinIf->decodeBinEP( uiSymbol );
+    ucMax |= (uiSymbol << ui);
+  }
+  ucMax++; // +1
+
+  // 4. Edges
+  UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * RBC_MAX_EDGE_NUM_PER_4x4 );
+  for( Int iPtr = 0; iPtr < ucMax; iPtr++ )
+  {
+    UChar ucEdge = 0;
+    UInt  uiReorderEdge = 0;
+    for( UInt ui = 0; ui < 6; ui++ )
+    {
+      m_pcTDecBinIf->decodeBin( uiSymbol, m_cRbcDataSCModel.get( 0, 0, 0 ) );
+      ucEdge <<= 1;
+      ucEdge |= uiSymbol;
+      if( uiSymbol == 0 )
+        break;
+    }
+
+    switch( ucEdge )
+    {
+    case 0 :  // "0"       
+      uiReorderEdge = 0;
+      break;
+    case 2 :  // "10"
+      uiReorderEdge = 1;
+      break;
+    case 6 :  // "110"
+      uiReorderEdge = 2;
+      break;
+    case 14 : // "1110"
+      uiReorderEdge = 3;
+      break;
+    case 30 : // "11110"
+      uiReorderEdge = 4;
+      break;
+    case 62 : // "111110"
+      uiReorderEdge = 5;
+      break;
+    case 63 : // "111111"
+      uiReorderEdge = 6;
+      break;
+    default :
+      printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge);
+      assert(false);
+      break;
+    }
+    pucSymbolList[iPtr] = uiReorderEdge;
+  }
+  /////////////////////
+  // Edge Reconstruction
+  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
+  pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion );
+  xFree( pucSymbolList );
+}
+#endif
+#if H_3D_DIM_SDC
+Void TDecSbac::xParseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiSegment )
+{
+  assert( pcCU->getSlice()->getIsDepth() );
+  assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N );
+  assert( pcCU->getSDCFlag(uiAbsPartIdx) );
+  assert( uiSegment < 2 );
+  
+  UInt uiResidual = 0;
+  UInt uiBit      = 0;
+  UInt uiAbsIdx   = 0;
+  UInt uiSign     = 0;
+  Int  iIdx       = 0;
+  
+#if H_3D_DIM_DLT
+  UInt uiMaxResidualBits = pcCU->getSlice()->getVPS()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() );
+#else
+  UInt uiMaxResidualBits = g_bitDepthY;
+#endif
+  assert( uiMaxResidualBits <= g_bitDepthY );
+  
+  m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) );
+  
+  if (uiResidual)
+  {
+    // decode residual sign bit
+    m_pcTDecBinIf->decodeBinEP(uiSign);
+    
+    // decode residual magnitude
+    // prefix part
+    UInt uiCount = 0;
+#if H_3D_DIM_DLT
+    UInt uiNumDepthValues = pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
+#else
+    UInt uiNumDepthValues = ((1 << g_bitDepthY)-1);
+#endif
+    UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2);
+    for ( UInt ui = 0; ui < uiPrefixThreshold; ui++)
+    {
+      m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) );
+      if ( uiBit == 0 )
+        break;
+      else
+        uiCount++;
+    }
+    // suffix part
+    if ( uiCount == uiPrefixThreshold )
+    {
+      for ( UInt ui = 0; ui < numBitsForValue(uiNumDepthValues - uiPrefixThreshold); ui++ )
+      {
+        m_pcTDecBinIf->decodeBinEP( uiBit );
+        uiAbsIdx |= uiBit << ui;
+      }
+      uiAbsIdx += uiCount;
+    }
+    else
+      uiAbsIdx = uiCount;
+    
+    uiAbsIdx += 1;
+    iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx;
+  }
+  
+  pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx);
+}
+#endif
+#endif
 
 /** Parse I_PCM information. 
@@ -495,31 +639,17 @@
 {
   UInt uiSymbol;
-  Int numSubseqIPCM = 0;
-  Bool readPCMSampleFlag = false;
-
-  if(pcCU->getNumSucIPCM() > 0) 
-  {
-    readPCMSampleFlag = true;
-  }
-  else
-  {
+
     m_pcTDecBinIf->decodeBinTrm(uiSymbol);
 
+#if H_MV_ENC_DEC_TRAC
+      DTRACE_CU("pcm_flag", uiSymbol)
+#endif
     if (uiSymbol)
     {
-      readPCMSampleFlag = true;
-      m_pcTDecBinIf->decodeNumSubseqIPCM(numSubseqIPCM);
-      pcCU->setNumSucIPCM(numSubseqIPCM + 1);
-      m_pcTDecBinIf->decodePCMAlignBits();
-    }
-  }
-
-  if (readPCMSampleFlag == true)
-  {
     Bool bIpcmFlag = true;
-
 
     pcCU->setPartSizeSubParts  ( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     pcCU->setSizeSubParts      ( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
+    pcCU->setTrIdxSubParts     ( 0, uiAbsPartIdx, uiDepth );
     pcCU->setIPCMFlagSubParts  ( bIpcmFlag, uiAbsPartIdx, uiDepth );
 
@@ -582,10 +712,16 @@
     }
 
-    pcCU->setNumSucIPCM( pcCU->getNumSucIPCM() - 1);
-    if(pcCU->getNumSucIPCM() == 0)
-    {
-      m_pcTDecBinIf->resetBac();
-    }
-  }
+    m_pcTDecBinIf->start();
+  }
+}
+
+Void TDecSbac::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiSymbol;
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_CUTransquantBypassFlagSCModel.get( 0, 0, 0 ) );
+#if H_MV_ENC_DEC_TRAC
+  DTRACE_CU("cu_transquant_bypass_flag", uiSymbol); 
+#endif
+  pcCU->setCUTransquantBypassSubParts(uiSymbol ? true : false, uiAbsPartIdx, uiDepth);
 }
 
@@ -606,4 +742,5 @@
   UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx );
   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) );
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ );
   DTRACE_CABAC_T( "\tSkipFlag" );
@@ -613,38 +750,18 @@
   DTRACE_CABAC_V( uiSymbol );
   DTRACE_CABAC_T( "\n");
+#endif
   
   if( uiSymbol )
   {
-    pcCU->setPredModeSubParts( MODE_SKIP,  uiAbsPartIdx, uiDepth );
+    pcCU->setSkipFlagSubParts( true,        uiAbsPartIdx, uiDepth );
+    pcCU->setPredModeSubParts( MODE_INTER,  uiAbsPartIdx, uiDepth );
     pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
     pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth );
   }
-}
-
-#if LGE_ILLUCOMP_B0045
-/** parse illumination compensation flag
- * \param pcCU
- * \param uiAbsPartIdx 
- * \param uiDepth
- * \returns Void
- */
-Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{ 
-  UInt uiSymbol = 0;
-  UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx );
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) );
-  DTRACE_CABAC_VL( g_nSymbolCounter++ );
-  DTRACE_CABAC_T( "\tICFlag" );
-  DTRACE_CABAC_T( "\tuiCtxIC: ");
-  DTRACE_CABAC_V( uiCtxIC );
-  DTRACE_CABAC_T( "\tuiSymbol: ");
-  DTRACE_CABAC_V( uiSymbol );
-  DTRACE_CABAC_T( "\n");
-  
-  pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth );
-}
-#endif
-
+#if H_MV_ENC_DEC_TRAC
+  DTRACE_CU("cu_skip_flag", uiSymbol); 
+#endif
+}
 
 /** parse merge flag
@@ -659,6 +776,10 @@
   UInt uiSymbol;
   m_pcTDecBinIf->decodeBin( uiSymbol, *m_cCUMergeFlagExtSCModel.get( 0 ) );
+#if H_MV_ENC_DEC_TRAC
+  DTRACE_PU("merge_flag", uiSymbol)
+#endif
   pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth );
 
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ );
   DTRACE_CABAC_T( "\tMergeFlag: " );
@@ -669,15 +790,11 @@
   DTRACE_CABAC_V( uiAbsPartIdx );
   DTRACE_CABAC_T( "\n" );
-}
-
-Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiNumCand = MRG_MAX_NUM_CANDS;
+#endif
+}
+
+Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex )
+{
   UInt uiUnaryIdx = 0;
-  uiNumCand = pcCU->getSlice()->getMaxNumMergeCand();
-#if HHI_MPI
-  const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE;
-  const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : uiNumCand;
-#endif
+  UInt uiNumCand = pcCU->getSlice()->getMaxNumMergeCand();
   if ( uiNumCand > 1 )
   {
@@ -698,7 +815,11 @@
       }
     }
+#if H_MV_ENC_DEC_TRAC
+    DTRACE_PU("merge_idx", uiUnaryIdx)
+#endif
   }
   ruiMergeIndex = uiUnaryIdx;
 
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tparseMergeIndex()" )
@@ -706,37 +827,7 @@
   DTRACE_CABAC_V( ruiMergeIndex )
   DTRACE_CABAC_T( "\n" )
-#if HHI_MPI
-  if( ruiMergeIndex > uiMviMergePos )
-  {
-    assert( bMVIAvailable );
-    ruiMergeIndex--;
-  }
-  else if( ruiMergeIndex == uiMviMergePos )
-  {
-    assert( bMVIAvailable );
-    pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth );
-  }
-#endif
-}
-
-#if H3D_IVRP
-Void
-TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiCtx    = pcCU->getCtxResPredFlag( uiAbsPartIdx );
-  UInt uiSymbol = 0;
-  m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) );
-  rbResPredFlag = ( uiSymbol != 0 );
-}
-#endif
-
-#if H3D_IVMP
-Void TDecSbac::parseMVPIdx      ( Int& riMVPIdx, Int iNumAMVPCands )
-{
-  UInt uiSymbol;
-  xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iNumAMVPCands-1);
-  riMVPIdx = uiSymbol;
-}
-#else
+#endif
+}
+
 Void TDecSbac::parseMVPIdx      ( Int& riMVPIdx )
 {
@@ -745,5 +836,4 @@
   riMVPIdx = uiSymbol;
 }
-#endif
 
 Void TDecSbac::parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
@@ -754,8 +844,7 @@
     return;
   }
-  
+
   UInt uiSymbol;
-
-#if H3D_QTL
+#if H_3D_QTLPC
   Bool bParseSplitFlag    = true;
 
@@ -765,6 +854,7 @@
   Bool bIntraSliceDetect  = (pcCU->getSlice()->getSliceType() == I_SLICE);
 
-  Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
-  if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC())
+  Bool rapPic = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
+
+  if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC())
   {
     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
@@ -777,12 +867,17 @@
 #endif
     m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) );
+#if H_MV_ENC_DEC_TRAC
+    DTRACE_CU("split_cu_flag", uiSymbol); 
+#else
     DTRACE_CABAC_VL( g_nSymbolCounter++ )
     DTRACE_CABAC_T( "\tSplitFlag\n" )
-#if H3D_QTL
+#endif
+#if H_3D_QTLPC
   }
   else
+  {
     uiSymbol = 0;
-#endif
-
+  }
+#endif
   pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx );
   
@@ -801,5 +896,5 @@
   PartSize eMode;
 
-#if H3D_QTL
+#if H_3D_QTLPC
   Bool bParsePartSize    = true;
   TComSPS *sps           = pcCU->getPic()->getSlice(0)->getSPS();
@@ -808,6 +903,7 @@
   Bool bIntraSliceDetect = (pcCU->getSlice()->getSliceType() == I_SLICE);
 
-  Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
-  if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTLPC())
+  Bool rapPic     = (pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || pcCU->getSlice()->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA);
+
+  if(bDepthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL() && sps->getUsePC())
   {
     TComDataCU *pcTextureCU = pcTexture->getCU(pcCU->getAddr());
@@ -820,18 +916,22 @@
   }
 #endif
+
   
   if ( pcCU->isIntra( uiAbsPartIdx ) )
   {
-#if H3D_QTL
+#if H_3D_QTLPC
     if(bParsePartSize)
     {
 #endif
-      uiSymbol = 1;
+     uiSymbol = 1;
       if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
       {
         m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) );
+#if H_MV_ENC_DEC_TRAC          
+        DTRACE_CU("part_mode", uiSymbol)
+#endif        
       }
       eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN;
-#if H3D_QTL
+#if H_3D_QTLPC
     }
 #endif
@@ -851,10 +951,10 @@
   else
   {
-#if H3D_QTL
+#if H_3D_QTLPC
     if(bParsePartSize)
     {
 #endif
       UInt uiMaxNumBits = 2;
-      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( pcCU->getSlice()->getSPS()->getDisInter4x4() && (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
+      if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && !( (g_uiMaxCUWidth>>uiDepth) == 8 && (g_uiMaxCUHeight>>uiDepth) == 8 ) )
       {
         uiMaxNumBits ++;
@@ -874,5 +974,5 @@
         if (eMode == SIZE_2NxN)
         {
-            m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
+          m_pcTDecBinIf->decodeBin(uiSymbol, m_cCUAMPSCModel.get( 0, 0, 0 ));
           if (uiSymbol == 0)
           {
@@ -891,5 +991,8 @@
         }
       }
-#if H3D_QTL
+#if H_MV_ENC_DEC_TRAC          
+      DTRACE_CU("part_mode", eMode )
+#endif
+#if H_3D_QTLPC
     }
 #endif
@@ -917,399 +1020,102 @@
   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 0 ) );
   iPredMode += uiSymbol;
+#if H_MV_ENC_DEC_TRAC          
+  DTRACE_CU("pred_mode_flag", uiSymbol)
+#endif        
   pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth );
 }
-#if PKU_QC_DEPTH_INTRA_UNI_D0195
-Void TDecSbac::parseDepthIntraMode  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiPuIdx = ( pcCU->getWidth(uiAbsPartIdx) == 64 )? 2 : ( ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && pcCU->getWidth(uiAbsPartIdx) == 8 )? 0 : 1);
-  UInt uiDir = 0;
-  Bool bSDCFlag = 0;
-  UInt uiSymbol = 1;
-  UInt uiCode = 0 ;
-  UInt uiBinNum = 0;
-  UInt uiCtxDepthMode = 0;
-  if ( uiPuIdx ==2 )
-  {
-    while(uiBinNum<2 && uiSymbol)
-    {
-      uiCtxDepthMode = uiPuIdx*3 + uiBinNum;
-      m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-      uiCode = (uiCode<<1)+uiSymbol;
-      uiBinNum++;
-    }
-    if (uiCode == 0)      { uiDir = PLANAR_IDX; bSDCFlag = 1;}
-    else if (uiCode == 2) { uiDir = 0;          bSDCFlag = 0;}
-    else if (uiCode == 3) { uiDir = DC_IDX;     bSDCFlag = 1;}
-  }
-  else if ( uiPuIdx ==0 )
-  {
-    while(uiBinNum<3 && uiSymbol)
-    {
-      uiCtxDepthMode = uiPuIdx*3 + ( uiBinNum >= 2? 2 : uiBinNum );
-      m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-      uiCode = (uiCode<<1)+uiSymbol;
-      uiBinNum++;
-    }
-    if (uiCode == 0)      { uiDir = 0;                     bSDCFlag = 0;}
-    else if (uiCode == 2) { uiDir = DMM_WEDGE_FULL_IDX;    bSDCFlag = 0;}
-    else if (uiCode == 6) { uiDir = DMM_WEDGE_PREDTEX_IDX; bSDCFlag = 0;}
-    else if (uiCode == 7) { uiDir = EDGE_INTRA_IDX;        bSDCFlag = 0;}
-  }
-  else
-  {
-    uiCtxDepthMode = uiPuIdx*3 ;
-    m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-    uiCode = (uiCode<<1)+uiSymbol;
-    if (!uiSymbol)
-    {
-      uiCtxDepthMode = uiPuIdx*3 + 1;
-      m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-      uiCode = (uiCode<<1)+uiSymbol;
-      if (uiSymbol) 
+
+Void TDecSbac::parseIntraDirLumaAng  ( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
+{
+  PartSize mode = pcCU->getPartitionSize( absPartIdx );
+  UInt partNum = mode==SIZE_NxN?4:1;
+  UInt partOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(absPartIdx) << 1 ) ) >> 2;
+  UInt mpmPred[4],symbol;
+  Int j,intraPredMode;    
+  if (mode==SIZE_NxN)
+  {
+    depth++;
+  }
+  for (j=0;j<partNum;j++)
+  {
+#if H_3D_DIM
+    if( pcCU->getSlice()->getVpsDepthModesFlag() )
+    {
+      parseIntraDepth( pcCU, absPartIdx+partOffset*j, depth );
+    }
+    if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
+#if H_3D_DIM_SDC
+      if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
+    {
+#endif
+    m_pcTDecBinIf->decodeBin( symbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
+    mpmPred[j] = symbol;
+#if H_MV_ENC_DEC_TRAC          
+    DTRACE_CU("prev_intra_luma_pred_flag", symbol)
+#endif
+#if H_3D_DIM
+    }
+#endif
+  }
+  for (j=0;j<partNum;j++)
+  {
+#if H_3D_DIM
+    if( pcCU->getLumaIntraDir( absPartIdx+partOffset*j ) < NUM_INTRA_MODE )
+#if H_3D_DIM_SDC
+      if( !pcCU->getSDCFlag( absPartIdx+partOffset*j ) )
+#endif
+    {
+#endif
+    Int preds[3] = {-1, -1, -1};
+    Int predNum = pcCU->getIntraDirLumaPredictor(absPartIdx+partOffset*j, preds);  
+    if (mpmPred[j])
+    {
+      m_pcTDecBinIf->decodeBinEP( symbol );
+      if (symbol)
+      {
+        m_pcTDecBinIf->decodeBinEP( symbol );
+        symbol++;
+      }
+#if H_MV_ENC_DEC_TRAC          
+      DTRACE_CU("mpm_idx", symbol)
+#endif
+      intraPredMode = preds[symbol];
+    }
+    else
+    {
+      m_pcTDecBinIf->decodeBinsEP( symbol, 5 );
+      intraPredMode = symbol;
+#if H_MV_ENC_DEC_TRAC          
+      DTRACE_CU("rem_intra_luma_pred_mode", symbol)
+#endif        
+      //postponed sorting of MPMs (only in remaining branch)
+      if (preds[0] > preds[1])
       { 
-        uiCtxDepthMode = uiPuIdx*3 + 2;
-        m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-        uiCode = (uiCode<<1)+uiSymbol;
-      }
-    }
-    else
-    {
-      uiCtxDepthMode = uiPuIdx*3 + 1;
-      m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-      uiCode = (uiCode<<1)+uiSymbol;
-      if (!uiSymbol) 
-      { 
-        uiCtxDepthMode = uiPuIdx*3 + 2;
-        m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-        uiCode = (uiCode<<1)+uiSymbol;
-      }
-      else
-      {
-        uiBinNum = 0;
-        while( uiSymbol && uiBinNum<3 )
-        {
-          uiCtxDepthMode = uiPuIdx*3 + 2;
-          m_pcTDecBinIf->decodeBin(uiSymbol,m_cDepthModeModel.get(0,0,uiCtxDepthMode));
-          uiCode = (uiCode<<1)+uiSymbol;
-          uiBinNum++;
-        }
-      }
-    }
-    if (uiCode == 0)       { uiDir = PLANAR_IDX;              bSDCFlag = 1;}
-    else if (uiCode == 2)  { uiDir = 5;                       bSDCFlag = 0;}
-    else if (uiCode == 3)  { uiDir = DMM_WEDGE_FULL_IDX;      bSDCFlag = 1;}
-    else if (uiCode == 4)  { uiDir = DMM_WEDGE_FULL_IDX;      bSDCFlag = 0;}
-    else if (uiCode == 5)  { uiDir = DMM_CONTOUR_PREDTEX_IDX; bSDCFlag = 0;}
-    else if (uiCode == 6)  { uiDir = DMM_WEDGE_PREDTEX_IDX;   bSDCFlag = 0;}
-    else if (uiCode == 14) { uiDir = DC_IDX;                  bSDCFlag = 1;}
-    else if (uiCode == 31) { uiDir = DMM_WEDGE_PREDDIR_IDX;   bSDCFlag = 0;}
-    else if (uiCode == 30) { uiDir = EDGE_INTRA_IDX;          bSDCFlag = 0;}
-  }
-  pcCU->setLumaIntraDirSubParts( (UChar)uiDir, uiAbsPartIdx, uiDepth );
-  pcCU->setSDCFlagSubParts(bSDCFlag, uiAbsPartIdx, 0, uiDepth); 
-}
-Void TDecSbac::parseDepthModelingTable  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  parseDepthIntraMode(pcCU,uiAbsPartIdx,uiDepth);
-  
-  UInt uiDir = pcCU->getLumaIntraDir(uiAbsPartIdx);
-  Bool bSdcFlag =  pcCU->getSDCAvailable(uiAbsPartIdx) && pcCU->getSDCFlag(uiAbsPartIdx);
-  Bool bDmmFlag = (uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX &&(!bSdcFlag))? 1:0;
-  if (uiDir >= NUM_INTRA_MODE && uiDir < EDGE_INTRA_IDX)//DMM modes and SDC DMM1
-  {
-    if( uiDir == DMM_WEDGE_FULL_IDX )          { xParseWedgeFullInfo          ( pcCU, uiAbsPartIdx, uiDepth ); }
-    else if( uiDir == DMM_WEDGE_PREDTEX_IDX )  { xParseWedgePredTexInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
-    else if( uiDir == DMM_WEDGE_PREDDIR_IDX )  { xParseWedgePredDirInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
-  } 
-  else if(uiDir >= EDGE_INTRA_IDX)//CCM mode
-  {
-    xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth );
-  }
-  
+        std::swap(preds[0], preds[1]); 
+      }
+      if (preds[0] > preds[2])
+      {
+        std::swap(preds[0], preds[2]);
+      }
+      if (preds[1] > preds[2])
+      {
+        std::swap(preds[1], preds[2]);
+      }
+      for ( Int i = 0; i < predNum; i++ )
+      {
+        intraPredMode += ( intraPredMode >= preds[i] );
+      }
+    }
+    pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, absPartIdx+partOffset*j, depth );
+#if H_3D_DIM
+    }
+#endif
+  }
+}
+
+Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
   UInt uiSymbol;
-  if (bDmmFlag)
-  {
-    if (bDmmFlag)
-    {
-      m_pcTDecBinIf->decodeBin( uiSymbol , m_cDmmDeltaFlagModel.get(0, 0, 0) );
-      uiDir += uiSymbol;
-    }
-    if (uiSymbol)
-    {
-      UInt uiDC;
-      Int iDC = 0,iDC1 = 0,iDC2 = 0;
-      for ( Int i = 0; i  <2; i++ )
-      {
-        xReadExGolombLevel( uiDC, m_cDmmDataSCModel.get(0, 0, 1) );
-        iDC = uiDC;
-        if ( uiDC )
-        {
-          UInt uiSign;
-          m_pcTDecBinIf->decodeBinEP( uiSign );
-          if ( uiSign )
-          {
-            iDC = -iDC;
-          }
-        }
-        if ( i == 0 ) { iDC1 = iDC; }
-        else          { iDC2 = iDC; }
-      }
-
-      if( uiDir == DMM_WEDGE_FULL_D_IDX )   
-      { 
-        pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-        pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-      }
-      else if( uiDir == DMM_WEDGE_PREDDIR_D_IDX ) 
-      { 
-        pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-        pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-      }
-      else if( uiDir == DMM_WEDGE_PREDTEX_D_IDX)  
-      { 
-        pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-        pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-      }
-      else if (uiDir== DMM_CONTOUR_PREDTEX_D_IDX )
-      {
-        pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-        pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-      }
-    }
-  }
-  else if (uiDir >= EDGE_INTRA_IDX)
-  {
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
-    if( uiSymbol )
-    {
-      uiDir = EDGE_INTRA_DELTA_IDX;
-      Int iDeltaDC = 0,iDeltaDC0 = 0,iDeltaDC1 = 0;
-      for (Int i = 0; i<2; i++)
-      {
-        xReadExGolombLevel( (UInt &) iDeltaDC, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
-        if( iDeltaDC != 0 )
-        {
-          UInt uiSign;
-          m_pcTDecBinIf->decodeBinEP( uiSign );
-          if ( uiSign )
-          {
-            iDeltaDC = -iDeltaDC;
-          }
-        }
-        if ( i == 0 ) { iDeltaDC0 = iDeltaDC; }
-        else          { iDeltaDC1 = iDeltaDC; }
-      }
-
-      pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
-      pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
-    }
-  }
-  else if(bSdcFlag)//SDC mode
-  {
-    assert(pcCU->getPartitionSize(uiAbsPartIdx)!=SIZE_NxN);
-    pcCU->setTrIdxSubParts(0, uiAbsPartIdx, uiDepth);
-    pcCU->setCbfSubParts(1, 1, 1, uiAbsPartIdx, uiDepth);
-
-    UInt uiNumSegments = ( uiDir == DC_IDX || uiDir == PLANAR_IDX )? 1 : 2;
-    for (int uiSeg=0; uiSeg<uiNumSegments; uiSeg++)
-    {
-      parseSDCResidualData(pcCU, uiAbsPartIdx, uiDepth, uiSeg);
-    }
-  }
-
-  pcCU->setLumaIntraDirSubParts( (UChar)uiDir, uiAbsPartIdx, uiDepth );
-}
-#endif
-Void TDecSbac::parseIntraDirLumaAng  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiSymbol;
-  Int  intraPredMode;
-#if PKU_QC_DEPTH_INTRA_UNI_D0195
-  if (pcCU->getSlice()->getSPS()->isDepth())
-  {
-    parseDepthModelingTable(pcCU, uiAbsPartIdx, uiDepth);
-  }
-  if (pcCU->getLumaIntraDir(uiAbsPartIdx)<NUM_INTRA_MODE && !pcCU->getSDCFlag(uiAbsPartIdx))
-  {
-#else
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  UInt uiFlag = 0;
-  if( pcCU->getSlice()->getSPS()->getUseDMM() && (g_uiMaxCUWidth>>uiDepth) <= DMM_WEDGEMODEL_MAX_SIZE )
-  {
-    m_pcTDecBinIf->decodeBin( uiFlag, m_cDmmFlagSCModel.get(0, 0, 0) );
-  }
-  if( uiFlag )
-  {
-    UInt uiDMMode;
-
-#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1;
-    if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 )
-    {
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 2;
-    }
-#else
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode  = uiSymbol;
-    if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 )
-    {
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmModeSCModel.get(0, 0, 0) ); uiDMMode |= uiSymbol << 1;
-    }
-#endif
-    intraPredMode = uiDMMode + NUM_INTRA_MODE;
-
-#if HHI_DMM_WEDGE_INTRA
-    if( intraPredMode == DMM_WEDGE_FULL_IDX )          { xParseWedgeFullInfo          ( pcCU, uiAbsPartIdx, uiDepth ); }
-    if( intraPredMode == DMM_WEDGE_FULL_D_IDX )        { xParseWedgeFullDeltaInfo     ( pcCU, uiAbsPartIdx, uiDepth ); }
-    if( intraPredMode == DMM_WEDGE_PREDDIR_IDX )       { xParseWedgePredDirInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
-    if( intraPredMode == DMM_WEDGE_PREDDIR_D_IDX )     { xParseWedgePredDirDeltaInfo  ( pcCU, uiAbsPartIdx, uiDepth ); }
-#endif
-#if HHI_DMM_PRED_TEX
-    if( intraPredMode == DMM_WEDGE_PREDTEX_D_IDX )     { xParseWedgePredTexDeltaInfo  ( pcCU, uiAbsPartIdx, uiDepth ); }
-#if LGE_DMM3_SIMP_C0044
-    if( intraPredMode == DMM_WEDGE_PREDTEX_IDX )       { xParseWedgePredTexInfo       ( pcCU, uiAbsPartIdx, uiDepth ); }
-#endif
-    if( intraPredMode == DMM_CONTOUR_PREDTEX_D_IDX )   { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); }
-#endif
-  }
-  else
-  {
-#endif
-
-#if LGE_EDGE_INTRA_A0070
-    Bool bCodeEdgeIntra = false;
-    if( pcCU->getSlice()->getSPS()->isDepth() )
-    {
-      UInt uiPUWidth = pcCU->getWidth( uiAbsPartIdx ) >> (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
-      if( uiPUWidth <= LGE_EDGE_INTRA_MAX_SIZE && uiPUWidth >= LGE_EDGE_INTRA_MIN_SIZE )
-        bCodeEdgeIntra = true;
-    }
-#endif
-#endif
-    Int uiPreds[3] = {-1, -1, -1};
-    Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds);  
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-#if LGE_EDGE_INTRA_A0070
-    UInt uiCheckBit = 0;
-#endif
-#endif
-
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) );
-
-    if ( uiSymbol )
-    {
-      m_pcTDecBinIf->decodeBinEP( uiSymbol );
-      if (uiSymbol)
-      {
-        m_pcTDecBinIf->decodeBinEP( uiSymbol );
-        uiSymbol++;
-      }
-      intraPredMode = uiPreds[uiSymbol];
-    }
-    else
-    {
-      intraPredMode = 0;
-
-
-      m_pcTDecBinIf->decodeBinsEP( uiSymbol, 5 );
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-#if LGE_EDGE_INTRA_A0070
-      if (bCodeEdgeIntra)
-      {
-        if (uiSymbol==31)
-        {
-          m_pcTDecBinIf->decodeBinsEP(uiCheckBit,1);
-          if (uiCheckBit)
-            uiSymbol = EDGE_INTRA_IDX;
-        }
-      }
-#endif
-#endif
-      intraPredMode = uiSymbol;
-
-      //postponed sorting of MPMs (only in remaining branch)
-      if (uiPreds[0] > uiPreds[1])
-      { 
-        std::swap(uiPreds[0], uiPreds[1]); 
-      }
-      if (uiPreds[0] > uiPreds[2])
-      {
-        std::swap(uiPreds[0], uiPreds[2]);
-      }
-      if (uiPreds[1] > uiPreds[2])
-      {
-        std::swap(uiPreds[1], uiPreds[2]);
-      }
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-#if LGE_EDGE_INTRA_A0070
-      if ( intraPredMode != EDGE_INTRA_IDX)
-      {
-#endif
-#endif
-        for ( Int i = 0; i < uiPredNum; i++ )
-        {
-          intraPredMode += ( intraPredMode >= uiPreds[i] );
-        }
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-#if LGE_EDGE_INTRA_A0070
-      }
-#endif
-#endif
-    }
-
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-#if LGE_EDGE_INTRA_A0070
-    if( intraPredMode == EDGE_INTRA_IDX )
-    {
-      xParseEdgeIntraInfo( pcCU, uiAbsPartIdx, uiDepth );
-#if LGE_EDGE_INTRA_DELTA_DC
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 0) );
-      if( uiSymbol )
-      {
-        intraPredMode = EDGE_INTRA_DELTA_IDX;
-        Int iDeltaDC0;
-        Int iDeltaDC1;
-
-        xReadExGolombLevel( (UInt &) iDeltaDC0, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
-        if( iDeltaDC0 != 0 )
-        {
-          UInt uiSign;
-          m_pcTDecBinIf->decodeBinEP( uiSign );
-          if ( uiSign )
-          {
-            iDeltaDC0 = -iDeltaDC0;
-          }
-        }
-        xReadExGolombLevel( (UInt &) iDeltaDC1, m_cEdgeIntraDeltaDCSCModel.get(0, 0, 1) );
-        if( iDeltaDC1 != 0 )
-        {
-          UInt uiSign;
-          m_pcTDecBinIf->decodeBinEP( uiSign );
-          if ( uiSign )
-          {
-            iDeltaDC1 = -iDeltaDC1;
-          }
-        }
-
-        pcCU->setEdgeDeltaDC0( uiAbsPartIdx, iDeltaDC0 );
-        pcCU->setEdgeDeltaDC1( uiAbsPartIdx, iDeltaDC1 );
-      }
-#endif
-    }
-#endif
-
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
-  }
-#endif
-  pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth );
-#else
-  pcCU->setLumaIntraDirSubParts( (UChar)intraPredMode, uiAbsPartIdx, uiDepth );
-}
-#endif
-}
-
-Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiSymbol;
 
   m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 0 ) );
@@ -1317,25 +1123,17 @@
   if( uiSymbol == 0 )
   {
+#if H_MV_ENC_DEC_TRAC          
+    DTRACE_CU("intra_chroma_pred_mode", uiSymbol )
+#endif        
     uiSymbol = DM_CHROMA_IDX;
   } 
   else 
   {
-    if( pcCU->getSlice()->getSPS()->getUseLMChroma() )
-    {
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) );
-    }
-    else
-    {
-      uiSymbol = 1;
-    }
-
-    if( uiSymbol == 0 )
-    {
-      uiSymbol = LM_CHROMA_IDX;
-    } 
-    else
     {
       UInt uiIPredMode;
       m_pcTDecBinIf->decodeBinsEP( uiIPredMode, 2 );
+#if H_MV_ENC_DEC_TRAC          
+      DTRACE_CU("intra_chroma_pred_mode", uiIPredMode )
+#endif        
       UInt uiAllowedChromaDir[ NUM_CHROMA_MODE ];
       pcCU->getAllowedChromaDir( uiAbsPartIdx, uiAllowedChromaDir );
@@ -1347,26 +1145,274 @@
 }
 
-Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth )
+#if H_3D_DIM
+Void TDecSbac::parseIntraDepth( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
+{
+  parseIntraDepthMode( pcCU, absPartIdx, depth );
+
+  UInt dir     = pcCU->getLumaIntraDir( absPartIdx );
+  UInt dimType = getDimType( dir );
+
+  switch( dimType )
+  {
+#if H_3D_DIM_DMM
+  case( DMM1_IDX ):
+    {
+      UInt uiTabIdx = 0;
+      xParseDmm1WedgeIdx( uiTabIdx, g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
+      pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dimType, absPartIdx, depth );
+    } break;
+#if !SEC_DMM2_E0146
+  case( DMM2_IDX ):
+    {
+      Int iOffset = 0;
+      xParseDmm2Offset( iOffset );
+      pcCU->setDmm2DeltaEndSubParts( iOffset, absPartIdx, depth );
+    } break;
+#endif
+  case( DMM3_IDX ):
+    {
+      UInt uiIntraIdx = 0;
+      xParseDmm3WedgeIdx( uiIntraIdx, g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
+      pcCU->setDmm3IntraTabIdxSubParts( uiIntraIdx, absPartIdx, depth );
+    } break;
+  case( DMM4_IDX ): break;
+#endif
+#if H_3D_DIM_RBC
+  case( RBC_IDX ): 
+    {
+      xParseRbcEdge( pcCU, absPartIdx, depth );
+    } break;
+#endif
+  default: break;
+  }
+
+#if H_3D_DIM_SDC
+  if( pcCU->getSDCFlag(absPartIdx) )
+  {
+    assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N);
+    pcCU->setTrIdxSubParts(0, absPartIdx, depth);
+    pcCU->setCbfSubParts(1, 1, 1, absPartIdx, depth);
+
+    UInt uiNumSegments = ( dir == DC_IDX || dir == PLANAR_IDX )? 1 : 2;
+    for (UInt uiSeg=0; uiSeg<uiNumSegments; uiSeg++)
+    {
+      xParseSDCResidualData(pcCU, absPartIdx, depth, uiSeg);
+    }
+  }
+  else
+  {
+#endif
+    if( dimType < DIM_NUM_TYPE )
+    {
+      UInt symbol;
+      m_pcTDecBinIf->decodeBin( symbol, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
+      if( symbol )
+      {
+        dir += symbol;
+        for( UInt segment = 0; segment < 2; segment++ )
+        {
+          Pel valDeltaDC = 0;
+          xParseDimDeltaDC( valDeltaDC, dimType );
+          pcCU->setDimDeltaDC( dimType, segment, absPartIdx, valDeltaDC );
+        }
+      }
+    }
+#if H_3D_DIM_SDC
+  }
+#endif
+
+  pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
+}
+
+Void TDecSbac::parseIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx, UInt depth )
+{
+  UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 );
+  UInt dir = 0;
+  Bool sdcFlag = 0;
+  UInt symbol = 1;
+  UInt modeCode = 0 ;
+  UInt binNum = 0;
+  UInt ctxDepthMode = 0;
+
+  if( puIdx == 2 )
+  {
+#if !LGE_SDC_REMOVE_DC_E0158
+    while( binNum < 2 && symbol )
+#endif
+    {
+      ctxDepthMode = puIdx*3 + binNum;
+      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+      modeCode = (modeCode<<1) + symbol;
+      binNum++;
+    }
+         if( modeCode == 0 ) { dir = PLANAR_IDX; sdcFlag = 1;}
+#if LGE_SDC_REMOVE_DC_E0158
+    else if( modeCode == 1 ) { dir = 0;          sdcFlag = 0;}
+#else
+    else if( modeCode == 2 ) { dir = 0;          sdcFlag = 0;}
+    else if( modeCode == 3 ) { dir =     DC_IDX; sdcFlag = 1;}
+#endif
+  }
+  else if( puIdx == 0 )
+  {
+    while( binNum < 3 && symbol )
+    {
+      ctxDepthMode = puIdx*3 + ((binNum >= 2) ? 2 : binNum);
+      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+      modeCode = (modeCode<<1) + symbol;
+      binNum++;
+    }
+         if( modeCode == 0 ) { dir = 0;                       sdcFlag = 0;}
+    else if( modeCode == 2 ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 6 ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 7 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+  }
+  else
+  {
+#if ZJU_DEPTH_INTRA_MODE_E0204
+      UInt maxBinNum = 0;
+      m_pcTDecBinIf->decodeBinEP(symbol);
+      if( symbol == 1 )
+      {
+          maxBinNum = 3;
+      }
+      else
+      {
+          maxBinNum = 2;
+          symbol = 1;
+      }
+      while( binNum<maxBinNum && symbol )
+      {
+          ctxDepthMode = puIdx*3 + ( binNum >= 2 ? 2 : binNum );
+          m_pcTDecBinIf->decodeBin(symbol,m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode));
+          modeCode = (modeCode<<1)+symbol;
+          binNum++;
+      }
+      if( maxBinNum == 3 )
+      {
+          if ( modeCode == 0 )       { dir =  PLANAR_IDX;             sdcFlag = 1;}
+          else if ( modeCode == 2 )  { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+          else if ( modeCode == 6 )  { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
+          else if ( modeCode == 7 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+      }
+      else
+      {
+          if ( modeCode == 0 )       { dir = 5;                       sdcFlag = 0;}
+          else if ( modeCode == 2 )  { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
+          else if ( modeCode == 3 )  { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
+      }
+#else
+    ctxDepthMode = puIdx*3 ;
+    m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+    modeCode = (modeCode<<1) + symbol;
+    if( !symbol )
+    {
+      ctxDepthMode = puIdx*3 + 1;
+      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+      modeCode = (modeCode<<1) + symbol;
+      if( symbol ) 
+      { 
+        ctxDepthMode = puIdx*3 + 2;
+        m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+        modeCode = (modeCode<<1) + symbol;
+      }
+    }
+    else
+    {
+      ctxDepthMode = puIdx*3 + 1;
+      m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+      modeCode = (modeCode<<1) + symbol;
+      if( !symbol ) 
+      { 
+        ctxDepthMode = puIdx*3 + 2;
+        m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+        modeCode = (modeCode<<1) + symbol;
+      }
+      else
+      {
+        binNum = 0;
+#if LGE_SDC_REMOVE_DC_E0158
+#if !SEC_DMM2_E0146
+        while( symbol && binNum < 2 )
+#endif
+#else
+#if SEC_DMM2_E0146
+        while( symbol && binNum < 2 )
+#else
+        while( symbol && binNum < 3 )
+#endif
+#endif
+        {
+          ctxDepthMode = puIdx*3 + 2;
+          m_pcTDecBinIf->decodeBin( symbol, m_cDepthIntraModeSCModel.get(0,0,ctxDepthMode) );
+          modeCode = (modeCode<<1) + symbol;
+          binNum++;
+        }
+      }
+    }
+         if( modeCode == 0  ) { dir =  PLANAR_IDX;             sdcFlag = 1;}
+    else if( modeCode == 2  ) { dir = 5;                       sdcFlag = 0;}
+    else if( modeCode == 3  ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 1;}
+    else if( modeCode == 4  ) { dir = (2*DMM1_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 5  ) { dir = (2*DMM4_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 6  ) { dir = (2*DMM3_IDX+DIM_OFFSET); sdcFlag = 0;}
+#if LGE_SDC_REMOVE_DC_E0158
+#if SEC_DMM2_E0146
+    else if( modeCode == 7 )  { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+#else
+    else if( modeCode == 14 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 15 ) { dir = (2*DMM2_IDX+DIM_OFFSET); sdcFlag = 0;}
+#endif
+#else
+    else if( modeCode == 14 ) { dir =      DC_IDX;             sdcFlag = 1;}
+#if SEC_DMM2_E0146
+    else if( modeCode == 15 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+#else
+    else if( modeCode == 30 ) { dir = (2* RBC_IDX+DIM_OFFSET); sdcFlag = 0;}
+    else if( modeCode == 31 ) { dir = (2*DMM2_IDX+DIM_OFFSET); sdcFlag = 0;}
+#endif
+#endif
+#endif
+  }
+  pcCU->setLumaIntraDirSubParts( (UChar)dir, absPartIdx, depth );
+#if H_3D_DIM_SDC
+  pcCU->setSDCFlagSubParts( sdcFlag, absPartIdx, depth ); 
+#endif
+}
+#endif
+
+Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx )
 {
   UInt uiSymbol;
   const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx );
   ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 );
-  m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );
+  uiSymbol = 0;
+  if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 )
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );
+  }
 
   if( uiSymbol )
   {
     uiSymbol = 2;
+  }
+  else
+  {
+    m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + 4 ) );
+    assert(uiSymbol == 0 || uiSymbol == 1);
   }
 
   uiSymbol++;
   ruiInterDir = uiSymbol;
+#if H_MV_ENC_DEC_TRAC
+    DTRACE_PU("inter_pred_idc", ruiInterDir - 1 )    
+#endif
+
   return;
 }
 
-Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
+Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList )
 {
   UInt uiSymbol;
-
-  if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C)
   {
     ContextModel *pCtx = m_cCURefPicSCModel.get( 0 );
@@ -1375,22 +1421,39 @@
     if( uiSymbol )
     {
-      xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 );
-      uiSymbol++;
+      UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2;
+      pCtx++;
+      UInt ui;
+      for( ui = 0; ui < uiRefNum; ++ui )
+      {
+        if( ui == 0 )
+        {
+          m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
+        }
+        else
+        {
+          m_pcTDecBinIf->decodeBinEP( uiSymbol );
+        }
+        if( uiSymbol == 0 )
+        {
+          break;
+        }
+      }
+      uiSymbol = ui + 1;
     }
     riRefFrmIdx = uiSymbol;
   }
+
+#if H_MV_ENC_DEC_TRAC
+#if ENC_DEC_TRACE
+  if ( eRefList == REF_PIC_LIST_0 )
+  {
+    DTRACE_PU("ref_idx_l0", uiSymbol)
+  }
   else
   {
-    ContextModel *pCtx = m_cCURefPicSCModel.get( 0 );
-    m_pcTDecBinIf->decodeBin( uiSymbol, *pCtx );
-
-    if( uiSymbol )
-    {
-      xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 );
-      uiSymbol++;
-    }
-    riRefFrmIdx = uiSymbol;
-  }
-
+    DTRACE_PU("ref_idx_l1", uiSymbol)
+  }
+#endif
+#endif
   return;
 }
@@ -1412,5 +1475,4 @@
   else
   {
-
     m_pcTDecBinIf->decodeBin( uiHorAbs, *pCtx );
     m_pcTDecBinIf->decodeBin( uiVerAbs, *pCtx );
@@ -1465,4 +1527,5 @@
 {
   m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) );
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" )
@@ -1472,11 +1535,13 @@
   DTRACE_CABAC_V( uiLog2TransformBlockSize )
   DTRACE_CABAC_T( "\n" )
-}
-
-Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf )
+#endif
+}
+
+Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf )
 {
   UInt uiSymbol;
   const UInt uiCtx = 0;
   m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) );
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tparseQtRootCbf()" )
@@ -1488,4 +1553,7 @@
   DTRACE_CABAC_V( uiAbsPartIdx )
   DTRACE_CABAC_T( "\n" )
+#else
+  DTRACE_CU( "rqt_root_cbf", uiSymbol )
+#endif
   
   uiQtRootCbf = uiSymbol;
@@ -1498,33 +1566,32 @@
   Int  iDQp;
   
-  m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) );
-  
-  if ( uiDQp == 0 )
-  {
-    qp = pcCU->getRefQP(uiAbsPartIdx);
-  }
-  else
+  UInt uiSymbol;
+
+  xReadUnaryMaxSymbol (uiDQp,  &m_cCUDeltaQpSCModel.get( 0, 0, 0 ), 1, CU_DQP_TU_CMAX);
+
+  if( uiDQp >= CU_DQP_TU_CMAX)
+  {
+    xReadEpExGolomb( uiSymbol, CU_DQP_EG_k );
+    uiDQp+=uiSymbol;
+  }
+
+  if ( uiDQp > 0 )
   {
     UInt uiSign;
     Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY();
     m_pcTDecBinIf->decodeBinEP(uiSign);
-
-    UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign);
-    UInt uiAbsDQpMinus1;
-    xReadUnaryMaxSymbol (uiAbsDQpMinus1,  &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1);
-
-    iDQp = uiAbsDQpMinus1 + 1;
-
+    iDQp = uiDQp;
     if(uiSign)
     {
       iDQp = -iDQp;
     }
-
     qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY;
   }
-  
-  UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ;
-  UInt uiQpCUDepth =   min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ;
-  pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth );
+  else 
+  {
+    qp = pcCU->getRefQP(uiAbsPartIdx);
+  }
+  pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth);  
+  pcCU->setCodedQP(qp);
 }
 
@@ -1532,7 +1599,7 @@
 {
   UInt uiSymbol;
-  const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth );
+  const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth );
   m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) );
-  
+#if !H_MV_ENC_DEC_TRAC  
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tparseQtCbf()" )
@@ -1546,6 +1613,45 @@
   DTRACE_CABAC_V( uiAbsPartIdx )
   DTRACE_CABAC_T( "\n" )
+#endif
   
   pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth );
+}
+
+void TDecSbac::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType)
+{
+  if (pcCU->getCUTransquantBypass(uiAbsPartIdx))
+  {
+    return;
+  }
+  if(width != 4 || height != 4)
+  {
+    return;
+  }
+  
+  UInt useTransformSkip;
+  m_pcTDecBinIf->decodeBin( useTransformSkip , m_cTransformSkipSCModel.get( 0, eTType? TEXT_CHROMA: TEXT_LUMA, 0 ) );
+  if(eTType!= TEXT_LUMA)
+  {
+    const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - uiDepth;
+    if(uiLog2TrafoSize == 2) 
+    { 
+      uiDepth --;
+    }
+  }
+#if !H_MV_ENC_DEC_TRAC
+  DTRACE_CABAC_VL( g_nSymbolCounter++ )
+  DTRACE_CABAC_T("\tparseTransformSkip()");
+  DTRACE_CABAC_T( "\tsymbol=" )
+  DTRACE_CABAC_V( useTransformSkip )
+  DTRACE_CABAC_T( "\tAddr=" )
+  DTRACE_CABAC_V( pcCU->getAddr() )
+  DTRACE_CABAC_T( "\tetype=" )
+  DTRACE_CABAC_V( eTType )
+  DTRACE_CABAC_T( "\tuiAbsPartIdx=" )
+  DTRACE_CABAC_V( uiAbsPartIdx )
+  DTRACE_CABAC_T( "\n" )
+#endif
+
+  pcCU->setTransformSkipSubParts( useTransformSkip, eTType, uiAbsPartIdx, uiDepth);
 }
 
@@ -1566,17 +1672,13 @@
   ContextModel *pCtxY = m_cCuCtxLastY.get( 0, eTType );
 
+  Int blkSizeOffsetX, blkSizeOffsetY, shiftX, shiftY;
+  blkSizeOffsetX = eTType ? 0: (g_aucConvertToBit[ width ] *3 + ((g_aucConvertToBit[ width ] +1)>>2));
+  blkSizeOffsetY = eTType ? 0: (g_aucConvertToBit[ height ]*3 + ((g_aucConvertToBit[ height ]+1)>>2));
+  shiftX= eTType ? g_aucConvertToBit[ width  ] :((g_aucConvertToBit[ width  ]+3)>>2);
+  shiftY= eTType ? g_aucConvertToBit[ height ] :((g_aucConvertToBit[ height ]+3)>>2);
   // posX
-  Int widthCtx = eTType ? 4 : width;
-  const UInt *puiCtxIdxX = g_uiLastCtx + ( g_aucConvertToBit[ widthCtx ] * ( g_aucConvertToBit[ widthCtx ] + 3 ) );
   for( uiPosLastX = 0; uiPosLastX < g_uiGroupIdx[ width - 1 ]; uiPosLastX++ )
   {
-    if ( eTType  )
-    {
-      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + (uiPosLastX>>g_aucConvertToBit[ width ])  ) );
-    }
-    else
-    {
-      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + puiCtxIdxX[ uiPosLastX ] ) );
-    }
+    m_pcTDecBinIf->decodeBin( uiLast, *( pCtxX + blkSizeOffsetX + (uiPosLastX >>shiftX) ) );
     if( !uiLast )
     {
@@ -1586,16 +1688,7 @@
 
   // posY
-  Int heightCtx = eTType? 4 : height;
-  const UInt *puiCtxIdxY = g_uiLastCtx + ( g_aucConvertToBit[ heightCtx ] * ( g_aucConvertToBit[ heightCtx ] + 3 ) );
   for( uiPosLastY = 0; uiPosLastY < g_uiGroupIdx[ height - 1 ]; uiPosLastY++ )
   {
-    if (eTType)
-    {
-      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + (uiPosLastY>>g_aucConvertToBit[ height ]) ) );
-    }
-    else
-    {
-      m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + puiCtxIdxY[ uiPosLastY ] ) );
-    }
+    m_pcTDecBinIf->decodeBin( uiLast, *( pCtxY + blkSizeOffsetY + (uiPosLastY >>shiftY)) );
     if( !uiLast )
     {
@@ -1634,4 +1727,5 @@
 Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType )
 {
+#if !H_MV_ENC_DEC_TRAC
   DTRACE_CABAC_VL( g_nSymbolCounter++ )
   DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" )
@@ -1658,4 +1752,5 @@
   DTRACE_CABAC_V(  pcCU->getPredictionMode( uiAbsPartIdx ) )
   DTRACE_CABAC_T( "\n" )
+#endif
   
   if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() )
@@ -1664,5 +1759,9 @@
     uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize();
   }
-  
+  if(pcCU->getSlice()->getPPS()->getUseTransformSkip())
+  {
+    parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType);
+  }
+
   eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA );
   
@@ -1672,10 +1771,4 @@
   const UInt  uiMaxNumCoeffM1   = uiMaxNumCoeff - 1;
   UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
-  int blockType = uiLog2BlockSize;
-  if (uiWidth != uiHeight)
-  {
-    uiScanIdx = SCAN_DIAG;
-    blockType = 4;
-  }
   
   //===== decode last significant =====
@@ -1686,19 +1779,6 @@
 
   //===== decode significance flags =====
-  UInt uiScanPosLast   = uiBlkPosLast;
-  if (uiScanIdx == SCAN_ZIGZAG)
-  {
-    // Map zigzag to diagonal scan
-    uiScanIdx = SCAN_DIAG;
-  }
-  const UInt * scan;
-  if (uiWidth == uiHeight)
-  {
-    scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
-  }
-  else
-  {
-    scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ];
-  }
+  UInt uiScanPosLast;
+  const UInt *scan   = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
   for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ )
   {
@@ -1714,11 +1794,9 @@
 
   const Int  iLastScanSet      = uiScanPosLast >> LOG2_SCAN_SET_SIZE;
-  UInt uiNumOne                = 0;
+  UInt c1 = 1;
   UInt uiGoRiceParam           = 0;
 
-  UInt const tsig = pcCU->getSlice()->getPPS()->getTSIG();
-#if LOSSLESS_CODING
   Bool beValid; 
-  if (pcCU->isLosslessCoded(uiAbsPartIdx))
+  if (pcCU->getCUTransquantBypass(uiAbsPartIdx))
   {
     beValid = false;
@@ -1728,7 +1806,4 @@
     beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0;
   }
-#else
-  Bool beValid = pcCU->getSlice()->getPPS()->getSignHideFlag() > 0;
-#endif
   UInt absSum = 0;
 
@@ -1737,5 +1812,4 @@
   const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1);
   const UInt * scanCG;
-  if (uiWidth == uiHeight)
   {
     scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0  ];    
@@ -1748,8 +1822,4 @@
       scanCG = g_sigLastScanCG32x32;
     }
-  }
-  else
-  {
-    scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ];
   }
   Int  iScanPosSig             = (Int) uiScanPosLast;
@@ -1772,75 +1842,66 @@
     }
 
-      // decode significant_coeffgroup_flag
-      Int iCGBlkPos = scanCG[ iSubSet ];
-      Int iCGPosY   = iCGBlkPos / uiNumBlkSide;
-      Int iCGPosX   = iCGBlkPos - (iCGPosY * uiNumBlkSide);
-      if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
-      {
-        iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0);
-        iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0);
-      }
-      if( iSubSet == iLastScanSet || iSubSet == 0)
-      {
-        uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
-      }
-      else
-      {
-          UInt uiSigCoeffGroup;
-          UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight );
-          m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );
-          uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup;
-      }
-
-      // decode significant_coeff_flag
-      UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig;
-      for( ; iScanPosSig >= iSubPos; iScanPosSig-- )
-      {
-        uiBlkPos  = scan[ iScanPosSig ];
-        uiPosY    = uiBlkPos >> uiLog2BlockSize;
-        uiPosX    = uiBlkPos - ( uiPosY << uiLog2BlockSize );
-        uiSig     = 0;
-        
-        if( uiSigCoeffGroupFlag[ iCGBlkPos ] )
+    // decode significant_coeffgroup_flag
+    Int iCGBlkPos = scanCG[ iSubSet ];
+    Int iCGPosY   = iCGBlkPos / uiNumBlkSide;
+    Int iCGPosX   = iCGBlkPos - (iCGPosY * uiNumBlkSide);
+    if( iSubSet == iLastScanSet || iSubSet == 0)
+    {
+      uiSigCoeffGroupFlag[ iCGBlkPos ] = 1;
+    }
+    else
+    {
+      UInt uiSigCoeffGroup;
+      UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );
+      m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );
+      uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup;
+    }
+
+    // decode significant_coeff_flag
+    Int patternSigCtx = TComTrQuant::calcPatternSigCtx( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );
+    UInt uiBlkPos, uiPosY, uiPosX, uiSig, uiCtxSig;
+    for( ; iScanPosSig >= iSubPos; iScanPosSig-- )
+    {
+      uiBlkPos  = scan[ iScanPosSig ];
+      uiPosY    = uiBlkPos >> uiLog2BlockSize;
+      uiPosX    = uiBlkPos - ( uiPosY << uiLog2BlockSize );
+      uiSig     = 0;
+      
+      if( uiSigCoeffGroupFlag[ iCGBlkPos ] )
+      {
+        if( iScanPosSig > iSubPos || iSubSet == 0  || numNonZero )
         {
-          if( iScanPosSig > iSubPos || iSubSet == 0  || numNonZero )
-          {
-            uiCtxSig  = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
-            m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );
-          }
-          else
-          {
-            uiSig = 1;
-          }
+          uiCtxSig  = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType );
+          m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );
         }
-        pcCoef[ uiBlkPos ] = uiSig;
-        if( uiSig )
+        else
         {
-          pos[ numNonZero ] = uiBlkPos;
-          numNonZero ++;
-          if( lastNZPosInCG == -1 )
-          {
-            lastNZPosInCG = iScanPosSig;
-          }
-          firstNZPosInCG = iScanPosSig;
+          uiSig = 1;
         }
       }
-
+      pcCoef[ uiBlkPos ] = uiSig;
+      if( uiSig )
+      {
+        pos[ numNonZero ] = uiBlkPos;
+        numNonZero ++;
+        if( lastNZPosInCG == -1 )
+        {
+          lastNZPosInCG = iScanPosSig;
+        }
+        firstNZPosInCG = iScanPosSig;
+      }
+    }
     
     if( numNonZero )
     {
-      Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= (Int)tsig );
+      Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD );
       absSum = 0;
-
-      UInt c1 = 1;
       UInt uiCtxSet    = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0;
       UInt uiBin;
-      
-      if( uiNumOne > 0 )
+      if( c1 == 0 )
       {
         uiCtxSet++;
       }
-      
-      uiNumOne       >>= 1;
+      c1 = 1;
       ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet;
       Int absCoeff[SCAN_SET_SIZE];
@@ -1900,6 +1961,10 @@
           {
             UInt uiLevel;
-            xReadGoRiceExGolomb( uiLevel, uiGoRiceParam );
+            xReadCoefRemainExGolomb( uiLevel, uiGoRiceParam );
             absCoeff[ idx ] = uiLevel + baseLevel;
+            if(absCoeff[idx]>3*(1<<uiGoRiceParam))
+            {
+              uiGoRiceParam = min<UInt>(uiGoRiceParam+ 1, 4);
+            }
           }
 
@@ -1907,5 +1972,4 @@
           {
             iFirstCoeff2 = 0;
-            uiNumOne++;
           }
         }
@@ -1923,5 +1987,7 @@
           // Infer sign of 1st element.
           if (absSum&0x1)
+          {
             pcCoef[ blkPos ] = -pcCoef[ blkPos ];
+          }
         }
         else
@@ -1933,8 +1999,4 @@
       }
     }
-    else
-    {
-      uiNumOne >>= 1;
-    }
   }
   
@@ -1942,355 +2004,69 @@
 }
 
-#if LGE_SAO_MIGRATION_D0091
+
 Void TDecSbac::parseSaoMaxUvlc ( UInt& val, UInt maxSymbol )
 {
-    if (maxSymbol == 0)
-    {
-        val = 0;
-        return;
-    }
-
-    UInt code;
-    Int  i;
+  if (maxSymbol == 0)
+  {
+    val = 0;
+    return;
+  }
+
+  UInt code;
+  Int  i;
+  m_pcTDecBinIf->decodeBinEP( code );
+  if ( code == 0 )
+  {
+    val = 0;
+    return;
+  }
+
+  i=1;
+  while (1)
+  {
     m_pcTDecBinIf->decodeBinEP( code );
     if ( code == 0 )
     {
-        val = 0;
-        return;
-    }
-
-    i=1;
-    while (1)
-    {
-        m_pcTDecBinIf->decodeBinEP( code );
-        if ( code == 0 )
-        {
-            break;
-        }
-        i++;
-        if (i == maxSymbol)
-        {
-            break;
-        }
-    }   
-
-    val = i;
-}
-
+      break;
+    }
+    i++;
+    if (i == maxSymbol) 
+    {
+      break;
+    }
+  }
+
+  val = i;
+}
 Void TDecSbac::parseSaoUflc (UInt uiLength, UInt&  riVal)
 {
-    m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength );
-}
-
+  m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength );
+}
 Void TDecSbac::parseSaoMerge (UInt&  ruiVal)
 {
-    UInt uiCode;
-    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) );
-    ruiVal = (Int)uiCode;
-}
-
+  UInt uiCode;
+  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) );
+  ruiVal = (Int)uiCode;
+}
 Void TDecSbac::parseSaoTypeIdx (UInt&  ruiVal)
 {
-    UInt uiCode;
-    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
-    if (uiCode == 0) 
-    {
-        ruiVal = 0;
+  UInt uiCode;
+  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
+  if (uiCode == 0) 
+  {
+    ruiVal = 0;
+  }
+  else
+  {
+    m_pcTDecBinIf->decodeBinEP( uiCode ); 
+    if (uiCode == 0)
+    {
+      ruiVal = 5;
     }
     else
     {
-        m_pcTDecBinIf->decodeBinEP( uiCode ); 
-        if (uiCode == 0)
-        {
-            ruiVal = 5;
-        }
-        else
-        {
-            ruiVal = 1;
-        }
-    }
-}
-
-inline Void copySaoOneLcuParam(SaoLcuParam* psDst,  SaoLcuParam* psSrc)
-{
-    Int i;
-    psDst->partIdx = psSrc->partIdx;
-    psDst->typeIdx = psSrc->typeIdx;
-    if (psDst->typeIdx != -1)
-    {
-        psDst->subTypeIdx = psSrc->subTypeIdx ;
-        psDst->length  = psSrc->length;
-        for (i=0;i<psDst->length;i++)
-        {
-            psDst->offset[i] = psSrc->offset[i];
-        }
-    }
-    else
-    {
-        psDst->length  = 0;
-        for (i=0;i<SAO_BO_LEN;i++)
-        {
-            psDst->offset[i] = 0;
-        }
-    }
-}
-
-Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx)
-{
-    UInt uiSymbol;
-    static Int iTypeLength[MAX_NUM_SAO_TYPE] =
-    {
-        SAO_EO_LEN,
-        SAO_EO_LEN,
-        SAO_EO_LEN,
-        SAO_EO_LEN,
-        SAO_BO_LEN
-    }; 
-
-    if (compIdx==2)
-    {
-        uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);
-    }
-    else
-    {
-        parseSaoTypeIdx(uiSymbol);
-    }
-    psSaoLcuParam->typeIdx = (Int)uiSymbol - 1;
-
-    if (uiSymbol)
-    {
-        psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx];
-#if FULL_NBIT
-        Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + (g_uiBitDepth-8)-5),5) );
-#else
-        Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + g_uiBitIncrement-5),5) );
-#endif
-
-        if( psSaoLcuParam->typeIdx == SAO_BO )
-        {
-            for(Int i=0; i< psSaoLcuParam->length; i++)
-            {
-                parseSaoMaxUvlc(uiSymbol, offsetTh -1 );
-                psSaoLcuParam->offset[i] = uiSymbol;
-            }   
-            for(Int i=0; i< psSaoLcuParam->length; i++)
-            {
-                if (psSaoLcuParam->offset[i] != 0)
-                {
-                    m_pcTDecBinIf->decodeBinEP ( uiSymbol);
-                    if (uiSymbol)
-                    {
-                        psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ;
-                    }
-                }
-            }
-            parseSaoUflc(5, uiSymbol );
-            psSaoLcuParam->subTypeIdx = uiSymbol;
-        }
-        else if( psSaoLcuParam->typeIdx < 4 )
-        {
-            parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol;   
-            parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol;
-            parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
-            parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
-            if (compIdx != 2)
-            {
-                parseSaoUflc(2, uiSymbol );
-                psSaoLcuParam->subTypeIdx = uiSymbol;
-                psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx;
-            }
-        }
-    }
-    else
-    {
-        psSaoLcuParam->length = 0;
-    }
-}
-
-Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)
-{
-    Int iAddr = pcCU->getAddr();
-    UInt uiSymbol;
-
-    for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
-    {
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx     = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        =-1;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]      = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1]      = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2]      = 0;
-        pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3]      = 0;
-    }
-    if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] )
-    {
-        if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
-        {
-            parseSaoMerge(uiSymbol); 
-            pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol;  
-        }
-        if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0)
-        {
-            if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
-            {
-                parseSaoMerge(uiSymbol);
-                pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol;
-            }
-        }
-    }
-
-    for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
-    {
-        if ((iCompIdx == 0  && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0  && pSaoParam->bSaoFlag[1]) )
-        {
-            if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
-            {
-                pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag;
-            }
-            else
-            {
-                pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = 0;
-            }
-
-            if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0)
-            {
-                if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
-                {
-                    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag;
-                }
-                else
-                {
-                    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = 0;
-                }
-    
-                if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag)
-                {
-                    pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx;
-                    parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx);
-                }
-                else
-                {
-                    copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr], &pSaoParam->saoLcuParam[iCompIdx][iAddr-pSaoParam->numCuInWidth]);
-                }
-            }
-            else
-            {
-                copySaoOneLcuParam(&pSaoParam->saoLcuParam[iCompIdx][iAddr],  &pSaoParam->saoLcuParam[iCompIdx][iAddr-1]);
-            }
-        }
-        else
-        {
-            pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx    = -1;
-            pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0;
-        }
-    }
-}
-#else
-Void TDecSbac::parseSaoUvlc (UInt& ruiVal)
-{
-  UInt uiCode;
-  Int  i;
-
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 0 ) );
-  if ( uiCode == 0 )
-  {
-    ruiVal = 0;
-    return;
-  }
-
-  i=1;
-  while (1)
-  {
-    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoUvlcSCModel.get( 0, 0, 1 ) );
-    if ( uiCode == 0 ) break;
-    i++;
-  }
-
-  ruiVal = i;
-}
-
-Void TDecSbac::parseSaoSvlc (Int&  riVal)
-{
-  UInt uiCode;
-  Int  iSign;
-  Int  i;
-
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 0 ) );
-
-  if ( uiCode == 0 )
-  {
-    riVal = 0;
-    return;
-  }
-
-  // read sign
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 1 ) );
-
-  if ( uiCode == 0 )
-  {
-    iSign =  1;
-  }
-  else
-  {
-    iSign = -1;
-  }
-
-  // read magnitude
-  i=1;
-  while (1)
-  {
-    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoSvlcSCModel.get( 0, 0, 2 ) );
-    if ( uiCode == 0 ) break;
-    i++;
-  }
-
-  riVal = i*iSign;
-}
-
-Void TDecSbac::parseSaoUflc (UInt&  riVal)
-{
-  UInt uiSymbol;
-  riVal = 0;
-  for (Int i=0;i<5;i++)
-  {
-    m_pcTDecBinIf->decodeBinEP ( uiSymbol );
-    if (uiSymbol)
-    {
-      riVal |= (1<<i);
-    }
-  }
-}
-Void TDecSbac::parseSaoMergeLeft (UInt&  ruiVal, UInt uiCompIdx)
-{
-  UInt uiCode;
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) );
-  ruiVal = (Int)uiCode;
-}
-
-Void TDecSbac::parseSaoMergeUp (UInt&  ruiVal)
-{
-  UInt uiCode;
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) );
-  ruiVal = (Int)uiCode;
-}
-Void TDecSbac::parseSaoTypeIdx (UInt&  ruiVal)
-{
-  UInt uiCode;
-  Int  i;
-  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
-  if ( uiCode == 0 )
-  {
-    ruiVal = 0;
-    return;
-  }
-  i=1;
-  while (1)
-  {
-    m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) );
-    if ( uiCode == 0 ) break;
-    i++;
-  }
-  ruiVal = i;
+      ruiVal = 1;
+    }
+  }
 }
 
@@ -2302,12 +2078,5 @@
   if (psDst->typeIdx != -1)
   {
-    if (psDst->typeIdx == SAO_BO)
-    {
-      psDst->bandPosition = psSrc->bandPosition ;
-    }
-    else
-    {
-      psDst->bandPosition = 0;
-    }
+    psDst->subTypeIdx = psSrc->subTypeIdx ;
     psDst->length  = psSrc->length;
     for (i=0;i<psDst->length;i++)
@@ -2325,9 +2094,10 @@
   }
 }
-Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam)
+
+Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx)
 {
   UInt uiSymbol;
-  Int iSymbol;
-  static Int iTypeLength[MAX_NUM_SAO_TYPE] = {
+  static Int iTypeLength[MAX_NUM_SAO_TYPE] =
+  {
     SAO_EO_LEN,
     SAO_EO_LEN,
@@ -2337,27 +2107,54 @@
   }; 
 
-  parseSaoTypeIdx(uiSymbol);
+  if (compIdx==2)
+  {
+    uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);
+  }
+  else
+  {
+    parseSaoTypeIdx(uiSymbol);
+  }
   psSaoLcuParam->typeIdx = (Int)uiSymbol - 1;
   if (uiSymbol)
   {
     psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx];
+
+    Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;
+    Int offsetTh = 1 << min(bitDepth - 5,5);
+
     if( psSaoLcuParam->typeIdx == SAO_BO )
     {
-      // Parse Left Band Index
-      parseSaoUflc( uiSymbol );
-      psSaoLcuParam->bandPosition = uiSymbol;
       for(Int i=0; i< psSaoLcuParam->length; i++)
       {
-        parseSaoSvlc(iSymbol);
-        psSaoLcuParam->offset[i] = iSymbol;
+        parseSaoMaxUvlc(uiSymbol, offsetTh -1 );
+        psSaoLcuParam->offset[i] = uiSymbol;
       }   
+      for(Int i=0; i< psSaoLcuParam->length; i++)
+      {
+        if (psSaoLcuParam->offset[i] != 0) 
+        {
+          m_pcTDecBinIf->decodeBinEP ( uiSymbol);
+          if (uiSymbol)
+          {
+            psSaoLcuParam->offset[i] = -psSaoLcuParam->offset[i] ;
+          }
+        }
+      }
+      parseSaoUflc(5, uiSymbol );
+      psSaoLcuParam->subTypeIdx = uiSymbol;
     }
     else if( psSaoLcuParam->typeIdx < 4 )
     {
-      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[0] = uiSymbol;
-      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[1] = uiSymbol;
-      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
-      parseSaoUvlc(uiSymbol); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
-    }
+      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[0] = uiSymbol;
+      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[1] = uiSymbol;
+      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
+      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
+     if (compIdx != 2)
+     {
+       parseSaoUflc(2, uiSymbol );
+       psSaoLcuParam->subTypeIdx = uiSymbol;
+       psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx;
+     }
+   }
   }
   else
@@ -2367,5 +2164,5 @@
 }
 
-Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Bool bLFCrossSliceBoundaryFlag)
+Void TDecSbac::parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp)
 {
   Int iAddr = pcCU->getAddr();
@@ -2375,5 +2172,5 @@
     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
-    pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition   = 0;
+    pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx     = 0;
     pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        = -1;
     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]     = 0;
@@ -2382,9 +2179,29 @@
     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3]     = 0;
 
-    if (pSaoParam->bSaoFlag[iCompIdx])
-    {
-      if (rx>0 && iCUAddrInSlice!=0)
-      {
-        parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol;
+  }
+ if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] )
+  {
+    if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
+    {
+      parseSaoMerge(uiSymbol); 
+      pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol;  
+    }
+    if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0)
+    {
+      if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
+      {
+        parseSaoMerge(uiSymbol);
+        pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol;
+      }
+    }
+  }
+
+  for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
+  {
+    if ((iCompIdx == 0  && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0  && pSaoParam->bSaoFlag[1]) )
+    {
+      if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
+      {
+        pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag;
       }
       else
@@ -2395,7 +2212,7 @@
       if (pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag==0)
       {
-        if ((ry > 0) && (iCUAddrUpInSlice>0||bLFCrossSliceBoundaryFlag))
+        if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
         {
-          parseSaoMergeUp(uiSymbol);  pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol;
+          pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag;
         }
         else
@@ -2405,5 +2222,6 @@
         if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag)
         {
-          parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]));
+          pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx;
+          parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx);
         }
         else
@@ -2420,9 +2238,9 @@
     {
       pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1;
-      pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0;
-    }
-  }
-}
-#endif
+      pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0;
+    }
+  }
+}
+
 /**
  - Initialize our contexts from the nominated source.
@@ -2454,554 +2272,90 @@
 }
 
-Void TDecSbac::decodeFlush ( )
-{
-  UInt uiBit;
-  m_pcTDecBinIf->decodeBinTrm(uiBit);
-  m_pcTDecBinIf->flush();
-
-}
-
-#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX || (LGE_EDGE_INTRA_A0070 && LGE_EDGE_INTRA_DELTA_DC)
-Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel  )
-{
-  UInt uiSymbol;
-  UInt uiCount = 0;
-  do
-  {
-    m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel );
-    uiCount++;
-  }
-  while( uiSymbol && ( uiCount != 13 ) );
-
-  ruiSymbol = uiCount - 1;
+#if H_3D_ARP
+Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{
+  UInt uiMaxW = pcCU->getSlice()->getARPStepNum() - 1;
+  UInt uiW = 0;
+  UInt uiOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
+  UInt uiCode = 0;
+
+  assert ( uiMaxW > 0 );
+
+  m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 0 + uiOffset ) );
+
+  uiW = uiCode;
+  if( 1 == uiW )   
+  {
+    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPWSCModel.get( 0, 0, 3 ) );
+    uiW += ( 1 == uiCode ? 1 : 0 );
+  }
+#if H_MV_ENC_DEC_TRAC
+  DTRACE_CU("iv_res_pred_weight_idx", uiW )
+#endif
+  pcCU->setARPWSubParts( ( UChar )( uiW ) , uiAbsPartIdx, uiDepth );  
+}
+#endif
+
+#if H_3D_IC
+/** parse illumination compensation flag
+ * \param pcCU
+ * \param uiAbsPartIdx 
+ * \param uiDepth
+ * \returns Void
+ */
+Void TDecSbac::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
+{ 
+  UInt uiSymbol = 0;
+  UInt uiCtxIC = pcCU->getCtxICFlag( uiAbsPartIdx );
+  m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUICFlagSCModel.get( 0, 0, uiCtxIC ) );
+#if !H_MV_ENC_DEC_TRAC 
+  DTRACE_CABAC_VL( g_nSymbolCounter++ );
+  DTRACE_CABAC_T( "\tICFlag" );
+  DTRACE_CABAC_T( "\tuiCtxIC: ");
+  DTRACE_CABAC_V( uiCtxIC );
+  DTRACE_CABAC_T( "\tuiSymbol: ");
+  DTRACE_CABAC_V( uiSymbol );
+  DTRACE_CABAC_T( "\n");
+#else
+  DTRACE_CU("ic_flag", uiSymbol)
+#endif
+  
+  pcCU->setICFlagSubParts( uiSymbol ? true : false , uiAbsPartIdx, 0, uiDepth );
+}
+#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 )
   {
-    xReadEpExGolomb( uiSymbol, 0 );
-    ruiSymbol += uiSymbol + 1;
-  }
-
-  return;
-}
-#endif
-#if HHI_DMM_WEDGE_INTRA
-Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
-  Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx];
-
-  UInt uiSymbol, uiTabIdx = 0;
-  for ( Int i = 0; i < iBits; i++ )
-  {
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) );
-    uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0;
-    uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0;
-    uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0;
-    uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0;
-    uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0;
-    uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0;
-    uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0;
-    uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0;
-    uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0;
-    uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0;
-    uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0;
-    uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0;
-    uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0;
-  }
-
-  pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth );
-}
-
-Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
-  Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx];
-
-  UInt uiSymbol, uiTabIdx = 0;
-  for ( Int i = 0; i < iBits; i++ )
-  {
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 0) );
-    uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0;
-    uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0;
-    uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0;
-    uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0;
-    uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0;
-    uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0;
-    uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0;
-    uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0;
-    uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0;
-    uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0;
-    uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0;
-    uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0;
-    uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0;
-  }
-
-  pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth );
-
-  UInt uiDC1, uiDC2;
-  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC1 = uiDC1;
-  if ( uiDC1 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC1 = -iDC1;
-    }
-  }
-  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC2 = uiDC2;
-  if ( uiDC2 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC2 = -iDC2;
-    }
-  }
-
-  pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-  pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-}
-
-Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 )
-  {
-    UInt uiDeltaEnd = 0;
-    m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) );
-
-    Int iDeltaEnd;
-    if( uiDeltaEnd != 0 )
-    {
-      UInt uiAbsValMinus1;
-      UInt uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1  = uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1;
-      uiDeltaEnd = uiAbsValMinus1 + 1;
-
-      iDeltaEnd = uiDeltaEnd;
-      UInt uiSign;
-      m_pcTDecBinIf->decodeBinEP( uiSign );
-      if( uiSign )
-      {
-        iDeltaEnd = -iDeltaEnd;
-      }
-    }
-    else
-    {
-      iDeltaEnd = 0;
-    }
-    pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth );
-  }
-}
-
-Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 )
-  {
-    UInt uiDeltaEnd = 0;
-    m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cDmmDataSCModel.get(0, 0, 2) );
-
-    Int iDeltaEnd;
-    if( uiDeltaEnd != 0 )
-    {
-      UInt uiAbsValMinus1;
-      UInt uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1  = uiSymbol;
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 2) ); uiAbsValMinus1 |= uiSymbol << 1;
-      uiDeltaEnd = uiAbsValMinus1 + 1;
-
-      iDeltaEnd = uiDeltaEnd;
-      UInt uiSign;
-      m_pcTDecBinIf->decodeBinEP( uiSign );
-      if( uiSign )
-      {
-        iDeltaEnd = -iDeltaEnd;
-      }
-    }
-    else
-    {
-      iDeltaEnd = 0;
-    }
-
-    pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth );
-  }
-
-  UInt uiDC1, uiDC2;
-  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC1 = uiDC1;
-  if ( uiDC1 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC1 = -iDC1;
-    }
-  }
-  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC2 = uiDC2;
-  if ( uiDC2 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC2 = -iDC2;
-    }
-  }
-
-  pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-  pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-}
-#endif
-#if HHI_DMM_PRED_TEX
-#if LGE_DMM3_SIMP_C0044
-Void TDecSbac::xParseWedgePredTexInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx);
-  Int iBits = g_aucWedgeTexPredBitsListIdx[iIntraIdx];
-
-  UInt uiSymbol, uiTabIdx = 0;
-  for ( Int i = 0; i < iBits; i++ )
-  {
-    m_pcTDecBinIf->decodeBin( uiSymbol, m_cDmmDataSCModel.get(0, 0, 3) );
-    uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0;
-    uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0;
-    uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0;
-    uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0;
-    uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0;
-    uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0;
-    uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0;
-    uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0;
-    uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0;
-    uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0;
-    uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0;
-  }
-
-  pcCU->setWedgePredTexIntraTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth );
-}
-#endif
-
-Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-#if LGE_DMM3_SIMP_C0044
-  xParseWedgePredTexInfo( pcCU, uiAbsPartIdx, uiDepth );
-#endif
-  UInt uiDC1, uiDC2;
-  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC1 = uiDC1;
-  if ( uiDC1 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC1 = -iDC1;
-    }
-  }
-  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC2 = uiDC2;
-  if ( uiDC2 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC2 = -iDC2;
-    }
-  }
-
-  pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-  pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-}
-
-Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiDC1, uiDC2;
-  xReadExGolombLevel( uiDC1, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC1 = uiDC1;
-  if ( uiDC1 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC1 = -iDC1;
-    }
-  }
-  xReadExGolombLevel( uiDC2, m_cDmmDataSCModel.get(0, 0, 1) );
-  Int iDC2 = uiDC2;
-  if ( uiDC2 )
-  {
-    UInt uiSign;
-    m_pcTDecBinIf->decodeBinEP( uiSign );
-    if ( uiSign )
-    {
-      iDC2 = -iDC2;
-    }
-  }
-
-  pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth );
-  pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth );
-}
-#endif
-#if QC_ARP_D0177
-Void TDecSbac::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt nMaxW = pcCU->getSlice()->getARPStepNum() - 1;
-#if !QC_ARP_WARNING_FIX
-  assert (nMaxW >= 0);
-#endif
-  UInt nW = 0;
-  if( nMaxW > 0 )
-  {
-    UInt nOffset = pcCU->getCTXARPWFlag(uiAbsPartIdx);
-#if !QC_ARP_WARNING_FIX
-    assert( 0 <= nOffset && nOffset <= 2 );
-#endif
-    UInt uiCode = 0;
-    m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPW.get( 0, 0, 0 + nOffset ) );
-    nW = uiCode;
-    if( nW == 1 )   
-    {
-      m_pcTDecBinIf->decodeBin( uiCode , m_cCUPUARPW.get( 0, 0, 3 ) );
-      nW += ( uiCode == 1 );
-    }
-  }
-  pcCU->setARPWSubParts( ( UChar )( nW ) , uiAbsPartIdx, uiDepth );  
-}
-#endif
-#if LGE_EDGE_INTRA_A0070
-Void TDecSbac::xParseEdgeIntraInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
-{
-  UInt uiSymbol = 0;
-
-  // 1. Top(0) or Left(1)
-  UChar ucLeft;
-  m_pcTDecBinIf->decodeBinEP( uiSymbol );
-  ucLeft = uiSymbol;
-
-  // 2. Start position (lowest bit first)
-  UChar ucStart = 0;
-  for( UInt ui = 0; ui < 6 - uiDepth; ui++ )
-  {
-    m_pcTDecBinIf->decodeBinEP( uiSymbol );
-    ucStart |= (uiSymbol << ui);
-  }
-
-  // 3. Number of edges
-  UChar ucMax = 0;
-  for( UInt ui = 0; ui < 7 - uiDepth; ui++ )
-  {
-    m_pcTDecBinIf->decodeBinEP( uiSymbol );
-    ucMax |= (uiSymbol << ui);
-  }
-  ucMax++; // +1
-
-  // 4. Edges
-  UChar* pucSymbolList = (UChar*) xMalloc( UChar, 256 * LGE_EDGE_INTRA_MAX_EDGE_NUM_PER_4x4 );
-  UInt uiCtxEdgeIntra = pcCU->getCtxEdgeIntra( uiAbsPartIdx );
-  for( Int iPtr = 0; iPtr < ucMax; iPtr++ )
-  {
-    UChar ucEdge = 0;
-    UInt  uiReorderEdge = 0;
-    // Left-friendly direction
-    // 0 (   0deg) => 0
-    // 1 (  45deg) => 10
-    // 2 ( -45deg) => 110
-    // 3 (  90deg) => 1110
-    // 4 ( -90deg) => 11110
-    // 5 ( 135deg) => 111110
-    // 6 (-135deg) => 111111
-    // Right-friendly direction
-    // 0 (   0deg) => 0
-    // 1 ( -45deg) => 10
-    // 2 (  45deg) => 110
-    // 3 ( -90deg) => 1110
-    // 4 (  90deg) => 11110
-    // 5 (-135deg) => 111110
-    // 6 ( 135deg) => 111111
-    // refer to a paper "An efficient chain code with Huffman coding"
-    for( UInt ui = 0; ui < 6; ui++ )
-    {
-      m_pcTDecBinIf->decodeBin( uiSymbol, m_cEdgeIntraSCModel.get( 0, 0, uiCtxEdgeIntra ) );
-      ucEdge <<= 1;
-      ucEdge |= uiSymbol;
-      if( uiSymbol == 0 )
-        break;
-    }
-
-    switch( ucEdge )
-    {
-    case 0 :  // "0"
-      uiReorderEdge = 0;
-      break;
-    case 2 :  // "10"
-      uiReorderEdge = 1;
-      break;
-    case 6 :  // "110"
-      uiReorderEdge = 2;
-      break;
-    case 14 : // "1110"
-      uiReorderEdge = 3;
-      break;
-    case 30 : // "11110"
-      uiReorderEdge = 4;
-      break;
-    case 62 : // "111110"
-      uiReorderEdge = 5;
-      break;
-    case 63 : // "111111"
-      uiReorderEdge = 6;
-      break;
-    default :
-      printf("parseIntraEdgeChain: error (unknown code %d)\n",ucEdge);
-      assert(false);
-      break;
-    }
-    pucSymbolList[iPtr] = uiReorderEdge;
-  }
-  /////////////////////
-  // Edge Reconstruction
-  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPartIdx );
-  pcCU->reconPartition( uiAbsPartIdx, uiDepth, ucLeft == 1, ucStart, ucMax, pucSymbolList, pbRegion );
-  xFree( pucSymbolList );
-}
-#endif
-  
-#if RWTH_SDC_DLT_B0036
-#if !PKU_QC_DEPTH_INTRA_UNI_D0195
-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;
-#if INTEL_SDC64_D0193
-    if( !(pcCU->getWidth(uiAbsPartIdx) == 64 && i == 1))
-#endif
-    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);
-}
-#endif
-
-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;
+    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;
-  
-  UInt uiMaxResidualBits  = pcCU->getSlice()->getSPS()->getBitsPerDepthValue();
-  assert( uiMaxResidualBits <= g_uiBitDepth );
-  
-#if RWTH_SDC_CTX_SIMPL_D0032
-  m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, 0, 0 ) );
-#else
-  m_pcTDecBinIf->decodeBin(uiResidual, m_cSDCResidualFlagSCModel.get( 0, uiSegment, 0 ) );
-#endif
-  
-  if (uiResidual)
-  {
-    // decode residual sign bit
-#if RWTH_SDC_CTX_SIMPL_D0032
-    m_pcTDecBinIf->decodeBinEP(uiSign);
-#else
-    m_pcTDecBinIf->decodeBin(uiSign, m_cSDCResidualSignFlagSCModel.get( 0, uiSegment, 0 ) );
-#endif
-    
-    // decode residual magnitude
-#if LGE_CONCATENATE_D0141
-    //prefix part
-    UInt uiCount = 0;
-    UInt uiNumDepthValues = pcCU->getSlice()->getSPS()->getNumDepthValues();
-    UInt uiPrefixThreshold = ((uiNumDepthValues * 3) >> 2);
-    for ( UInt ui = 0; ui < uiPrefixThreshold; ui++)
-    {
-        m_pcTDecBinIf->decodeBin( uiBit, m_cSDCResidualSCModel.get(0, 0, 0) );
-        if ( uiBit == 0 )
-            break;
-        else
-            uiCount++;
-    }
-    //suffix part
-    if ( uiCount == uiPrefixThreshold )
-    {
-        for ( UInt ui = 0; ui < ( (UInt)ceil( Log2(uiNumDepthValues - uiPrefixThreshold) ) ); ui++ )
-        {
-            m_pcTDecBinIf->decodeBinEP( uiBit );
-            uiAbsIdx |= uiBit << ui;
-        }
-        uiAbsIdx += uiCount;
-    }
-    else
-        uiAbsIdx = uiCount;
-#else
-    for (Int i=0; i<uiMaxResidualBits; i++)
-    {
-#if RWTH_SDC_CTX_SIMPL_D0032
-      m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, 0, i ) );
-#else
-      m_pcTDecBinIf->decodeBin(uiBit, m_cSDCResidualSCModel.get( 0, uiSegment, i ) );
-#endif
-      uiAbsIdx |= uiBit << i;
-    }
-#endif
-    
-    uiAbsIdx += 1;
-    iIdx =(Int)(uiSign ? -1 : 1)*uiAbsIdx;
-  }
-  
-  pcCU->setSDCSegmentDCOffset(iIdx, uiSegment, uiAbsPartIdx);
+
+  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
