Index: branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 730)
@@ -85,5 +85,9 @@
   ("OutputBitDepthC,d", m_outputBitDepthC, 0, "bit depth of YUV output chroma component (default: use 0 for native depth)")
 #if H_MV
-  ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.")
+#if H_MV_6_HRD_O0217_13
+  ("TargetOptLayerSetIdx,x", m_targetOptLayerSetIdx, -1, "Target output layer set index. (default: -1, determine automatically to be equal to highest layer set index") // Should actually equal to 0 as default. However, this would cause only the base layer to be decoded.  
+#else
+  ("MaxLayerId,-ls", m_maxLayerId, MAX_NUM_LAYER_IDS-1, "Maximum LayerId to be decoded.")   
+#endif
 #endif
   ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
@@ -124,4 +128,7 @@
   if ( !cfg_TargetDecLayerIdSetFile.empty() )
   {
+#if H_MV_6_HRD_O0217_13
+    m_targetDecLayerIdSetFileEmpty = false;     
+#endif
     FILE* targetDecLayerIdSetFile = fopen ( cfg_TargetDecLayerIdSetFile.c_str(), "r" );
     if ( targetDecLayerIdSetFile )
@@ -167,4 +174,7 @@
   }
 #if H_MV
+#if H_MV_6_HRD_O0217_13
+  m_targetDecLayerIdSet.push_back( 0 );         // Only base layer at startup
+#else
   else
   {
@@ -174,4 +184,5 @@
     }
   }
+#endif
 #endif
 
Index: branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecCfg.h	(revision 730)
@@ -59,4 +59,7 @@
   Char*         m_pchBitstreamFile;                   ///< input bitstream file name
 #if H_MV
+#if H_MV_6_HRD_O0217_13
+  Int           m_targetOptLayerSetIdx;               ///< target output layer set index
+#endif
   Int           m_maxLayerId;                         ///< maximum nuh_layer_id decoded
   std::vector<Char*> m_pchReconFiles;                 ///< array of output reconstruction file name create from output reconstruction file name
@@ -74,4 +77,7 @@
 
   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
+#if H_MV_6_HRD_O0217_13
+  Bool          m_targetDecLayerIdSetFileEmpty;      ///< indication if target layers are given by file
+#endif
   Int           m_respectDefDispWindow;               ///< Only output content inside the default display window 
 
@@ -83,5 +89,7 @@
   : m_pchBitstreamFile(NULL)
 #if H_MV
+#if !H_MV_6_HRD_O0217_13
   , m_maxLayerId(0)
+#endif
 #endif
   , m_pchReconFile(NULL)
@@ -91,4 +99,7 @@
   , m_iMaxTemporalLayer(-1)
   , m_decodedPictureHashSEIEnabled(0)
+#if H_MV_6_HRD_O0217_13
+  , m_targetDecLayerIdSetFileEmpty(true)
+#endif
   , m_respectDefDispWindow(0)
   {}
Index: branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.cpp	(revision 730)
@@ -61,5 +61,13 @@
 {
 #if H_MV
+#if H_MV_LAYER_WISE_STARTUP
+  for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) 
+  {
+    m_layerIdToDecIdx[i] = -1; 
+    m_layerInitilizedFlags[i] = false; 
+  }
+#else
   for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) m_layerIdToDecIdx[i] = -1; 
+#endif
 #endif
 #if H_3D
@@ -184,4 +192,7 @@
     Bool newSliceDiffPoc   = false;
     Bool newSliceDiffLayer = false;
+#if H_MV_FIX_SKIP_PICTURES
+    Bool sliceSkippedFlag = false; 
+#endif
 #if H_3D
     Bool allLayersDecoded  = false;     
@@ -201,22 +212,58 @@
       read(nalu, nalUnit);
 #if H_MV      
-      Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );
-      
+#if !H_MV_6_HRD_O0217_13
+      Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );      
+#endif
+#if H_MV_6_LAYER_ID_32
+      if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) || nalu.m_layerId > MAX_NUM_LAYER_IDS-1 ) 
+#else            
       if( (m_iMaxTemporalLayer >= 0 && nalu.m_temporalId > m_iMaxTemporalLayer) || !isNaluWithinTargetDecLayerIdSet(&nalu) )
+#endif
       {
         bNewPicture = false;
+#if H_MV_6_LAYER_ID_32
+        if ( !bitstreamFile )
+        {
+          decIdxLastPic     = decIdxCurrPic; 
+        }
+#endif
       }
       else
-      { 
+      {
+#if H_MV_6_HRD_O0217_13
+        Int decIdx     = xGetDecoderIdx( nalu.m_layerId , true );      
+#endif
         newSliceDiffLayer = nalu.isSlice() && ( nalu.m_layerId != layerIdCurrPic ) && !firstSlice;
+#if H_MV_FIX_SKIP_PICTURES
+        newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer, sliceSkippedFlag );
+#else
         newSliceDiffPoc   = m_tDecTop[decIdx]->decode(nalu, m_iSkipFrame, m_pocLastDisplay[decIdx], newSliceDiffLayer );
+#endif
         // decode function only returns true when all of the following conditions are true
         // - poc in particular layer changes
         // - nalu does not belong to first slice in layer
-        // - nalu.isSlice() == true      
-
+        // - nalu.isSlice() == true              
+
+#if H_MV_6_HRD_O0217_13
+        // Update TargetDecLayerIdList only when not specified by layer id file, specification by file might actually out of conformance. 
+        if (nalu.m_nalUnitType == NAL_UNIT_VPS && m_targetDecLayerIdSetFileEmpty )
+        {
+          TComVPS* vps = m_tDecTop[decIdx]->getPrefetchedVPS(); 
+          if ( m_targetOptLayerSetIdx == -1 )
+          {
+            // Not normative! Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. ) 
+            m_targetOptLayerSetIdx = vps->getVpsNumLayerSetsMinus1(); 
+          }
+
+          m_targetDecLayerIdSet = vps->getTargetDecLayerIdList( m_targetOptLayerSetIdx ); 
+        }
+#endif
+#if H_MV_FIX_SKIP_PICTURES
+        bNewPicture       = ( newSliceDiffLayer || newSliceDiffPoc ) && !sliceSkippedFlag; 
+        if ( nalu.isSlice() && firstSlice && !sliceSkippedFlag )        
+#else
         bNewPicture       = newSliceDiffLayer || newSliceDiffPoc; 
-
         if ( nalu.isSlice() && firstSlice )
+#endif
         {
           layerIdCurrPic = nalu.m_layerId; 
@@ -832,4 +879,12 @@
 {
   Int decIdx = -1; 
+
+#if H_MV_6_LAYER_ID_32
+  if ( layerId > MAX_NUM_LAYER_IDS-1 )  
+  {
+    return decIdx; 
+  }
+#endif
+
   if ( m_layerIdToDecIdx[ layerId ] != -1 ) 
   {      
@@ -850,4 +905,8 @@
     m_tDecTop[ decIdx ]->setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     m_tDecTop[ decIdx ]->setIvPicLists( &m_ivPicLists ); 
+#if H_MV_LAYER_WISE_STARTUP
+    m_tDecTop[ decIdx ]->setLayerInitilizedFlags( m_layerInitilizedFlags );
+#endif
+
 #if H_3D
    m_tDecTop[ decIdx ]->setCamParsCollector( &m_cCamParsCollector );
Index: branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.h
===================================================================
--- branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/App/TAppDecoder/TAppDecTop.h	(revision 730)
@@ -67,4 +67,8 @@
   Int                             m_numDecoders;                               ///< number of decoder instances
   TComPicLists                    m_ivPicLists;                                ///< picture buffers of decoder instances
+#if H_MV_LAYER_WISE_STARTUP
+  Bool                            m_layerInitilizedFlags[ MAX_NUM_LAYER_IDS ]; ///< for layerwise startup 
+#endif
+
 #else
   TDecTop                         m_cTDecTop;                     ///< decoder class
