Index: trunk/source/Lib/TLibDecoder/AnnexBread.h
===================================================================
--- trunk/source/Lib/TLibDecoder/AnnexBread.h	(revision 950)
+++ trunk/source/Lib/TLibDecoder/AnnexBread.h	(revision 964)
@@ -65,5 +65,5 @@
   , m_Input(istream)
   {
-    istream.exceptions(std::istream::eofbit);
+    istream.exceptions(std::istream::eofbit | std::istream::badbit);
   }
 
Index: trunk/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/NALread.cpp	(revision 964)
@@ -127,8 +127,25 @@
   else
   {
+#if H_MV_HLS_8_GEN_Q0108_13
+
+    // If nal_unit_type is in the range of BLA_W_LP to RSV_IRAP_VCL23, inclusive, i.e. the coded 
+    // slice segment belongs to an IRAP picture, TemporalId shall be equal to 0. 
+    // Otherwise, when nal_unit_type is equal to TSA_R, TSA_N, STSA_R, or STSA_N, TemporalId shall not be equal to 0. 
+    // Otherwise, if nal_unit_type is equal to TSA or TSA_N, TemporalId shall not be equal to 0. 
+    // Otherwise, when nuh_layer_id is equal to 0 and nal_unit_type is equal to STSA_R or STSA_N, 
+    // TemporalId shall not be equal to 0.
+
+    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
+         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N    );
+
+    assert( nalu.m_layerId > 0 
+      || ( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
+        && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N ) );
+#else
     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_R
          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
+#endif
   }
 }
Index: trunk/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/SEIread.cpp	(revision 964)
@@ -399,21 +399,16 @@
 {
   UInt val; 
-  READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val; 
-  READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
-  READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
+  READ_CODE(4, val, "active_video_parameter_set_id");   sei.activeVPSId = val; 
+  READ_FLAG(   val, "self_contained_cvs_flag");         sei.m_selfContainedCvsFlag = val ? true : false;
+  READ_FLAG(   val, "no_parameter_set_update_flag");    sei.m_noParameterSetUpdateFlag = val ? true : false;
   READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
 
-  sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1);
+  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
   for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
   {
-    READ_UVLC(val, "active_seq_param_set_id");  sei.activeSeqParamSetId[i] = val; 
-  }
-
-  UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned(); 
-  
-  while(uibits--)
-  {
-    READ_FLAG(val, "alignment_bit");
-  }
+    READ_UVLC(val, "active_seq_parameter_set_id");      sei.activeSeqParameterSetId[i] = val; 
+  }
+
+  xParseByteAlign();
 }
 
@@ -681,8 +676,13 @@
     case 4:
       {
-        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedValue = val;
-        if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO
+        READ_CODE( 8, val, "camera_iso_speed_idc" );                     sei.m_cameraIsoSpeedIdc = val;
+        if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO
         {
           READ_CODE( 32,   val,   "camera_iso_speed_value" );            sei.m_cameraIsoSpeedValue = val;
+        }
+        READ_CODE( 8, val, "exposure_index_idc" );                       sei.m_exposureIndexIdc = val;
+        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
+        {
+          READ_CODE( 32,   val,   "exposure_index_value" );              sei.m_exposureIndexValue = val;
         }
         READ_FLAG( val, "exposure_compensation_value_sign_flag" );       sei.m_exposureCompensationValueSignFlag = val;
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 964)
@@ -364,9 +364,47 @@
   READ_FLAG( uiCode, "slice_segment_header_extension_present_flag");
   pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
-
+  
+#if H_MV
+  READ_FLAG( uiCode, "pps_extension_present_flag");
+#else
   READ_FLAG( uiCode, "pps_extension_flag");
+#endif
   if (uiCode)
   {
+
 #if H_MV
+#if H_MV_HLS_8_SPS_NODOC_48
+    READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 );
+    READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 );
+#if !H_3D
+    READ_CODE( 6, uiCode, "pps_extension_6bits" ); pcPPS->setPpsExtension6bits( uiCode );
+#else
+    READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 );
+    READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode );
+#endif
+    if ( pcPPS->getPpsRangeExtensionsFlag() )
+    { 
+      assert(0); 
+    }
+
+    if ( pcPPS->getPpsMultilayerExtensionFlag() )
+    { 
+        READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
+#if H_MV_HLS_8_PPS_NODOC_NN
+        READ_FLAG( uiCode, "pps_extension_reserved_zero_flag" );
+#endif
+    }
+#if !H_3D
+    if ( pcPPS->getPpsExtension6bits() )
+    {
+#else
+    if ( pcPPS->getPps3dExtensionFlag() )
+    { 
+      parsePPSExtension( pcPPS, pcVPS );
+    }
+    if ( pcPPS->getPpsExtension5bits() )
+    {
+#endif
+#else
     for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
     {
@@ -395,4 +433,6 @@
     {
 #endif
+#endif
+
       while ( xMoreRbspData() )
       {
@@ -845,21 +885,9 @@
   for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
   {
-#if H_MV
     READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
-#else
-    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
-#endif
     pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
-#if H_MV
     READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );
-#else
-    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
-#endif
     pcSPS->setNumReorderPics(uiCode, i);
-#if H_MV
     READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
-#else
-    READ_UVLC ( uiCode, "sps_max_latency_increase_plus1");
-#endif
     pcSPS->setMaxLatencyIncrease( uiCode, i );
 
@@ -978,13 +1006,49 @@
   }
 
+
+#if H_MV
+  READ_FLAG( uiCode, "sps_extension_present_flag");
+  pcSPS->setSpsExtensionPresentFlag( uiCode ); 
+  if (pcSPS->getSpsExtensionPresentFlag( ) )
+#else
   READ_FLAG( uiCode, "sps_extension_flag");
+  if (uiCode)
+#endif
+  {
 #if H_MV
-  pcSPS->setSpsExtensionFlag( uiCode ); 
-  if (pcSPS->getSpsExtensionFlag( ) )
-#else
-  if (uiCode)
-#endif
-  {
-#if H_MV
+#if H_MV_HLS_8_SPS_NODOC_48
+    READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 );
+    READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 );
+#if !H_3D
+    READ_CODE( 6, uiCode, "sps_extension_6bits" ); pcSPS->setSpsExtension6bits( uiCode );
+#else
+    READ_FLAG( uiCode, "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 );
+    READ_CODE( 5, uiCode, "sps_extension_5bits" ); pcSPS->setSpsExtension5bits( uiCode );
+#endif
+  }
+
+  if ( pcSPS->getSpsRangeExtensionsFlag() )
+  {
+    assert( 0 ); 
+  }
+
+  if ( pcSPS->getSpsMultilayerExtensionFlag() )
+  {
+    parseSPSExtension( pcSPS ); 
+  }
+
+#if H_3D
+  if ( pcSPS->getSps3dExtensionFlag() )
+  {
+    parseSPSExtension2( pcSPS, viewIndex, depthFlag  ); 
+  }
+
+  if ( pcSPS->getSpsExtension5bits() )
+  { 
+#else
+  if ( pcSPS->getSpsExtension6bits() )
+  { 
+#endif
+#else
     for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
     {
@@ -1012,9 +1076,10 @@
     {   
 #endif
+#endif
         while ( xMoreRbspData() )
         {
           READ_FLAG( uiCode, "sps_extension_data_flag");
         }
-#if H_MV
+#if H_MV && !H_MV_HLS_8_SPS_NODOC_48
     }
 #endif
@@ -1067,5 +1132,10 @@
   
   READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
+#if H_MV_HLS_8_SYN_Q0041_03
+  READ_FLAG( uiCode, "vps_base_layer_internal_flag" );            pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 );
+  READ_FLAG( uiCode, "vps_reserved_one_bit" );                    assert( uiCode == 1 ); 
+#else
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
+#endif
 #if H_MV
   READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) )  );
@@ -1073,5 +1143,5 @@
   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
 #endif
-  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );
+  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );    assert(uiCode+1 <= MAX_TLAYER);
   READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
@@ -1151,6 +1221,11 @@
     }
   }
+#if H_MV_HLS_8_RPS_Q0100_36
+  READ_FLAG( uiCode,  "vps_extension_flag" );                      pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false );
+  if ( pcVPS->getVpsExtensionFlag() )
+#else
   READ_FLAG( uiCode,  "vps_extension_flag" );
   if (uiCode)
+#endif
   {
 #if H_MV
@@ -1187,5 +1262,7 @@
 {
   UInt uiCode; 
+#if !H_MV_HLS_8_SYN_Q0041_03
   READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
+#endif
 
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
@@ -1267,5 +1344,4 @@
       READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode );    
       pcVPS->checkSubLayersVpsMaxMinus1( i ); 
-
     }
   }  
@@ -1294,5 +1370,4 @@
 
   READ_FLAG( uiCode, "all_ref_layers_active_flag" );             pcVPS->setAllRefLayersActiveFlag( uiCode == 1 );
-
   READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );  
 
@@ -1309,25 +1384,52 @@
   }
 
-  READ_UVLC( uiCode, "num_add_output_layer_sets"      ); pcVPS->setNumAddOutputLayerSets( uiCode );
+#if H_MV_HLS_8_SYN_39_19
+  if ( pcVPS->getNumIndependentLayers() > 1 ) 
+  {
+   READ_UVLC( uiCode, "num_add_layer_sets"      ); pcVPS->setNumAddLayerSets( uiCode );
+  }
+  for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++)
+  {
+    for (Int j = 0; j < pcVPS->getNumIndependentLayers(); j++)
+    {
+      READ_CODE( pcVPS->getHighestLayerIdxPlus1Len( j ) , uiCode, "highest_layer_idx_plus1" ); pcVPS->setHighestLayerIdxPlus1( i, j, uiCode );
+    }
+  }
+  if (pcVPS->getNumLayerSets() > 1)
+  {
+    READ_UVLC( uiCode, "num_add_olss" ); pcVPS->setNumAddOlss( uiCode );
+    READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
+  }
+
+  pcVPS->initTargetLayerIdLists( ); 
+
+#else
+  READ_UVLC( uiCode, "num_add_layer_sets"      ); pcVPS->setNumAddLayerSets( uiCode );
   pcVPS->initTargetLayerIdLists( ); 
   if( pcVPS->getNumOutputLayerSets() > 1)
   {
-    READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); pcVPS->setDefaultTargetOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
+    READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
   }  
+#endif
 
   pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
-  pcVPS->setOutputLayerSetIdxMinus1(0, -1); 
+  pcVPS->setLayerSetIdxForOlsMinus1(0, -1); 
 
   pcVPS->deriveTargetLayerIdList( 0 ); 
+
   for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
   {
+#if H_MV_HLS_8_SYN_39_19
+    if( i >= pcVPS->getNumLayerSets( ) )    
+#else
     if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
+#endif
     {        
-      READ_UVLC( uiCode,      "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); 
-    }
-
-    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultTargetOutputLayerIdc() == 2 )
+      READ_UVLC( uiCode,      "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); 
+    }
+
+    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 )
     {       
-      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ )
       {
         READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); 
@@ -1336,5 +1438,5 @@
     else
     { 
-      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ )
       {              
         pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); 
@@ -1347,5 +1449,4 @@
       READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" );   pcVPS->setProfileLevelTierIdx( i , uiCode ); 
     }
-
     if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 )
     {
@@ -1354,4 +1455,5 @@
   }
 
+#if !H_MV_HLS_8_PMS_Q0195_20
   READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
@@ -1359,4 +1461,7 @@
     READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
   }
+#else
+  READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
+#endif
 
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
@@ -1369,14 +1474,41 @@
   }
 
+#if H_MV_HLS_8_PMS_Q0195_20
+  if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
+  {
+    READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
+  }
+#endif
   if( pcVPS->getRepFormatIdxPresentFlag() ) 
   {
+#if H_MV_HLS_8_SYN_Q0041_03
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+#else
     for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-    {
+#endif
+    {
+#if !H_MV_HLS_8_PMS_Q0195_20
       if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
       {
+#endif
         READ_CODE( pcVPS->getVpsRepFormatIdxLen(), uiCode, "vps_rep_format_idx[i]" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
-      }
-    }
-  }
+#if !H_MV_HLS_8_PMS_Q0195_20
+      }
+#endif
+    }
+  }
+#if H_MV_HLS_8_PMS_Q0195_20
+  else
+  {
+#if H_MV_HLS_8_SYN_Q0041_03
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+#else
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+#endif
+    {
+      pcVPS->setVpsRepFormatIdx( i, pcVPS->inferVpsRepFormatIdx( i ) );
+    }
+  }
+#endif
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
@@ -1403,7 +1535,13 @@
   }
 
+#if H_MV_HLS_8_SYN_Q0041_03
+  for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ?  1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ?  0 : 1; j < i; j++ )
+#else
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
   {
     for( Int j = 0; j < i; j++ )
+#endif
     {
       if (pcVPS->getDirectDependencyFlag( i, j) )
@@ -1415,4 +1553,5 @@
         else
         {
+
           READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
         }
@@ -1420,5 +1559,4 @@
     }
   }  
-
   READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); 
   for ( Int i = 1; i <= pcVPS->getVpsNonVuiExtensionLength(); i++ )
@@ -1437,5 +1575,4 @@
     pcVPSVUI->inferVpsVui( false ); 
   }
-
   pcVPS->checkVPSExtensionSyntax(); 
 }
@@ -1492,7 +1629,15 @@
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
+#if H_MV_HLS_8_SYN_Q0041_03
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
+#else
     for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
-    {
+#endif
+    {
+#if H_MV_HLS_8_MIS_Q0102_30
+      for( Int j = 0; j  <=  pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) 
+#else        
       for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
+#endif
       {
         if( pcVPSVUI->getBitRatePresentVpsFlag( ) )
@@ -1551,9 +1696,12 @@
     }
   }
-
   READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
   {      
+#if H_MV_HLS_8_SYN_Q0041_03
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+#else
     for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+#endif
     {
       READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 );
@@ -1563,6 +1711,9 @@
       }
     }  
-
-    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+#if H_MV_HLS_8_SYN_Q0041_03
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+#else
+    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )      
+#endif
     {
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
@@ -1586,5 +1737,4 @@
     }
   }
-
   READ_CODE( 3, uiCode, "vps_vui_reserved_zero_3bits" ); 
   READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );
@@ -1596,13 +1746,20 @@
       for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ )
       {
-        READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode );
-        if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
-        {
-          READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 );
-          if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
+#if H_MV_HLS_8_SYN_Q0041_03
+        if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getRefLayerId( pcVPS->getLayerIdInNuh( i ), j ) > 0 )
+        {        
+#endif
+          READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode );
+          if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 )
           {
-            READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode );
+            READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 );
+            if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) )
+            {
+              READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode );
+            }
           }
-        }
+#if H_MV_HLS_8_SYN_Q0041_03
+        }
+#endif
       }
     }
@@ -1613,5 +1770,5 @@
   {
     parseVpsVuiBspHrdParameters( pcVPS ); 
-}
+  }
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1651,4 +1808,9 @@
     for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
     {
+#if H_MV_HLS_8_HRD_Q0101_04
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( h ); j++ )  
+      {
+        READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 );
+#else
       for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
       {
@@ -1661,4 +1823,5 @@
           vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
         }
+#endif
       }
     }
@@ -1667,11 +1830,22 @@
     if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) )
     {  
-      READ_UVLC( uiCode, "num_bsp_sched_combinations" ); vpsVuiBspHrdP->setNumBspSchedCombinations( h, uiCode );
-      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinations( h ); i++ )
+      READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1" ); vpsVuiBspHrdP->setNumBspSchedCombinationsMinus1( h, uiCode );
+#if H_MV_HLS_8_HRD_Q0182_05
+      for( Int i = 0; i <= vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
+#else
+      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ )
+#endif
       {
         for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
         {  
+#if H_MV_HLS_8_HRD_Q0101_04
+          READ_CODE( vpsVuiBspHrdP->getBspCombHrdIdxLen(), uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
+#else
           READ_UVLC( uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
+#endif
           READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode );
+#if H_MV_HLS_8_HRD_Q0101_04
+          vpsVuiBspHrdP->checkBspCombHrdAndShedIdx( pcVPS, h, i, j ); 
+#endif
         }  
       }
@@ -1698,6 +1872,13 @@
   for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
   {  
+#if H_MV_HLS_8_MIS_Q0102_30
+    Int currLsIdx = vps->olsIdxToLsIdx( i ); 
+#endif
     READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
+#if H_MV_HLS_8_MIS_Q0102_30
+    for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ )
+#else
     for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( i ); j++ )
+#endif
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1707,18 +1888,13 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
-        for( Int k = 0; k < vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i )); k++ )   
+#if H_MV_HLS_8_MIS_Q0102_30
+        for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ )   
+#else
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i )); k++ )   
+#endif
         {
           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 );
-#if H_MV_HLS7_GEN
-        if( vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i ) ) != vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ) ) 
-        {
-          for( Int k = 0; k < vps->getNumLayersInIdList( vps->getLayerSetIdxForOutputLayerSet( i ) ); k++ )
-          {
-            READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1" ); dpbSize->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode );
-          }
-        }
-#endif
         READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );
       }
@@ -1727,5 +1903,9 @@
         if ( j > 0 )
         {
-          for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+#if H_MV_HLS_8_DBP_NODOC_42
+          for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ )   
+#else
+          for( Int k = 0; k < vps->getNumSubDpbs( vps->olsIdxToLsIdx( i ) ); k++ )   
+#endif
           {
             dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
@@ -1858,5 +2038,9 @@
 #endif
 
+#if H_MV_HLS_8_HRD_Q0102_08
+Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx)
+#else
 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)
+#endif
 {
   UInt  uiCode;
@@ -1876,6 +2060,12 @@
   if( rpcSlice->getRapPicFlag())
   { 
-    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
-  }
+    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored -- updated already
+#if SETTING_NO_OUT_PIC_PRIOR
+    rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false);
+#else
+    rpcSlice->setNoOutputPicPrior( false );
+#endif
+  }
+
   READ_UVLC (    uiCode, "slice_pic_parameter_set_id" );  rpcSlice->setPPSId(uiCode);
   pps = parameterSetManager->getPrefetchedPPS(uiCode);
@@ -1891,4 +2081,11 @@
   sps->inferRepFormat  ( vps , rpcSlice->getLayerId() ); 
   sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) );   
+#if H_MV_HLS_8_HRD_Q0102_08
+  sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, rpcSlice->getLayerId(), false ); 
+#endif
+#if H_MV_HLS_8_RPS_Q0100_36
+  vps->inferDbpSizeLayerSetZero( sps, false ); 
+#endif
+
   if ( sps->getVuiParametersPresentFlag() )
   {
@@ -1944,4 +2141,8 @@
   }
   
+#if H0044_POC_LSB_NOT_PRESENT
+    UInt slicePicOrderCntLsb = 0;
+#endif
+
   if(!rpcSlice->getDependentSliceSegmentFlag())
   {
@@ -1994,5 +2195,7 @@
 
 #if H_MV
+#if !H0044_POC_LSB_NOT_PRESENT
     UInt slicePicOrderCntLsb = 0;
+#endif
     Int iPOClsb = slicePicOrderCntLsb;  // Needed later
     if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() )
@@ -2000,4 +2203,7 @@
       READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb");        
     }    
+#if H_MV_HLS_8_POC_Q0142_32
+    rpcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); 
+#endif
 
     Bool picOrderCntMSBZeroFlag = false;     
@@ -2093,6 +2299,16 @@
       READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
       if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
-      {
+      {        
         parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
+#if H_MV_HLS_8_RPS_Q0100_36
+        if ( !rps->getInterRPSPrediction( ) )
+        { // check sum of num_positive_pics and num_negative_pics
+          rps->checkMaxNumPics( 
+            vps->getVpsExtensionFlag(), 
+            vps->getMaxNumPics( rpcSlice->getLayerId() ),
+            rpcSlice->getLayerId(), 
+            sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 );
+        }
+#endif
       }
       else // use reference to short-term reference picture set in PPS
@@ -2198,4 +2414,14 @@
         rps->setNumberOfPictures(offset);        
       }  
+#if H_MV_HLS_8_RPS_Q0100_36
+      if ( !rps->getInterRPSPrediction( ) )
+      { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics 
+        rps->checkMaxNumPics( 
+          vps->getVpsExtensionFlag(), 
+          vps->getMaxNumPics( rpcSlice->getLayerId() ),
+          rpcSlice->getLayerId(), 
+          sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 );
+      }
+#endif
       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
@@ -2578,5 +2804,14 @@
       rpcSlice->setPocResetIdc( 0 );
     }
-
+#if H_MV_HLS_8_POC_Q0142_32
+    rpcSlice->checkPocResetIdc(); 
+#endif
+
+#if H0044_POC_LSB_NOT_PRESENT
+    if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && slicePicOrderCntLsb > 0 )
+    {
+      assert( rpcSlice->getPocResetIdc() != 2 );
+    }
+#endif
     if( rpcSlice->getPocResetIdc() !=  0 )
     {
@@ -2593,7 +2828,18 @@
       READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 );
       READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode );
+#if !H_MV_HLS_8_POC_Q0142_32
+#if H0044_POC_LSB_NOT_PRESENT
+      if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() )
+      {
+        assert( rpcSlice->getPocLsbVal() == 0 );
+      }
+#endif
+#endif
     }          
-
-    // Derive the value of PocMsbValRequiredFlag
+#if H_MV_HLS_8_POC_Q0142_32
+    rpcSlice->checkPocLsbVal(); 
+#endif
+
+    // Derive the value of PocMs8bValRequiredFlag
     rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()
                                           /* || TODO related to vps_poc_lsb_aligned_flag */
@@ -2606,4 +2852,7 @@
     else
     {
+#if H_MV_HLS_8_POC_Q0146_15
+      rpcSlice->setPocMsbValPresentFlag( rpcSlice->inferPocMsbValPresentFlag( ) ); 
+#else
       if( rpcSlice->getPocMsbValRequiredFlag() )
       {
@@ -2614,4 +2863,5 @@
         rpcSlice->setPocMsbValPresentFlag( false );
       }
+#endif
     }
 
@@ -2633,6 +2883,5 @@
       UInt ignore;
       READ_CODE(8,ignore,"slice_header_extension_data_byte");
-    }
-  }
+    }  
 #endif
   }
Index: trunk/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 964)
@@ -67,4 +67,5 @@
   Int**    m_aaiTempOffset;
 #endif
+
 public:
 
@@ -80,7 +81,7 @@
   Void  parseRepFormat      ( Int i, TComRepFormat* curRepFormat, TComRepFormat* prevRepFormat );
   Void  parseVPSVUI         ( TComVPS* pcVPS );
-  Void parseVideoSignalInfo ( TComVideoSignalInfo* pcVideoSignalInfo ); 
+  Void  parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ); 
   Void  parseDpbSize        ( TComVPS* pcVPS ); 
-  Void parseVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
+  Void  parseVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
 #endif
 
@@ -108,5 +109,9 @@
   Void  parseProfileTier    (ProfileTierLevel *ptl);
   Void  parseHrdParameters  (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);
+#if H_MV_HLS_8_HRD_Q0102_08
+  Void  parseSliceHeader    ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx);
+#else
   Void  parseSliceHeader    ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager);
+#endif
   Void  parseTerminatingBit ( UInt& ruiBit );
   
Index: trunk/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecCu.cpp	(revision 964)
@@ -1113,5 +1113,5 @@
 {
   UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
-  UInt  uiNumPart     = pcCU->getNumPartInter();
+  UInt  uiNumPart     = pcCU->getNumPartitions();
   UInt  uiNumQParts   = pcCU->getTotalNumPart() >> 2;
   
Index: trunk/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecEntropy.h	(revision 964)
@@ -67,5 +67,5 @@
   virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
 #if H_3D
-  virtual Void  parseSPS                  ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag  )         = 0;
+  virtual Void  parseSPS                  ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag  )                    = 0;
 #else
   virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
@@ -77,5 +77,9 @@
 #endif
 
+#if H_MV_HLS_8_HRD_Q0102_08
+  virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx )       = 0;
+#else
   virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)       = 0;
+#endif
 
   virtual Void  parseTerminatingBit       ( UInt& ruilsLast )                                     = 0;
@@ -125,5 +129,5 @@
   virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0;
   
-  virtual ~TDecEntropyIf() {}
+  virtual ~TDecEntropyIf() {}; 
 };
 
@@ -160,6 +164,9 @@
   Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
 #endif
+#if H_MV_HLS_8_HRD_Q0102_08
+  Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager, targetOlsIdx );         }
+#else
   Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager);         }
-
+#endif
   Void    decodeTerminatingBit        ( UInt& ruiIsLast )       { m_pcEntropyDecoderIf->parseTerminatingBit(ruiIsLast);     }
   
Index: trunk/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecGop.cpp	(revision 964)
@@ -249,6 +249,12 @@
   }
 
+#if !H_MV_HLS_7_VPS_P0300_27
+#if SETTING_PIC_OUTPUT_MARK
+  rpcPic->setOutputMark(rpcPic->getSlice(0)->getPicOutputFlag() ? true : false);
+#else
   rpcPic->setOutputMark(true);
+#endif
   rpcPic->setReconMark(true);
+#endif
 }
 
Index: trunk/source/Lib/TLibDecoder/TDecSbac.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.cpp	(revision 964)
@@ -957,7 +957,9 @@
         assert(0);
       }
+#endif
 #if H_MV_ENC_DEC_TRAC          
       DTRACE_CU("part_mode", eMode )
 #endif
+#if H_3D_QTLPC
     }
 #endif
Index: trunk/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecSbac.h	(revision 964)
@@ -87,5 +87,9 @@
 #endif
 
+#if H_MV_HLS_8_HRD_Q0102_08
+  Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/, Int targetOlsIdx ) {}
+#else
   Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}
+#endif
   Void  parseTerminatingBit       ( UInt& ruiBit );
   Void  parseMVPIdx               ( Int& riMVPIdx          );
Index: trunk/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecTop.cpp	(revision 964)
@@ -365,4 +365,13 @@
   m_prevSliceSkipped = false;
   m_skippedPOC = 0;
+#if SETTING_NO_OUT_PIC_PRIOR
+  m_bFirstSliceInBitstream  = true;
+  m_lastPOCNoOutputPriorPics = -1;
+  m_craNoRaslOutputFlag = false;
+  m_isNoOutputPriorPics = false;
+#endif
+#if H0056_EOS_CHECKS
+  m_isLastNALWasEos = false;
+#endif
 #if H_MV
   m_layerId = 0;
@@ -372,4 +381,7 @@
   m_isDepth = false;
   m_pcCamParsCollector = 0;
+#endif
+#if H_MV_HLS_8_HRD_Q0102_08
+  m_targetOptLayerSetIdx = -1; 
 #endif
 #endif
@@ -471,5 +483,5 @@
     TComVPS* vps         = pcSlice->getVPS();
     TComDpbSize* dpbSize = vps->getDpbSize(); 
-    Int lsIdx            = vps->getLayerSetIdxForOutputLayerSet( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
+    Int lsIdx            = vps->olsIdxToLsIdx( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
     Int layerIdx         = vps->getIdxInLayerSet     ( lsIdx, getLayerId() ); 
     Int subDpbIdx        = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); 
@@ -499,4 +511,7 @@
     {
       rpcPic->setOutputMark(false);
+#if H_MV_HLS_7_VPS_P0300_27
+      rpcPic->setPicOutputFlag(false); 
+#endif
       bBufferIsAvailable = true;
       break;
@@ -506,4 +521,7 @@
     {
       rpcPic->setOutputMark(false);
+#if H_MV_HLS_7_VPS_P0300_27
+      rpcPic->setPicOutputFlag(false); 
+#endif
       rpcPic->setReconMark( false );
       rpcPic->getPicYuvRec()->setBorderExtension( false );
@@ -550,10 +568,33 @@
   TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 );  
   TComSlice::markCurrPic( pcPic ); 
+#if !H_MV_HLS_8_DBP_NODOC_42
   TComSlice::markIvRefPicsAsUnused   ( m_ivPicLists, targetDecLayerIdSet, m_parameterSetManagerDecoder.getActiveVPS(), m_layerId, poc ); 
 #endif
+#endif
   m_bFirstSliceInPicture  = true;
 
   return;
 }
+
+#if SETTING_NO_OUT_PIC_PRIOR
+Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic)
+{
+  if (!rpcListPic || !m_isNoOutputPriorPics) return;
+
+  TComList<TComPic*>::iterator  iterPic   = rpcListPic->begin();
+
+  while (iterPic != rpcListPic->end())
+  {
+    TComPic*& pcPicTmp = *(iterPic++);
+    if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC())
+    {
+      pcPicTmp->setOutputMark(false);
+#if H_MV_HLS_7_VPS_P0300_27
+      pcPicTmp->setPicOutputFlag(false); 
+#endif
+    }
+  }
+}
+#endif
 
 Void TDecTop::xCreateLostPicture(Int iLostPoc) 
@@ -620,5 +661,5 @@
   TComVPS* vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
   assert (vps != 0); 
-  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
+  if (!m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP(), m_layerId ) )
 #else
   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
@@ -628,4 +669,32 @@
     assert (0);
   }
+
+#if H_MV_HLS_8_HRD_Q0102_08
+  sps->inferSpsMaxDecPicBufferingMinus1( vps, m_targetOptLayerSetIdx, getLayerId(), false ); 
+#endif
+
+#if H_MV_HLS_8_RPS_Q0100_36
+  vps->inferDbpSizeLayerSetZero( sps, false ); 
+#endif
+
+#if H_MV_HLS_8_PMS_Q0195_21
+  // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0
+  if ( vps->getVpsNumRepFormatsMinus1() == 0 )
+  {
+    //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0.
+    assert( sps->getUpdateRepFormatFlag() == false ); 
+  }
+#endif
+
+#if H_MV_HLS_8_RPS_Q0100_36
+  sps->checkRpsMaxNumPics( vps, getLayerId() ); 
+#endif
+
+#if H_MV_HLS_8_MIS_Q0177_22
+  if( m_layerId > 0 )
+  {
+    sps->setTemporalIdNestingFlag( (sps->getMaxTLayers() > 1) ? vps->getTemporalNestingFlag() : true );
+  }
+#endif
 
   if( pps->getDependentSliceSegmentsEnabledFlag() )
@@ -719,6 +788,10 @@
   m_apcSlicePilot->setLayerId( nalu.m_layerId );
 #endif
+
+#if H_MV_HLS_8_HRD_Q0102_08
+  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_targetOptLayerSetIdx );
+#else
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
-
+#endif
   // set POC for dependent slices in skipped pictures
   if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) 
@@ -741,4 +814,59 @@
 #endif
 
+#if SETTING_NO_OUT_PIC_PRIOR
+  //For inference of NoOutputOfPriorPicsFlag
+  if (m_apcSlicePilot->getRapPicFlag())
+  {
+    if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || 
+        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) ||
+        (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag()))
+    {
+      m_apcSlicePilot->setNoRaslOutputFlag(true);
+    }
+    //the inference for NoOutputPriorPicsFlag
+    if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag())
+    {
+      if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
+      {
+        m_apcSlicePilot->setNoOutputPriorPicsFlag(true);
+      }
+    }
+    else
+    {
+      m_apcSlicePilot->setNoOutputPriorPicsFlag(false);
+    }
+
+    if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
+    {
+      m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag();
+    }
+  }
+  if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag())
+  {
+    m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC();
+    m_isNoOutputPriorPics = true;
+  }
+  else
+  {
+    m_isNoOutputPriorPics = false;
+  }
+
+  //For inference of PicOutputFlag
+  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
+  {
+    if ( m_craNoRaslOutputFlag )
+    {
+      m_apcSlicePilot->setPicOutputFlag(false);
+    }
+  }
+#endif
+
+#if FIX_POC_CRA_NORASL_OUTPUT
+  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1
+  {
+    Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC();
+    m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
+  }
+#endif
 #if H_MV
     xCeckNoClrasOutput();
@@ -769,5 +897,5 @@
 
   //we should only get a different poc for a new picture (with CTU address==0)
-  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (!m_apcSlicePilot->getSliceCurStartCUAddr()==0))
+  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0))
   {
     printf ("Warning, the first slice of a picture might have been lost!\n");
@@ -810,4 +938,7 @@
   }
   m_bFirstSliceInSequence = false;
+#if SETTING_NO_OUT_PIC_PRIOR  
+  m_bFirstSliceInBitstream  = false;
+#endif
   //detect lost reference picture and insert copy of earlier frame.
   Int lostPoc;
@@ -1127,8 +1258,8 @@
 #endif
 #if H_3D
-  // Preliminary fix. assuming that all sps refer to the same SPS. 
+  // Preliminary fix. assuming that all sps refer to the same VPS. 
   // Parsing dependency should be resolved!
   TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
-  assert( vps != 0 ); 
+  assert( vps != 0 );
   m_cEntropyDecoder.decodeSPS( sps, vps->getViewIndex( m_layerId ), ( vps->getDepthId( m_layerId ) == 1 ) );
 #else
@@ -1182,9 +1313,9 @@
       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
       m_parameterSetManagerDecoder.applyPrefetchedPS();
-      assert(seiAps->activeSeqParamSetId.size()>0);
-#if H_MV
-      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0], m_layerId ))
-#else
-      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
+      assert(seiAps->activeSeqParameterSetId.size()>0);
+#if H_MV
+      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0], m_layerId ))
+#else
+      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] ))
 #endif
       {
@@ -1209,4 +1340,7 @@
     case NAL_UNIT_VPS:
       xDecodeVPS();
+#if H0056_EOS_CHECKS
+      m_isLastNALWasEos = false;
+#endif
       return false;
       
@@ -1221,4 +1355,10 @@
     case NAL_UNIT_PREFIX_SEI:
     case NAL_UNIT_SUFFIX_SEI:
+#if H0056_EOS_CHECKS
+      if ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_SEI )
+      {
+        assert( m_isLastNALWasEos == false );
+      }
+#endif
       xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
       return false;
@@ -1240,4 +1380,18 @@
     case NAL_UNIT_CODED_SLICE_RASL_N:
     case NAL_UNIT_CODED_SLICE_RASL_R:
+#if H0056_EOS_CHECKS
+      if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N ||
+          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TSA_N ||
+          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA_N ||
+          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N ||
+          nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N )
+      {
+        assert( m_isLastNALWasEos == false );
+      }
+      else
+      {
+        m_isLastNALWasEos = false;
+      }
+#endif
 #if H_MV
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
@@ -1247,4 +1401,14 @@
       break;
     case NAL_UNIT_EOS:
+#if H0056_EOS_CHECKS
+      assert( m_isLastNALWasEos == false );
+      //Check layer id of the nalu. if it is not 0, give a warning message and just return without doing anything.
+      if (nalu.m_layerId > 0)
+      {
+        printf( "\nThis bitstream has EOS with non-zero layer id.\n" );
+        return false;
+      }
+      m_isLastNALWasEos = true;
+#endif
       m_associatedIRAPType = NAL_UNIT_INVALID;
       m_pocCRA = 0;
@@ -1264,4 +1428,9 @@
       return false;
       
+    case NAL_UNIT_FILLER_DATA:
+#if H_MV
+      assert( m_isLastNALWasEos == false );
+#endif
+      return false;
       
     case NAL_UNIT_RESERVED_VCL_N10:
@@ -1284,5 +1453,4 @@
     case NAL_UNIT_RESERVED_VCL31:
       
-    case NAL_UNIT_FILLER_DATA:
     case NAL_UNIT_RESERVED_NVCL41:
     case NAL_UNIT_RESERVED_NVCL42:
Index: trunk/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 950)
+++ trunk/source/Lib/TLibDecoder/TDecTop.h	(revision 964)
@@ -195,4 +195,7 @@
   Bool*                    m_layerInitilizedFlag; // initialization Layers
   static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
+#if  H_MV_HLS_8_HRD_Q0102_08
+  Int                      m_targetOptLayerSetIdx; 
+#endif
 #else
   ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
@@ -225,4 +228,13 @@
   Bool                    m_prevSliceSkipped;
   Int                     m_skippedPOC;
+#if SETTING_NO_OUT_PIC_PRIOR  
+  Bool                    m_bFirstSliceInBitstream;
+  Int                     m_lastPOCNoOutputPriorPics;
+  Bool                    m_isNoOutputPriorPics;
+  Bool                    m_craNoRaslOutputFlag;    //value of variable NoRaslOutputFlag of the last CRA pic
+#endif
+#if H0056_EOS_CHECKS
+  Bool                    m_isLastNALWasEos;
+#endif
 
 #if H_MV
@@ -258,4 +270,12 @@
   
   Void  deletePicBuffer();
+#if H_MV
+#if H_MV_HLS_7_VPS_P0300_27
+  TComVPS* getActiveVPS() { return m_parameterSetManagerDecoder.getActiveVPS( ); }
+#endif
+  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS( m_layerId ); }
+#else
+  TComSPS* getActiveSPS() { return m_parameterSetManagerDecoder.getActiveSPS(); }
+#endif
 
 #if H_MV
@@ -265,4 +285,10 @@
 #endif
   
+#if SETTING_NO_OUT_PIC_PRIOR  
+  Void  checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic);
+
+  Bool  getNoOutputPriorPicsFlag () { return m_isNoOutputPriorPics; }
+  Void  setNoOutputPriorPicsFlag (bool val) { m_isNoOutputPriorPics = val; }
+#endif
 #if H_MV    
   TComPic*                getPic                ( Int poc );
@@ -270,4 +296,7 @@
   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
   Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
+#if  H_MV_HLS_8_HRD_Q0102_08
+  Void                    setTargetOptLayerSetIdx( Int targetOptLayerSetIdx ) { m_targetOptLayerSetIdx = targetOptLayerSetIdx; }    
+#endif
   TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present. 
   Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
