Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 897)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 898)
@@ -1663,4 +1663,7 @@
   Bool        m_extensionFlag;
   UInt        m_numScaledRefLayerOffsets;
+#if R0042_PROFILE_INDICATION  
+  Int         m_NumDirectRefLayers;
+#endif
 #if P0312_VERT_PHASE_ADJ
  Bool         m_vertPhasePositionEnableFlag[MAX_LAYERS];
@@ -1830,4 +1833,8 @@
   Int      getExtensionFlag()                  { return m_extensionFlag;  }
   Void     setExtensionFlag(Int n)             { m_extensionFlag = n;     }
+#if R0042_PROFILE_INDICATION
+  Int      getNumDirectRefLayers()                  { return  m_NumDirectRefLayers;  }
+  Void     setNumDirectRefLayers(Int n)             {  m_NumDirectRefLayers = n;     }
+#endif
 #if !MOVE_SCALED_OFFSET_TO_PPS
   UInt     getNumScaledRefLayerOffsets()       { return m_numScaledRefLayerOffsets; }
Index: branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 897)
+++ branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 898)
@@ -75,4 +75,5 @@
 #define R0227_REP_FORMAT_CONSTRAINT      1      ///< JCTVC-R0227, Conformance checking such that representation format of a particular layer shall not be greater than the one defined in VPS for that layer
 #define R0227_BR_PR_ADD_LAYER_SET        1      ///< JCTVC-R0227, Signalling of bit-rate and picture rate for additional layer set
+#define R0042_PROFILE_INDICATION         1      ///< JCTVC-R0042, Profile indication for additional layer sets
 
 #define Q0108_TSA_STSA                   1      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 897)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 898)
@@ -295,5 +295,5 @@
     }
   }
-
+#if !R0042_PROFILE_INDICATION
 #if SCALINGLIST_INFERRING
   if( pcPPS->getLayerId() > 0 )
@@ -315,4 +315,5 @@
   {
 #endif
+#endif
 
     READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" );           pcPPS->setScalingListPresentFlag( uiCode ? true : false );
@@ -322,7 +323,8 @@
       parseScalingList( pcPPS->getScalingList() );
     }
-
+#if !R0042_PROFILE_INDICATION
 #if SCALINGLIST_INFERRING
   }
+#endif
 #endif
 
@@ -336,5 +338,11 @@
   pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
 
+#if !R0042_PROFILE_INDICATION
   READ_FLAG( uiCode, "pps_extension_flag");
+#else
+  READ_FLAG( uiCode, "pps_extension_present_flag");
+#endif
+
+#if !R0042_PROFILE_INDICATION
 #if POC_RESET_INFO_INFERENCE
   pcPPS->setExtensionFlag( uiCode ? true : false );
@@ -451,4 +459,101 @@
   }
 #endif
+#else
+  pcPPS->setExtensionFlag( uiCode ? true : false );
+  if( pcPPS->getExtensionFlag() )
+  {
+    READ_FLAG( uiCode, "pps_range_extension_flag" );
+    assert(uiCode == 0);
+    READ_FLAG( uiCode, "pps_multilayer_extension_flag" );
+    assert(uiCode == 1);
+    READ_CODE(6, uiCode, "pps_extension_6bits");
+    assert(uiCode == 0);
+
+    READ_FLAG( uiCode, "poc_reset_info_present_flag" );
+    pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false);
+
+#if SCALINGLIST_INFERRING
+    READ_FLAG( uiCode, "pps_infer_scaling_list_flag" );
+    pcPPS->setInferScalingListFlag( uiCode );
+
+    if( pcPPS->getInferScalingListFlag() )
+    {
+      READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); 
+      pcPPS->setScalingListRefLayerId( uiCode );
+      // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+      assert( pcPPS->getScalingListRefLayerId() <= 62 );
+      pcPPS->setScalingListPresentFlag( false );
+    }
+#endif
+
+#if REF_REGION_OFFSET
+    READ_UVLC( uiCode,      "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
+    for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
+    {
+      READ_CODE( 6, uiCode,  "ref_loc_offset_layer_id" );  pcPPS->setScaledRefLayerId( i, uiCode );
+      READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" );   pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode );
+      if (uiCode)
+      {
+        Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
+        READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
+#if P0312_VERT_PHASE_ADJ
+        READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
+#endif
+      }
+      READ_FLAG( uiCode, "ref_region_offset_present_flag" );   pcPPS->setRefRegionOffsetPresentFlag( i, uiCode );
+      if (uiCode)
+      {
+        Window& refWindow = pcPPS->getRefLayerWindow(i);
+        READ_SVLC( iCode, "ref_region_left_offset" );    refWindow.setWindowLeftOffset  (iCode << 1);
+        READ_SVLC( iCode, "ref_region_top_offset" );     refWindow.setWindowTopOffset   (iCode << 1);
+        READ_SVLC( iCode, "ref_region_right_offset" );   refWindow.setWindowRightOffset (iCode << 1);
+        READ_SVLC( iCode, "ref_region_bottom_offset" );  refWindow.setWindowBottomOffset(iCode << 1);
+      }
+#if R0209_GENERIC_PHASE
+      READ_FLAG( uiCode, "resample_phase_set_present_flag" );   pcPPS->setResamplePhaseSetPresentFlag( i, uiCode );
+      if (uiCode)
+      {
+        READ_UVLC( uiCode, "phase_hor_luma" );    pcPPS->setPhaseHorLuma ( i, uiCode );
+        READ_UVLC( uiCode, "phase_ver_luma" );    pcPPS->setPhaseVerLuma ( i, uiCode );
+        READ_UVLC( uiCode, "phase_hor_chroma_plus8" );  pcPPS->setPhaseHorChroma (i, uiCode - 8);
+        READ_UVLC( uiCode, "phase_ver_chroma_plus8" );  pcPPS->setPhaseVerChroma (i, uiCode - 8);
+      }
+#endif
+    }
+#else
+#if MOVE_SCALED_OFFSET_TO_PPS
+      READ_UVLC( uiCode,      "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
+      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
+      {
+        Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
+#if O0098_SCALED_REF_LAYER_ID
+        READ_CODE( 6,  uiCode,  "scaled_ref_layer_id" );       pcPPS->setScaledRefLayerId( i, uiCode );
+#endif
+        READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
+        READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
+#if P0312_VERT_PHASE_ADJ
+        READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
+#endif
+      }
+#endif
+#endif
+#if Q0048_CGS_3D_ASYMLUT
+      READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 
+      pcPPS->setCGSFlag( uiCode );
+      if( pcPPS->getCGSFlag() )
+      {
+        xParse3DAsymLUT( pc3DAsymLUT );
+        pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() );
+        pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() );
+      }
+#endif
+  }
+#endif
+
 }
 
@@ -643,4 +748,8 @@
 #endif
 
+#if R0042_PROFILE_INDICATION
+  UInt uiTmp;
+  bool bMultiLayerExtSpsFlag;
+#endif
   UInt  uiCode;
   READ_CODE( 4,  uiCode, "sps_video_parameter_set_id");          pcSPS->setVPSId        ( uiCode );
@@ -651,5 +760,34 @@
     READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
     assert(uiCode <= 6);
-
+#if SVC_EXTENSION
+  }
+#if R0042_PROFILE_INDICATION
+  else
+  {
+    READ_CODE( 3,  uiCode, "sps_ext_or_max_sub_layers_minus1" );     uiTmp = uiCode;
+  }
+#endif
+#if !SPS_DPB_PARAMS
+  if(pcSPS->getLayerId() != 0)
+  {
+    pcSPS->setMaxTLayers           ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers()          );
+  }
+#endif
+#endif
+
+#if SVC_EXTENSION
+#if R0042_PROFILE_INDICATION
+  bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 );
+#endif
+#endif
+
+#if SVC_EXTENSION
+#if !R0042_PROFILE_INDICATION
+  if(pcSPS->getLayerId() == 0)
+#else
+  if(!bMultiLayerExtSpsFlag)
+#endif
+  {
+#endif
     READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
 #if SVC_EXTENSION
@@ -658,5 +796,4 @@
   else
   {
-    pcSPS->setMaxTLayers           ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers()          );
     pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() );
   }
@@ -679,5 +816,9 @@
 
 #ifdef SPS_PTL_FIX
+#if !R0042_PROFILE_INDICATION
   if ( pcSPS->getLayerId() == 0)
+#else
+  if(!bMultiLayerExtSpsFlag)
+#endif
   {
     parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
@@ -691,8 +832,19 @@
 
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION
   if( pcSPS->getLayerId() > 0 )
+#else
+  if( bMultiLayerExtSpsFlag)
+#endif
   {
     READ_FLAG( uiCode, "update_rep_format_flag" );
     pcSPS->setUpdateRepFormatFlag( uiCode ? true : false );
+#if R0042_PROFILE_INDICATION    
+    if( bMultiLayerExtSpsFlag && uiCode)
+    {
+      READ_CODE(8, uiCode, "sps_rep_format_idx");
+      pcSPS->setUpdateRepFormatIndex(uiCode);
+    }
+#endif
   }
   else
@@ -704,8 +856,14 @@
 #endif
   }
+
+#if R0042_PROFILE_INDICATION  
+  if( !bMultiLayerExtSpsFlag )
+  {
+#else
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 )
 #else
   if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
+#endif
 #endif
   {
@@ -729,4 +887,5 @@
   }
 #if O0096_REP_FORMAT_INDEX
+#if !R0042_PROFILE_INDICATION
   else if ( pcSPS->getUpdateRepFormatFlag() )
   {
@@ -736,11 +895,14 @@
 #endif
 #endif
+#endif
 
 #if R0156_CONF_WINDOW_IN_REP_FORMAT
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION  
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 )
 #else
   if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
+#endif
 #endif
   {
@@ -770,8 +932,10 @@
 
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION  
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 )
 #else
   if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
+#endif
 #endif
   {
@@ -789,10 +953,19 @@
   }
 #endif
+#if R0042_PROFILE_INDICATION  
+  }
+#endif
+
   READ_UVLC( uiCode,    "log2_max_pic_order_cnt_lsb_minus4" );   pcSPS->setBitsForPOC( 4 + uiCode );
   assert(uiCode <= 12);
 
 #if SPS_DPB_PARAMS
+#if !R0042_PROFILE_INDICATION
   if( pcSPS->getLayerId() == 0 )  
   {
+#else
+  if( !bMultiLayerExtSpsFlag )  
+  {
+#endif
 #endif
     UInt subLayerOrderingInfoPresentFlag;
@@ -851,5 +1024,9 @@
   {
 #if SCALINGLIST_INFERRING
+#if !R0042_PROFILE_INDICATION
     if( pcSPS->getLayerId() > 0 )
+#else
+    if( bMultiLayerExtSpsFlag )
+#endif
     {
       READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode );
@@ -932,4 +1109,5 @@
   if( pcSPS->getExtensionFlag() )
   {
+#if !R0042_PROFILE_INDICATION
 #if O0142_CONDITIONAL_SPS_EXTENSION
     UInt spsExtensionTypeFlag[8];
@@ -955,5 +1133,15 @@
       }
     }
-  }
+    }
+#else
+    READ_FLAG( uiCode, "sps_range_extension_flag" );
+    assert(uiCode == 0);
+    READ_FLAG( uiCode, "sps_multilayer_extension_flag" );
+    assert(uiCode == 1);
+    READ_CODE(6, uiCode, "sps_extension_6bits");
+    assert(uiCode == 0);
+    parseSPSExtension( pcSPS );
+  }
+#endif
 #else
   if (uiCode)
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 897)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 898)
@@ -225,4 +225,5 @@
   }
 
+#if !R0042_PROFILE_INDICATION
 #if SCALINGLIST_INFERRING
   if( pcPPS->getLayerId() > 0 )
@@ -241,4 +242,5 @@
   {
 #endif
+#endif
 
   WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0,                          "pps_scaling_list_data_present_flag" ); 
@@ -247,7 +249,8 @@
     codeScalingList( m_pcSlice->getScalingList() );
   }
-
+#if !R0042_PROFILE_INDICATION
 #if SCALINGLIST_INFERRING
   }
+#endif
 #endif
 
@@ -256,8 +259,13 @@
   WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
 #if P0166_MODIFIED_PPS_EXTENSION
+#if !R0042_PROFILE_INDICATION
   WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_flag" );
+#else
+  WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_present_flag" );
+#endif
 
   if( pcPPS->getExtensionFlag() )
   {
+#if !R0042_PROFILE_INDICATION
 #if !POC_RESET_IDC
     UInt ppsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 };
@@ -335,4 +343,81 @@
 #endif
     }
+#else
+  WRITE_FLAG( 0, "pps_range_extension_flag" );
+  WRITE_FLAG( 1, "pps_multilayer_extension_flag" );
+  WRITE_CODE( 0, 6,  "pps_extension_6bits" );     
+
+  WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
+#if SCALINGLIST_INFERRING
+  WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" );
+  if( pcPPS->getInferScalingListFlag() )
+  {
+    // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+    assert( pcPPS->getScalingListRefLayerId() <= 62 );
+    WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "pps_scaling_list_ref_layer_id" );
+  }
+#endif
+
+#if REF_REGION_OFFSET
+  WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_ref_loc_offsets" );
+  for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
+  {
+    WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "ref_loc_offset_layer_id" );
+    WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(i) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" );
+    if (pcPPS->getScaledRefLayerOffsetPresentFlag(i))
+    {
+      Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
+      WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
+      WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
+      WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
+      WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
+    }
+    WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(i) ? 1 : 0, "ref_region_offset_prsent_flag" );
+    if (pcPPS->getRefRegionOffsetPresentFlag(i))
+    {
+      Window refWindow = pcPPS->getRefLayerWindow(i);
+      WRITE_SVLC( refWindow.getWindowLeftOffset()   >> 1, "ref_region_left_offset" );
+      WRITE_SVLC( refWindow.getWindowTopOffset()    >> 1, "ref_region_top_offset" );
+      WRITE_SVLC( refWindow.getWindowRightOffset()  >> 1, "ref_region_right_offset" );
+      WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_region_bottom_offset" );
+    }
+#if R0209_GENERIC_PHASE
+    WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(i) ? 1 : 0, "resample_phase_set_present_flag" );
+    if (pcPPS->getResamplePhaseSetPresentFlag(i))
+    {
+      WRITE_UVLC( pcPPS->getPhaseHorLuma(i), "phase_hor_luma" );
+      WRITE_UVLC( pcPPS->getPhaseVerLuma(i), "phase_ver_luma" );
+      WRITE_UVLC( pcPPS->getPhaseHorChroma(i) + 8, "phase_hor_chroma_plus8" );
+      WRITE_UVLC( pcPPS->getPhaseVerChroma(i) + 8, "phase_ver_chroma_plus8" );
+    }
+#endif
+  }
+#else
+#if MOVE_SCALED_OFFSET_TO_PPS
+  WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_scaled_ref_layer_offsets" );
+  for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
+  {
+    Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
+#if O0098_SCALED_REF_LAYER_ID
+    WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6,          "scaled_ref_layer_id" );
+#endif
+    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
+    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
+    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
+    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
+  }
+#endif
+#endif
+#if Q0048_CGS_3D_ASYMLUT
+  UInt uiPos = getNumberOfWrittenBits();
+  WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" );
+  if( pcPPS->getCGSFlag() )
+  {
+    assert( pc3DAsymLUT != NULL );
+    xCode3DAsymLUT( pc3DAsymLUT );
+  }
+  pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos );
+#endif
+#endif
   }
 #else
@@ -502,4 +587,7 @@
 Void TEncCavlc::codeSPS( TComSPS* pcSPS )
 {
+#if R0042_PROFILE_INDICATION
+  bool bMultiLayerExtSpsFlag = (pcSPS->getNumDirectRefLayers() != 0 ) ; 
+#endif
 #if ENC_DEC_TRACE  
   xTraceSPSHeader (pcSPS);
@@ -511,4 +599,22 @@
 #endif
     WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
+#if SVC_EXTENSION
+  }
+#if R0042_PROFILE_INDICATION
+  else
+  {
+    WRITE_CODE(bMultiLayerExtSpsFlag? 7:(pcSPS->getMaxTLayers() - 1) ,  3,       "sps_ext_or_max_sub_layers_minus1" );
+  }
+#endif
+#endif
+
+#if SVC_EXTENSION
+#if !R0042_PROFILE_INDICATION
+  if(pcSPS->getLayerId() == 0)
+#else
+  if(!bMultiLayerExtSpsFlag)
+#endif
+  {
+#endif
     WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "sps_temporal_id_nesting_flag" );
 #if SVC_EXTENSION
@@ -516,5 +622,9 @@
 #endif
 #ifdef SPS_PTL_FIX
+#if !R0042_PROFILE_INDICATION
   if (pcSPS->getLayerId() == 0)
+#else
+  if(!bMultiLayerExtSpsFlag)
+#endif
   {
     codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
@@ -525,12 +635,29 @@
   WRITE_UVLC( pcSPS->getSPSId (),                   "sps_seq_parameter_set_id" );
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION
   if( pcSPS->getLayerId() > 0 )
+#else
+  if(bMultiLayerExtSpsFlag)
+#endif
   {
     WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" );
   }
+#if R0042_PROFILE_INDICATION
+  if( bMultiLayerExtSpsFlag && pcSPS->getUpdateRepFormatFlag())
+  {
+    WRITE_CODE( pcSPS->getUpdateRepFormatIndex(), 8,   "sps_rep_format_idx");
+  }
+#endif
+
+#if R0042_PROFILE_INDICATION
+  if(!bMultiLayerExtSpsFlag)
+  {
+#endif
+#if !R0042_PROFILE_INDICATION
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 ) 
 #else
   if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
+#endif
 #endif
   {
@@ -548,4 +675,5 @@
 #if REPN_FORMAT_IN_VPS
   }
+#if !R0042_PROFILE_INDICATION
 #if O0096_REP_FORMAT_INDEX
   else if (pcSPS->getUpdateRepFormatFlag())
@@ -555,7 +683,9 @@
 #endif
 #endif
+#endif
 
 #if R0156_CONF_WINDOW_IN_REP_FORMAT
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 ) 
@@ -563,4 +693,5 @@
   if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
 #endif  
+#endif
   {
 #endif
@@ -590,9 +721,11 @@
 
 #if REPN_FORMAT_IN_VPS
+#if !R0042_PROFILE_INDICATION
 #if O0096_REP_FORMAT_INDEX
   if( pcSPS->getLayerId() == 0 ) 
 #else
   if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 
-#endif  
+#endif
+#endif
   {
     assert( pcSPS->getBitDepthY() >= 8 );
@@ -604,8 +737,16 @@
   }
 #endif
+#if R0042_PROFILE_INDICATION
+  }
+#endif
+
   WRITE_UVLC( pcSPS->getBitsForPOC()-4,                 "log2_max_pic_order_cnt_lsb_minus4" );
 
 #if SPS_DPB_PARAMS
+#if !R0042_PROFILE_INDICATION
   if( pcSPS->getLayerId() == 0 )
+#else
+  if(!bMultiLayerExtSpsFlag)
+#endif
   {
 #endif
@@ -637,5 +778,9 @@
   {
 #if SCALINGLIST_INFERRING
+#if !R0042_PROFILE_INDICATION
     if( pcSPS->getLayerId() > 0 )
+#else
+    if( bMultiLayerExtSpsFlag)
+#endif
     {
       WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" );
@@ -706,8 +851,13 @@
 
 #if SVC_EXTENSION
+#if !R0042_PROFILE_INDICATION
   WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_flag" );
+#else
+  WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_present_flag" );
+#endif
 
   if( pcSPS->getExtensionFlag() )
   {
+#if !R0042_PROFILE_INDICATION
 #if O0142_CONDITIONAL_SPS_EXTENSION
     UInt spsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 };
@@ -723,4 +873,10 @@
     codeSPSExtension( pcSPS );
     WRITE_FLAG( 0, "sps_extension2_flag" );
+#endif
+#else
+    WRITE_FLAG( 0, "sps_range_extension_flag" );
+    WRITE_FLAG( 1, "sps_multilayer_extension_flag" );
+    WRITE_CODE( 0, 6,  "sps_extension_6bits" );   
+    codeSPSExtension( pcSPS ); //it is sps_multilayer_extension
 #endif
   }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 897)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 898)
@@ -985,5 +985,7 @@
 #if SVC_EXTENSION
   m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false );
-
+#if R0042_PROFILE_INDICATION
+  m_cSPS.setNumDirectRefLayers(m_numAddLayerSets);
+#endif
 #if Q0078_ADD_LAYER_SETS
   if( !m_numDirectRefLayers && m_numAddLayerSets )
