Index: trunk/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 735)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 738)
@@ -391,5 +391,9 @@
   ("VpsNumLayerSets",       m_vpsNumLayerSets    , 1                    , "Number of layer sets")    
   ("LayerIdsInSet_%d",      m_layerIdsInSets     , std::vector<Int>(1,0), MAX_VPS_OP_SETS_PLUS1 ,"LayerIds of Layer set")  
+#if H_MV_6_PS_0109_25
+  ("DefaultOneTargetOutputLayerFlag"  , m_defaultOneTargetOutputLayerIdc  , 0, "Output highest layer of layer sets by default")
+#else
   ("DefaultOneTargetOutputLayerFlag", m_defaultOneTargetOutputLayerFlag,  false , "Output highest layer of layer sets by default")      
+#endif
   ("OutputLayerSetIdx",     m_outputLayerSetIdx  , std::vector<Int>(0,0), "Indices of layer sets used as additional output layer sets")  
   ("LayerIdsInAddOutputLayerSet_%d", m_layerIdsInAddOutputLayerSet      , std::vector<Int>(1,0), MAX_VPS_ADD_OUTPUT_LAYER_SETS, "LayerIds of additional output layers")  
@@ -448,6 +452,10 @@
   ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
   
-  // Coding structure paramters
+  // Coding structure parameters
+#if H_MV_LAYER_WISE_STARTUP
+  ("IntraPeriod,-ip",         m_iIntraPeriod,std::vector<Int>(1,-1), "Intra period in frames, (-1: only first frame), per layer")
+#else
   ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
+#endif
   ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
   ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
@@ -624,6 +632,15 @@
 
 #if H_MV
+
+#if H_MV_6_HRD_O0217_13
+  // DBP Size
+  ("SubLayerFlagInfoPresentFlag",  m_subLayerFlagInfoPresentFlag , false                                           , "SubLayerFlagInfoPresentFlag")
+#endif
   // VPS VUI
   ("VpsVuiPresentFlag"           , m_vpsVuiPresentFlag           , false                                           , "VpsVuiPresentFlag           ")
+#if H_MV_6_PS_O0223_29
+  ("CrossLayerPicTypeAlignedFlag", m_crossLayerPicTypeAlignedFlag, false                                           , "CrossLayerPicTypeAlignedFlag")  // Could actually be derived by the encoder
+  ("CrossLayerIrapAlignedFlag"   , m_crossLayerIrapAlignedFlag   , false                                           , "CrossLayerIrapAlignedFlag   ")  // Could actually be derived by the encoder
+#endif
   ("BitRatePresentVpsFlag"       , m_bitRatePresentVpsFlag       , false                                           , "BitRatePresentVpsFlag       ")
   ("PicRatePresentVpsFlag"       , m_picRatePresentVpsFlag       , false                                           , "PicRatePresentVpsFlag       ")
@@ -634,4 +651,11 @@
   ("ConstantPicRateIdc"          , m_constantPicRateIdc          , std::vector< Int  >(1,0)  ,MAX_VPS_OP_SETS_PLUS1, "ConstantPicRateIdc per sub layer for the N-th layer set")
   ("AvgPicRate"                  , m_avgPicRate                  , std::vector< Int  >(1,0)  ,MAX_VPS_OP_SETS_PLUS1, "AvgPicRate         per sub layer for the N-th layer set")
+#if H_MV_6_O0226_37
+  ("TilesNotInUseFlag"            , m_tilesNotInUseFlag            , true                                          , "TilesNotInUseFlag            ")
+  ("TilesInUseFlag"               , m_tilesInUseFlag               , std::vector< Bool >(1,false)                   , "TilesInUseFlag               ")
+  ("LoopFilterNotAcrossTilesFlag" , m_loopFilterNotAcrossTilesFlag , std::vector< Bool >(1,false)                  , "LoopFilterNotAcrossTilesFlag ")
+  ("WppNotInUseFlag"              , m_wppNotInUseFlag              , true                                          , "WppNotInUseFlag              ")
+  ("WppInUseFlag"                 , m_wppInUseFlag                 , std::vector< Bool >(1,0)                      , "WppInUseFlag                 ")
+#endif
   ("TileBoundariesAlignedFlag"   , m_tileBoundariesAlignedFlag   , std::vector< Bool >(1,0)  ,MAX_NUM_LAYERS       , "TileBoundariesAlignedFlag    per direct reference for the N-th layer")
   ("IlpRestrictedRefLayersFlag"  , m_ilpRestrictedRefLayersFlag  , false                                           , "IlpRestrictedRefLayersFlag")
@@ -1050,5 +1074,12 @@
   xResizeVector( m_bLoopFilterDisable ); 
   xResizeVector( m_bUseSAO ); 
-
+#if H_MV_LAYER_WISE_STARTUP
+  xResizeVector( m_iIntraPeriod ); 
+#endif
+#if H_MV_6_O0226_37
+  xResizeVector( m_tilesInUseFlag ); 
+  xResizeVector( m_loopFilterNotAcrossTilesFlag ); 
+  xResizeVector( m_wppInUseFlag ); 
+#endif
 #else
   m_aidQP = new Int[ m_framesToBeEncoded + m_iGOPSize + 1 ];
@@ -1395,5 +1426,9 @@
     for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++ )
     {
+#if H_MV_6_LAYER_ID_32
+      xConfirmPara( m_layerIdsInSets[lsIdx][i] < 0 || m_layerIdsInSets[lsIdx].size() >= MAX_NUM_LAYER_IDS, "LayerIdsInSet must be greater than and less than MAX_NUM_LAYER_IDS" ); 
+#else
       xConfirmPara( m_layerIdsInSets[lsIdx][i] < 0 || m_layerIdsInSets[lsIdx].size() >= MAX_NUM_LAYER_IDS, "LayerIdsInSet must be greater than and less than 64" ); 
+#endif
     }
   }
@@ -1420,4 +1455,8 @@
     }
   }
+
+#if H_MV_6_PS_0109_25
+  xConfirmPara( m_defaultOneTargetOutputLayerIdc < 0 || m_defaultOneTargetOutputLayerIdc > 1, "Default one target output layer idc must be equal to 0 or equal to 1" );
+#endif
   xConfirmPara( m_profileLevelTierIdx.size() < m_vpsNumLayerSets + m_outputLayerSetIdx.size(), "The number of Profile Level Tier indices must be equal to the number of layer set plus the number of output layer set indices" );
 
@@ -1436,5 +1475,12 @@
   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
   xConfirmPara( m_iGOPSize > 1 &&  m_iGOPSize % 2,                                          "GOP Size must be a multiple of 2, if GOP Size is greater than 1" );
+#if H_MV_LAYER_WISE_STARTUP
+  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
+  {
+    xConfirmPara( (m_iIntraPeriod[layer] > 0 && m_iIntraPeriod[layer] < m_iGOPSize) || m_iIntraPeriod[layer] == 0, "Intra period must be more than GOP size, or -1 , not 0" );
+  }
+#else
   xConfirmPara( (m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0, "Intra period must be more than GOP size, or -1 , not 0" );
+#endif
   xConfirmPara( m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,                   "Decoding Refresh Type must be equal to 0, 1 or 2" );
 #if H_MV
@@ -1462,5 +1508,12 @@
   if (m_iDecodingRefreshType == 2)
   {
+#if H_MV_LAYER_WISE_STARTUP
+    for (Int i = 0; i < m_numberOfLayers; i++ )
+    {
+      xConfirmPara( m_iIntraPeriod[i] > 0 && m_iIntraPeriod[i] <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
+    }
+#else
     xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize ,                      "Intra period must be larger than GOP size for periodic IDR pictures");
+#endif
   }
   xConfirmPara( (m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,                                    "Minimum partition width size should be larger than or equal to 8");
@@ -1721,5 +1774,9 @@
   /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
    * This permits the ability to omit a GOP structure specification */
+#if H_MV_LAYER_WISE_STARTUP
+  if (m_iIntraPeriod[layer] == 1 && m_GOPList[0].m_POC == -1) {
+#else
   if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1) {
+#endif
     m_GOPList[0] = GOPEntry();
     m_GOPList[0].m_QPFactor = 1;
@@ -1746,5 +1803,9 @@
   }
   Int numOK=0;
+#if H_MV_LAYER_WISE_STARTUP
+  xConfirmPara( m_iIntraPeriod[layer] >=0&&(m_iIntraPeriod[layer]%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" ); 
+#else
   xConfirmPara( m_iIntraPeriod >=0&&(m_iIntraPeriod%m_iGOPSize!=0), "Intra period must be a multiple of GOPSize, or -1" );
+#endif
 
   for(Int i=0; i<m_iGOPSize; i++)
@@ -1757,5 +1818,9 @@
   
 #if H_MV
+#if H_MV_LAYER_WISE_STARTUP
+  if ( (m_iIntraPeriod[layer] != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable[layer]) )
+#else
   if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable[layer]) )
+#endif
 #else
   if ( (m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable) )
@@ -2282,5 +2347,9 @@
   printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
   printf("Motion search range          : %d\n", m_iSearchRange );
+#if H_MV_LAYER_WISE_STARTUP
+  xPrintParaVector( "Intra period", m_iIntraPeriod );
+#else
   printf("Intra period                 : %d\n", m_iIntraPeriod );
+#endif
   printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType );
 #if !H_MV
Index: trunk/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 735)
+++ trunk/source/App/TAppEncoder/TAppEncCfg.h	(revision 738)
@@ -89,5 +89,9 @@
   Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
   std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
+#if H_MV_6_PS_0109_25
+  Int                    m_defaultOneTargetOutputLayerIdc;    ///< Output highest layer of layer sets by default when equal to 1
+#else
   Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default  
+#endif
   std::vector<Int>       m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
   std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds in vps of additional output layers
@@ -98,6 +102,15 @@
   std::vector< std::vector<Int> > m_dependencyTypes;          ///< Dependency types of direct reference layers
 
+#if H_MV_6_HRD_O0217_13
+  // DBP Size
+  Bool m_subLayerFlagInfoPresentFlag;
+#endif
+
   // VPS VUI
   Bool m_vpsVuiPresentFlag;
+#if H_MV_6_PS_O0223_29
+  Bool m_crossLayerPicTypeAlignedFlag;
+  Bool m_crossLayerIrapAlignedFlag;
+#endif
   Bool m_bitRatePresentVpsFlag;
   Bool m_picRatePresentVpsFlag;
@@ -108,4 +121,12 @@
   std::vector< std::vector<Int  > > m_constantPicRateIdc;
   std::vector< std::vector<Int  > > m_avgPicRate;
+#if H_MV_6_O0226_37
+  Bool                              m_tilesNotInUseFlag; 
+  std::vector< Bool >               m_tilesInUseFlag;
+  std::vector< Bool >               m_loopFilterNotAcrossTilesFlag; 
+  Bool                              m_wppNotInUseFlag;
+  std::vector< Bool >               m_wppInUseFlag;
+
+#endif
   std::vector< std::vector<Bool > > m_tileBoundariesAlignedFlag;  
   Bool m_ilpRestrictedRefLayersFlag;
@@ -175,5 +196,9 @@
   
   // coding structure
+#if H_MV_LAYER_WISE_STARTUP
+  std::vector<Int> m_iIntraPeriod;                            ///< period of I-slice (random access period)
+#else
   Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
+#endif
   Int       m_iDecodingRefreshType;                           ///< random access type
   Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
Index: trunk/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 735)
+++ trunk/source/App/TAppEncoder/TAppEncTop.cpp	(revision 738)
@@ -216,5 +216,5 @@
 
     m_cTEncTop.setIvPicLists                   ( &m_ivPicLists ); 
-#endif // H_MV
+  // H_MV
   m_cTEncTop.setVPS(&vps);
 
@@ -234,5 +234,9 @@
   
   //====== Coding Structure ========
+#if H_MV_LAYER_WISE_STARTUP
+  m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod[ layerIdInVps ] );
+#else
   m_cTEncTop.setIntraPeriod                  ( m_iIntraPeriod );
+#endif
   m_cTEncTop.setDecodingRefreshType          ( m_iDecodingRefreshType );
   m_cTEncTop.setGOPSize                      ( m_iGOPSize );
@@ -1332,8 +1336,15 @@
   Int maxViewId = xGetMax( m_viewId ); 
 
+#if H_MV_6_PS_O0109_22
+  Int viewIdLen = gCeilLog2( maxViewId + 1 ); 
+  const Int maxViewIdLen = ( 1 << 4 ) - 1; 
+  assert( viewIdLen <= maxViewIdLen ); 
+  vps.setViewIdLen( viewIdLen ); 
+#else
   Int viewIdLenMinus1 = std::max( gCeilLog2( maxViewId + 1 ) - 1, 0 ) ; 
   const Int maxViewIdLenMinus1 = ( 1 << 4 ) - 1; 
   assert( viewIdLenMinus1 <= maxViewIdLenMinus1  ); 
   vps.setViewIdLenMinus1( viewIdLenMinus1 ); 
+#endif
   for (Int i = 0; i < m_iNumberOfViews; i++)
   {
@@ -1355,4 +1366,9 @@
     }
     }
+
+#if H_MV_6_PS_O0096_21
+  Int  defaultDirectDependencyType = -1; 
+  Bool defaultDirectDependencyFlag = true; 
+#endif
   for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
   {
@@ -1363,7 +1379,55 @@
       Int refLayer = m_directRefLayers[depLayer][i]; 
       vps.setDirectDependencyFlag( depLayer, refLayer, true); 
+#if H_MV_6_PS_O0096_21
+      Int curDirectDependencyType = m_dependencyTypes[depLayer][i]; 
+
+      if ( defaultDirectDependencyType != -1 )    
+      {
+        defaultDirectDependencyFlag = defaultDirectDependencyFlag && (curDirectDependencyType == defaultDirectDependencyType );         
+      }
+      else
+      {
+        defaultDirectDependencyType = curDirectDependencyType; 
+      }
+      
+      vps.setDirectDependencyType( depLayer, refLayer, curDirectDependencyType);       
+#else
       vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); 
-    }
-  }
+#endif
+    }
+  }
+
+#if H_MV_6_PS_O0096_21
+  vps.setDefaultDirectDependencyFlag( defaultDirectDependencyFlag );       
+  vps.setDefaultDirectDependencyType( defaultDirectDependencyFlag ? defaultDirectDependencyType : -1 );       
+#endif
+
+#if H_MV_6_ILDSD_O0120_26
+  // Max sub layers, + presence flag
+  Bool subLayersMaxMinus1PresentFlag = false; 
+  Int  subLayersMaxMinus1 = -1; 
+  for (Int curLayerIdInVps = 0; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++ )
+  {
+    Int curSubLayersMaxMinus1 = -1; 
+    for( Int i = 0; i < getGOPSize(); i++ ) 
+    {
+      GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
+      curSubLayersMaxMinus1 = std::max( curSubLayersMaxMinus1, geCur.m_temporalId ); 
+    }  
+
+    vps.setSubLayersVpsMaxMinus1( curLayerIdInVps, curSubLayersMaxMinus1 ); 
+    if ( subLayersMaxMinus1 == -1 )
+    {
+      subLayersMaxMinus1 = curSubLayersMaxMinus1; 
+    }
+    else
+    {
+      subLayersMaxMinus1PresentFlag = subLayersMaxMinus1PresentFlag || ( curSubLayersMaxMinus1 != subLayersMaxMinus1 ); 
+    }
+  }
+
+  vps.setVpsSubLayersMaxMinus1PresentFlag( subLayersMaxMinus1PresentFlag ); 
+#endif
+
 
   // Max temporal id for inter layer reference pictures + presence flag
@@ -1371,7 +1435,12 @@
   for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
     {
+#if !H_MV_6_ILDDS_O0225_30
     Int maxTid = -1; 
+#endif
     for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
       {
+#if H_MV_6_ILDDS_O0225_30
+      Int maxTid = -1; 
+#endif
       for( Int i = 0; i < getGOPSize(); i++ ) 
       {        
@@ -1387,7 +1456,13 @@
         }
       }
+#if H_MV_6_ILDDS_O0225_30    
+      vps.setMaxTidIlRefPicsPlus1( refLayerIdInVps, curLayerIdInVps, maxTid + 1 );
+      maxTidRefPresentFlag = maxTidRefPresentFlag || ( maxTid != 6 );    
+    }
+#else
     }
     vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
     maxTidRefPresentFlag = maxTidRefPresentFlag || ( maxTid != 6 );    
+#endif
   }
 
@@ -1406,4 +1481,14 @@
   vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
   
+  // Poc Lsb Not Present Flag
+#if H_MV_6_MISC_O0062_31
+  for ( Int layerIdInVps = 1; layerIdInVps < m_numberOfLayers; layerIdInVps++)
+  {
+    if ( m_directRefLayers[ layerIdInVps ].size() == 0 ) 
+    {    
+      vps.setPocLsbNotPresentFlag( layerIdInVps,  true );  
+    }
+  }
+#endif
   
   // All Ref layers active flag
@@ -1414,5 +1499,43 @@
     {        
       GOPEntry ge =  m_GOPListMvc[layerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+      Int tId = ge.m_temporalId;  // Should be equal for all layers. 
+      
+      // check if all reference layers when allRefLayerActiveFlag is equal to 1 are reference layer pictures specified in the gop entry
+      for (Int k = 0; k < m_directRefLayers[ layerIdInVps].size() && allRefLayersActiveFlag; k++ )
+      {
+        Int refLayerIdInVps = vps.getLayerIdInVps( m_directRefLayers[ layerIdInVps ][ k ] ); 
+        if ( vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId  && vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId )
+        {
+          Bool gopEntryFoundFlag = false; 
+          for( Int l = 0; l < ge.m_numActiveRefLayerPics && !gopEntryFoundFlag; l++ )
+          {
+            gopEntryFoundFlag = gopEntryFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); 
+          }          
+          allRefLayersActiveFlag = allRefLayersActiveFlag && gopEntryFoundFlag;  
+        }        
+      }
+
+      // check if all inter layer reference pictures specified in the gop entry are valid reference layer pictures when allRefLayerActiveFlag is equal to 1 
+      // (Should actually always be true) 
+      Bool maxTidIlRefAndSubLayerMaxVaildFlag = true; 
+      for( Int l = 0; l < ge.m_numActiveRefLayerPics; l++ )
+      {   
+        Bool referenceLayerFoundFlag = false; 
+        for (Int k = 0; k < m_directRefLayers[ layerIdInVps].size(); k++ )
+        {
+          Int refLayerIdInVps = vps.getLayerIdInVps( m_directRefLayers[ layerIdInVps ][ k ] ); 
+
+          if ( vps.getMaxTidIlRefPicsPlus1(refLayerIdInVps,layerIdInVps) > tId  && vps.getSubLayersVpsMaxMinus1(refLayerIdInVps) >= tId )
+          {          
+            referenceLayerFoundFlag = referenceLayerFoundFlag || ( ge.m_interLayerPredLayerIdc[l] == k ); 
+          }          
+        }
+       maxTidIlRefAndSubLayerMaxVaildFlag = maxTidIlRefAndSubLayerMaxVaildFlag && referenceLayerFoundFlag;  
+      }
+      assert ( maxTidIlRefAndSubLayerMaxVaildFlag ); // Something wrong with MaxTidIlRefPicsPlus1 or SubLayersVpsMaxMinus1
+#else
       allRefLayersActiveFlag = allRefLayersActiveFlag && (ge.m_numActiveRefLayerPics == m_directRefLayers[ layerIdInVps ].size() ); 
+#endif
     }            
   }
@@ -1420,6 +1543,8 @@
   vps.setAllRefLayersActiveFlag( allRefLayersActiveFlag );
 
+#if !H_MV_6_PS_O0223_29
   // Currently cross layer irap aligned is always true.   
   vps.setCrossLayerIrapAlignedFlag( true ); 
+#endif
   vps.setRefLayers(); 
 }; 
@@ -1491,4 +1616,7 @@
   repFormat->setPicHeightVpsInLumaSamples ( m_iSourceHeight );
   repFormat->setPicWidthVpsInLumaSamples  ( m_iSourceWidth  );    
+#if H_MV_6_PS_REP_FORM_18_19_20
+  repFormat->setChromaAndBitDepthVpsPresentFlag( true );    
+#endif
   // ToDo not supported yet. 
   //repFormat->setSeparateColourPlaneVpsFlag( );
@@ -1502,4 +1630,63 @@
   }
 }
+
+#if H_MV_6_HRD_O0217_13
+Void TAppEncTop::xSetDpbSize                ( TComVPS& vps )
+{
+  // These settings need to be verified
+
+  TComDpbSize* dpbSize = vps.getDpbSize(); 
+
+  assert ( dpbSize != 0 ); 
+
+  for( Int i = 1; i < vps.getNumOutputLayerSets(); i++ )
+  {  
+    std::vector<Int> targetDecLayerIdList = vps.getTargetDecLayerIdList( i ); 
+    dpbSize->setSubLayerFlagInfoPresentFlag( i, m_subLayerFlagInfoPresentFlag );
+
+    if ( dpbSize->getSubLayerFlagInfoPresentFlag( i ) )
+    {
+      for( Int j = 0; j  <=  vps.getMaxTLayers() - 1 ; j++ )
+      {   
+        Int maxNumReorderPics  = MIN_INT; 
+        Int maxDecPicBuffering = MIN_INT; 
+        Int maxLatencyIncrease = MIN_INT; 
+
+        Int prevMaxNumReorderPics  = MIN_INT; 
+        Int prevMaxDecPicBuffering = MIN_INT; 
+        Int prevMaxLatencyIncrease = MIN_INT; 
+
+        assert( vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ) == targetDecLayerIdList.size() ); 
+        for( Int k = 0; k < vps.getNumSubDpbs( vps.getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+        {
+          Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[k] );           
+          dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, m_maxDecPicBufferingMvc[ layerIdInVps ][ j ] - 1 );
+        }        
+
+        for ( Int idx = 0; idx < targetDecLayerIdList.size(); idx++ )
+        {
+          Int layerIdInVps = vps.getLayerIdInVps( targetDecLayerIdList[ idx ] ); 
+          maxNumReorderPics = std::max( maxNumReorderPics, m_numReorderPicsMvc[ layerIdInVps ][ j ] ); 
+        }
+        assert( maxNumReorderPics != MIN_INT ); 
+        dpbSize->setMaxVpsNumReorderPics( i, j, maxNumReorderPics );
+
+        // To Be Done !
+        // dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );
+
+        if( j > 0 )  
+        {
+          dpbSize->setSubLayerDpbInfoPresentFlag( i, j, prevMaxDecPicBuffering == maxDecPicBuffering && prevMaxLatencyIncrease == maxLatencyIncrease && prevMaxNumReorderPics == maxNumReorderPics );
+        }        
+
+        prevMaxNumReorderPics   = maxNumReorderPics; 
+        prevMaxDecPicBuffering  = maxDecPicBuffering; 
+        prevMaxLatencyIncrease  = maxLatencyIncrease; 
+      }  
+    }  
+  }  
+}
+#endif
+
 
 Void TAppEncTop::xSetLayerSets( TComVPS& vps )
@@ -1520,15 +1707,41 @@
     } 
   }
+#if H_MV_6_HRD_O0217_13
+  vps.deriveLayerSetLayerIdList(); 
+#endif
 
   Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
   // Additional output layer sets + profileLevelTierIdx
+#if H_MV_6_PS_0109_25
+  vps.setDefaultOneTargetOutputLayerIdc   ( m_defaultOneTargetOutputLayerIdc ); 
+#else
   vps.setDefaultOneTargetOutputLayerFlag   ( m_defaultOneTargetOutputLayerFlag ); 
+#endif
   vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets       != 0 );   
   vps.setNumAddOutputLayerSetsMinus1       ( numAddOuputLayerSets - 1        ); 
 
+
+
+#if H_MV_6_HRD_O0217_13
+  for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++)
+  {
+    if ( lsIdx > 0 ) 
+    {
+      vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); 
+    }  
+
+    vps.setOutputLayerSetIdxMinus1( lsIdx, lsIdx - 1 ); 
+
+    for (Int i = 0; i < m_layerIdsInSets[ lsIdx ].size(); i++ )
+    { 
+      vps.setOutputLayerFlag( lsIdx, i, vps.inferOutputLayerFlag( lsIdx, i ));       
+    }
+  }
+#else
   for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++)
   {
     vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); 
   }
+#endif
 
   for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ )
@@ -1553,4 +1766,7 @@
     }
   }
+#if H_MV_6_HRD_O0217_13
+  vps.deriveTargetLayerIdLists(); 
+#endif
 }
 
@@ -1564,4 +1780,13 @@
 
     assert( pcVPSVUI ); 
+
+
+    // All this stuff could actually be derived by the encoder, 
+    // however preliminary setting it from input parameters
+
+#if H_MV_6_PS_O0223_29
+    pcVPSVUI->setCrossLayerPicTypeAlignedFlag( m_crossLayerPicTypeAlignedFlag );
+    pcVPSVUI->setCrossLayerIrapAlignedFlag   ( m_crossLayerIrapAlignedFlag    );
+#endif
 
     pcVPSVUI->setBitRatePresentVpsFlag( m_bitRatePresentVpsFlag );
@@ -1602,4 +1827,41 @@
     }
 
+#if H_MV_6_O0226_37
+    pcVPSVUI->setTilesNotInUseFlag( m_tilesNotInUseFlag );
+
+    if( !pcVPSVUI->getTilesNotInUseFlag() ) 
+    {      
+      for( Int i = 0; i  <=  vps.getMaxLayersMinus1(); i++ )
+      {
+        pcVPSVUI->setTilesInUseFlag( i, m_tilesInUseFlag[ i ] );
+        if( pcVPSVUI->getTilesInUseFlag( i ) )  
+        {
+          pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, m_loopFilterNotAcrossTilesFlag[ i ] );
+        }
+      }  
+
+      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ )  
+      {
+        for( Int j = 0; j < vps.getNumDirectRefLayers( vps.getLayerIdInNuh( i ) ) ; j++ )
+        {  
+          Int layerIdx = vps.getLayerIdInVps( vps.getRefLayerId(vps.getLayerIdInNuh( i ) , j  ));  
+          if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) )  
+          {
+            pcVPSVUI->setTileBoundariesAlignedFlag( i, j, m_tileBoundariesAlignedFlag[i][j] );
+          }
+        }  
+      }
+    }  
+
+    pcVPSVUI->setWppNotInUseFlag( m_wppNotInUseFlag );
+
+    if( !pcVPSVUI->getWppNotInUseFlag( ) )
+    {
+      for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ )  
+      {
+        pcVPSVUI->setWppInUseFlag( i, m_wppInUseFlag[ i ]);
+      }
+    }
+#else
     for( Int i = 1; i  <=  vps.getMaxLayersMinus1(); i++ )
     {
@@ -1612,4 +1874,5 @@
       }
     }
+#endif
 
     pcVPSVUI->setIlpRestrictedRefLayersFlag( m_ilpRestrictedRefLayersFlag );
@@ -1642,4 +1905,28 @@
       }
     }      
+#if H_MV_6_PS_O0118_33
+    pcVPSVUI->setVideoSignalInfoIdxPresentFlag( true ); 
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1  ( 0    ); 
+
+    assert ( pcVPSVUI->getVideoSignalInfo( 0 ) == NULL );
+
+    TComVideoSignalInfo* videoSignalInfo = new TComVideoSignalInfo; 
+
+    videoSignalInfo->setColourPrimariesVps        ( m_colourPrimaries ); 
+    videoSignalInfo->setMatrixCoeffsVps           ( m_matrixCoefficients ); 
+    videoSignalInfo->setTransferCharacteristicsVps( m_transferCharacteristics ); 
+    videoSignalInfo->setVideoVpsFormat            ( m_videoFormat ); 
+    videoSignalInfo->setVideoFullRangeVpsFlag     ( m_videoFullRangeFlag );  
+
+    pcVPSVUI->setVideoSignalInfo( 0, videoSignalInfo );       
+
+    for (Int i = 0; i < m_numberOfLayers; i++)
+    {      
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 ); 
+    }
+#endif
+#if H_MV_6_HRD_O0164_15
+    pcVPSVUI->setVpsVuiBspHrdPresentFlag( false ); // TBD
+#endif
   }
 }
@@ -1683,5 +1970,9 @@
     if( vps.getUseDLTFlag( layer ) )
     {
+#if H_MV_LAYER_WISE_STARTUP
+      xAnalyzeInputBaseDepth(layer, max(  m_iIntraPeriod[layer], 24), &vps);
+#else
       xAnalyzeInputBaseDepth(layer, max(m_iIntraPeriod, 24), &vps);
+#endif
     }
 #endif
@@ -1720,3 +2011,4 @@
 }
 #endif
+#endif
 //! \}
Index: trunk/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 735)
+++ trunk/source/App/TAppEncoder/TAppEncTop.h	(revision 738)
@@ -125,4 +125,7 @@
   Void xSetProfileTierLevel       ( TComVPS& vps );
   Void xSetRepFormat              ( TComVPS& vps );
+#if H_MV_6_HRD_O0217_13
+  Void xSetDpbSize                ( TComVPS& vps );
+#endif
   Void xSetVPSVUI                 ( TComVPS& vps );
   GOPEntry* xGetGopEntry( Int layerIdInVps, Int poc );
