Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 735)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 738)
@@ -396,4 +396,8 @@
 
   READ_FLAG(     uiCode, "video_signal_type_present_flag");           pcVUI->setVideoSignalTypePresentFlag(uiCode);
+#if H_MV_6_PS_O0118_33
+  assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 
+#endif
+
   if (pcVUI->getVideoSignalTypePresentFlag())
   {
@@ -582,8 +586,18 @@
   {
     READ_FLAG( uiCode, "update_rep_format_flag" );               pcSPS->setUpdateRepFormatFlag( uiCode == 1 );
+#if H_MV_6_PS_REP_FORM_18_19_20
+    if ( pcSPS->getUpdateRepFormatFlag() )
+    { 
+      READ_CODE( 8, uiCode, "sps_rep_format_idx" );                pcSPS->setSpsRepFormatIdx( uiCode );
+    }
+  }
+  else
+  {
+#else
   }
   
   if ( pcSPS->getUpdateRepFormatFlag() )
   { 
+#endif
 #endif
   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
@@ -621,5 +635,9 @@
 
 #if H_MV
+#if H_MV_6_PS_REP_FORM_18_19_20
+  if ( pcSPS->getLayerId() == 0 )
+#else
   if ( pcSPS->getUpdateRepFormatFlag() )
+#endif
   { 
 #endif
@@ -770,6 +788,10 @@
 
   READ_FLAG( uiCode, "sps_extension_flag");
-  if (uiCode)
-  {
+#if H_MV_6_PSEM_O0142_3
+  pcSPS->setSpsExtensionFlag( uiCode ); 
+#endif
+  if (pcSPS->getSpsExtensionFlag( ) )
+  {
+#if !H_MV_6_PSEM_O0142_3
 #if H_MV
     parseSPSExtension( pcSPS ); 
@@ -784,8 +806,37 @@
 #endif
 #endif
+#else    
+    for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
+    {
+      READ_FLAG( uiCode, "sps_extension_type_flag" ); pcSPS->setSpsExtensionTypeFlag( i, uiCode );
+#if H_3D
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D || i == PS_EX_T_ESC ); 
+#else
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_ESC ); 
+#endif
+    }  
+
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV ))
+    {
+      parseSPSExtension( pcSPS ); 
+    }
+
+#if H_3D
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D ))
+    {
+      parseSPSExtension2( pcSPS, viewIndex, depthFlag  ); 
+    }
+#endif
+
+    if ( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_ESC ))
+    {   
+#endif
         while ( xMoreRbspData() )
         {
           READ_FLAG( uiCode, "sps_extension_data_flag");
         }
+#if H_MV_6_PSEM_O0142_3
+    }
+#else
 #if H_MV      
 #if H_3D
@@ -794,4 +845,5 @@
     }
 #endif
+#endif
   }
 }
@@ -802,5 +854,22 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );    pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
+#if !H_MV_6_SHVC_O0098_36
   READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); 
+#else
+  
+  READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets( uiCode );
+
+  for( Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets( ); i++)
+  {    
+    READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 
+
+    Int j = pcSPS->getScaledRefLayerId( i ); 
+    Int iCode; 
+    READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); pcSPS->setScaledRefLayerLeftOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); pcSPS->setScaledRefLayerTopOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode );
+  }
+#endif  
 }
 
@@ -850,5 +919,9 @@
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
 #if H_MV
+#if H_MV_6_LAYER_ID_32
+  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) )  );
+#else
   READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( uiCode  );
+#endif
 #else
   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
@@ -905,4 +978,7 @@
     }
   }
+#if H_MV_6_HRD_O0217_13
+  pcVPS->deriveLayerSetLayerIdList(); 
+#endif
   TimingInfo *timingInfo = pcVPS->getTimingInfo();
   READ_FLAG(       uiCode, "vps_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
@@ -968,5 +1044,13 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
+#if H_MV_6_PS_O0109_24
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+  {  
+#endif
   READ_CODE( 16, uiCode, "vps_vui_offset" );                      pcVPS->setVpsVuiOffset( uiCode );
+#if H_MV_6_PS_O0109_24
+  }
+#endif
+
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
 
@@ -1014,4 +1098,22 @@
   }
 
+#if H_MV_6_PS_O0109_22
+  READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode );
+
+  if ( pcVPS->getViewIdLen( ) > 0 )
+  {    
+    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+    {
+      READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode );
+    }
+  }
+  else
+  {
+    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+    {
+      pcVPS->setViewIdVal( i, 0 );  
+    }
+  }
+#else
   // GT spec says: trac #39
   // if ( pcVPS->getNumViews() > 1 )  
@@ -1025,4 +1127,6 @@
     READ_CODE( pcVPS->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode );
   }
+#endif
+
 
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
@@ -1033,5 +1137,26 @@
     }
   }
-
+#if H_MV_6_MISC_O0062_31
+  pcVPS->setRefLayers(); 
+#endif
+#if H_MV_6_ILDSD_O0120_26
+  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 );
+  if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode );    
+      pcVPS->checkSubLayersVpsMaxMinus1( i ); 
+
+    }
+  }  
+  else
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1);    
+    }
+  }
+#endif
   READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 );
 
@@ -1040,5 +1165,15 @@
     for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
     {
+#if H_MV_6_ILDDS_O0225_30
+      for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ )
+      {
+        if ( pcVPS->getDirectDependencyFlag(j,i) )
+        {
+          READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode );
+        }
+      }
+#else
       READ_CODE( 3, uiCode,       "max_tid_il_ref_pics_plus1[i]" );      pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); 
+#endif
     }
   }
@@ -1054,4 +1189,7 @@
     {
       READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode );
+#if H_MV_6_PS_O0109_23
+      pcVPS->checkProfileRefMinus1( i );      
+#endif
     }
     parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
@@ -1076,7 +1214,16 @@
   if( numOutputLayerSets > 1)
   {
+#if H_MV_6_PS_0109_25
+    READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); pcVPS->setDefaultOneTargetOutputLayerIdc( uiCode );
+    pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
+#else
     READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag(  uiCode == 1); 
+#endif
   }  
 
+#if H_MV_6_HRD_O0217_13
+  pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
+  pcVPS->setOutputLayerSetIdxMinus1(0, -1); 
+#endif
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
@@ -1089,4 +1236,15 @@
       }        
     }
+#if H_MV_6_HRD_O0217_13
+    else
+    { // These inference rules would also be helpful in spec text
+      pcVPS->setOutputLayerSetIdxMinus1(i, i - 1 ); 
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
+      {              
+        pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }
+#endif
+
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
@@ -1094,5 +1252,13 @@
     }
   }
-
+#if H_MV_6_GEN_0153_28
+  if( pcVPS->getMaxLayersMinus1() > 0 )
+  {
+    READ_FLAG( uiCode, "alt_output_layer_flag" ); pcVPS->setAltOutputLayerFlag( uiCode == 1 );
+  }
+#endif
+#if H_MV_6_HRD_O0217_13
+  pcVPS->deriveTargetLayerIdLists(); 
+#endif
   READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
@@ -1103,8 +1269,16 @@
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
   { 
+#if H_MV_6_PS_REP_FORM_18_19_20
+    assert( pcVPS->getRepFormat(i) == NULL ); 
+    TComRepFormat* curRepFormat = new TComRepFormat(); 
+    TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 
+    parseRepFormat( i, curRepFormat ,  prevRepFormat); 
+    pcVPS->setRepFormat(i, curRepFormat ); 
+#else
     assert( pcVPS->getRepFormat(i) == NULL ); 
     TComRepFormat* repFormat = new TComRepFormat(); 
     parseRepFormat( repFormat );
     pcVPS->setRepFormat(i, repFormat ); 
+#endif
   }
 
@@ -1115,5 +1289,9 @@
       if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
       {
+#if H_MV_6_PS_REP_FORM_18_19_20
+        READ_CODE( 8, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
+#else
         READ_CODE( 4, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
+#endif
       }
     }
@@ -1121,7 +1299,48 @@
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
+#if H_MV_6_MISC_O0062_31
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) )  ==  0 )
+    {      
+      READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 );
+    }
+  }
+#endif
+
+#if H_MV_6_HRD_O0217_13
+  parseDpbSize( pcVPS ); 
+#endif
+
+#if !H_MV_6_PS_O0223_29
   READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPS->setCrossLayerIrapAlignedFlag( uiCode == 1 );
+#endif
   READ_UVLC( uiCode, "direct_dep_type_len_minus2")    ; pcVPS->setDirectDepTypeLenMinus2   ( uiCode ); 
 
+#if H_MV_6_PS_O0096_21
+  READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 );
+  if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+  {  
+    READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode );
+  }
+
+  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    for( Int j = 0; j < i; j++ )
+    {
+      if (pcVPS->getDirectDependencyFlag( i, j) )
+      {        
+        if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+        {  
+          pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) );
+        }
+        else
+        {
+          READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
+        }
+      }
+    }
+  }  
+#else
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1134,7 +1353,10 @@
     }
   }
+#endif
 
   READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); 
+#if !H_MV_6_PS_O0109_24
   READ_FLAG( uiCode, "vps_vui_present_flag" )       ; pcVPS->setVpsVuiPresentFlag( uiCode == 1 );
+#endif
 
   if( pcVPS->getVpsVuiPresentFlag() )
@@ -1145,12 +1367,29 @@
 
   pcVPS->checkVPSExtensionSyntax(); 
+#if !H_MV_6_MISC_O0062_31
   pcVPS->setRefLayers(); 
-}
-
+#endif
+}
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat )
+#else
 Void TDecCavlc::parseRepFormat( TComRepFormat* pcRepFormat )
+#endif
 {
   assert( pcRepFormat ); 
 
   UInt uiCode; 
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+  READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );  pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode );
+  READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode );
+  READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 );
+
+  pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); 
+
+  if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() )
+  {  
+#endif
   READ_CODE( 2,  uiCode, "chroma_format_vps_idc" );          pcRepFormat->setChromaFormatVpsIdc       ( uiCode );
   if ( pcRepFormat->getChromaFormatVpsIdc() == 3 )
@@ -1158,8 +1397,17 @@
     READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); 
   }
+#if !H_MV_6_PS_REP_FORM_18_19_20
   READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );  pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode );
   READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode );
+#endif
   READ_CODE( 4,  uiCode, "bit_depth_vps_luma_minus8" );      pcRepFormat->setBitDepthVpsLumaMinus8    ( uiCode );
   READ_CODE( 4,  uiCode, "bit_depth_vps_chroma_minus8" );    pcRepFormat->setBitDepthVpsChromaMinus8  ( uiCode );
+#if H_MV_6_PS_REP_FORM_18_19_20
+  }
+  else
+  {
+    pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, false ); 
+  }
+#endif
 }
 
@@ -1174,4 +1422,11 @@
 
   UInt uiCode; 
+#if H_MV_6_PS_O0223_29
+  READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 );
+  if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )
+  {  
+    READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 );
+  }
+#endif
   READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 );
   READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 );
@@ -1204,4 +1459,40 @@
   }
 
+#if H_MV_6_O0226_37
+  READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
+  if( !pcVPSVUI->getTilesNotInUseFlag() ) 
+  {      
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 );
+      if( pcVPSVUI->getTilesInUseFlag( i ) )  
+      {
+        READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 );
+      }
+    }  
+
+    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
+      {  
+        Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getRefLayerId(pcVPS->getLayerIdInNuh( i ) , j  ));  
+        if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) )  
+        {
+          READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 );
+        }
+      }  
+    }
+  }  
+  
+  READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 );
+  
+  if( !pcVPSVUI->getWppNotInUseFlag( ))
+  {
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 );
+    }
+  }
+#else
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1211,4 +1502,5 @@
     }
   }
+#endif
 
   READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );
@@ -1232,5 +1524,162 @@
     }
   }
-}
+
+#if H_MV_6_PS_O0118_33
+  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode );
+  }
+  else
+  {
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); 
+  }
+
+  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
+  {
+    assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); 
+    TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo();     
+    parseVideoSignalInfo( curVideoSignalInfo ); 
+    pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); 
+  }
+  
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() );
+    }
+  }
+  else
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ); 
+    }
+  }
+#endif
+#if H_MV_6_HRD_O0164_15
+  READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 );
+  if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
+  {
+    parseVpsVuiBspHrdParameters( pcVPS ); 
+}
+#endif
+}
+
+#if H_MV_6_HRD_O0164_15
+Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS )
+{
+  assert( pcVPS ); 
+
+  TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+
+  assert( pcVPSVUI ); 
+
+  TComVpsVuiBspHrdParameters*  vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 
+  
+  assert ( vpsVuiBspHrdP );
+
+  UInt uiCode; 
+  READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vpsVuiBspHrdP->setVpsNumBspHrdParametersMinus1( uiCode );
+  for( Int i = 0; i <= vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ); i++ )
+  {  
+    if( i > 0 )
+    {
+      READ_FLAG( uiCode, "bsp_cprms_present_flag" ); vpsVuiBspHrdP->setBspCprmsPresentFlag( i, uiCode == 1 );
+    }
+    TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 
+    parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getBspCprmsPresentFlag( i ), pcVPS->getMaxSubLayersMinus1() );     
+  }  
+  for( Int h = 1; h <= pcVPS->getVpsNumLayerSetsMinus1(); h++ )
+  {  
+    READ_UVLC( uiCode, "num_bitstream_partitions" ); vpsVuiBspHrdP->setNumBitstreamPartitions( h, uiCode );
+    for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
+    {
+      for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
+      {
+        if( pcVPS->getLayerIdIncludedFlag( h ,j ) )
+        {
+          READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 );
+        }
+        else
+        {
+          vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
+        }
+      }
+    }
+    vpsVuiBspHrdP->checkLayerInBspFlag( pcVPS, h ); 
+    
+    if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) )
+    {  
+      READ_UVLC( uiCode, "num_bsp_sched_combinations" ); vpsVuiBspHrdP->setNumBspSchedCombinations( h, uiCode );
+      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinations( h ); i++ )
+      {
+        for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
+        {  
+          READ_UVLC( uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
+          READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode );
+        }  
+      }
+    }  
+  }  
+}  
+#endif
+
+#if H_MV_6_PS_O0118_33
+Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) 
+{
+  UInt uiCode; 
+  READ_CODE( 3, uiCode, "video_vps_format" );             pcVideoSignalInfo->setVideoVpsFormat( uiCode );
+  READ_FLAG( uiCode, "video_full_range_vps_flag" );       pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 );
+  READ_CODE( 8, uiCode, "colour_primaries_vps" );         pcVideoSignalInfo->setColourPrimariesVps( uiCode );
+  READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode );
+  READ_CODE( 8, uiCode, "matrix_coeffs_vps" );            pcVideoSignalInfo->setMatrixCoeffsVps( uiCode );
+}
+#endif
+
+#if H_MV_6_HRD_O0217_13
+Void TDecCavlc::parseDpbSize( TComVPS* vps )
+{
+  UInt uiCode; 
+  TComDpbSize* dpbSize = vps->getDpbSize(); 
+  assert ( dpbSize != 0 ); 
+
+  for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
+  {  
+    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
+
+    for( Int j = 0; j  <=  vps->getMaxTLayers() - 1 ; j++ )
+    {  
+      if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
+      {
+        READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 );
+      }
+      if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
+      {  
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+        {
+          READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
+        }
+        READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode );
+        READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );
+      }
+      else
+      {
+        if ( j > 0 )
+        {
+          for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+          {
+            dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
+          }
+          dpbSize->setMaxVpsNumReorderPics      ( i, j, dpbSize->getMaxVpsNumReorderPics      ( i, j - 1 ) );
+          dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );
+        }
+      }
+    }  
+  }  
+}
+#endif
 #endif
 
@@ -1280,5 +1729,5 @@
         if (i!=1)
         {
-          READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+          READ_UVLC (uiCode, "log2_sub_PU_size_minus2[i]");     pcVPS->setSubPULog2Size(i, uiCode+2); 
         }
 #endif
@@ -1357,5 +1806,10 @@
   sps->inferRepFormat  ( vps , rpcSlice->getLayerId() ); 
   sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) );   
-
+#if H_MV_6_PS_O0118_33
+  if ( sps->getVuiParametersPresentFlag() )
+  {
+    sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); 
+  }
+#endif
   rpcSlice->setVPS(vps);      
   rpcSlice->setViewId   ( vps->getViewId   ( rpcSlice->getLayerId() )      );
@@ -1411,4 +1865,5 @@
 #if H_MV    
     Int esb = 0; //Don't use i, otherwise will shadow something below
+#if !H_MV_6_RALS_O0149_11
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1416,4 +1871,5 @@
       READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
     }
+#endif
 
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
@@ -1422,4 +1878,19 @@
       READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 );
     }
+
+#if H_MV_6_RALS_O0149_11
+    if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 );
+    }
+    rpcSlice->checkCrossLayerBlaFlag( ); 
+
+    if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
+    }
+#endif
 
     for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
@@ -1445,7 +1916,59 @@
     //   colour_plane_id                                      u(2)
 
+
+#if H_MV_6_POC_31_35_38
+    UInt slicePicOrderCntLsb = 0;
+    Int iPOClsb = slicePicOrderCntLsb;  // Needed later
+    if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() )
+    {
+      READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb");        
+    }    
+
+    Bool picOrderCntMSBZeroFlag = false;     
+
+    // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered??
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag ||   rpcSlice->getIdrPicFlag(); 
+
+    // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 &&   !rpcSlice->getFirstPicInLayerDecodedFlag() ); 
+
+    Int picOrderCntMSB = 0; 
+
+    if ( !picOrderCntMSBZeroFlag )
+    {
+      Int prevPicOrderCnt    = rpcSlice->getPrevTid0POC();
+      Int maxPicOrderCntLsb  = 1 << sps->getBitsForPOC();
+      Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1);
+      Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb;
+            
+      if( ( slicePicOrderCntLsb  <  prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb )  >=  ( maxPicOrderCntLsb / 2 ) ) )
+      {
+        picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb;
+      }
+      else if( (slicePicOrderCntLsb  >  prevPicOrderCntLsb )  && ( (slicePicOrderCntLsb - prevPicOrderCntLsb )  >  ( maxPicOrderCntLsb / 2 ) ) ) 
+      {
+        picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb;
+      }
+      else
+      {
+        picOrderCntMSB = prevPicOrderCntMsb;
+      }   
+    }
+      
+    rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb );
+    if ( rpcSlice->getPocResetFlag() )  
+    {
+      rpcSlice->setPocBeforeReset   ( rpcSlice->getPOC() ); 
+      rpcSlice->setPOC              ( 0 );
+    }      
+#endif
+
     if( rpcSlice->getIdrPicFlag() )
     {
+#if !H_MV_6_POC_31_35_38
       rpcSlice->setPOC(0);
+#endif
       TComReferencePictureSet* rps = rpcSlice->getLocalRPS();
       rps->setNumberOfNegativePictures(0);
@@ -1460,4 +1983,5 @@
     else
     {
+#if !H_MV_6_POC_31_35_38
       READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");  
       Int iPOClsb = uiCode;
@@ -1494,4 +2018,5 @@
 
       }      
+#endif
 #endif
       TComReferencePictureSet* rps;
@@ -1628,6 +2153,10 @@
     }
 #if H_MV
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    Bool interLayerPredLayerIdcPresentFlag = false; 
+#endif
     Int layerId       = rpcSlice->getLayerId(); 
-    if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )    {   
+    if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
+    {   
       READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 );
       if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )
@@ -1639,4 +2168,7 @@
         if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
         {
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+          interLayerPredLayerIdcPresentFlag = true; 
+#endif
           for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ )   
           {
@@ -1646,4 +2178,13 @@
       }  
     }
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    if ( !interLayerPredLayerIdcPresentFlag )
+    {
+      for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ )   
+      {
+        rpcSlice->setInterLayerPredLayerIdc( i, rpcSlice->getRefLayerPicIdc( i ) );
+      }
+    }
+#endif
 #endif
     if(sps->getUseSAO())
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 735)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 738)
@@ -78,6 +78,19 @@
 #if H_MV
   Void  parseVPSExtension   ( TComVPS* pcVPS ); 
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Void  parseRepFormat      ( Int i, TComRepFormat* curRepFormat, TComRepFormat* prevRepFormat );
+#else
   Void  parseRepFormat      ( TComRepFormat* pcRepFormat );
+#endif
   Void  parseVPSVUI         ( TComVPS* pcVPS );
+#if H_MV_6_PS_O0118_33
+  Void parseVideoSignalInfo ( TComVideoSignalInfo* pcVideoSignalInfo ); 
+#endif
+#if H_MV_6_HRD_O0217_13
+  Void  parseDpbSize        ( TComVPS* pcVPS ); 
+#endif
+#if H_MV_6_HRD_O0164_15
+  Void parseVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
+#endif
 #endif
 
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 735)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 738)
@@ -635,4 +635,10 @@
 #if H_MV
   m_apcSlicePilot->setVPS(vps);  
+#if H_MV_6_PS_0092_17
+  // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
+  assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, pps->getLayerId() ) );   
+  // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
+  assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, sps->getLayerId() ) );
+#endif
   sps->inferRepFormat  ( vps , m_layerId ); 
   sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); 
@@ -665,5 +671,9 @@
 
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
+#else
 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag )
+#endif
 {
   assert( nalu.m_layerId == m_layerId ); 
@@ -722,4 +732,8 @@
 #endif
 #endif
+
+#if H_MV_LAYER_WISE_STARTUP
+    xCeckNoClrasOutput();
+#endif
     // Skip pictures due to random access
     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
@@ -727,4 +741,7 @@
     m_prevSliceSkipped = true;
     m_skippedPOC = m_apcSlicePilot->getPOC();
+#if H_MV_FIX_SKIP_PICTURES
+      sliceSkippedFlag = true; 
+#endif
       return false;
     }
@@ -734,4 +751,7 @@
     m_prevSliceSkipped = true;
     m_skippedPOC = m_apcSlicePilot->getPOC();
+#if H_MV_FIX_SKIP_PICTURES
+      sliceSkippedFlag = true; 
+#endif
       return false;
     }
@@ -1171,5 +1191,9 @@
 
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
+#else
 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag)
+#endif
 #else
 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
@@ -1216,5 +1240,9 @@
     case NAL_UNIT_CODED_SLICE_RASL_R:
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
+#else
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag);
+#endif
 #else
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
@@ -1265,5 +1293,9 @@
     return true;
   }
+#if H_MV_LAYER_WISE_STARTUP
+  else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
+#else
   else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
+#endif
   {
     if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
@@ -1272,13 +1304,57 @@
         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
     {
+
+#if H_MV_LAYER_WISE_STARTUP
+      if ( xAllRefLayersInitilized() )
+      {
+        m_layerInitilizedFlag[ m_layerId ] = true; 
+        m_pocRandomAccess = m_apcSlicePilot->getPOC();
+      }
+      else
+      {
+        return true; 
+      }
+#else
       // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
       m_pocRandomAccess = m_apcSlicePilot->getPOC();
+#endif
     }
     else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     {
+#if H_MV_LAYER_WISE_STARTUP
+      if ( xAllRefLayersInitilized() )
+      {
+        m_layerInitilizedFlag[ m_layerId ] = true; 
       m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
     }
     else 
     {
+        return true; 
+      }
+#else
+      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
+#endif
+    }
+    else 
+    {
+#if H_MV_FIX_SKIP_PICTURES
+      static Bool warningMessage[MAX_NUM_LAYERS];
+      static Bool warningInitFlag = false;
+      
+      if (!warningInitFlag)
+      {
+        for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
+        {
+          warningMessage[i] = true; 
+        }
+        warningInitFlag = true; 
+      }
+
+      if ( warningMessage[getLayerId()] )
+      {
+        printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); 
+        warningMessage[m_layerId] = false; 
+      }
+#else
       static Bool warningMessage = false;
       if(!warningMessage)
@@ -1287,4 +1363,5 @@
         warningMessage = true;
       }
+#endif
       return true;
     }
@@ -1296,6 +1373,10 @@
     return true;
   }
+#if H_MV_LAYER_WISE_STARTUP
+  return !m_layerInitilizedFlag[ getLayerId() ]; 
+#else
   // if we reach here, then the picture is not skipped.
   return false; 
+#endif
 }
 
@@ -1338,4 +1419,40 @@
   }
 }
+
+#if H_MV_LAYER_WISE_STARTUP
+Void TDecTop::xCeckNoClrasOutput()
+{
+  // This part needs further testing! 
+  if ( getLayerId() == 0 )
+  {    
+    NalUnitType nut = m_apcSlicePilot->getNalUnitType(); 
+
+    Bool isBLA =  ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP  )  || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 
+    Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); 
+    Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() ); 
+
+    if ( noClrasOutputFlag ) 
+    {
+      for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
+      {
+        m_layerInitilizedFlag[i] = false; 
+      } 
+    }
+  }
+}
+
+Bool TDecTop::xAllRefLayersInitilized()
+{
+  Bool allRefLayersInitilizedFlag = true; 
+  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
+  for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
+  {
+    Int refLayerId = vps->getRefLayerId( m_layerId, i ); 
+    allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; 
+  }
+
+  return allRefLayersInitilizedFlag;
+}
+#endif
 #endif
 //! \}
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 735)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 738)
@@ -186,4 +186,7 @@
   TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
 #if H_MV
+#if H_MV_LAYER_WISE_STARTUP
+  Bool*                    m_layerInitilizedFlag; // initialization Layers
+#endif
   static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
 #else
@@ -243,4 +246,9 @@
   Void  init();
 #if H_MV  
+#if H_MV_FIX_SKIP_PICTURES
+  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
+#else
+  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
+#endif
   Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
 #else  
@@ -260,5 +268,10 @@
   TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  }  
   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
-  
+#if H_MV_LAYER_WISE_STARTUP
+  Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
+#endif
+#if H_MV_6_HRD_O0217_13
+  TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present. 
+#endif
   Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
   Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
@@ -281,6 +294,15 @@
 #if H_MV  
   TComPic*  xGetPic( Int layerId, Int poc ); 
+#if H_MV_FIX_SKIP_PICTURES
+  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag );  
+#else
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag );  
+#endif
   Void      xResetPocInPicBuffer();
+#if H_MV_LAYER_WISE_STARTUP
+  Void      xCeckNoClrasOutput();
+
+  Bool      xAllRefLayersInitilized();
+#endif
 #else
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
