Index: trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 773)
@@ -176,7 +176,18 @@
   WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" );
   WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
+#if PPS_FIX_DEPTH
+  if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
+  {
+    WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive(),     "num_ref_idx_l0_default_active_minus1");
+    WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive(),     "num_ref_idx_l1_default_active_minus1");
+  }
+  else
+  {
+#endif
   WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1,     "num_ref_idx_l0_default_active_minus1");
   WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1,     "num_ref_idx_l1_default_active_minus1");
-
+#if PPS_FIX_DEPTH
+  }
+#endif
   WRITE_SVLC( pcPPS->getPicInitQPMinus26(),                  "init_qp_minus26");
   WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0,      "constrained_intra_pred_flag" );
@@ -253,9 +264,23 @@
   }
 #endif
+#if PPS_FIX_DEPTH
+  if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
+  {
+    WRITE_FLAG( 1, "lists_modification_present_flag" );
+  }
+  else
+#endif
   WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
   WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
+#if PPS_FIX_DEPTH
+  if( pcPPS->getSPS()->getVPS()->getDepthId(pcPPS->getSPS()->getLayerId()) )
+  {
+    WRITE_FLAG( 1, "slice_segment_header_extension_present_flag" );
+  }
+  else
+#endif
   WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
 
-#if !DLT_DIFF_CODING_IN_PPS
+#if !H_3D
   WRITE_FLAG( 0, "pps_extension_flag" );
 #else
@@ -266,5 +291,5 @@
 }
 
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
 Void  TEncCavlc::codePPSExtension        ( TComPPS* pcPPS )
 {
@@ -275,5 +300,5 @@
   //   Step 1) decoding DLT tables based on the number of depth layers, and
   //   Step 2) mapping DLT tables to the depth layers
-  // as descripted in the 3D-HEVC WD.
+  // as described in the 3D-HEVC WD.
   TComVPS* pcVPS = pcPPS->getSPS()->getVPS();
 
@@ -470,5 +495,5 @@
   }
   WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(),            "video_signal_type_present_flag");
-#if H_MV_6_PS_O0118_33
+#if H_MV
   assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 
 #endif
@@ -636,5 +661,4 @@
   {
     WRITE_FLAG( pcSPS->getUpdateRepFormatFlag( ) ? 1 : 0 , "update_rep_format_flag" );
-#if H_MV_6_PS_REP_FORM_18_19_20    
     if ( pcSPS->getUpdateRepFormatFlag() )
     { 
@@ -644,10 +668,4 @@
   else
   {
-#else
-  }
-
-  if ( pcSPS->getUpdateRepFormatFlag() )
-  { 
-#endif
 #endif
   WRITE_UVLC( pcSPS->getChromaFormatIdc (),         "chroma_format_idc" );
@@ -675,9 +693,5 @@
   }
 #if H_MV
-#if H_MV_6_PS_REP_FORM_18_19_20
   if ( pcSPS->getLayerId() == 0 )
-#else
-  if ( pcSPS->getUpdateRepFormatFlag() )
-#endif
   { 
 #endif
@@ -784,5 +798,4 @@
   WRITE_FLAG( 0, "sps_extension_flag" );
 #else
-#if H_MV_6_PSEM_O0142_3
   WRITE_FLAG( pcSPS->getSpsExtensionFlag(), "sps_extension_flag" );
 
@@ -811,15 +824,4 @@
 #endif
   }
-#else
-  WRITE_FLAG( 1, "sps_extension_flag" );
-  codeSPSExtension( pcSPS ); 
-#if !H_3D
-  WRITE_FLAG( 0, "sps_extension2_flag" );
-#else
-  WRITE_FLAG( 1, "sps_extension2_flag" );
-  codeSPSExtension2( pcSPS, viewIndex, depthFlag ); 
-  WRITE_FLAG( 0, "sps_extension3_flag" );
-#endif  
-#endif
 #endif
 }
@@ -830,7 +832,4 @@
   WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" );
 
-#if !H_MV_6_SHVC_O0098_36
-  WRITE_UVLC( 0, "sps_shvc_reserved_zero_idc" ); 
-#else
   WRITE_UVLC( pcSPS->getNumScaledRefLayerOffsets( ), "num_scaled_ref_layer_offsets" );
 
@@ -846,5 +845,4 @@
     WRITE_SVLC( pcSPS->getScaledRefLayerBottomOffset( j ), "scaled_ref_layer_bottom_offset" );
   }
-#endif  
 }
 #endif
@@ -859,21 +857,4 @@
   WRITE_FLAG( pcSPS->getUseQTL() ? 1 : 0, "use_qtl_flag");
   WRITE_FLAG( pcSPS->getUsePC()  ? 1 : 0, "use_pc_flag");
-}
-#endif
-#if !CAM_HLS_F0136_F0045_F0082
-if (!depthFlag )
-{
-  WRITE_UVLC( pcSPS->getCamParPrecision(), "cp_precision" );
-  WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "cp_in_slice_header_flag" );
-  if( !pcSPS->hasCamParInSliceHeader() )
-  {
-    for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )
-    {
-      WRITE_SVLC( pcSPS->getCodedScale    ()[ uiIndex ],                                      "cp_scale" );
-      WRITE_SVLC( pcSPS->getCodedOffset   ()[ uiIndex ],                                      "cp_off" );
-      WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiIndex ] + pcSPS->getCodedScale ()[ uiIndex ], "cp_inv_scale_plus_scale" );
-      WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiIndex ] + pcSPS->getCodedOffset()[ uiIndex ], "cp_inv_off_plus_off" );
-    }
-  }
 }
 #endif
@@ -995,13 +976,9 @@
 {
   WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0,          "avc_base_layer_flag" );
-#if H_MV_6_PS_O0109_24
   WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
   if ( pcVPS->getVpsVuiPresentFlag() )
   {  
-#endif
   WRITE_CODE( pcVPS->getVpsVuiOffset( ), 16,                 "vps_vui_offset" );  // TBD
-#if H_MV_6_PS_O0109_24
-  }
-#endif
+  }
   WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
   
@@ -1050,5 +1027,4 @@
 
 
-#if H_MV_6_PS_O0109_22
     WRITE_CODE( pcVPS->getViewIdLen( ), 4, "view_id_len" );
     
@@ -1067,17 +1043,4 @@
       }
     }
-#else
-  // GT spec says: trac #39
-  // if ( pcVPS->getNumViews() > 1 )  
-  //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. 
-  {
-    WRITE_CODE( pcVPS->getViewIdLenMinus1( ), 4, "view_id_len_minus1" );
-  }
-
-  for( Int i = 0; i < pcVPS->getNumViews(); i++ )
-  {
-    WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLenMinus1( ) + 1, "view_id_val[i]" );
-  }
-#endif
 
 
@@ -1089,5 +1052,4 @@
     }
   }
-#if H_MV_6_ILDSD_O0120_26
   WRITE_FLAG( pcVPS->getVpsSubLayersMaxMinus1PresentFlag( ) ? 1 : 0 , "vps_sub_layers_max_minus1_present_flag" );
   if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
@@ -1106,5 +1068,4 @@
     }
   }
-#endif
   WRITE_FLAG( pcVPS->getMaxTidRefPresentFlag( ) ? 1 : 0 , "max_tid_ref_present_flag" );
 
@@ -1113,5 +1074,4 @@
     for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
     {
-#if H_MV_6_ILDDS_O0225_30
       for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ )
       {
@@ -1121,7 +1081,4 @@
         }
       }
-#else
-      WRITE_CODE( pcVPS->getMaxTidIlRefPicPlus1( i ), 3,       "max_tid_il_ref_pics_plus1[i]" );
-#endif
     }
   }
@@ -1137,7 +1094,5 @@
     {    
       WRITE_CODE( pcVPS->getProfileRefMinus1( i ), 6, "profile_ref_minus1[i]" );
-#if H_MV_6_PS_O0109_23
       pcVPS->checkProfileRefMinus1( i );      
-#endif
     }
     codePTL( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 );
@@ -1156,16 +1111,10 @@
   if( numOutputLayerSets > 1)
   {
-#if H_MV_6_PS_0109_25
     WRITE_CODE( pcVPS->getDefaultOneTargetOutputLayerIdc( ), 2, "default_one_target_output_layer_idc" );
     pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
-#else
-    WRITE_FLAG( pcVPS->getDefaultOneTargetOutputLayerFlag( ) ? 1 : 0, "default_one_target_output_layer_flag" );
-#endif        
   }  
 
-#if H_MV_6_HRD_O0217_13
   assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); 
   assert( pcVPS->getOutputLayerSetIdxMinus1( 0 ) == -1 ); 
-#endif
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
@@ -1178,5 +1127,4 @@
       }      
     }
-#if H_MV_6_HRD_O0217_13
     else
     { // These inference rules would also be helpful in spec text
@@ -1187,5 +1135,4 @@
       }
     }
-#endif
 
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
@@ -1195,10 +1142,8 @@
   }
 
-#if H_MV_6_GEN_0153_28
   if( pcVPS->getMaxLayersMinus1() > 0 )
   {
     WRITE_FLAG( pcVPS->getAltOutputLayerFlag( ) ? 1 : 0 , "alt_output_layer_flag" );
   }
-#endif
 
   WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
@@ -1210,12 +1155,7 @@
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
   {    
-#if H_MV_6_PS_REP_FORM_18_19_20
     TComRepFormat* curRepFormat = pcVPS->getRepFormat(i);     
     TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 
     codeRepFormat( i, curRepFormat ,  prevRepFormat); 
-#else
-    TComRepFormat* pcRepFormat = pcVPS->getRepFormat(i);     
-    codeRepFormat( pcRepFormat ); 
-#endif
   }
 
@@ -1226,9 +1166,5 @@
       if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
       {
-#if H_MV_6_PS_REP_FORM_18_19_20
         WRITE_CODE( pcVPS->getVpsRepFormatIdx( i ), 8, "vps_rep_format_idx" );
-#else
-        WRITE_CODE( pcVPS->getVpsRepFormatIdx( i ), 4, "vps_rep_format_idx" );
-#endif
       }
     }
@@ -1236,5 +1172,4 @@
 
   WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );
-#if H_MV_6_MISC_O0062_31
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1244,15 +1179,8 @@
     }
   }
-#endif
-#if H_MV_6_HRD_O0217_13
   codeDpbSize( pcVPS ); 
-#endif
-
-#if !H_MV_6_PS_O0223_29
-  WRITE_FLAG( pcVPS->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
-#endif
+
   WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ),         "direct_dep_type_len_minus2"); 
 
-#if H_MV_6_PS_O0096_21
   WRITE_FLAG( pcVPS->getDefaultDirectDependencyFlag( ) ? 1 : 0 , "default_direct_dependency_flag" );
 
@@ -1280,21 +1208,5 @@
     }
   }  
-#else
-    for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
-    {
-      for( Int j = 0; j < i; j++ )
-      {
-        if (pcVPS->getDirectDependencyFlag( i, j) )
-        {        
-          assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); 
-          WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2,  "direct_dependency_type[i][j]" );
-        }
-      }
-    }
-#endif
     WRITE_FLAG ( 0,                                      "vps_shvc_reserved_zero_flag" ); 
-#if !H_MV_6_PS_O0109_24
-    WRITE_FLAG( pcVPS->getVpsVuiPresentFlag( ) ? 1 : 0 , "vps_vui_present_flag" );
-#endif
 
     if( pcVPS->getVpsVuiPresentFlag() )
@@ -1304,5 +1216,4 @@
     }     
 }
-#if H_MV_6_PS_O0118_33
 Void TEncCavlc::codeVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo )
 {
@@ -1314,7 +1225,5 @@
   WRITE_CODE( pcVideoSignalInfo->getMatrixCoeffsVps( ), 8, "matrix_coeffs_vps" );
 }
-#endif
-
-#if H_MV_6_HRD_O0217_13
+
 Void TEncCavlc::codeDpbSize( TComVPS* vps )
 { 
@@ -1356,15 +1265,9 @@
   }  
 }
-#endif
-
-#if H_MV_6_PS_REP_FORM_18_19_20
+
 Void TEncCavlc::codeRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat )
-#else
-Void TEncCavlc::codeRepFormat( TComRepFormat* pcRepFormat )
-#endif
 {
   assert( pcRepFormat ); 
 
-#if H_MV_6_PS_REP_FORM_18_19_20
   WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ),  16, "pic_width_vps_in_luma_samples" );
   WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" );
@@ -1375,5 +1278,4 @@
   if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() )
   {  
-#endif
   WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" );
 
@@ -1382,11 +1284,6 @@
     WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" );
   }
-#if !H_MV_6_PS_REP_FORM_18_19_20
-  WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ),  16, "pic_width_vps_in_luma_samples" );
-  WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" );
-#endif
   WRITE_CODE( pcRepFormat->getBitDepthVpsLumaMinus8( ),      4, "bit_depth_vps_luma_minus8" );
   WRITE_CODE( pcRepFormat->getBitDepthVpsChromaMinus8( ),    4, "bit_depth_vps_chroma_minus8" );
-#if H_MV_6_PS_REP_FORM_18_19_20
   }
   else
@@ -1394,5 +1291,4 @@
     pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, true ); 
   }
-#endif
 }
 
@@ -1405,5 +1301,4 @@
   assert( pcVPSVUI ); 
 
-#if H_MV_6_PS_O0223_29
   WRITE_FLAG( pcVPSVUI->getCrossLayerPicTypeAlignedFlag( ) ? 1 : 0 , "cross_layer_pic_type_aligned_flag" );
   if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )
@@ -1411,5 +1306,4 @@
     WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
   }
-#endif
 
   WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" );
@@ -1443,5 +1337,4 @@
   }
 
-#if H_MV_6_O0226_37
   WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" );
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
@@ -1478,13 +1371,4 @@
     }
   }
-#else
-  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
-  {
-    for( Int  j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) 
-    {
-      WRITE_FLAG( pcVPSVUI->getTileBoundariesAlignedFlag( i, j ) ? 1 : 0 , "tile_boundaries_aligned_flag" );
-    }
-  }
-#endif
   WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" );
 
@@ -1507,5 +1391,4 @@
     }
   }
-#if H_MV_6_PS_O0118_33
   WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" );
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
@@ -1540,6 +1423,4 @@
     }
   }
-#endif
-#if H_MV_6_HRD_O0164_15
   WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" );
   if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
@@ -1547,7 +1428,5 @@
     codeVpsVuiBspHrdParameters( pcVPS ); 
   }
-#endif
-}
-#if H_MV_6_HRD_O0164_15
+}
 Void TEncCavlc::codeVpsVuiBspHrdParameters( TComVPS* pcVPS )
 {
@@ -1606,5 +1485,4 @@
   }  
 }  
-#endif
 
 #endif
@@ -1621,5 +1499,5 @@
 #if H_3D_IV_MERGE
         WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
         WRITE_UVLC( pcVPS->getSubPULog2Size(i)-2, "log2_sub_PU_size_minus2[i]");
 #endif
@@ -1637,11 +1515,9 @@
       else
       {
-#if QC_DEPTH_IV_MRG_F0125
         if(i!=1)
         {
           WRITE_FLAG( pcVPS->getIvMvPredFlag         ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");
         }
-#endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
         if (i!=1)
         {
@@ -1649,26 +1525,9 @@
         }
 #endif
-#if SEC_MPI_ENABLING_MERGE_F0150
+#if H_3D_IV_MERGE
         WRITE_FLAG( pcVPS->getMPIFlag( i ) ? 1 : 0 ,          "mpi_flag[i]" );
 #endif
         WRITE_FLAG( pcVPS->getVpsDepthModesFlag( i ) ? 1 : 0 ,          "vps_depth_modes_flag[i]" );
         //WRITE_FLAG( pcVPS->getLimQtPredFlag    ( i ) ? 1 : 0 ,          "lim_qt_pred_flag[i]"     ); 
-#if H_3D_DIM_DLT
-#if !DLT_DIFF_CODING_IN_PPS
-        if( pcVPS->getVpsDepthModesFlag( i ) )
-        {
-          WRITE_FLAG( pcVPS->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" );
-        }
-        if( pcVPS->getUseDLTFlag( i ) )
-        {
-          // code mapping
-          WRITE_UVLC(pcVPS->getNumDepthValues(i), "num_depth_values_in_dlt[i]");
-          for(Int d=0; d<pcVPS->getNumDepthValues(i); d++)
-          {
-            WRITE_UVLC( pcVPS->idx2DepthValue(i, d), "dlt_depth_value[i][d]" );
-          }
-        }
-#endif
-#endif
 #if H_3D_INTER_SDC
         WRITE_FLAG( pcVPS->getInterSDCFlag( i ) ? 1 : 0, "depth_inter_SDC_flag" );
@@ -1677,5 +1536,4 @@
     }  
   }
-#if CAM_HLS_F0136_F0045_F0082
   WRITE_UVLC( pcVPS->getCamParPrecision(), "cp_precision" );
   for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
@@ -1697,5 +1555,4 @@
     }
   }
-#endif
 #if H_3D_TMVP
   WRITE_FLAG( pcVPS->getIvMvScalingFlag( ) ? 1 : 0 ,          "iv_mv_scaling_flag" );
@@ -1739,4 +1596,11 @@
     WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );
   }
+#if PPS_FIX_DEPTH
+  if( pcSlice->getIsDepth() )
+  {
+    WRITE_UVLC( 1, "slice_pic_parameter_set_id" );
+  }
+  else
+#endif
   WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" );
   pcSlice->setDependentSliceSegmentFlag(!pcSlice->isNextSlice());
@@ -1753,5 +1617,18 @@
 #if H_MV    
     Int esb = 0;  //Don't use i, otherwise will shadow something below
-#if !H_MV_6_RALS_O0149_11
+
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );
+    }
+
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" );
+    }
+    pcSlice->checkCrossLayerBlaFlag( ); 
+
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1759,26 +1636,4 @@
       WRITE_FLAG( pcSlice->getPocResetFlag( ) ? 1 : 0 , "poc_reset_flag" );
     }
-#endif
-
-    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
-    {
-      esb++; 
-      WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );
-    }
-
-#if H_MV_6_RALS_O0149_11
-    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
-    {
-      esb++; 
-      WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" );
-    }
-    pcSlice->checkCrossLayerBlaFlag( ); 
-
-    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
-    {
-      esb++; 
-      WRITE_FLAG( pcSlice->getPocResetFlag( ) ? 1 : 0 , "poc_reset_flag" );
-    }
-#endif
 
 
@@ -1804,6 +1659,5 @@
     // if( separate_colour_plane_flag  ==  1 )
     //   colour_plane_id                                      u(2)
-
-#if H_MV_6_POC_31_35_38
+#if H_MV
     if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() )
     {
@@ -1814,5 +1668,5 @@
     if( !pcSlice->getIdrPicFlag() )
     {
-#if !H_MV_6_POC_31_35_38
+#if !H_MV
       Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
       WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
@@ -1931,7 +1785,5 @@
     }
 #if H_MV
-#if H_MV_6_ILDDS_ILREFPICS_27_34
     Bool interLayerPredLayerIdcPresentFlag = false; 
-#endif
     Int layerId = pcSlice->getLayerId(); 
     if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
@@ -1946,7 +1798,5 @@
         if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
         {        
-#if H_MV_6_ILDDS_ILREFPICS_27_34
           interLayerPredLayerIdcPresentFlag = true; 
-#endif
           for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ )   
           {
@@ -1956,5 +1806,4 @@
       }  
     }
-#if H_MV_6_ILDDS_ILREFPICS_27_34
     if ( !interLayerPredLayerIdcPresentFlag )
     {
@@ -1964,5 +1813,4 @@
       }
     }
-#endif
 #endif
     if(pcSlice->getSPS()->getUseSAO())
@@ -1983,4 +1831,7 @@
     {
       Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive()));
+#if PPS_FIX_DEPTH
+      overrideFlag |= (pcSlice->getIsDepth() && !pcSlice->getViewIndex());
+#endif
       WRITE_FLAG( overrideFlag ? 1 : 0,                               "num_ref_idx_active_override_flag");
       if (overrideFlag) 
@@ -2002,6 +1853,9 @@
       pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
     }
-
+#if PPS_FIX_DEPTH
+    if( (pcSlice->getPPS()->getListsModificationPresentFlag() || (pcSlice->getIsDepth() && !pcSlice->getViewIndex())) && pcSlice->getNumRpsCurrTempList() > 1)
+#else
     if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1)
+#endif
     {
       TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
@@ -2086,9 +1940,5 @@
     }
 #if H_3D_IC
-#if SEC_ONLY_TEXTURE_IC_F0151
     else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) && !pcSlice->getIsDepth())
-#else
-    else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) )
-#endif
     {
       WRITE_FLAG( pcSlice->getApplyIC() ? 1 : 0, "slice_ic_enable_flag" );
@@ -2108,5 +1958,4 @@
     {
 #if H_3D_IV_MERGE
-#if SEC_MPI_ENABLING_MERGE_F0150
       if(pcSlice->getIsDepth())
       {
@@ -2120,8 +1969,4 @@
         WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
       }
-#else
-      Bool ivMvPredFlag = pcSlice->getVPS()->getIvMvPredFlag( pcSlice->getLayerIdInVps() ) ;
-      WRITE_UVLC( ( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
-#endif
 #else
       WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
@@ -2162,14 +2007,6 @@
     }
   }
-#if CAM_HLS_F0044
-#if QC_DEPTH_IV_MRG_F0125
-#if CAM_HLS_F0136_F0045_F0082
+#if H_3D
   if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && !pcSlice->getIsDepth() )
-#else
-  if( pcSlice->getSPS()->hasCamParInSliceHeader() && !pcSlice->getIsDepth() )
-#endif
-#else
-  if( pcSlice->getSPS()->hasCamParInSliceHeader() )
-#endif
   {
     for( UInt uiId = 0; uiId < pcSlice->getViewIndex(); uiId++ )
@@ -2183,36 +2020,11 @@
 #endif
 
+#if PPS_FIX_DEPTH
+  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag() || pcSlice->getIsDepth() )
+#else
   if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
-  {
-#if !H_3D || CAM_HLS_F0044
+#endif
+  {
     WRITE_UVLC(0,"slice_header_extension_length");
-#else
-    WRITE_UVLC(0,"slice_header_extension_length"); //<- this element needs to be set to the correct value!!
-#if QC_DEPTH_IV_MRG_F0125
-#if CAM_HLS_F0136_F0045_F0082
-    if( pcSlice->getVPS()->hasCamParInSliceHeader( pcSlice->getViewIndex() ) && !pcSlice->getIsDepth() )
-#else
-    if( pcSlice->getSPS()->hasCamParInSliceHeader() && !pcSlice->getIsDepth() )
-#endif
-#else
-    if( pcSlice->getSPS()->hasCamParInSliceHeader() )
-#endif
-    {
-      for( UInt uiId = 0; uiId < pcSlice->getViewIndex(); uiId++ )
-      {
-        WRITE_SVLC( pcSlice->getCodedScale    ()[ uiId ],                                     "cp_scale" );
-        WRITE_SVLC( pcSlice->getCodedOffset   ()[ uiId ],                                     "cp_off" );
-        WRITE_SVLC( pcSlice->getInvCodedScale ()[ uiId ] + pcSlice->getCodedScale ()[ uiId ], "cp_inv_scale_plus_scale" );
-        WRITE_SVLC( pcSlice->getInvCodedOffset()[ uiId ] + pcSlice->getCodedOffset()[ uiId ], "cp_inv_off_plus_off" );
-      }
-    }
-
-    Bool sliceSegmentHeaderExtension2Flag = false; 
-    WRITE_FLAG( sliceSegmentHeaderExtension2Flag ? 1 : 0 , "slice_segment_header_extension2_flag" ); 
-    if ( sliceSegmentHeaderExtension2Flag )
-    {
-      WRITE_UVLC(0,"slice_header_extension2_length");
-    }
-#endif
   }
 }
Index: trunk/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncCavlc.h	(revision 773)
@@ -86,21 +86,11 @@
 #if H_MV
   Void  codeVPSExtension       ( TComVPS *pcVPS );
-#if H_MV_6_PS_O0118_33
   Void  codeVideoSignalInfo     ( TComVideoSignalInfo* pcVideoSignalInfo ); 
-#endif
 
-#if H_MV_6_HRD_O0217_13
   Void  codeDpbSize   ( TComVPS* vps );
-#endif
 
-#if H_MV_6_PS_REP_FORM_18_19_20
   Void  codeRepFormat           ( Int i, TComRepFormat* curRepFormat, TComRepFormat* prevRepFormat );
-#else
-  Void  codeRepFormat          ( TComRepFormat* pcRepFormat );
-#endif
   Void  codeVPSVUI             ( TComVPS* pcVPS );
-#if H_MV_6_HRD_O0164_15
   Void  codeVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
-#endif
 #endif 
   Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
@@ -117,5 +107,5 @@
   Void  codePPS                 ( TComPPS* pcPPS );
 
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
   Void  codePPSExtension        ( TComPPS* pcPPS );
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncCfg.h	(revision 773)
@@ -331,5 +331,5 @@
 #endif
 
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
   TComDLT*  m_cDLT;
 #endif
@@ -408,5 +408,5 @@
   UInt      m_uiARPStepNum;
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
   Int      m_iSubPULog2Size;
 #endif
@@ -420,11 +420,8 @@
 #if H_3D_DIM
   Bool      m_useDMM;
-#if !SEC_DMM3_RBC_F0147
-  Bool      m_useRBC;
-#endif
   Bool      m_useSDC;
   Bool      m_useDLT;
 #endif
-#if SEC_MPI_ENABLING_MERGE_F0150
+#if H_3D_IV_MERGE
   Bool      m_useMPI;
 #endif
@@ -514,5 +511,5 @@
   Void       setARPStepNum                  ( UInt  u )      { m_uiARPStepNum = u;       }
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
   Int        getSubPULog2Size                   ()                   { return m_iSubPULog2Size;}
   Void       setSubPULog2Size                   (Int u)              { m_iSubPULog2Size = u; }     
@@ -873,5 +870,5 @@
 #endif
 
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
   Void      setDLT           ( TComDLT *p ) { m_cDLT = p; }
   TComDLT*  getDLT           ()             { return m_cDLT; }
@@ -1003,8 +1000,4 @@
   Bool      getUseDMM                       ()        { return m_useDMM; }
   Void      setUseDMM                       ( Bool b) { m_useDMM = b;    }
-#if !SEC_DMM3_RBC_F0147
-  Bool      getUseRBC                       ()        { return m_useRBC; }
-  Void      setUseRBC                       ( Bool b) { m_useRBC = b;    }
-#endif
   Bool      getUseSDC                       ()        { return m_useSDC; }
   Void      setUseSDC                       ( Bool b) { m_useSDC = b;    }
@@ -1018,5 +1011,5 @@
   Bool      getUsePC                        ()         { return m_bUsePC;  }
 #endif
-#if SEC_MPI_ENABLING_MERGE_F0150
+#if H_3D_IV_MERGE
   Void      setUseMPI                       ( Bool b ) { m_useMPI = b;    }
   Bool      getUseMPI                       ()         { return m_useMPI; }
Index: trunk/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncCu.cpp	(revision 773)
@@ -497,9 +497,5 @@
 #endif
 #if H_3D_IC
-#if SEC_ONLY_TEXTURE_IC_F0151
   Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE ) && !rpcTempCU->getSlice()->getIsDepth();
-#else
-  Bool bICEnabled = rpcTempCU->getSlice()->getViewIndex() && ( rpcTempCU->getSlice()->getSliceType() == P_SLICE || rpcTempCU->getSlice()->getSliceType() == B_SLICE );
-#endif
   bICEnabled = bICEnabled && rpcTempCU->getSlice()->getApplyIC();
 #endif
@@ -571,5 +567,5 @@
           PartSize ePartTemp = rpcTempCU->getPartitionSize(0);
           rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth );     
-#if QC_DEPTH_IV_MRG_F0125
+#if H_3D_IV_MERGE
           if (rpcTempCU->getSlice()->getIsDepth() )
           {
@@ -586,5 +582,5 @@
             DvInfo.bDV = rpcTempCU->getDisMvpCandNBDV(&DvInfo);
 
-#if QC_DEPTH_IV_MRG_F0125
+#if H_3D_IV_MERGE
           }
 #endif
@@ -1779,5 +1775,5 @@
 #endif
 
-#if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104 
+#if H_3D_ARP
   DisInfo cOrigDisInfo = rpcTempCU->getDvInfo(0);
 #else
@@ -1787,9 +1783,8 @@
 
 #if H_3D_VSP
-#if !(H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104)
+#if !H_3D_ARP
   Int vspFlag[MRG_MAX_NUM_CANDS_MEM];
   memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
   InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
-#if ETRIKHU_MERGE_REUSE_F0093
   rpcTempCU->m_bAvailableFlagA1 = 0;
   rpcTempCU->m_bAvailableFlagB1 = 0;
@@ -1799,10 +1794,7 @@
   rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
   rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo, numValidMergeCand );
-#else
-  rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
-#endif
-#endif
-#else
-#if ETRIKHU_MERGE_REUSE_F0093
+#endif
+#else
+#if H_3D
   rpcTempCU->m_bAvailableFlagA1 = 0;
   rpcTempCU->m_bAvailableFlagB1 = 0;
@@ -1822,5 +1814,5 @@
   Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
 #endif
-#if H_3D_ARP && LGE_SHARP_VSP_INHERIT_F0104
+#if H_3D_ARP
 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
 #else
@@ -1851,10 +1843,5 @@
   for( Int nARPW=nARPWMax; nARPW >= 0 ; nARPW-- )
   {
-#if FIX_MISSING_MACRO_R690
     memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS_MEM*sizeof(Int) );
-#else
-    memset( mergeCandBuffer, 0, MRG_MAX_NUM_CANDS*sizeof(Int) );
-#endif
-#if LGE_SHARP_VSP_INHERIT_F0104
     rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uhDepth ); // interprets depth relative to LCU level
     rpcTempCU->setCUTransquantBypassSubParts( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth );
@@ -1868,5 +1855,5 @@
     memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM);
     InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM];
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
     Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
     memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
@@ -1876,9 +1863,9 @@
     puhInterDirSP = new UChar[rpcTempCU->getPic()->getPicSym()->getNumPartition()]; 
 #endif
-#if ETRIKHU_MERGE_REUSE_F0093
+#if H_3D
     rpcTempCU->initAvailableFlags();
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     rpcTempCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag,inheritedVSPDisInfo
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif
@@ -1888,5 +1875,5 @@
     rpcTempCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand );
 #endif
-#endif
+
 #endif
   for( UInt uiNoResidual = 0; uiNoResidual < iteration; ++uiNoResidual )
@@ -1923,5 +1910,5 @@
           rpcTempCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeCand].m_acDvInfo, 0, 0, uhDepth );
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
           rpcTempCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeCand], 0, 0, uhDepth);
           if (bSPIVMPFlag[uiMergeCand])
@@ -1949,28 +1936,5 @@
             rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
             rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level
-#if MTK_SPIVMP_F0110
-          }
-#endif
-#if H_3D_ARP && !QC_MTK_INTERVIEW_ARP_F0123_F0108
-          if( nARPW )
-          {
-            Bool bSignalflag[2] = { true, true };
-            for( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )
-            {
-              Int iRefIdx = cMvFieldNeighbours[uiRefListIdx + 2*uiMergeCand].getRefIdx();
-              RefPicList eRefList = uiRefListIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
-              if( iRefIdx < 0 || rpcTempCU->getSlice()->getPOC() == rpcTempCU->getSlice()->getRefPOC(eRefList, iRefIdx) )
-              {
-                bSignalflag[uiRefListIdx] = false;
-              }
-            }
-            if( !bSignalflag[0] && !bSignalflag[1] )
-            {
-#if LGE_SHARP_VSP_INHERIT_F0104
-              continue;
-#else
-              rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
-#endif
-            }
+#if H_3D_SPIVMP
           }
 #endif
@@ -2093,12 +2057,7 @@
   }
  }
-#if MTK_SPIVMP_F0110
-#if MTK_F0110_FIX
+#if H_3D_SPIVMP
  delete[] pcMvFieldSP;
  delete[] puhInterDirSP;
-#else
- delete pcMvFieldSP;
- delete puhInterDirSP;
-#endif
 #endif
 #if H_3D_ARP
@@ -2170,24 +2129,4 @@
 
     m_pcPredSearch->motionCompensation( rpcTempCU , m_ppcPredYuvTemp[uhDepth] );
-
-#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
-    if(rpcTempCU->getPartitionSize(0)==SIZE_2Nx2N)
-    {
-      Bool bSignalflag[2] = { true, true };
-      for(UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )
-      {
-        RefPicList eRefList = uiRefListIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
-        Int iRefIdx = rpcTempCU->getCUMvField(eRefList)->getRefIdx(0);
-        if( iRefIdx < 0 || rpcTempCU->getSlice()->getPOC() == rpcTempCU->getSlice()->getRefPOC(eRefList, iRefIdx) )
-        {
-          bSignalflag[uiRefListIdx] = false;
-        }
-      }
-      if( !bSignalflag[0] && !bSignalflag[1] )
-      {
-        rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
-      }
-    }
-#endif
   }
   else
@@ -2209,21 +2148,4 @@
    {
      m_ppcWeightedTempCU[uhDepth]->copyPartFrom( rpcTempCU , 0 , uhDepth );
-
-#if !QC_MTK_INTERVIEW_ARP_F0123_F0108
-     Bool bSignalflag[2] = { true, true };
-     for(UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx ++ )
-     {
-       RefPicList eRefList = uiRefListIdx ? REF_PIC_LIST_1 : REF_PIC_LIST_0;
-       Int iRefIdx = rpcTempCU->getCUMvField(eRefList)->getRefIdx(0);
-       if( iRefIdx < 0 || rpcTempCU->getSlice()->getPOC() == rpcTempCU->getSlice()->getRefPOC(eRefList, iRefIdx) )
-       {
-         bSignalflag[uiRefListIdx] = false;
-       }
-     }
-     if( !bSignalflag[0] && !bSignalflag[1])
-     {
-       rpcTempCU->setARPWSubParts( 0 , 0 , uhDepth );
-     }
-#endif
    }
   }
Index: trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 773)
@@ -160,9 +160,5 @@
 Void TEncEntropy::encodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD )
 {
-#if SEC_ONLY_TEXTURE_IC_F0151
   if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() )
-#else
-  if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) )
-#endif
   {
     return;
Index: trunk/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 773)
@@ -664,9 +664,5 @@
     refPicListModification->setRefPicListModificationFlagL1(0);
 #if H_MV
-#if H_MV_6_RALS_O0149_11
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )
-#else
-    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 1 )
-#endif
     {
       // Some more sophisticated algorithm to determine discardable_flag might be added here. 
@@ -678,7 +674,5 @@
     GOPEntry gopEntry      = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );     
     
-#if H_MV_6_ILDDS_ILREFPICS_27_34
     Bool interLayerPredLayerIdcPresentFlag = false; 
-#endif
     if ( getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && numDirectRefLayers > 0 )
     {         
@@ -692,7 +686,5 @@
         if ( gopEntry.m_numActiveRefLayerPics != vps->getNumDirectRefLayers( getLayerId() ) )
         {        
-#if H_MV_6_ILDDS_ILREFPICS_27_34
           interLayerPredLayerIdcPresentFlag = true; 
-#endif
           for (Int i = 0; i < gopEntry.m_numActiveRefLayerPics; i++ )
           {
@@ -702,5 +694,4 @@
       }
     }
-#if H_MV_6_ILDDS_ILREFPICS_27_34
     if ( !interLayerPredLayerIdcPresentFlag )
     {
@@ -710,5 +701,4 @@
       }
     }
-#endif
 
 
@@ -745,9 +735,5 @@
 #if H_3D_ARP
     //GT: This seems to be broken when layerId in vps is not equal to layerId in nuh
-#if SHARP_ARP_REF_CHECK_F0105
     pcSlice->setARPStepNum(m_ivPicLists);
-#else
-    pcSlice->setARPStepNum();
-#endif
     if(pcSlice->getARPStepNum() > 1)
     {
@@ -1319,4 +1305,8 @@
       nalu = NALUnit(NAL_UNIT_PPS);
 #endif
+#if PPS_FIX_DEPTH
+      if(!pcSlice->getIsDepth() || !pcSlice->getViewIndex() )
+      {
+#endif
       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
       m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
@@ -1326,5 +1316,7 @@
       actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
 #endif
-
+#if PPS_FIX_DEPTH
+      }
+#endif
       xCreateLeadingSEIMessages(accessUnit, pcSlice->getSPS());
 
Index: trunk/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 773)
@@ -95,10 +95,4 @@
 #if H_3D_DIM_DMM
 , m_cDmm1DataSCModel          ( 1,             1,               NUM_DMM1_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#if !SEC_DMM3_RBC_F0147
-, m_cDmm3DataSCModel          ( 1,             1,               NUM_DMM3_DATA_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
-#endif
-#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
@@ -176,10 +170,4 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#if !SEC_DMM3_RBC_F0147
-  m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
-#endif
-#endif
-#if H_3D_DIM_RBC
-  m_cRbcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_RBC_DATA );
 #endif
 #if H_3D_DIM_SDC
@@ -266,10 +254,4 @@
 #if H_3D_DIM_DMM
       curCost += m_cDmm1DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM1_DATA );
-#if !SEC_DMM3_RBC_F0147
-      curCost += m_cDmm3DataSCModel.calcCost          ( curSliceType, qp, (UChar*)INIT_DMM3_DATA );
-#endif
-#endif
-#if H_3D_DIM_RBC
-      curCost += m_cRbcDataSCModel.calcCost           ( curSliceType, qp, (UChar*)INIT_RBC_DATA );
 #endif
     }
@@ -337,10 +319,4 @@
 #if H_3D_DIM_DMM
   m_cDmm1DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA );
-#if !SEC_DMM3_RBC_F0147
-  m_cDmm3DataSCModel.initBuffer          ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA );
-#endif
-#endif
-#if H_3D_DIM_RBC
-  m_cRbcDataSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_RBC_DATA );
 #endif
 #if H_3D_DIM_SDC
@@ -526,5 +502,4 @@
 }
 
-#if QC_DIM_DELTADC_UNIFY_F0132
 Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt uiNumSeg )
 {
@@ -536,15 +511,4 @@
   }
 }
-#else
-Void TEncSbac::xCodeDimDeltaDC( Pel valDeltaDC, UInt dimType )
-{
-  xWriteExGolombLevel( UInt( abs( valDeltaDC ) ), m_cDdcDataSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
-  if( valDeltaDC != 0 )
-  {
-    UInt uiSign = valDeltaDC > 0 ? 0 : 1;
-    m_pcBinIf->encodeBinEP( uiSign );
-  }
-}
-#endif
 
 #if H_3D_DIM_DMM
@@ -557,64 +521,6 @@
 }
 
-#if !SEC_DMM3_RBC_F0147
-Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit )
-{
-  for( Int i = 0; i < iNumBit; i++ )
-  {
-    m_pcBinIf->encodeBin( ( uiIntraIdx >> i ) & 1, m_cDmm3DataSCModel.get(0, 0, 0) );
-  }
-}
-#endif
-#endif
-#if H_3D_DIM_RBC
-Void TEncSbac::xCodeRbcEdge( TComDataCU* pcCU, UInt uiAbsPartIdx )
-{
-  UInt   uiDepth        = pcCU->getDepth( uiAbsPartIdx ) + (pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ? 1 : 0);
-  UChar* pucSymbolList  = pcCU->getEdgeCode     ( uiAbsPartIdx );
-  UChar  ucEdgeNumber   = pcCU->getEdgeNumber   ( uiAbsPartIdx );
-  Bool   bLeft          = pcCU->getEdgeLeftFirst( uiAbsPartIdx );
-  UChar  ucStart        = pcCU->getEdgeStartPos ( uiAbsPartIdx );
-  UInt   uiSymbol;
-
-  // 1. Top(0) or Left(1)
-  uiSymbol = (bLeft == false) ? 0 : 1;
-  m_pcBinIf->encodeBinEP( uiSymbol );
-
-  // 2. Start position (lowest bit first)
-  uiSymbol = ucStart;
-  for( UInt ui = 6; ui > uiDepth; ui-- ) // 64(0)->6, 32(1)->5, 16(2)->4, 8(3)->3, 4(4)->2
-  {
-    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
-    uiSymbol >>= 1;
-  }
-
-  // 3. Number of edges
-  uiSymbol = ucEdgeNumber > 0 ? ucEdgeNumber - 1 : 0;
-  for( UInt ui = 7; ui > uiDepth; ui-- ) // 64(0)->7, 32(1)->6, 16(2)->5, 8(3)->4, 4(4)->3
-  {
-    m_pcBinIf->encodeBinEP( uiSymbol & 0x1 );
-    uiSymbol >>= 1;
-  }
-
-  if(uiSymbol != 0)
-  {
-    printf(" ucEdgeNumber %d at depth %d\n",ucEdgeNumber, uiDepth);
-    assert(false);
-  }
-
-  // 4. Edges
-  for( Int iPtr2 = 0; iPtr2 < ucEdgeNumber; iPtr2++ )
-  {
-    UInt uiReorderSymbol = pucSymbolList[iPtr2];
-    for( UInt ui = 0; ui < uiReorderSymbol; ui++ )
-    {
-      m_pcBinIf->encodeBin( 1, m_cRbcDataSCModel.get( 0, 0, 0 ) );
-    }
-
-    if( uiReorderSymbol != 6 )
-      m_pcBinIf->encodeBin( 0, m_cRbcDataSCModel.get( 0, 0, 0 ) );
-  }
-}
-#endif
+#endif
+
 #if H_3D_DIM_SDC
 Void TEncSbac::xCodeSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment )
@@ -632,9 +538,5 @@
 
 #if H_3D_DIM_DLT
-#if DLT_DIFF_CODING_IN_PPS
   UInt uiMaxResidualBits = pcCU->getSlice()->getPPS()->getDLT()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() );
-#else
-  UInt uiMaxResidualBits = pcCU->getSlice()->getVPS()->getBitsPerDepthValue( pcCU->getSlice()->getLayerIdInVps() );
-#endif
 #else
   UInt uiMaxResidualBits = g_bitDepthY;
@@ -655,14 +557,10 @@
     DTRACE_CU("sdc_residual_sign_flag[i]", uiSign)
 #endif
-    
-#if H_3D_DIM_DLT
-#if DLT_DIFF_CODING_IN_PPS
-      UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
-#else
-      UInt uiNumDepthValues = pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
-#endif
+#if H_3D_DIM_DLT    
+    UInt uiNumDepthValues = pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() );
 #else
     UInt uiNumDepthValues = ((1 << g_bitDepthY)-1);
 #endif
+
     assert(uiAbsIdx <= uiNumDepthValues);
     
@@ -1239,97 +1137,47 @@
       xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
     } break;
-#if !SEC_DMM3_RBC_F0147
-  case( DMM3_IDX ):
-    {
-      xCodeDmm3WedgeIdx( pcCU->getDmm3IntraTabIdx( absPartIdx ), g_dmm3IntraTabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] );
-    } break;
-#endif
   case( DMM4_IDX ): break;
 #endif
-#if H_3D_DIM_RBC
-  case( RBC_IDX ):
-    {
-      assert( pcCU->getWidth( absPartIdx ) < 64 );
-      xCodeRbcEdge( pcCU, absPartIdx );
-    } break;
-#endif
   default: break;
   }
 
-#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
-  if( pcCU->getSDCFlag( absPartIdx ) )
-  {
-    assert(pcCU->getPartitionSize(absPartIdx)==SIZE_2Nx2N);
-    UInt uiNumSegments = ( dir == DC_IDX || dir == PLANAR_IDX )? 1 : 2;
-    for(UInt uiSeg=0; uiSeg<uiNumSegments; uiSeg++)
-    {
-      xCodeSDCResidualData(pcCU, absPartIdx, uiSeg);
-    }
-  }
-  else
-  {
-#endif
-#if QC_DIM_DELTADC_UNIFY_F0132
-    if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
-#else
-    if( dimType < DIM_NUM_TYPE )
-#endif
-    {
-#if QC_DIM_DELTADC_UNIFY_F0132
-      UInt dimDeltaDC;
-      Pel  deltaDC;
-      UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
-      if( pcCU->getSDCFlag( absPartIdx ) )
-    {
-        if( uiNumSegments==1 )
-        {
-          dimDeltaDC = pcCU->getSDCSegmentDCOffset(0, absPartIdx) ? 1 : 0;
-        }
-        else
-        {
-          dimDeltaDC = ( pcCU->getSDCSegmentDCOffset(0, absPartIdx) || pcCU->getSDCSegmentDCOffset(1, absPartIdx) ) ? 1 : 0;
-        }
+  if( dimType < DIM_NUM_TYPE || pcCU->getSDCFlag( absPartIdx ) )
+  {
+    UInt dimDeltaDC;
+    Pel  deltaDC;
+    UInt uiNumSegments = ( dir == PLANAR_IDX ) ? 1 : 2;
+    if( pcCU->getSDCFlag( absPartIdx ) )
+    {
+      if( uiNumSegments==1 )
+      {
+        dimDeltaDC = pcCU->getSDCSegmentDCOffset(0, absPartIdx) ? 1 : 0;
       }
       else
       {
-        dimDeltaDC = isDimDeltaDC( dir );
-      }
-
-      m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) );
-
-      if( dimDeltaDC ) 
-      {
-        for( UInt segment = 0; segment < uiNumSegments; segment++ )
-        {
-          deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset(segment, absPartIdx) : pcCU->getDimDeltaDC( dimType, segment, absPartIdx );
-          xCodeDimDeltaDC( deltaDC, uiNumSegments );
-        }
-      }
-#else
-      UInt dimDeltaDC = isDimDeltaDC( dir );
-      m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, (RBC_IDX == dimType) ? 1 : 0) );
-      if( dimDeltaDC ) 
-      {
-        for( UInt segment = 0; segment < 2; segment++ )
-        {
-          xCodeDimDeltaDC( pcCU->getDimDeltaDC( dimType, segment, absPartIdx ), dimType );
-        }
-      }
-#endif
-    }
-#if H_3D_DIM_SDC && !QC_DIM_DELTADC_UNIFY_F0132
-  }
-#endif
+        dimDeltaDC = ( pcCU->getSDCSegmentDCOffset(0, absPartIdx) || pcCU->getSDCSegmentDCOffset(1, absPartIdx) ) ? 1 : 0;
+      }
+    }
+    else
+    {
+      dimDeltaDC = isDimDeltaDC( dir );
+    }
+
+    m_pcBinIf->encodeBin( dimDeltaDC, m_cDdcFlagSCModel.get(0, 0, uiNumSegments-1) );
+
+    if( dimDeltaDC ) 
+    {
+      for( UInt segment = 0; segment < uiNumSegments; segment++ )
+      {
+        deltaDC = pcCU->getSDCFlag( absPartIdx ) ? pcCU->getSDCSegmentDCOffset(segment, absPartIdx) : pcCU->getDimDeltaDC( dimType, segment, absPartIdx );
+        xCodeDimDeltaDC( deltaDC, uiNumSegments );
+      }
+    }
+  }
 }
 
 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx )
 {
-#if SEC_DMM3_RBC_F0147
   UInt codeWordTable[3][7] =    {{0, 0, 0, 1, 0, 0, 0},{0, 2, 6, 14, 15, 0, 0},{0, 1, 0, 0, 0, 0, 0}};
   UInt codeWordLenTable[3][7] = {{0, 1, 0, 1, 0, 0, 0},{1, 2, 3,  4,  4, 0, 0},{1, 1, 0, 0, 0, 0, 0}};
-#else
-    UInt codeWordTable[3][7] =    {{0, 0, 0, 2, 0,6, 7},{0, 0, 2, 7, 3, 6, 2},{0, 1, 0, 0, 0, 0, 0}};
-    UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{1, 1, 2, 3, 2, 3, 2},{1, 1, 0, 0, 0, 0, 0}};
-#endif
   UInt dir = pcCU->getLumaIntraDir( absPartIdx );
   UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 );
@@ -1346,8 +1194,4 @@
     case DMM1_IDX: codeIdx = 3; break;
     case DMM4_IDX: codeIdx = 4; break;
-#if !SEC_DMM3_RBC_F0147
-    case DMM3_IDX: codeIdx = 5; break;
-    case  RBC_IDX: codeIdx = 6; break;
-#endif
     default:                    break;
     }
@@ -1362,17 +1206,4 @@
       default:          codeIdx = 2; break;
     }
-  }
-#endif
-#if !SEC_DMM3_RBC_F0147 
-  if( puIdx==1 )
-  {
-      if( codeIdx==1 || codeIdx==2 || codeIdx==4 )
-      {
-          m_pcBinIf->encodeBinEP( 0 );
-      }
-      else
-      {
-          m_pcBinIf->encodeBinEP( 1 );
-      }
   }
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncSbac.h	(revision 773)
@@ -116,19 +116,9 @@
   Void  xWriteEpExGolomb     ( UInt uiSymbol, UInt uiCount );
   Void  xWriteCoefRemainExGolomb ( UInt symbol, UInt &rParam );
-  #if H_3D_DIM
+#if H_3D_DIM
   Void  xWriteExGolombLevel  ( UInt uiSymbol, ContextModel& rcSCModel  );
-#if QC_DIM_DELTADC_UNIFY_F0132
   Void  xCodeDimDeltaDC      ( Pel valDeltaDC, UInt uiNumSeg );
-#else
-  Void  xCodeDimDeltaDC      ( Pel valDeltaDC, UInt dimType );
-#endif
 #if H_3D_DIM_DMM
   Void  xCodeDmm1WedgeIdx    ( UInt uiTabIdx, Int iNumBit );
-#if !SEC_DMM3_RBC_F0147
-  Void  xCodeDmm3WedgeIdx    ( UInt uiIntraIdx, Int iNumBit );
-#endif
-#endif
-#if H_3D_DIM_RBC
-  Void  xCodeRbcEdge         ( TComDataCU* pcCU, UInt uiAbsPartIdx );
 #endif
 #if H_3D_DIM_SDC
@@ -259,10 +249,4 @@
 #if H_3D_DIM_DMM
   ContextModel3DBuffer m_cDmm1DataSCModel;
-#if !SEC_DMM3_RBC_F0147
-  ContextModel3DBuffer m_cDmm3DataSCModel;
-#endif
-#endif
-#if H_3D_DIM_RBC
-  ContextModel3DBuffer m_cRbcDataSCModel;
 #endif
 #if H_3D_DIM_SDC  
Index: trunk/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 773)
@@ -1124,30 +1124,22 @@
       {
 #endif
-      for( UInt uiX = 0; uiX < uiWidth; uiX++ )
-      {
-#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
-#if DLT_DIFF_CODING_IN_PPS
-        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-#else
-        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-#endif
+        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
+        {
+#if H_3D_DIM
+          if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
           {
-#if DLT_DIFF_CODING_IN_PPS
             pResi[ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] );
-#else
-            pResi[ uiX ] = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pOrg[ uiX ] ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] );
-#endif
           }
           else
           {
-              pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
+            pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
           }
 #else
-        pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
-#endif
-      }
-      pOrg  += uiStride;
-      pResi += uiStride;
-      pPred += uiStride;
+          pResi[ uiX ] = pOrg[ uiX ] - pPred[ uiX ];
+#endif
+        }
+        pOrg  += uiStride;
+        pResi += uiStride;
+        pPred += uiStride;
 #if H_3D_DIM_ENC
       }
@@ -1209,21 +1201,13 @@
       for( UInt uiX = 0; uiX < uiWidth; uiX++ )
       {
-#if LGE_PRED_RES_CODING_DLT_DOMAIN_F0159
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D_DIM
         if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-#else
-        if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) )
-#endif
-          {
-#if DLT_DIFF_CODING_IN_PPS
-            pReco    [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
-#else
-            pReco    [ uiX ] = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getVPS()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
-#endif
-          }
-          else
-          {
-              pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
-          }
+        {
+          pReco    [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) );
+        }
+        else
+        {
+          pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
+        }
 #else
         pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
@@ -1951,9 +1935,5 @@
     // get residual (idx)
 #if H_3D_DIM_DLT
-#if DLT_DIFF_CODING_IN_PPS
     Pel pResidualIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pDCRec ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
-#else
-    Pel pResidualIdx = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pDCRec ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
-#endif
 #else
     Pel pResidualIdx = pDCRec - apDCPredValues[uiSegment];
@@ -1969,13 +1949,7 @@
   {
 #if H_3D_DIM_DLT
-#if DLT_DIFF_CODING_IN_PPS
     Pel   pPredIdx    = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
     Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
     Pel   pRecoValue  = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
-#else
-    Pel   pPredIdx    = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] );
-    Pel   pResiIdx    = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx);
-    Pel   pRecoValue  = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx );
-#endif
 
     apDCResiValues[uiSegment]  = pRecoValue - apDCPredValues[uiSegment];
@@ -2924,23 +2898,5 @@
               biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
             } break;
-#if !SEC_DMM3_RBC_F0147
-          case( DMM3_IDX ):
-            {
-
-              TComPic*      pcPicTex = pcCU->getSlice()->getTexturePic();
-              TComDataCU* pcColTexCU = pcPicTex->getCU( pcCU->getAddr() );
-              UInt      uiTexPartIdx = pcCU->getZorderIdxInCU() + uiPartOffset;
-              Int   uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255;
-
-              if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 )
-              {
-             UInt uiIntraTabIdx = 0;
-              xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx, uiColTexIntraDir );
-              pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth );
-              pcCU->setDmm3IntraTabIdxSubParts( uiIntraTabIdx, uiPartOffset, uiDepth + uiInitTrDepth );
-              biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);
-              }
-            } break;
-#endif
+
           case( DMM4_IDX ):
             {
@@ -2968,27 +2924,4 @@
       }
 #endif
-#if H_3D_DIM_RBC
-      if( m_pcEncCfg->getUseRBC()
-#if H_3D_FAST_DEPTH_INTRA
-          && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold)
-#endif
-        )
-      {
-        if( xSearchRbcEdge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight ) )
-        {
-          Pel deltaDC1 = 0; Pel deltaDC2 = 0;
-#if QC_DIM_DELTADC_UNIFY_F0132
-          xSearchDmmDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
-#else
-          xSearchRbcDeltaDCs( pcCU, uiPartOffset, piOrg, piPred, uiStride, pcCU->getEdgePartition( uiPartOffset ), uiWidth, uiWidth, uiHeight, deltaDC1, deltaDC2 );
-#endif
-          pcCU->setDimDeltaDC( RBC_IDX, 0, uiPartOffset, deltaDC1 );
-          pcCU->setDimDeltaDC( RBC_IDX, 1, uiPartOffset, deltaDC2 );
-
-          uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX  +DIM_OFFSET);
-          uiRdModeList[ numModesForFullRD++ ] = (2*RBC_IDX+1+DIM_OFFSET);
-        }
-      }
-#endif
     }
 #endif
@@ -3029,9 +2962,5 @@
       Bool bTestZeroResi = false;
 #if H_3D_DIM_ENC
-#if LGE_BUGFIX_F0158
       bTestZeroResi |= pcCU->getSlice()->getIsDepth() && !pcCU->getSlice()->isIRAP();
-#else
-      bTestZeroResi |= pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->isIRAP();
-#endif
 #endif
 #if H_3D_DIM_SDC
@@ -3642,5 +3571,5 @@
                                  , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
                                  , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
@@ -3660,5 +3589,5 @@
     if ( iPUIdx == 0 )
     {
-#if ETRIKHU_MERGE_REUSE_F0093
+#if H_3D
       pcCU->initAvailableFlags();
       pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
@@ -3668,5 +3597,5 @@
                                         , inheritedVSPDisInfo
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
                                         , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif
@@ -3674,11 +3603,5 @@
         );
 #else
-      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours
-#if H_3D_VSP
-                                   , vspFlag
-                                   , inheritedVSPDisInfo
-#endif
-                                   , numValidMergeCand
-                                   );
+      pcCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );
 #endif
     }
@@ -3687,5 +3610,5 @@
   else
   {
-#if ETRIKHU_MERGE_REUSE_F0093
+#if H_3D
     pcCU->initAvailableFlags();
     pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand);
@@ -3695,5 +3618,5 @@
                                       , inheritedVSPDisInfo
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
                                       , pbSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif
@@ -3701,10 +3624,5 @@
       );
 #else
-    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours
-#if H_3D_VSP
-                                 , vspFlag
-                                 , inheritedVSPDisInfo
-#endif
-                                 , numValidMergeCand
+    pcCU->getInterMergeCandidates( uiAbsPartIdx, iPUIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand
                                  );
 #endif
@@ -3726,5 +3644,5 @@
       PartSize ePartSize = pcCU->getPartitionSize( 0 );
 
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
       pcCU->setSPIVMPFlagSubParts( pbSPIVMPFlag[uiMergeCand], uiAbsPartIdx, iPUIdx, pcCU->getDepth( uiAbsPartIdx )); 
       if (pbSPIVMPFlag[uiMergeCand])
@@ -3748,5 +3666,5 @@
         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], ePartSize, uiAbsPartIdx, 0, iPUIdx );
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
       }
 #endif
@@ -4427,5 +4345,5 @@
       DisInfo OriginalDvInfo = pcCU->getDvInfo(uiAbsPartIdx);
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
       Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM];
       memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM);
@@ -4440,5 +4358,5 @@
                       , inheritedVSPDisInfo
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
                       , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP
 #endif 
@@ -4454,5 +4372,5 @@
         pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMRGIndex].m_acDvInfo, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
         pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMRGIndex], uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );  
         if (bSPIVMPFlag[uiMRGIndex]!=0)
@@ -4488,5 +4406,5 @@
             pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMRGMvField[1], ePartSize, uiPartAddr, 0, iPartIdx );
           }
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
         }
 #endif
@@ -4502,5 +4420,5 @@
       else
       {
-#if MTK_SPIVMP_F0110        
+#if H_3D_SPIVMP        
         pcCU->setSPIVMPFlagSubParts(0, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 
 #endif
@@ -4517,12 +4435,7 @@
         }
       }
-#if MTK_SPIVMP_F0110
-#if MTK_F0110_FIX
+#if H_3D_SPIVMP
       delete[] pcMvFieldSP;
       delete[] puhInterDirSP;
-#else
-      delete pcMvFieldSP;
-      delete puhInterDirSP;
-#endif
 #endif
     }
@@ -5438,5 +5351,5 @@
       dZeroCost = dCost + 1;
     }
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
     if ( dZeroCost < dCost || pcCU->getQtRootCbf(0)==0)
 #else
@@ -7372,11 +7285,6 @@
 
 #if H_3D_DIM_DLT
-#if DLT_DIFF_CODING_IN_PPS
   rDeltaDC1 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC1 + rDeltaDC1) ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 );
   rDeltaDC2 = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC2 + rDeltaDC2) ) - pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 );
-#else
-  rDeltaDC1 = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC1 + rDeltaDC1) ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC1 );
-  rDeltaDC2 = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), ClipY(predDC2 + rDeltaDC2) ) - pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), predDC2 );
-#endif
 #endif
 }
@@ -7477,1031 +7385,7 @@
 }
 
-#if !SEC_DMM3_RBC_F0147
-Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir )
-{
-  ruiTabIdx       = 0;
-  ruiIntraTabIdx  = 0;
-
-  // local pred buffer
-  TComYuv cPredYuv; 
-  cPredYuv.create( uiWidth, uiHeight ); 
-  cPredYuv.clear();
-  Pel* piPred = cPredYuv.getLumaAddr();
-  UInt uiPredStride = cPredYuv.getStride();
-
-  // wedge search
-  UInt uiBestDist = MAX_UINT;
-  WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])];
-  Pel refDC1 = 0; Pel refDC2 = 0;
-
-  std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]];
-  std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[colTexIntraDir-2];
-  for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ )
-  {
-    UInt uiIdx     =   pauiWdgLst->at(uiIdxW);
-    TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiIdx));
-    xCalcBiSegDCs  ( piRef,  uiRefStride,  pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
-    xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );
-
-    UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD );
-    if( uiActDist < uiBestDist || uiBestDist == MAX_UINT )
-    {
-      uiBestDist     = uiActDist;
-      ruiTabIdx      = uiIdx;
-      ruiIntraTabIdx = uiIdxW;
-    }
-  }
-  cPredYuv.destroy();
-}
-#endif
-#endif
-#if H_3D_DIM_RBC
-Void TEncSearch::xSearchRbcDeltaDCs( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 )
-{
-  assert( biSegPattern );
-  Pel origDC1 = 0; Pel origDC2 = 0;
-  xCalcBiSegDCs  ( piOrig,   uiStride, biSegPattern, patternStride, origDC1, origDC2 );
-  xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, origDC1, origDC2 );
-
-  Int* piMask = pcCU->getPattern()->getAdiOrgBuf( uiWidth, uiHeight, m_piYuvExt ); // no filtering for DMM
-  Int  maskStride = 2*uiWidth + 1;
-  Int* ptrSrc = piMask+maskStride+1;
-  Pel  predDC1 = 0; Pel predDC2 = 0;
-  xPredBiSegDCs( ptrSrc, maskStride, biSegPattern, patternStride, predDC1, predDC2 );
-
-  rDeltaDC1 = origDC1 - predDC1;
-  rDeltaDC2 = origDC2 - predDC2;
-
-#if H_3D_VSO
-  if( m_pcRdCost->getUseVSO() )
-  {
-    Pel fullDeltaDC1 = rDeltaDC1;
-    Pel fullDeltaDC2 = rDeltaDC2;
-
-    xDeltaDCQuantScaleDown( pcCU, fullDeltaDC1 );
-    xDeltaDCQuantScaleDown( pcCU, fullDeltaDC2 );
-
-    Dist uiBestDist     = RDO_DIST_MAX;
-    UInt uiBestQStepDC1 = 0;
-    UInt uiBestQStepDC2 = 0;
-
-    UInt uiDeltaDC1Max = abs(fullDeltaDC1);
-    UInt uiDeltaDC2Max = abs(fullDeltaDC2);
-
-    //VSO Level delta DC check range extension
-    uiDeltaDC1Max += (uiDeltaDC1Max>>1);
-    uiDeltaDC2Max += (uiDeltaDC2Max>>1);
-
-    for( UInt uiQStepDC1 = 1; uiQStepDC1 <= uiDeltaDC1Max; uiQStepDC1++  )
-    {
-      Pel iLevelDeltaDC1 = (Pel)(uiQStepDC1) * (Pel)(( fullDeltaDC1 < 0 ) ? -1 : 1);
-      xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC1 );
-      Pel testDC1 = ClipY( predDC1 + iLevelDeltaDC1 );
-
-      for( UInt uiQStepDC2 = 1; uiQStepDC2 <= uiDeltaDC2Max; uiQStepDC2++  )
-      {
-        Pel iLevelDeltaDC2 = (Pel)(uiQStepDC2) * (Pel)(( fullDeltaDC2 < 0 ) ? -1 : 1);
-        xDeltaDCQuantScaleUp( pcCU, iLevelDeltaDC2 );
-        Pel testDC2 = ClipY( predDC2 + iLevelDeltaDC2 );
-
-        xAssignBiSegDCs( piPredic, uiStride, biSegPattern, patternStride, testDC1, testDC2 );
-
-        Dist uiActDist = RDO_DIST_MAX;
-        if( m_pcRdCost->getUseEstimatedVSD() )
-        {
-          uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
-        }
-        else
-        {
-          uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPredic, uiStride, piOrig, uiStride, uiWidth, uiHeight, false );
-        }
-
-        if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )
-        {
-          uiBestDist     = uiActDist;
-          uiBestQStepDC1 = uiQStepDC1;
-          uiBestQStepDC2 = uiQStepDC2;
-        }
-      }
-    }
-
-    fullDeltaDC1 = (Int)(uiBestQStepDC1) * (Int)(( fullDeltaDC1 < 0 ) ? -1 : 1);
-    fullDeltaDC2 = (Int)(uiBestQStepDC2) * (Int)(( fullDeltaDC2 < 0 ) ? -1 : 1);
-    xDeltaDCQuantScaleUp( pcCU, fullDeltaDC1 );
-    xDeltaDCQuantScaleUp( pcCU, fullDeltaDC2 );
-    rDeltaDC1 = fullDeltaDC1;
-    rDeltaDC2 = fullDeltaDC2;
-  }
-#endif
-
-  xDeltaDCQuantScaleDown( pcCU, rDeltaDC1 );
-  xDeltaDCQuantScaleDown( pcCU, rDeltaDC2 );
-}
-
-Bool TEncSearch::xSearchRbcEdge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, Int iWidth, Int iHeight )
-{
-  Bool* pbEdge  = (Bool*) xMalloc( Bool, iWidth * iHeight * 4 );
-
-  Short* psDiffX = new Short[ iWidth * iHeight ];
-  Short* psDiffY = new Short[ iWidth * iHeight ];
-  Bool*  pbEdgeX = new Bool [ iWidth * iHeight ];
-  Bool*  pbEdgeY = new Bool [ iWidth * iHeight ];
-
-  // Find Horizontal Gradient & Edge Detection ((x+1, y) - (x,y))
-  for( Int y=0; y<iHeight; y++ )
-  {
-    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
-    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
-    for(Int x=0; x<iWidth-1; x++ )
-    {
-      *psDiffXPtr = piRef[ x+1 + y*uiRefStride ] - piRef[ x + y*uiRefStride ];
-      if(*psDiffXPtr >= RBC_THRESHOLD || *psDiffXPtr <= (-1)*RBC_THRESHOLD)
-      {
-        *pbEdgeXPtr = true;
-      }
-      else
-      {
-        *pbEdgeXPtr = false;
-      }
-
-      psDiffXPtr++;
-      pbEdgeXPtr++;
-    }
-  }
-
-  // Find Vertical Gradient & Edge Detection((x,y+1) - (x,y))
-  for( Int y=0; y<iHeight-1; y++ )
-  {
-    Short* psDiffYPtr = &psDiffY[ y * iHeight ];
-    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iHeight ];
-    for(Int x=0; x<iWidth; x++ )
-    {
-      *psDiffYPtr = piRef[ x + (y+1)*uiRefStride ] - piRef[ x + y*uiRefStride ];
-      if(*psDiffYPtr >= RBC_THRESHOLD || *psDiffYPtr <= (-1)*RBC_THRESHOLD)
-      {
-        *pbEdgeYPtr = true;
-      }
-      else
-      {
-        *pbEdgeYPtr = false;
-      }
-
-      psDiffYPtr++;
-      pbEdgeYPtr++;
-    }
-  }
-
-  // Eliminate local maximum
-  for( Int y=0; y<iHeight; y++ )
-  {
-    Short* psDiffXPtr = &psDiffX[ y * iHeight ];
-    Bool*  pbEdgeXPtr = &pbEdgeX[ y * iHeight ];
-    for( Int x=0; x<iWidth-1; x++ )
-    {
-      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : left, 1 : current, 2 : right
-
-      if( x > 0 && *(pbEdgeXPtr-1) == true )
-      {
-        if( *(psDiffXPtr-1) >= 0)
-        {
-          usAbs0 = *(psDiffXPtr-1);
-
-        }
-        else
-        {
-          usAbs0 = (-1) * *(psDiffXPtr-1);
-        }
-      }
-      if( *pbEdgeXPtr == true )
-      {
-        if( *(psDiffXPtr) >= 0)
-        {
-          usAbs1 = *(psDiffXPtr);
-        }
-        else
-        {
-          usAbs1 = (-1) * *(psDiffXPtr);
-        }
-      }
-      if( x < iWidth-2 && *(pbEdgeXPtr+1) == true )
-      {
-        if( *(psDiffXPtr+1) >= 0)
-        {
-          usAbs2 = *(psDiffXPtr+1);
-          //bSign2 = true;
-        }
-        else
-        {
-          usAbs2 = (-1) * *(psDiffXPtr+1);
-        }
-      }
-
-      if( x == 0 )
-      {
-        if( usAbs1 < usAbs2 )
-        {
-          *pbEdgeXPtr = false;
-        }
-      }
-      else if( x == iWidth-2 )
-      {
-        if( usAbs1 <= usAbs0 )
-          *pbEdgeXPtr = false;
-      }
-      else
-      {
-        if( usAbs2 > usAbs0 )
-        {
-          if( usAbs1 < usAbs2 )
-            *pbEdgeXPtr = false;
-        }
-        else
-        {
-          if( usAbs1 <= usAbs0 )
-            *pbEdgeXPtr = false;
-        }
-      }
-
-      psDiffXPtr++;
-      pbEdgeXPtr++;
-    }
-  }
-
-  for( Int y=0; y<iHeight-1; y++ )
-  {
-    Short* psDiffYPtr = &psDiffY[ y * iWidth ];
-    Bool*  pbEdgeYPtr = &pbEdgeY[ y * iWidth ];
-    for( Int x=0; x<iWidth; x++ )
-    {
-      UShort usAbs0=0, usAbs1=0, usAbs2=0;  // 0 : upper, 1 : current, 2 : bottom
-      if( y > 0 && *(pbEdgeYPtr-iWidth) == true )
-      {
-        if( *(psDiffYPtr-iWidth) >= 0)
-        {
-          usAbs0 = *(psDiffYPtr-iWidth);
-        }
-        else
-        {
-          usAbs0 = (-1) * *(psDiffYPtr-iWidth);          
-        }
-      }
-      if( *pbEdgeYPtr == true )
-      {
-        if( *(psDiffYPtr) >= 0)
-        {
-          usAbs1 = *(psDiffYPtr);
-        }
-        else
-        {
-          usAbs1 = (-1) * *(psDiffYPtr);
-        }
-      }
-      if( y < iHeight-2 && *(pbEdgeYPtr+iWidth) == true )
-      {
-        if( *(psDiffYPtr+iWidth) >= 0)
-        {
-          usAbs2 = *(psDiffYPtr+iWidth);          
-        }
-        else
-        {
-          usAbs2 = (-1) * *(psDiffYPtr+iWidth);
-        }
-      }
-
-      if( y == 0 )
-      {
-        if( usAbs1 < usAbs2 )
-          *pbEdgeYPtr = false;
-      }
-      else if( y == iHeight-2 )
-      {
-        if( usAbs1 <= usAbs0 )
-          *pbEdgeYPtr = false;
-      }
-      else
-      {
-        if( usAbs2 > usAbs0 )
-        {
-          if( usAbs1 < usAbs2 )
-            *pbEdgeYPtr = false;
-        }
-        else
-        {
-          if( usAbs1 <= usAbs0 )
-            *pbEdgeYPtr = false;
-        }
-      }
-
-      psDiffYPtr++;
-      pbEdgeYPtr++;
-    }
-  }
-
-  // Edge Merging
-  for( Int i=0; i< 4 * iWidth * iHeight; i++ )
-    pbEdge[ i ] = false;
-  /// Even Line (0,2,4,6,...) => Vertical Edge
-  for( Int i=0; i<iHeight; i++)
-  {
-    for( Int j=0; j<iWidth-1; j++)
-    {
-      pbEdge[ (2 * j + 1) + (2 * i) * 2 * iWidth ] = pbEdgeX[ j + i * iHeight ];
-    }
-  }
-  /// Odd Line (1,3,5,7,...) => Horizontal Edge
-  for( Int i=0; i<iHeight-1; i++)
-  {
-    for( Int j=0; j<iWidth; j++)
-    {
-      pbEdge[ (2 * j) + (2 * i + 1) * 2 * iWidth ] = pbEdgeY[ j + i * iHeight ]; 
-    }
-  }
-
-  // Intersection Filling
-  /// Vertical Edge between Horizontal Edges
-  for( Int i = 1; i < 2 * iHeight - 3; i += 2)
-  {
-    for( Int j = 0; j < 2 * iWidth - 1; j += 2)
-    {
-      if( pbEdge[ j + i * 2 * iWidth ] )
-      {
-        if( j != 0 && pbEdge[ (j - 2) + ((i + 2) * 2 * iWidth) ] )
-        {
-          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j - 1) + ((i + 3) * 2 * iWidth) ] )
-            pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] = true;
-        }
-        if( j != 2 * iWidth - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
-        {
-          if( !pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 1) + ((i + 3) * 2 * iWidth) ] )
-            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
-        }
-      }
-    }
-  }
-  /// Horizontal Edge between Vertical Edges
-  for( Int j = 1; j < 2 * iWidth - 3; j += 2)
-  {
-    for( Int i = 0; i < 2 * iHeight - 1; i += 2)
-    {
-      if( pbEdge[ j + i * 2 * iWidth ] )
-      {
-        if( i != 0 && pbEdge[ (j + 2) + ((i - 2) * 2 * iWidth) ] )
-        {
-          if( !pbEdge[ (j - 1) + ((i - 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i - 1) * 2 * iWidth) ] )
-            pbEdge[ (j + 1) + ((i - 1) * 2 * iWidth) ] = true;
-        }
-        if( i != 2 * iHeight - 2 && pbEdge[ (j + 2) + ((i + 2) * 2 * iWidth) ] )
-        {
-          if( !pbEdge[ (j - 1) + ((i + 1) * 2 * iWidth) ] && !pbEdge[ (j + 3) + ((i + 1) * 2 * iWidth) ] )
-            pbEdge[ (j + 1) + ((i + 1) * 2 * iWidth) ] = true;
-        }
-      }
-    }
-  }
-
-  // Static Pruning Unnecessary Edges
-  /// Step1. Stack push the unconnected edges
-  UShort* pusUnconnectedEdgeStack = new UShort[ 4 * iWidth * iHeight ]; // approximate size calculation
-  Int iUnconnectedEdgeStackPtr = 0;
-  //// Vertical Edges
-  for( Int i = 0; i < 2 * iHeight - 1; i += 2 )
-  {
-    for( Int j = 1; j < 2 * iWidth - 2; j += 2 )
-    {
-      if( pbEdge[ j + i * 2 * iWidth ] )
-      {
-        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
-        {
-          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
-          iUnconnectedEdgeStackPtr++;
-        }
-      }
-    }
-  }
-
-  //// Horizontal Edges
-  for( Int i = 1; i < 2 * iHeight - 2; i += 2 )
-  {
-    for( Int j = 0; j < 2 * iWidth - 1; j += 2 )
-    {
-      if( pbEdge[ j + i * 2 * iWidth ] )
-      {
-        if( !xCheckTerminatedEdge( pbEdge, j, i, iWidth, iHeight ) )
-        {
-          pusUnconnectedEdgeStack[iUnconnectedEdgeStackPtr] = (i << 8) | (j);
-          iUnconnectedEdgeStackPtr++;
-        }
-      }
-    }
-  }
-
-  /// Step2. Remove the edges from the stack and push the new unconnected edges
-  //// (This step may contain duplicated edges already in the stack)
-  //// (But it doesn't cause any functional problems)
-  while( iUnconnectedEdgeStackPtr != 0 )
-  {
-    iUnconnectedEdgeStackPtr--;
-    Int iX = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] & 0xff;
-    Int iY = pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] >> 8;
-
-    pbEdge[ iX + iY * 2 * iWidth ] = false;
-
-    if( iY % 2 == 1 && iX > 0 && pbEdge[ iX - 2 + iY * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX - 2, iY, iWidth, iHeight ) ) // left
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX - 2);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iY % 2 == 1 && iX < 2 * iWidth - 2 && pbEdge[ iX + 2 + iY * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX + 2, iY, iWidth, iHeight ) ) // right
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 0) << 8) | (iX + 2);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iY % 2 == 0 && iY > 0 && pbEdge[ iX + (iY - 2) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX, iY - 2, iWidth, iHeight ) ) // top
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 2) << 8) | (iX + 0);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iY % 2 == 0 && iY < 2 * iHeight - 2 && pbEdge[ iX + (iY + 2) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX, iY + 2, iWidth, iHeight ) ) // bottom
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 2) << 8) | (iX + 0);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iX > 0 && iY > 0 && pbEdge[ iX - 1 + (iY - 1) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX - 1, iY - 1, iWidth, iHeight ) ) // left-top
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX - 1);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iX < 2 * iWidth - 1 && iY > 0 && pbEdge[ iX + 1 + (iY - 1) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX + 1, iY - 1, iWidth, iHeight ) ) // right-top
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY - 1) << 8) | (iX + 1);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iX > 0 && iY < 2 * iHeight - 1 && pbEdge[ iX - 1 + (iY + 1) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX - 1, iY + 1, iWidth, iHeight ) ) // left-bottom
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX - 1);
-      iUnconnectedEdgeStackPtr++;
-    }
-    if( iX < 2 * iWidth - 1 && iY < 2 * iHeight - 1 && pbEdge[ iX + 1 + (iY + 1) * 2 * iWidth ] &&
-      !xCheckTerminatedEdge( pbEdge, iX + 1, iY + 1, iWidth, iHeight ) ) // right-bottom
-    {
-      pusUnconnectedEdgeStack[ iUnconnectedEdgeStackPtr ] = ((iY + 1) << 8) | (iX + 1);
-      iUnconnectedEdgeStackPtr++;
-    }
-  }
-
-
-  // Region Generation ( edge -> region )
-  Bool* pbRegion = pcCU->getEdgePartition( uiAbsPtIdx );
-  Bool* pbVisit  = new Bool[ iWidth * iHeight ];
-
-  for( UInt ui = 0; ui < iWidth * iHeight; ui++ )
-  {
-    pbRegion[ ui ] = true; // fill it as region 1 (we'll discover region 0 next)
-    pbVisit [ ui ] = false;
-  }
-
-  Int* piStack = new Int[ iWidth * iHeight ];
-
-  Int iPtr = 0;
-
-  piStack[iPtr++] = (0 << 8) | (0);
-  pbRegion[ 0 ] = false;
-
-  while(iPtr > 0)
-  {
-    Int iTmp = piStack[--iPtr];
-    Int iX1, iY1;
-    iX1 = iTmp & 0xff;
-    iY1 = (iTmp >> 8) & 0xff;
-
-    pbVisit[ iX1 + iY1 * iWidth ] = true;
-
-    assert( iX1 >= 0 && iX1 < iWidth );
-    assert( iY1 >= 0 && iY1 < iHeight );
-
-    if( iX1 > 0 && !pbEdge[ 2 * iX1 - 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 - 1 + iY1 * iWidth ] )
-    {
-      piStack[iPtr++] = (iY1 << 8) | (iX1 - 1);
-      pbRegion[ iX1 - 1 + iY1 * iWidth ] = false;
-    }
-    if( iX1 < iWidth - 1 && !pbEdge[ 2 * iX1 + 1 + 4 * iY1 * iWidth ] && !pbVisit[ iX1 + 1 + iY1 * iWidth ] )
-    {
-      piStack[iPtr++] = (iY1 << 8) | (iX1 + 1);
-      pbRegion[ iX1 + 1 + iY1 * iWidth ] = false;
-    }
-    if( iY1 > 0 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 - 1) * iWidth ] && !pbVisit[ iX1 + (iY1 - 1) * iWidth ] )
-    {
-      piStack[iPtr++] = ((iY1 - 1) << 8) | iX1;
-      pbRegion[ iX1 + (iY1 - 1) * iWidth ] = false;
-    }
-    if( iY1 < iHeight - 1 && !pbEdge[ 2 * iX1 + 2 * (2 * iY1 + 1) * iWidth ] && !pbVisit[ iX1 + (iY1 + 1) * iWidth ] )
-    {
-      piStack[iPtr++] = ((iY1 + 1) << 8) | iX1;
-      pbRegion[ iX1 + (iY1 + 1) * iWidth ] = false;
-    }
-  }
-
-  ///////////
-  iPtr = 0;
-  for( Int i = 0; i < iWidth * iHeight; i++ )
-    pbVisit[ i ] = false;
-  piStack[ iPtr++ ] = (0 << 8) | (0); // initial seed
-  while( iPtr > 0 && iPtr < iWidth * iHeight )
-  {
-    Int iX;
-    Int iY;
-    iPtr--;
-    iX = piStack[ iPtr ] & 0xff;
-    iY = piStack[ iPtr ] >> 8;
-    pbVisit[ iY * iWidth + iX ] = true;
-
-    if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
-    {
-      piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
-    }
-    if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
-    {
-      piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
-    }
-    if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
-    {
-      piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
-    }
-    if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
-    {
-      piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
-    }
-  }
-  assert( iPtr == 0 || iPtr == iWidth * iHeight );
-
-  Bool bBipartition;
-  if( iPtr == iWidth * iHeight )
-  {
-    bBipartition = false; // single partition
-  }
-  else
-  {
-    for( Int i = 0; i < iWidth * iHeight; i++ )
-    {
-      if( !pbVisit[ i ] )
-      {
-        piStack[ iPtr++ ] = (( i / iWidth ) << 8) | ( i % iWidth );
-        pbVisit[ i ] = true;
-        break;
-      }
-    }
-    while( iPtr > 0 )
-    {
-      Int iX;
-      Int iY;
-      iPtr--;
-      iX = piStack[ iPtr ] & 0xff;
-      iY = piStack[ iPtr ] >> 8;
-      pbVisit[ iY * iWidth + iX ] = true;
-
-      if( iY > 0 && !pbVisit[ (iY - 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY - 1) * iWidth + iX ] )
-      {
-        piStack[ iPtr++ ] = ((iY - 1) << 8) | iX;
-      }
-      if( iY < iHeight - 1 && !pbVisit[ (iY + 1) * iWidth + iX ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ (iY + 1) * iWidth + iX ] )
-      {
-        piStack[ iPtr++ ] = ((iY + 1) << 8) | iX;
-      }
-      if( iX > 0 && !pbVisit[ iY * iWidth + (iX - 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX - 1) ] )
-      {
-        piStack[ iPtr++ ] = (iY << 8) | (iX - 1);
-      }
-      if( iX < iWidth - 1 && !pbVisit[ iY * iWidth + (iX + 1) ] && pbRegion[ iY * iWidth + iX ] == pbRegion[ iY * iWidth + (iX + 1) ] )
-      {
-        piStack[ iPtr++ ] = (iY << 8) | (iX + 1);
-      }
-    }
-    bBipartition = true;
-    for( Int i = 0; i < iWidth * iHeight; i++ )
-    {
-      if( !pbVisit[ i ] )
-      {
-        bBipartition = false;
-        break;
-      }
-    }
-  }
-
-  xFree( pbEdge );
-  delete[] pbEdgeX; pbEdgeX = NULL;
-  delete[] pbEdgeY; pbEdgeY = NULL;
-  delete[] psDiffX; psDiffX = NULL;
-  delete[] psDiffY; psDiffY = NULL;
-  delete[] pusUnconnectedEdgeStack; pusUnconnectedEdgeStack = NULL;
-  delete[] pbVisit; pbVisit = NULL;
-  delete[] piStack; piStack = NULL;
-
-  if( bBipartition )
-  {
-    return xConstructChainCode( pcCU, uiAbsPtIdx, (UInt)iWidth, (UInt)iHeight );
-  }
-  else
-  {
-    return false;
-  }
-}
-
-Bool TEncSearch::xCheckTerminatedEdge( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight )
-{
-  if( (iY % 2) == 0 ) // vertical edge
-  {
-    Bool bTopConnected = false;
-    Bool bBottomConnected = false;
-
-    if( iY != 0 )
-    {
-      if( pbEdge[ iX + (iY - 2) * 2 * iWidth ] )
-        bTopConnected = true;
-      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
-        bTopConnected = true;
-      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
-        bTopConnected = true;
-    }
-    else
-    {
-      bTopConnected = true;
-    }
-
-
-    if( iY != 2 * iHeight - 2 )
-    {
-      if( pbEdge[ iX + (iY + 2) * 2 * iWidth ] )
-        bBottomConnected = true;
-      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
-        bBottomConnected = true;
-      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
-        bBottomConnected = true;
-    }
-    else
-    {
-      bBottomConnected = true;
-    }
-
-
-    if( bTopConnected && bBottomConnected )
-    {
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-  }
-  else
-  {
-    Bool bLeftConnected = false;
-    Bool bRightConnected = false;
-
-    if( iX != 0 )
-    {
-      if( pbEdge[ (iX - 2) + iY * 2 * iWidth ] )
-        bLeftConnected = true;
-      if( pbEdge[ (iX - 1) + (iY - 1) * 2 * iWidth ] )
-        bLeftConnected = true;
-      if( pbEdge[ (iX - 1) + (iY + 1) * 2 * iWidth ] )
-        bLeftConnected = true;
-    }
-    else
-    {
-      bLeftConnected = true;
-    }
-
-    if( iX != 2 * iWidth - 2 )
-    {
-      if( pbEdge[ (iX + 2) + iY * 2 * iWidth ] )
-        bRightConnected = true;
-      if( pbEdge[ (iX + 1) + (iY - 1) * 2 * iWidth ] )
-        bRightConnected = true;
-      if( pbEdge[ (iX + 1) + (iY + 1) * 2 * iWidth ] )
-        bRightConnected = true;
-    }
-    else
-    {
-      bRightConnected = true;
-    }
-
-
-    if( bLeftConnected && bRightConnected )
-    {
-      return true;
-    }
-    else
-    {
-      return false;
-    }
-  }
-}
-Bool TEncSearch::xConstructChainCode( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight )
-{
-  //UInt   uiWidth    = pcCU->getWidth( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
-  //UInt   uiHeight   = pcCU->getHeight( uiPartIdx ) >> (bPU4x4 ? 1 : 0);
-  Bool*  pbEdge     = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
-  Bool*  pbVisit    = (Bool*) xMalloc( Bool, uiWidth * uiHeight * 4 );
-  UInt   uiMaxEdge  = uiWidth * (RBC_MAX_EDGE_NUM_PER_4x4 / 4);
-  Bool*  pbRegion   = pcCU->getEdgePartition( uiAbsPtIdx );
-  UChar* piEdgeCode = pcCU->getEdgeCode( uiAbsPtIdx );
-  Bool   bStartLeft = false;
-  Bool   bPossible  = false;
-  Bool   bFinish    = false;
-  Int    iStartPosition = -1;
-  Int    iPtr = 0;
-  Int    iDir = -1, iNextDir = -1;
-  Int    iArrow = -1, iNextArrow = -1;
-  Int    iX = -1, iY = -1;
-  Int    iDiffX = 0, iDiffY = 0;
-  UChar  iCode = 255;
-  UInt   uiWidth2 = uiWidth * 2;
-
-  for( Int i = 0; i < uiWidth * uiHeight * 4; i++ )
-    pbEdge[ i ] = false;
-
-  for( Int i = 0; i < uiHeight; i++ )
-  {
-    for( Int j = 0; j < uiWidth - 1; j++ )
-    {
-      if( pbRegion[ i * uiWidth + j ] != pbRegion[ i * uiWidth + j + 1 ] )
-        pbEdge[ i * uiWidth * 4 + j * 2 + 1 ] = true;
-    }
-  }
-
-  for( Int i = 0; i < uiHeight - 1; i++ )
-  {
-    for( Int j = 0; j < uiWidth; j++ )
-    {
-      if( pbRegion[ (i + 0) * uiWidth + j ] != pbRegion[ (i + 1) * uiWidth + j ] )
-        pbEdge[ (2 * i + 1) * 2 * uiWidth + j * 2 ] = true;
-    }
-  }
-
-  for( Int i = 1; i < uiWidth2 - 2; i+=2 )
-  {
-    if(pbEdge[ i ])
-    {
-      bPossible  = true;
-      bStartLeft = false;
-      iStartPosition = iX = i;
-      iY = 0;
-      iDir = 3;
-      iArrow = 3;
-      break;
-    }
-  }
-
-  if( !bPossible )
-  {
-    for( Int i = 1; i < uiWidth2 - 2; i+=2 )
-    {
-      if(pbEdge[ i * uiWidth2 ])
-      {
-        bPossible  = true;
-        bStartLeft = true;
-        iX = 0;
-        iStartPosition = iY = i;
-        iDir = 1;
-        iArrow = 1;
-        break;
-      }
-    }
-  }
-
-  if( bPossible )
-  {
-    for( Int i = 0; i < 4 * uiWidth * uiHeight; i++ )
-      pbVisit[ i ] = false;
-
-    while( !bFinish )
-    {
-      Bool bArrowSkip = false;
-      pbVisit[ iX + iY * uiWidth2 ] = true;
-
-      switch( iDir )
-      {
-      case 0: // left
-        if( iX > 0 && !pbVisit[ (iX - 2) + iY * uiWidth2 ] && pbEdge[ (iX - 2) + iY * uiWidth2 ] ) // left
-        {
-          iDiffX = -2;
-          iDiffY =  0;
-          iNextDir = 0;
-          iNextArrow = 0;
-        }
-        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // top
-        {
-          iDiffX = -1;
-          iDiffY = -1;
-          iNextDir = 2;
-          iNextArrow = 4;
-        }
-        else if( iX > 0 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // bottom
-        {
-          iDiffX = -1;
-          iDiffY = +1;
-          iNextDir = 3;
-          iNextArrow = iArrow;
-          if( !(iPtr == 0 && iX == uiWidth2 - 2 && iY == uiHeight * 2 - 3) )
-            bArrowSkip = true;
-          else
-            iNextArrow = 3;
-        }
-        else if( iX == 0 )
-        {
-          iDiffX = 0;
-          iDiffY = 0;
-          iNextDir = iDir;
-          iNextArrow = iArrow;
-          bFinish = true;
-          continue;
-        }
-        else
-        {
-          iPtr = 0; // edge loop or unwanted case
-          bFinish = true;
-          //continue;
-          assert(false);
-        }
-        break;
-      case 1: // right
-        if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 2) + iY * uiWidth2 ] && pbEdge[ (iX + 2) + iY * uiWidth2 ] ) // right
-        {
-          iDiffX = +2;
-          iDiffY =  0;
-          iNextDir = 1;
-          iNextArrow = 1;
-        }
-        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // top
-        {
-          iDiffX = +1;
-          iDiffY = -1;
-          iNextDir = 2;
-          iNextArrow = iArrow;
-          if( !(iPtr == 0 && iX == 0 && iY == 1) )
-            bArrowSkip = true;
-          else
-            iNextArrow = 2;
-        }
-        else if( iX < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // bottom
-        {
-          iDiffX = +1;
-          iDiffY = +1;
-          iNextDir = 3;
-          iNextArrow = 7;
-        }
-        else if( iX == uiWidth2 - 2 )
-        {
-          iDiffX = 0;
-          iDiffY = 0;
-          iNextDir = iDir;
-          iNextArrow = iArrow;
-          bFinish = true;
-          continue;
-        }
-        else
-        {
-          iPtr = 0; // edge loop or unwanted case
-          bFinish = true;
-          //continue;
-          assert(false);
-        }
-        break;
-      case 2: // top
-        if( iY > 0 && !pbVisit[ (iX - 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY - 1) * uiWidth2 ] ) // left
-        {
-          iDiffX = -1;
-          iDiffY = -1;
-          iNextDir = 0;
-          iNextArrow = iArrow;
-          if( !(iPtr == 0 && iX == 1 && iY == uiHeight * 2 - 2) )
-            bArrowSkip = true;
-          else
-            iNextArrow = 0;
-        }
-        else if( iY > 0 && !pbVisit[ (iX + 1) + (iY - 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY - 1) * uiWidth2 ] ) // right
-        {
-          iDiffX = +1;
-          iDiffY = -1;
-          iNextDir = 1;
-          iNextArrow = 5;
-        }
-        else if( iY > 0 && !pbVisit[ iX + (iY - 2) * uiWidth2 ] && pbEdge[ iX + (iY - 2) * uiWidth2 ] ) // top
-        {
-          iDiffX =  0;
-          iDiffY = -2;
-          iNextDir = 2;
-          iNextArrow = 2;
-        }
-        else if( iY == 0 )
-        {
-          iDiffX = 0;
-          iDiffY = 0;
-          iNextDir = iDir;
-          iNextArrow = iArrow;
-          bFinish = true;
-          continue;
-        }
-        else
-        {
-          iPtr = 0; // edge loop or unwanted case
-          bFinish = true;
-          //continue;
-          assert(false);
-        }
-        break;
-      case 3: // bottom
-        if( iY < uiWidth2 - 2 && !pbVisit[ (iX - 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX - 1) + (iY + 1) * uiWidth2 ] ) // left
-        {
-          iDiffX = -1;
-          iDiffY = +1;
-          iNextDir = 0;
-          iNextArrow = 6;
-        }
-        else if( iY < uiWidth2 - 2 && !pbVisit[ (iX + 1) + (iY + 1) * uiWidth2 ] && pbEdge[ (iX + 1) + (iY + 1) * uiWidth2 ] ) // right
-        {
-          iDiffX = +1;
-          iDiffY = +1;
-          iNextDir = 1;
-          iNextArrow = iArrow;
-          if( !(iPtr == 0 && iX == uiWidth * 2 - 3 && iY == 0) )
-            bArrowSkip = true;
-          else
-            iNextArrow = 1;
-        }
-        else if( iY < uiWidth2 - 2 && !pbVisit[ iX + (iY + 2) * uiWidth2 ] && pbEdge[ iX + (iY + 2) * uiWidth2 ] ) // bottom
-        {
-          iDiffX =  0;
-          iDiffY = +2;
-          iNextDir = 3;
-          iNextArrow = 3;
-        }
-        else if( iY == uiWidth2 - 2 )
-        {
-          iDiffX = 0;
-          iDiffY = 0;
-          iNextDir = iDir;
-          iNextArrow = iArrow;
-          bFinish = true;
-          continue;
-        }
-        else
-        {
-          iPtr = 0; // edge loop or unwanted case
-          bFinish = true;
-          //continue;
-          assert(false);
-        }
-        break;
-      }
-
-      const UChar tableCode[8][8] = { { 0, -1, 4, 3, 2, 6, 1, 5 }, // iArrow(current direction), iNextArrow(next direction)
-      { -1, 0, 3, 4, 5, 1, 6, 2 },
-      { 3, 4, 0, -1, 1, 2, 5, 6 },
-      { 4, 3, -1, 0, 6, 5, 2, 1 },
-      { 1, 6, 2, 5, 0, 4, 3, -1 },
-      { 5, 2, 1, 6, 3, 0, -1, 4 },
-      { 2, 5, 6, 1, 4, -1, 0, 3 },
-      { 6, 1, 5, 2, -1, 3, 4, 0 } };
-
-      iCode = tableCode[iArrow][iNextArrow];
-
-      if(iPtr >= uiMaxEdge)
-      {
-        iPtr = 0; // over the maximum number of edge
-        bPossible = false;
-        break;
-      }
-
-      if( !bArrowSkip )
-      {
-        piEdgeCode[iPtr++] = iCode; // first edge coding
-        //printf("xEdgeCoding: (%d,%d)->(%d,%d) code %d\n",iX,iY, iX+iDiffX, iY+iDiffY, iCode);
-      }
-
-      iX += iDiffX;
-      iY += iDiffY;
-      iDir = iNextDir;
-      iArrow = iNextArrow;
-    }
-  }
-
-  pcCU->setEdgeLeftFirst( uiAbsPtIdx, bStartLeft );
-  pcCU->setEdgeStartPos ( uiAbsPtIdx, bStartLeft ? (iStartPosition - 1) >> 1 : (iStartPosition + 1) >> 1);
-  pcCU->setEdgeNumber   ( uiAbsPtIdx, iPtr );
-
-  xFree( pbEdge );
-  xFree( pbVisit );
-
-  return (iPtr != 0);
-}
-#endif
+
+#endif
+
 #endif
 //! \}
Index: trunk/source/Lib/TLibEncoder/TEncSearch.h
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncSearch.h	(revision 773)
@@ -351,14 +351,4 @@
   Void xSearchDmmDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
   Void xSearchDmm1Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx );
-#if !SEC_DMM3_RBC_F0147
-  Void xSearchDmm3Wedge           ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir );
-#endif
-#endif
-#if H_3D_DIM_RBC
-  Void xSearchRbcDeltaDCs         ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 );
-  Bool xSearchRbcEdge             ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride,  Int  iWidth,  Int  iHeight );
-  
-  Bool xCheckTerminatedEdge       ( Bool* pbEdge, Int iX, Int iY, Int iWidth, Int iHeight );
-  Bool xConstructChainCode        ( TComDataCU* pcCU, UInt uiAbsPtIdx, UInt uiWidth, UInt uiHeight );
 #endif
 #if H_3D_DIM_SDC
@@ -427,5 +417,5 @@
                                   , InheritedVSPDisInfo*  inheritedVSPDisInfo
 #endif
-#if MTK_SPIVMP_F0110
+#if H_3D_SPIVMP
                                   , Bool* pbSPIVMPFlag, TComMvField* pcMvFieldSP, UChar* puhInterDirSP
 #endif
Index: trunk/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 773)
@@ -556,5 +556,4 @@
   rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
 #if H_3D_IV_MERGE
-#if SEC_MPI_ENABLING_MERGE_F0150
   if(rpcSlice->getIsDepth())
   {
@@ -565,7 +564,4 @@
     rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
   }
-#else
-   rpcSlice->setMaxNumMergeCand      ( m_pcCfg->getMaxNumMergeCand()   + ( rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ? 1 : 0 ) );
-#endif
 #else
   rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
Index: trunk/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 758)
+++ trunk/source/Lib/TLibEncoder/TEncTop.cpp	(revision 773)
@@ -299,5 +299,5 @@
 {
   // initialize SPS
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
   // Assuming that all PPS indirectly refer to the same VPS via different SPS
   m_cSPS.setVPS(m_cVPS);
@@ -723,17 +723,11 @@
 
 #if H_MV  
-#if H_MV_6_PS_REP_FORM_18_19_20
   m_cSPS.setUpdateRepFormatFlag           ( false );    
-#else
-  m_cSPS.setUpdateRepFormatFlag           ( m_layerId == 0 );    
-#endif
   m_cSPS.setSpsInferScalingListFlag       ( m_layerId > 0 && m_cVPS->getInDirectDependencyFlag( getLayerIdInVps(), 0 ) ); 
   m_cSPS.setSpsScalingListRefLayerId      ( 0              ); 
-#if H_MV_6_PSEM_O0142_3
   m_cSPS.setSpsExtensionFlag              ( true ); 
   m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_MV ,true ); 
 #if H_3D
   m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_3D ,true ); 
-#endif
 #endif
 #endif
@@ -823,8 +817,8 @@
     pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
     pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
-#if H_MV_6_PS_O0118_33
+#if H_MV
     pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 );
 #else
-    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
+   pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
 #endif
     pcVUI->setVideoFormat(getVideoFormat());
@@ -853,14 +847,4 @@
     pcVUI->setLog2MaxMvLengthVertical(getLog2MaxMvLengthVertical());
   }
-#if H_3D
-#if !CAM_HLS_F0136_F0045_F0082
-#if !QC_DEPTH_IV_MRG_F0125
-  if ( !m_isDepth )
-#endif
-  {
-    m_cSPS.initCamParaSPS           ( m_viewIndex, m_uiCamParPrecision, m_bCamParInSliceHeader, m_aaiCodedScale, m_aaiCodedOffset );
-  }
-#endif
-#endif
 }
 
@@ -877,5 +861,5 @@
 #endif
 
-#if DLT_DIFF_CODING_IN_PPS
+#if H_3D
   m_cPPS.setDLT( getDLT() );
 #endif
@@ -948,9 +932,5 @@
   m_cPPS.setOutputFlagPresentFlag( false );
 #if H_MV
-#if H_MV_6_RALS_O0149_11
   m_cPPS.setNumExtraSliceHeaderBits( 3 ); 
-#else
-  m_cPPS.setNumExtraSliceHeaderBits( 2 ); 
-#endif
 #endif
   m_cPPS.setSignHideFlag(getSignHideFlag());
@@ -1012,9 +992,5 @@
   }
 #if H_3D
-#if CAM_HLS_F0136_F0045_F0082
   if( m_cVPS->hasCamParInSliceHeader( getViewIndex() ) )
-#else
-  if( m_cSPS.hasCamParInSliceHeader() )
-#endif
   {
     m_cPPS.setSliceHeaderExtensionPresentFlag( true ); 
