Index: branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 852)
+++ branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 854)
@@ -366,4 +366,45 @@
 
   READ_FLAG( uiCode, "pps_extension_flag");
+#if H_MV_HLS_7_GEN_P0166_PPS_EXTENSION
+  if (uiCode)
+  {
+#if H_MV
+    for ( Int i = 0; i < PPS_EX_T_MAX_NUM; i++ )
+    {
+      READ_FLAG( uiCode, "pps_extension_type_flag" ); pcPPS->setPpsExtensionTypeFlag( i, uiCode == 1 );
+#if H_3D
+      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_3D || i == PPS_EX_T_ESC ); 
+#else
+      assert( !pcPPS->getPpsExtensionTypeFlag( i ) || i == PPS_EX_T_MV || i == PPS_EX_T_ESC ); 
+#endif
+    }
+    
+
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_MV ) )
+    {
+#if H_MV_HLS7_GEN
+      READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 );
+#endif
+    }
+
+#if H_3D
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_3D ) ) // This probably needs to be aligned with Rext and SHVC
+    {
+      parsePPSExtension( pcPPS, pcVPS );
+    }
+#endif
+
+    if( pcPPS->getPpsExtensionTypeFlag( PPS_EX_T_ESC ) )
+    {
+#endif
+      while ( xMoreRbspData() )
+      {
+        READ_FLAG( uiCode, "pps_extension_data_flag");
+      }
+#if H_MV
+    }
+#endif
+  }
+#else
   if (uiCode)
   {
@@ -382,4 +423,5 @@
 #endif
   }
+#endif
 }
 
@@ -807,4 +849,8 @@
   assert(uiCode <= 12);
 
+#if H_MV_HLS_7_SPS_P0155_16_32
+  if ( pcSPS->getLayerId() == 0 ) 
+  {  
+#endif
   UInt subLayerOrderingInfoPresentFlag;
   READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
@@ -842,4 +888,7 @@
     }
   }
+#if H_MV_HLS_7_SPS_P0155_16_32
+  }
+#endif
 
   READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
@@ -1004,4 +1053,7 @@
     READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode );
     READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode );
+#if H_MV_HLS_7_RESERVED_FLAGS
+    READ_FLAG( uiCode, "sps_multilayer_ext_reserved_zero_flag[ i ]" );
+#endif
   }
 }
@@ -1039,5 +1091,7 @@
   READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
   assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
-#if H_MV
+
+
+#if H_MV && !H_MV_HLS7_GEN
   READ_CODE( 16, uiCode,  "vps_extension_offset" );               
 #else
@@ -1154,8 +1208,11 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
-  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+#if !H_MV_HLS7_GEN
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );
+  if ( pcVPS->getVpsVuiPresentFlag() )
   {  
   READ_CODE( 16, uiCode, "vps_vui_offset" );                      pcVPS->setVpsVuiOffset( uiCode );
   }
+#endif
 
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
@@ -1233,5 +1290,5 @@
   if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode );    
@@ -1242,5 +1299,5 @@
   else
   {
-    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
       pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1);    
@@ -1264,10 +1321,17 @@
 
   READ_FLAG( uiCode, "all_ref_layers_active_flag" );             pcVPS->setAllRefLayersActiveFlag( uiCode == 1 );
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1"      );  pcVPS->setVpsNumberLayerSetsMinus1    ( uiCode ); 
+#endif
+
+#if !H_MV_HLS7_GEN
   READ_CODE( 6,  uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );
-
+#else
+  READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );  
+#endif
   for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )
   {
     READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
+#if !H_MV_HLS_7_VPS_P0048_14
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {
@@ -1275,13 +1339,27 @@
       pcVPS->checkProfileRefMinus1( i );      
     }
+#endif
     parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {
       TComPTL temp = *pcVPS->getPTL( i );
+#if H_MV_HLS_7_VPS_P0048_14
+      *pcVPS->getPTL( i ) = *pcVPS->getPTL( i - 1 );
+#else
       *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 );
+#endif
       pcVPS->getPTL( i )->copyLevelFrom( &temp );
     }
   }
 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  READ_UVLC( uiCode, "num_add_output_layer_sets"      ); pcVPS->setNumAddOutputLayerSets( uiCode );
+  pcVPS->initTargetLayerIdLists( ); 
+  if( pcVPS->getNumOutputLayerSets() > 1)
+  {
+    READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); pcVPS->setDefaultTargetOutputLayerIdc( std::min( uiCode, (UInt) 2 ) );    
+  }  
+
+#else
   Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; 
 
@@ -1299,12 +1377,40 @@
     pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
   }  
+#endif
 
   pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
   pcVPS->setOutputLayerSetIdxMinus1(0, -1); 
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+  pcVPS->deriveTargetLayerIdList( 0 ); 
+  for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ )
+  {
+    if( i > pcVPS->getVpsNumLayerSetsMinus1( ) )    
+#else
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
     if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) )
+#endif
     {        
       READ_UVLC( uiCode,      "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); 
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    }
+
+    if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultTargetOutputLayerIdc() == 2 )
+    {       
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      {
+        READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); 
+      }
+    }
+    else
+    { 
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->getLayerSetIdxForOutputLayerSet( i ) ); j++ )
+      {              
+        pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }
+    pcVPS->deriveTargetLayerIdList( i ); 
+#else
       for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
       {
@@ -1320,9 +1426,17 @@
       }
     }
-
+#endif
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
       READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" );   pcVPS->setProfileLevelTierIdx( i , uiCode ); 
     }
+
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 )
+    {
+      READ_FLAG( uiCode, "alt_output_layer_flag[ i ]" ); pcVPS->setAltOutputLayerFlag( i, uiCode == 1 );
+    }
+  }
+#else
   }
   if( pcVPS->getMaxLayersMinus1() > 0 )
@@ -1330,9 +1444,18 @@
     READ_FLAG( uiCode, "alt_output_layer_flag" ); pcVPS->setAltOutputLayerFlag( uiCode == 1 );
   }
+#endif
+
+#if !H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
   pcVPS->deriveTargetLayerIdLists(); 
+#endif
+
   READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
   {
+#if H_MV_HLS7_GEN
+    READ_UVLC( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
+#else
     READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode );
+#endif
   }
 
@@ -1358,4 +1481,7 @@
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
+#if H_MV_HLS7_GEN
+  READ_FLAG( uiCode, "vps_poc_lsb_aligned_flag" ); pcVPS->setVpsPocLsbAlignedFlag( uiCode == 1 );
+#endif
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1366,4 +1492,7 @@
   }
 
+#if H_MV_HLS_7_RESERVED_FLAGS
+  READ_FLAG( uiCode, "vps_reserved_zero_flag" ); 
+#endif
   parseDpbSize( pcVPS ); 
 
@@ -1394,6 +1523,15 @@
   }  
 
+#if H_MV_HLS7_GEN
+  READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); 
+  for ( Int i = 1; i < pcVPS->getVpsNonVuiExtensionLength(); i++ )
+  {
+    READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" );
+  }
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+#endif
+#if !H_MV_HLS_7_RESERVED_FLAGS
   READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); 
-
+#endif
   if( pcVPS->getVpsVuiPresentFlag() )
   {
@@ -1401,4 +1539,11 @@
     parseVPSVUI( pcVPS ); 
   }     
+#if H_MV_HLS_7_FIX_INFER_CROSS_LAYER_IRAP_ALIGNED_FLAG
+  {
+    TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+    assert( pcVPSVUI ); 
+    pcVPSVUI->inferVpsVui( false ); 
+  }
+#endif
 
   pcVPS->checkVPSExtensionSyntax(); 
@@ -1448,9 +1593,19 @@
     READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 );
   }
+#if H_MV_HLS_7_MISC_P0068_21
+  if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) )
+  {
+    READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); pcVPSVUI->setAllLayersIdrAlignedFlag( 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 );
   if( pcVPSVUI->getBitRatePresentVpsFlag( )  ||  pcVPSVUI->getPicRatePresentVpsFlag( ) )
   {
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+    for( Int i = 0; i  <=  pcVPS->getVpsNumLayerSetsMinus1(); i++ )
+#else
     for( Int i = 0; i  <=  pcVPS->getVpsNumberLayerSetsMinus1(); i++ )
+#endif
     {
       for( Int j = 0; j  <=  pcVPS->getMaxTLayers(); j++ ) 
@@ -1477,4 +1632,40 @@
     }
   }
+
+#if H_MV_HLS_7_VPS_P0076_15
+  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
 
   READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
@@ -1513,4 +1704,8 @@
   }
 
+#if H_MV_HLS_7_RESERVED_FLAGS
+  READ_CODE( 3, uiCode, "vps_vui_reserved_zero_3bits" ); 
+#endif
+
   READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );
 
@@ -1534,4 +1729,5 @@
   }
 
+#if !H_MV_HLS_7_VPS_P0076_15
   READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
@@ -1567,4 +1763,5 @@
     }
   }
+#endif
   READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 );
   if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
@@ -1572,4 +1769,13 @@
     parseVpsVuiBspHrdParameters( pcVPS ); 
 }
+#if H_MV_HLS_7_MISC_P0182_13
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) 
+    {
+      READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); pcVPSVUI->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 );
+    }
+  }
+#endif
 }
 
@@ -1650,6 +1856,9 @@
   {  
     READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
-
+#if H_MV_HLS_7_HRD_P0156_7
+    for( Int j = 0; j  <=  vps->getMaxSubLayersInLayerSetMinus1( i ); j++ )
+#else
     for( Int j = 0; j  <=  vps->getMaxTLayers() - 1 ; j++ )
+#endif
     {  
       if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
@@ -1659,9 +1868,22 @@
       if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
       {  
+#if H_MV_HLS_7_OUTPUT_LAYERS_5_10_22_27
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getLayerSetIdxForOutputLayerSet( i )); k++ )   
+#else
         for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); 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 );
       }
@@ -1704,5 +1926,5 @@
 #if H_3D_SPIVMP
 #if SEC_SPIVMP_MCP_SIZE_G0077
-        READ_UVLC (uiCode, "log2_sub_PU_size_minus3");     pcVPS->setSubPULog2Size(i, uiCode+3); 
+        READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]");     pcVPS->setSubPULog2Size(i, uiCode+3); 
 #else
         READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
@@ -1761,4 +1983,8 @@
   for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++)
   {
+#if FIX_CAM_PARS_COLLECTOR
+    pcVPS->setCamParPresent         ( viewIndex, false );
+    pcVPS->setHasCamParInSliceHeader( viewIndex, false );
+#endif
     READ_FLAG( uiCode, "cp_present_flag[i]" );                  bCamParPresentFlag = ( uiCode == 1);
     if ( bCamParPresentFlag )
@@ -1890,4 +2116,5 @@
     rpcSlice->checkCrossLayerBlaFlag( ); 
 
+#if !H_MV_HLS7_GEN
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1895,4 +2122,5 @@
       READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
     }
+#endif
 
     for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
@@ -2492,6 +2720,6 @@
   if(pps->getSliceHeaderExtensionPresentFlag())
   {
+#if !H_MV_HLS7_GEN    
     READ_UVLC(uiCode,"slice_header_extension_length");
-
     for(Int i=0; i<uiCode; i++)
     {
@@ -2500,4 +2728,51 @@
     }
   }
+#else
+#if H_MV
+    READ_UVLC( uiCode, "slice_segment_header_extension_length" ); rpcSlice->setSliceSegmentHeaderExtensionLength( uiCode );
+    UInt posFollSliceSegHeaderExtLen = m_pcBitstream->getNumBitsRead();
+
+    if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
+    {
+      READ_CODE( 2, uiCode, "poc_reset_idc" ); rpcSlice->setPocResetIdc( uiCode );
+    }
+
+    if( rpcSlice->getPocResetIdc() !=  0 )
+    {
+      READ_CODE( 6, uiCode, "poc_reset_period_id" ); rpcSlice->setPocResetPeriodId( uiCode );
+    }
+    
+    if( rpcSlice->getPocResetIdc() ==  3 ) 
+    {
+      READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 );
+      READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode );
+    }          
+
+    if( !rpcSlice->getPocMsbValRequiredFlag() &&  rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() )
+    {
+      READ_FLAG( uiCode, "poc_msb_val_present_flag" ); rpcSlice->setPocMsbValPresentFlag( uiCode == 1 );
+    }
+    
+    if( rpcSlice->getPocMsbValPresentFlag() )
+    {
+      READ_UVLC( uiCode, "poc_msb_val" ); rpcSlice->setPocMsbVal( uiCode );
+    }
+
+    while( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) < rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 );
+    {
+     READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" );
+    }
+    assert( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) == rpcSlice->getSliceSegmentHeaderExtensionLength() * 8  ); 
+#else
+    READ_UVLC( uiCode, "slice_header_extension_length" );
+    for(Int i=0; i<uiCode; i++)
+    {
+      UInt ignore;
+      READ_CODE(8,ignore,"slice_header_extension_data_byte");
+    }
+  }
+#endif
+#endif
+
 
   m_pcBitstream->readByteAlignment();
Index: branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 852)
+++ branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecCu.cpp	(revision 854)
@@ -37,4 +37,5 @@
 
 #include "TDecCu.h"
+
 //! \ingroup TLibDecoder
 //! \{
@@ -638,5 +639,5 @@
   
   m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth );
-
+  
 #if H_MV_ENC_DEC_TRAC
 #if ENC_DEC_TRACE
@@ -927,5 +928,5 @@
   }
 #endif
-
+  
 #if H_3D && UPDATE_HM13
   Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps());
Index: branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 852)
+++ branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecGop.cpp	(revision 854)
@@ -43,4 +43,5 @@
 #include "libmd5/MD5.h"
 #include "TLibCommon/SEI.h"
+
 #include <time.h>
 
Index: branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 852)
+++ branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 854)
@@ -51,7 +51,9 @@
   m_aaiCodedOffset         = new Int* [ MAX_NUM_LAYERS ];
   m_aaiCodedScale          = new Int* [ MAX_NUM_LAYERS ];
+#if !FIX_CAM_PARS_COLLECTOR
   m_aiViewId               = new Int  [ MAX_NUM_LAYERS ];
 
   m_bViewReceived          = new Bool [ MAX_NUM_LAYERS ];
+#endif
   for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ )
   {
@@ -63,4 +65,8 @@
   m_iLog2Precision   = LOG2_DISP_PREC_LUT;
   m_uiBitDepthForLUT = 8; // fixed
+#if FIX_CAM_PARS_COLLECTOR
+  m_receivedIdc = NULL; 
+  m_vps         = NULL; 
+#endif
 }
 
@@ -74,11 +80,84 @@
   delete [] m_aaiCodedOffset;
   delete [] m_aaiCodedScale;
+#if !FIX_CAM_PARS_COLLECTOR
   delete [] m_aiViewId;  
   delete [] m_bViewReceived;
+#endif
 
   xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
   xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 );
-}
-
+#if FIX_CAM_PARS_COLLECTOR
+  xDeleteArray( m_receivedIdc, m_uiMaxViewIndex + 1 );
+#endif
+}
+
+
+#if FIX_CAM_PARS_COLLECTOR
+Void
+CamParsCollector::init( FILE* pCodedScaleOffsetFile, TComVPS* vps)
+{
+  assert( !isInitialized() ); // Only one initialization currently supported
+  m_bInitialized            = true;
+  m_vps                     = vps; 
+  m_bCamParsVaryOverTime    = false; 
+  m_pCodedScaleOffsetFile   = pCodedScaleOffsetFile;
+  m_lastPoc                 = -1;   
+  m_firstReceivedPoc        = -2; 
+
+  m_uiMaxViewIndex            = -1; 
+  for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++)
+  {
+    Int curViewIdx = m_vps->getViewIndex( m_vps->getLayerIdInNuh( i )); 
+    m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->hasCamParInSliceHeader( curViewIdx );
+    m_uiMaxViewIndex = std::max( m_uiMaxViewIndex, curViewIdx  ) ; 
+  }
+
+  assert( m_receivedIdc == NULL ); 
+  m_receivedIdc = new Int*[ m_uiMaxViewIndex + 1]; 
+  for (Int i = 0; i <= m_uiMaxViewIndex; i++)
+  {
+    m_receivedIdc[i] = new Int[ m_uiMaxViewIndex + 1 ]; 
+  }
+
+  xResetReceivedIdc( true ); 
+
+  for (Int viewIndex = 0; viewIndex <= m_uiMaxViewIndex ; viewIndex++ )
+  {
+    if (m_vps->getCamParPresent( viewIndex ) )
+    {    
+      if( !m_vps->hasCamParInSliceHeader( viewIndex ) ) 
+      {
+        for (Int baseViewIndex = 0; baseViewIndex < viewIndex ; baseViewIndex++ )
+        { 
+          m_receivedIdc   [ baseViewIndex ][ viewIndex ] = -1; 
+          m_aaiCodedScale [ baseViewIndex ][ viewIndex ] = m_vps->getCodedScale    (viewIndex) [ baseViewIndex ];
+          m_aaiCodedOffset[ baseViewIndex ][ viewIndex ] = m_vps->getCodedOffset   (viewIndex) [ baseViewIndex ];
+
+          m_receivedIdc   [ viewIndex ][ baseViewIndex ] = -1; 
+          m_aaiCodedScale [ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedScale (viewIndex) [ baseViewIndex ];
+          m_aaiCodedOffset[ viewIndex ][ baseViewIndex ] = m_vps->getInvCodedOffset(viewIndex) [ baseViewIndex ];
+          xInitLUTs( baseViewIndex, viewIndex, m_aaiCodedScale[ baseViewIndex ][ viewIndex ], m_aaiCodedOffset[ baseViewIndex ][ viewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
+          xInitLUTs( viewIndex, baseViewIndex, m_aaiCodedScale[ viewIndex ][ baseViewIndex ], m_aaiCodedOffset[ viewIndex ][ baseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
+        }
+      }
+    }
+  }
+}
+
+Void
+CamParsCollector::xResetReceivedIdc( Bool overWriteFlag )
+{
+  for (Int i = 0; i <= m_uiMaxViewIndex; i++)
+  {  
+    for (Int j = 0; j <= m_uiMaxViewIndex; j++)
+    {
+      if ( overWriteFlag ||  ( m_receivedIdc[i][j] != -1 ) )
+      {
+        m_receivedIdc[i][j] = 0; 
+      }      
+    }
+  }
+}
+#else
 Void
 CamParsCollector::init( FILE* pCodedScaleOffsetFile )
@@ -92,4 +171,7 @@
   m_uiMaxViewIndex             = 0;
 }
+#endif
+
+
 
 Void
@@ -124,5 +206,9 @@
   CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
 {
+#if FIX_CAM_PARS_COLLECTOR
+  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_vps->getCamParPrecision() + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
+#else
   Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
+#endif
   Int     iLog2DivChroma = iLog2DivLuma + 1;
 
@@ -166,4 +252,5 @@
 }
 
+#if !FIX_CAM_PARS_COLLECTOR
 Void
 CamParsCollector::setSlice( TComSlice* pcSlice )
@@ -284,4 +371,76 @@
 }
 
+#else
+Void
+CamParsCollector::setSlice( TComSlice* pcSlice )
+{
+  if( pcSlice == 0 )
+  {
+    xOutput( m_lastPoc );
+    return;
+  }
+
+  if ( pcSlice->getIsDepth())
+  {
+    return;
+  }
+
+  Int curPoc = pcSlice->getPOC();
+  if( m_firstReceivedPoc == -2 )
+  {
+    m_firstReceivedPoc = curPoc; 
+  }
+
+  Bool newPocFlag = ( m_lastPoc != curPoc );  
+
+  if ( newPocFlag )
+  {    
+    if( m_lastPoc != -1 )
+    {
+      xOutput( m_lastPoc );
+    }
+
+    xResetReceivedIdc( false ); 
+    m_lastPoc = pcSlice->getPOC();
+  }
+
+  UInt uiViewIndex          = pcSlice->getViewIndex();  
+  if( m_vps->getCamParPresent( uiViewIndex ) )
+  {    
+    if( m_vps->hasCamParInSliceHeader( uiViewIndex ) ) // check consistency of slice parameters here
+    {   
+      for( UInt uiBaseViewIndex = 0; uiBaseViewIndex < uiViewIndex; uiBaseViewIndex++ )
+      {        
+        if ( m_receivedIdc[ uiViewIndex ][ uiBaseViewIndex ] != 0 )
+        {      
+          AOF( m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedScale () [ uiBaseViewIndex ] );
+          AOF( m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ] == pcSlice->getInvCodedOffset() [ uiBaseViewIndex ] );
+        }
+        else
+        {          
+          m_receivedIdc   [ uiViewIndex ][ uiBaseViewIndex ]  = 1; 
+          m_aaiCodedScale [ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedScale () [ uiBaseViewIndex ];
+          m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ]  = pcSlice->getInvCodedOffset() [ uiBaseViewIndex ];
+          xInitLUTs( uiViewIndex, uiBaseViewIndex, m_aaiCodedScale[ uiViewIndex ][ uiBaseViewIndex ], m_aaiCodedOffset[ uiViewIndex ][ uiBaseViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
+        }
+        if ( m_receivedIdc[ uiBaseViewIndex ][ uiViewIndex ] != 0 )
+        {      
+          AOF( m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedScale    () [ uiBaseViewIndex ] );
+          AOF( m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ] == pcSlice->getCodedOffset   () [ uiBaseViewIndex ] );
+        }
+        else
+        {        
+          m_receivedIdc   [ uiBaseViewIndex ][ uiViewIndex ]  = 1; 
+          m_aaiCodedScale [ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedScale    () [ uiBaseViewIndex ];
+          m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ]  = pcSlice->getCodedOffset   () [ uiBaseViewIndex ];
+          xInitLUTs( uiBaseViewIndex, uiViewIndex, m_aaiCodedScale[ uiBaseViewIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseViewIndex ][ uiViewIndex ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
+        }
+      }
+    }
+  }
+}
+#endif
+
+
 #if H_3D_IV_MERGE
 Void
@@ -295,4 +454,5 @@
 #endif
 
+#if !FIX_CAM_PARS_COLLECTOR
 Bool
 CamParsCollector::xIsComplete()
@@ -307,4 +467,5 @@
   return true;
 }
+#endif
 
 Void
@@ -313,11 +474,21 @@
   if( m_pCodedScaleOffsetFile )
   {
+#if FIX_CAM_PARS_COLLECTOR
+    if( iPOC == m_firstReceivedPoc )
+#else
     if( iPOC == 0 )
+#endif
     {
       fprintf( m_pCodedScaleOffsetFile, "#  ViewIndex       ViewId\n" );
       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------\n" );
+#if FIX_CAM_PARS_COLLECTOR
       for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
       {
+        fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_vps->getViewIdVal( uiViewIndex ) );
+#else        
+      for( UInt uiViewIndex = 0; uiViewIndex <= m_uiMaxViewIndex; uiViewIndex++ )
+      {
         fprintf( m_pCodedScaleOffsetFile, "%12d %12d\n", uiViewIndex, m_aiViewId[ uiViewIndex ] );
+#endif
       }
       fprintf( m_pCodedScaleOffsetFile, "\n\n");
@@ -325,5 +496,9 @@
       fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" );
     }
+#if FIX_CAM_PARS_COLLECTOR
+    if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime  )
+#else
     if( iPOC == 0 || m_bCamParsVaryOverTime )
+#endif
     {
       Int iS = iPOC;
@@ -335,6 +510,15 @@
           if( uiViewIndex != uiBaseIndex )
           {
+#if FIX_CAM_PARS_COLLECTOR
+            if ( m_receivedIdc[uiBaseIndex][uiViewIndex] != 0 )
+            {            
+              fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
+                iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_vps->getCamParPrecision() );
+            }            
+#else
             fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n",
               iS, iE, uiViewIndex, uiBaseIndex, m_aaiCodedScale[ uiBaseIndex ][ uiViewIndex ], m_aaiCodedOffset[ uiBaseIndex ][ uiViewIndex ], m_uiCamParsCodedPrecision );
+#endif
+
           }
         }
@@ -457,8 +641,30 @@
   for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) 
   {
+#if H_MV_HLS_7_SPS_P0155_16_32
+    numReorderPics[temporalLayer] = ( getLayerId() == 0 ) ? pcSlice->getSPS()->getNumReorderPics(temporalLayer) : pcSlice->getVPS()->getNumReorderPics(temporalLayer);
+#else
     numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
-  }
-
+#endif
+  }
+#if H_MV_HLS_7_SPS_P0155_16_32
+  if ( getLayerId() == 0 )
+  {  
+    m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
+  }
+  else
+  {
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxDecPicBuffering(pcSlice->getTLayer());
+#if H_MV_HLS7_GEN
+    TComVPS* vps         = pcSlice->getVPS();
+    TComDpbSize* dpbSize = vps->getDpbSize(); 
+    Int lsIdx            = vps->getLayerSetIdxForOutputLayerSet( getTargetOutputLayerSetIdx()); // Is this correct, seems to be missing in spec?
+    Int layerIdx         = vps->getIdxInLayerSet     ( lsIdx, getLayerId() ); 
+    Int subDpbIdx        = dpbSize->getSubDpbAssigned( lsIdx, layerIdx ); 
+    m_iMaxRefPicNum      = dpbSize->getMaxVpsDecPicBufferingMinus1(getTargetOutputLayerSetIdx(), subDpbIdx , vps->getSubLayersVpsMaxMinus1( vps->getLayerIdInVps( getLayerId() ) ) + 1 ) + 1 ;  
+#endif    
+  }
+#else
   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer());     // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#endif
   if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
   {
Index: branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 852)
+++ branches/HTM-10.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 854)
@@ -71,5 +71,10 @@
   ~CamParsCollector ();
 
+#if FIX_CAM_PARS_COLLECTOR
+  Void  init        ( FILE* pCodedScaleOffsetFile, TComVPS* vps );
+#else
   Void  init        ( FILE* pCodedScaleOffsetFile );
+#endif
+
   Void  uninit      ();
   Void  setSlice    ( TComSlice* pcSlice );
@@ -85,9 +90,13 @@
   Int getCodedScale( Int iBaseView, Int iCureView){ return m_aaiCodedScale[ iBaseView ][ iCureView ];}
   Int getCodedOffset( Int iBaseView, Int iCureView){ return m_aaiCodedOffset[ iBaseView ][ iCureView ];}
-  UInt getCamParsCodedPrecision(){ return m_uiCamParsCodedPrecision; }
+  UInt getCamParsCodedPrecision(){ return m_vps->getCamParPrecision(); }
 #endif
 
 private:
+#if FIX_CAM_PARS_COLLECTOR
+  Void xResetReceivedIdc( Bool overWriteFlag ); 
+#else
   Bool  xIsComplete ();
+#endif
   Void  xOutput     ( Int iPOC );
 
@@ -98,12 +107,26 @@
   Int**   m_aaiCodedOffset;
   Int**   m_aaiCodedScale;
+  
+#if !FIX_CAM_PARS_COLLECTOR
   Int*    m_aiViewId;  
-
+#else
+  TComVPS* m_vps; 
+  Int**    m_receivedIdc; 
+  Int      m_uiMaxViewIndex; 
+  Int      m_lastPoc; 
+  Int      m_firstReceivedPoc; 
+#endif
+
+  
+#if !FIX_CAM_PARS_COLLECTOR
   Bool*   m_bViewReceived;
   UInt    m_uiCamParsCodedPrecision;
+#endif
   Bool    m_bCamParsVaryOverTime;
+#if !FIX_CAM_PARS_COLLECTOR
   Int     m_iLastViewIndex;
   Int     m_iLastPOC;
   UInt    m_uiMaxViewIndex;
+#endif
 
 
