Index: branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 532)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppDecoder/TAppDecTop.cpp	(revision 534)
@@ -150,6 +150,8 @@
   Bool recon_opened = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
 #else
+#if H_3D
   Int  pocCurrPic        = -MAX_INT;     
   Int  pocLastPic        = -MAX_INT;   
+#endif
 
   Int  layerIdCurrPic    = 0; 
@@ -187,5 +189,7 @@
     Bool newSliceDiffPoc   = false;
     Bool newSliceDiffLayer = false;
+#if H_3D
     Bool allLayersDecoded  = false;     
+#endif
 #endif
     if (nalUnit.empty())
@@ -222,5 +226,7 @@
         {
           layerIdCurrPic = nalu.m_layerId; 
+#if H_3D
           pocCurrPic     = m_tDecTop[decIdx]->getCurrPoc(); 
+#endif
           decIdxCurrPic  = decIdx; 
           firstSlice     = false; 
@@ -230,12 +236,13 @@
         { 
           layerIdCurrPic    = nalu.m_layerId; 
-          
+#if H_3D          
           pocLastPic        = pocCurrPic; 
           pocCurrPic        = m_tDecTop[decIdx]->getCurrPoc(); 
-          
+#endif          
           decIdxLastPic     = decIdxCurrPic; 
           decIdxCurrPic     = decIdx; 
-
+#if H_3D
           allLayersDecoded = ( pocCurrPic != pocLastPic );
+#endif
         }
 
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 532)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 534)
@@ -215,16 +215,20 @@
 #endif
 #if H_MV
-  in>>entry.m_numInterViewRefPics;
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
-  {
-    in>>entry.m_interViewRefs[i];
-  }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
+  in>>entry.m_numActiveRefLayerPics;
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
+  {
+    in>>entry.m_interLayerPredLayerIdc[i];
+  }
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
   {
     in>>entry.m_interViewRefPosL[0][i];
   }
-  for( Int i = 0; i < entry.m_numInterViewRefPics; i++ )
+  for( Int i = 0; i < entry.m_numActiveRefLayerPics; i++ )
   {
     in>>entry.m_interViewRefPosL[1][i];
+  }
+  if (entry.m_numActiveRefLayerPics > 0 )
+  {
+    in>>entry.m_collocatedRefLayerIdx; 
   }
 #endif
@@ -398,4 +402,16 @@
   ("LayerIdInNuh",          m_layerIdInNuh       , std::vector<Int>(1,0), "LayerId in Nuh")
   ("SplittingFlag",         m_splittingFlag      , false                , "Splitting Flag")    
+
+  // Layer Sets + Output Layer Sets + Profile Tier Level
+  ("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")  
+  ("DefaultOneTargetOutputLayerFlag", m_defaultOneTargetOutputLayerFlag,  false , "Output highest layer of layer sets by default")      
+  ("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")  
+  ("ProfileLevelTierIdx",   m_profileLevelTierIdx, std::vector<Int>(1,0), "Indices to profile level tier")
+  
+  // Layer dependencies
+  ("DirectRefLayers_%d",    m_directRefLayers    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "LayerIds of direct reference layers")
+  ("DependencyTypes_%d",    m_dependencyTypes    , std::vector<Int>(0,0), MAX_NUM_LAYERS, "Dependency types of direct reference layers, 0: Sample 1: Motion 2: Sample+Motion")
 #endif
   ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
@@ -756,4 +772,8 @@
         cOSS<<"Frame"<<i;
         opts.addOptions()( cOSS.str(), m_GOPListMvc[k][i-1], GOPEntry() );
+        if ( i != 1 )
+        {
+          opts.opt_list.back()->opt->opt_duplicate = true; 
+        }        
       }
     }
@@ -762,5 +782,11 @@
       std::ostringstream cOSS1;
       cOSS1<<"FrameI"<<"_l"<<k;
+
       opts.addOptions()(cOSS1.str(), m_GOPListMvc[k][MAX_GOP], GOPEntry());
+      if ( k > 1 )
+      {
+        opts.opt_list.back()->opt->opt_duplicate = true; 
+      }        
+
 
       for( Int i = 1; i < MAX_GOP + 1; i++ ) 
@@ -769,4 +795,8 @@
         cOSS2<<"Frame"<<i<<"_l"<<k;
         opts.addOptions()(cOSS2.str(), m_GOPListMvc[k][i-1], GOPEntry());
+        if ( i != 1 || k > 0 )
+        {
+          opts.opt_list.back()->opt->opt_duplicate = true; 
+        }        
       }
     }
@@ -1311,14 +1341,32 @@
 #endif
 
-  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   ); 
-
- for( Int dim = 0; dim < m_dimIds.size(); dim++ )
+  xConfirmPara(  m_dimensionIdLen.size() < m_dimIds.size(), "DimensionIdLen must be given for all dimensions. "   );   Int dimBitOffset[MAX_NUM_SCALABILITY_TYPES+1]; 
+
+  dimBitOffset[ 0 ] = 0; 
+  for (Int j = 1; j <= ((Int) m_dimIds.size() - m_splittingFlag ? 1 : 0); j++ )
  {
-   xConfirmPara( m_dimIds[dim].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
-   xConfirmPara( ( dim != viewDimPosition ) &&  (m_dimIds[dim][0] != 0), "DimensionId of layer 0 must be 0. " );
-   xConfirmPara( m_dimensionIdLen[dim] < 1 || m_dimensionIdLen[dim] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " ); 
+    dimBitOffset[ j ] = dimBitOffset[ j - 1 ] + m_dimensionIdLen[ j - 1]; 
+  }
+
+  if ( m_splittingFlag )
+  {
+    dimBitOffset[ (Int) m_dimIds.size() ] = 6; 
+  }
+  
+  for( Int j = 0; j < m_dimIds.size(); j++ )
+  {    
+    xConfirmPara( m_dimIds[j].size() < m_numberOfLayers,  "DimensionId must be given for all layers and all dimensions. ");   
+    xConfirmPara( ( j != viewDimPosition ) &&  (m_dimIds[j][0] != 0), "DimensionId of layer 0 must be 0. " );
+    xConfirmPara( m_dimensionIdLen[j] < 1 || m_dimensionIdLen[j] > 8, "DimensionIdLen must be greater than 0 and less than 9 in all dimensions. " ); 
+     
+
    for( Int i = 1; i < m_numberOfLayers; i++ )
    {     
-     xConfirmPara(  ( m_dimIds[dim][i] < 0 ) || ( m_dimIds[dim][i] > ( ( 1 << m_dimensionIdLen[dim] ) - 1 ) )   , "DimensionId shall be in the range of 0 to 2^DimensionIdLen - 1. " );
+      xConfirmPara(  ( m_dimIds[j][i] < 0 ) || ( m_dimIds[j][i] > ( ( 1 << m_dimensionIdLen[j] ) - 1 ) )   , "DimensionId shall be in the range of 0 to 2^DimensionIdLen - 1. " );
+      if ( m_splittingFlag )
+      {
+        Int layerIdInNuh = (m_layerIdInNuh.size()!=1) ? m_layerIdInNuh[i] :  i; 
+        xConfirmPara( ( ( layerIdInNuh & ( (1 << dimBitOffset[ j + 1 ] ) - 1) ) >> dimBitOffset[ j ] )  != m_dimIds[j][ i ]  , "When Splitting Flag is equal to 1 dimension ids shall match values derived from layer ids. "); 
+      }
    }
  }
@@ -1361,4 +1409,52 @@
  }
 
+  /// Layer sets
+  xConfirmPara( m_vpsNumLayerSets < 0 || m_vpsNumLayerSets > 1024, "VpsNumLayerSets must be greater than 0 and less than 1025") ; 
+  for( Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
+  {
+    if (lsIdx == 0)
+    {
+      xConfirmPara( m_layerIdsInSets[lsIdx].size() != 1 || m_layerIdsInSets[lsIdx][0] != 0 , "0-th layer shall only include layer 0. ");
+    }
+    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++ )
+    {
+      xConfirmPara( m_layerIdsInSets[lsIdx][i] < 0 || m_layerIdsInSets[lsIdx].size() >= MAX_NUM_LAYER_IDS, "LayerIdsInSet must be greater than and less than 64" ); 
+    }
+  }
+
+  // Output layer sets
+  xConfirmPara( m_outputLayerSetIdx.size() > 1024, "The number of output layer set indices must be less than 1025.") ;
+  for (Int lsIdx = 0; lsIdx < m_outputLayerSetIdx.size(); lsIdx++)
+  {   
+    Int refLayerSetIdx = m_outputLayerSetIdx[ lsIdx ]; 
+    xConfirmPara(  refLayerSetIdx < 0 || refLayerSetIdx >= m_vpsNumLayerSets, "Output layer set idx must be greater or equal to 0 and less than the VpsNumLayerSets." );
+
+    for (Int i = 0; i < m_layerIdsInAddOutputLayerSet[ lsIdx ].size(); i++)
+    {
+      Bool isAlsoInLayerSet = false; 
+      for (Int j = 0; j < m_layerIdsInSets[ refLayerSetIdx ].size(); j++ )
+      {
+        if ( m_layerIdsInSets[ refLayerSetIdx ][ j ] == m_layerIdsInAddOutputLayerSet[ lsIdx ][ i ] )
+        {
+          isAlsoInLayerSet = true; 
+          break; 
+        }        
+      }
+      xConfirmPara( !isAlsoInLayerSet, "All output layers of a output layer set be included in corresponding layer set.");
+    }
+  }
+  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" );
+
+  // Layer Dependencies  
+  for (Int i = 0; i < m_numberOfLayers; i++ )
+  {
+    xConfirmPara( (i == 0)  && m_directRefLayers[0].size() != 0, "Layer 0 shall not have reference layers." ); 
+    xConfirmPara( m_directRefLayers[i].size() != m_dependencyTypes[ i ].size(), "Each reference layer shall have a reference type." ); 
+    for (Int j = 0; j < m_directRefLayers[i].size(); j++)
+    {
+      xConfirmPara( m_directRefLayers[i][j] < 0 || m_directRefLayers[i][j] >= i , "Reference layer id shall be greater than or equal to 0 and less than dependent layer id"); 
+      xConfirmPara( m_dependencyTypes[i][j] < 0 || m_dependencyTypes[i][j] >  2 , "Dependency type shall be greater than or equal to 0 and less than 3"); 
+    }        
+  }  
 #endif
   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
@@ -1518,5 +1614,5 @@
   for( Int i = 0; i < MAX_GOP; i++ )
   {
-    if( m_GOPListMvc[0][i].m_numInterViewRefPics != 0 )
+    if( m_GOPListMvc[0][i].m_numActiveRefLayerPics != 0 )
     {
       printf( "\nError: Frame%d inter_layer refs not available in layer 0\n", i );
@@ -1530,24 +1626,25 @@
   if( m_numberOfLayers > 1 )
   {
-    for( Int k = 1; k < m_numberOfLayers; k++ )
+    for( Int layer = 1; layer < m_numberOfLayers; layer++ )
     {
       for( Int i = 0; i < MAX_GOP+1; i++ )
       {
-        for( Int j = 0; j < m_GOPListMvc[k][i].m_numInterViewRefPics; j++ )
+        GOPEntry gopEntry = m_GOPListMvc[layer][i];  
+        for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
         {
-          Int iAbsViewId = m_GOPListMvc[k][i].m_interViewRefs[j] + k;
-          if( iAbsViewId < 0 || iAbsViewId >= k )
+          Int ilPredLayerIdc = gopEntry.m_interLayerPredLayerIdc[j];
+          if( ilPredLayerIdc < 0 || ilPredLayerIdc >= m_directRefLayers[layer].size() )
           {
-            printf( "\nError: inter-layer ref pic %d is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefs[j], i, k );
+            printf( "\nError: inter-layer ref idc %d is not available for Frame%d_l%d\n", gopEntry.m_interLayerPredLayerIdc[j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListMvc[k][i].m_interViewRefPosL[0][j] < -1 || m_GOPListMvc[k][i].m_interViewRefPosL[0][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[0][j] < -1 || gopEntry.m_interViewRefPosL[0][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[0][j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L0 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[0][j], i, layer );
             bErrorIvpEnhV = true;
           }
-          if( m_GOPListMvc[k][i].m_interViewRefPosL[1][j] < -1  || m_GOPListMvc[k][i].m_interViewRefPosL[1][j] > m_GOPListMvc[k][i].m_numRefPicsActive )
+          if( gopEntry.m_interViewRefPosL[1][j] < -1  || gopEntry.m_interViewRefPosL[1][j] > gopEntry.m_numRefPicsActive )
           {
-            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", m_GOPListMvc[k][i].m_interViewRefPosL[1][j], i, k );
+            printf( "\nError: inter-layer ref pos %d on L1 is not available for Frame%d_l%d\n", gopEntry.m_interViewRefPosL[1][j], i, layer );
             bErrorIvpEnhV = true;
           }
@@ -1555,63 +1652,63 @@
         if( i == MAX_GOP ) // inter-view refs at I pic position in base view
         {
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType != 'B' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'P' && m_GOPListMvc[k][MAX_GOP].m_sliceType != 'I' )
+          if( gopEntry.m_sliceType != 'B' && gopEntry.m_sliceType != 'P' && gopEntry.m_sliceType != 'I' )
           {
-            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", k );
+            printf( "\nError: slice type of FrameI_l%d must be equal to B or P or I\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_POC != 0 )
+          if( gopEntry.m_POC != 0 )
           {
-            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", m_GOPListMvc[k][MAX_GOP].m_POC, k );
+            printf( "\nError: POC %d not possible for FrameI_l%d, must be 0\n", gopEntry.m_POC, layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_temporalId != 0 )
+          if( gopEntry.m_temporalId != 0 )
           {
-            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", k );
-            m_GOPListMvc[k][MAX_GOP].m_temporalId = 0;
+            printf( "\nWarning: Temporal id of FrameI_l%d must be 0 (cp. I-frame in base layer)\n", layer );
+            gopEntry.m_temporalId = 0;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_numRefPics != 0 )
+          if( gopEntry.m_numRefPics != 0 )
           {
-            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", k );
-            for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numRefPics; j++ )
+            printf( "\nWarning: temporal references not possible for FrameI_l%d\n", layer );
+            for( Int j = 0; j < m_GOPListMvc[layer][MAX_GOP].m_numRefPics; j++ )
             {
-              m_GOPListMvc[k][MAX_GOP].m_referencePics[j] = 0;
+              gopEntry.m_referencePics[j] = 0;
             }
-            m_GOPListMvc[k][MAX_GOP].m_numRefPics = 0;
+            gopEntry.m_numRefPics = 0;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_interRPSPrediction )
+          if( gopEntry.m_interRPSPrediction )
           {
-            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", k );
+            printf( "\nError: inter RPS prediction not possible for FrameI_l%d, must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'I' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics != 0 )
+          if( gopEntry.m_sliceType == 'I' && gopEntry.m_numActiveRefLayerPics != 0 )
           {
-            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", k );
+            printf( "\nError: inter-layer prediction not possible for FrameI_l%d with slice type I, #IL_ref_pics must be 0\n", layer );
             bErrorIvpEnhV = true;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive > m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics )
+          if( gopEntry.m_numRefPicsActive > gopEntry.m_numActiveRefLayerPics )
           {
-            m_GOPListMvc[k][MAX_GOP].m_numRefPicsActive = m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics;
+            gopEntry.m_numRefPicsActive = gopEntry.m_numActiveRefLayerPics;
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'P' )
+          if( gopEntry.m_sliceType == 'P' )
           {
-            if( m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+            if( gopEntry.m_numActiveRefLayerPics < 1 )
             {
-              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", k );
+              printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type P\n", layer );
               bErrorIvpEnhV = true;
             }
             else
             {
-              for( Int j = 0; j < m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics; j++ )
+              for( Int j = 0; j < gopEntry.m_numActiveRefLayerPics; j++ )
               {
-                if( m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j] != -1 )
+                if( gopEntry.m_interViewRefPosL[1][j] != -1 )
                 {
-                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", m_GOPListMvc[k][MAX_GOP].m_interViewRefPosL[1][j], k );
+                  printf( "\nError: inter-layer ref pos %d on L1 not possible for FrameI_l%d with slice type P\n", gopEntry.m_interViewRefPosL[1][j], layer );
                   bErrorIvpEnhV = true;
                 }
@@ -1620,7 +1717,7 @@
           }
 
-          if( m_GOPListMvc[k][MAX_GOP].m_sliceType == 'B' && m_GOPListMvc[k][MAX_GOP].m_numInterViewRefPics < 1 )
+          if( gopEntry.m_sliceType == 'B' && gopEntry.m_numActiveRefLayerPics < 1 )
           {
-            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", k );
+            printf( "\nError: #IL_ref_pics must be at least one for FrameI_l%d with slice type B\n", layer );
             bErrorIvpEnhV = true;
           }
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h	(revision 532)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncCfg.h	(revision 534)
@@ -86,4 +86,17 @@
   Int                    m_scalabilityMask;                   ///< Mask indicating scalabilities, 1: texture; 3: texture + depth                                                                
   std::vector<Int>       m_dimensionIdLen;                    ///< Length of scalability dimension s 
+  
+// layer sets   
+  Int                    m_vpsNumLayerSets;                   ///< Number of layer sets
+  std::vector< std::vector<Int> > m_layerIdsInSets;           ///< LayerIds in vps of layer set 
+  Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default  
+  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
+  std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
+  
+  // Dependencies
+  std::vector< std::vector<Int> > m_directRefLayers;          ///< LayerIds of direct reference layers
+  std::vector< std::vector<Int> > m_dependencyTypes;          ///< Dependency types of direct reference layers
+
 #if H_3D_IV_MERGE
   Bool                   m_ivMvPredFlag;                      ///< Interview motion vector prediction 
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp	(revision 532)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.cpp	(revision 534)
@@ -118,5 +118,7 @@
   xSetLayerIds             ( vps );   
   xSetDimensionIdAndLength ( vps );
-  xSetDirectDependencyFlags( vps );
+  xSetDependencies( vps );
+  xSetProfileTierLevel     ( vps ); 
+  xSetLayerSets            ( vps ); 
 #if H_3D
   vps.initViewIndex(); 
@@ -1079,26 +1081,64 @@
 }
 
-Void TAppEncTop::xSetDirectDependencyFlags( TComVPS& vps )
-{
-  for( Int layer = 0; layer < m_numberOfLayers; layer++ )
-  {
-    if( m_GOPListMvc[layer][MAX_GOP].m_POC == -1 )
-    {
-      continue;
-    }
-    for( Int i = 0; i < getGOPSize()+1; i++ ) 
-    {
-      GOPEntry ge = ( i < getGOPSize() ) ? m_GOPListMvc[layer][i] : m_GOPListMvc[layer][MAX_GOP];
-      for( Int j = 0; j < ge.m_numInterViewRefPics; j++ )
+Void TAppEncTop::xSetDependencies( TComVPS& vps )
+{
+  // Direct dependency flags + dependency types
+  for( Int depLayer = 1; depLayer < MAX_NUM_LAYERS; depLayer++ )
+  {
+    for( Int refLayer = 0; refLayer < MAX_NUM_LAYERS; refLayer++ )
+    {
+      vps.setDirectDependencyFlag( depLayer, refLayer, false); 
+      vps.setDirectDependencyType( depLayer, refLayer,    -1 ); 
+    }
+    }
+  for( Int depLayer = 1; depLayer < m_numberOfLayers; depLayer++ )
+  {
+    Int numRefLayers = (Int) m_directRefLayers[depLayer].size(); 
+    assert(  numRefLayers == (Int) m_dependencyTypes[depLayer].size() ); 
+    for( Int i = 0; i < numRefLayers; i++ )
+    {
+      Int refLayer = m_directRefLayers[depLayer][i]; 
+      vps.setDirectDependencyFlag( depLayer, refLayer, true); 
+      vps.setDirectDependencyType( depLayer, refLayer,m_dependencyTypes[depLayer][i]); 
+    }
+  }
+
+  // Max temporal id for inter layer reference pictures
+  for ( Int refLayerIdInVps = 0; refLayerIdInVps < m_numberOfLayers; refLayerIdInVps++)
+    {
+    Int maxTid = -1; 
+    for ( Int curLayerIdInVps = 1; curLayerIdInVps < m_numberOfLayers; curLayerIdInVps++)
       {
-        Int interLayerRef = layer + ge.m_interViewRefs[j];
-        vps.setDirectDependencyFlag( layer, interLayerRef, true );
+      for( Int i = 0; i < getGOPSize(); i++ ) 
+      {        
+        GOPEntry geCur =  m_GOPListMvc[curLayerIdInVps][i];
+        GOPEntry geRef =  m_GOPListMvc[refLayerIdInVps][i];
+        
+        for (Int j = 0; j < geCur.m_numActiveRefLayerPics; j++)
+        {        
+          if ( m_directRefLayers[ curLayerIdInVps ][ geCur.m_interLayerPredLayerIdc[ j ]] == refLayerIdInVps )
+          {
+            maxTid = std::max( maxTid, geRef.m_temporalId ); 
+          }
+        }
       }
     }
-  }
-
-  vps.checkVPSExtensionSyntax(); 
-  vps.calcIvRefLayers();
-}
+    vps.setMaxTidIlRefPicPlus1( refLayerIdInVps, maxTid + 1 );
+  }
+
+  // Max one active ref layer flag
+  Bool maxOneActiveRefLayerFlag = true;  
+  for ( Int currLayerIdInVps = 1; currLayerIdInVps < m_numberOfLayers && maxOneActiveRefLayerFlag; currLayerIdInVps++)
+  {
+    for( Int i = 0; i < ( getGOPSize() + 1) && maxOneActiveRefLayerFlag; i++ ) 
+    {        
+      GOPEntry ge =  m_GOPListMvc[currLayerIdInVps][ ( i < getGOPSize()  ? i : MAX_GOP ) ]; 
+      maxOneActiveRefLayerFlag =  maxOneActiveRefLayerFlag && (ge.m_numActiveRefLayerPics <= 1); 
+    }            
+}
+
+  vps.setMaxOneActiveRefLayerFlag( maxOneActiveRefLayerFlag );
+  vps.setRefLayers(); 
+}; 
 
 Void TAppEncTop::xSetLayerIds( TComVPS& vps )
@@ -1109,5 +1149,5 @@
   Int  maxNuhLayerId = nuhLayerIdPresentFlag ? xGetMax( m_layerIdInNuh ) : ( m_numberOfLayers - 1 ) ; 
 
-  vps.setMaxNuhLayerId( maxNuhLayerId ); 
+  vps.setVpsMaxLayerId( maxNuhLayerId ); 
   vps.setVpsNuhLayerIdPresentFlag( nuhLayerIdPresentFlag ); 
 
@@ -1125,4 +1165,68 @@
     maxVec = max( vec[i], maxVec ); 
   return maxVec;
+}
+
+Void TAppEncTop::xSetProfileTierLevel( TComVPS& vps )
+{ 
+  const Int vpsNumProfileTierLevelMinus1 = 0; //TBD
+  vps.setVpsNumProfileTierLevelMinus1( vpsNumProfileTierLevelMinus1 ); 
+  
+  for (Int i = 0; i <= vps.getVpsNumProfileTierLevelMinus1(); i++ )
+  {
+    vps.setVpsProfilePresentFlag( i, true ); 
+  }
+}
+
+
+Void TAppEncTop::xSetLayerSets( TComVPS& vps )
+{   
+  // Layer sets
+  vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets - 1 ); 
+  vps.setVpsNumberLayerSetsMinus1( vps.getVpsNumLayerSetsMinus1() ); 
+    
+  for (Int lsIdx = 0; lsIdx < m_vpsNumLayerSets; lsIdx++ )
+  {
+    for( Int layerId = 0; layerId < MAX_NUM_LAYER_IDS; layerId++ )
+    {
+      vps.setLayerIdIncludedFlag( false, lsIdx, layerId ); 
+    }
+    for ( Int i = 0; i < m_layerIdsInSets[lsIdx].size(); i++)
+    {       
+      vps.setLayerIdIncludedFlag( true, lsIdx, vps.getLayerIdInNuh( m_layerIdsInSets[lsIdx][i] ) ); 
+    } 
+  }
+
+  Int numAddOuputLayerSets = (Int) m_outputLayerSetIdx.size(); 
+  // Additional output layer sets + profileLevelTierIdx
+  vps.setDefaultOneTargetOutputLayerFlag   ( m_defaultOneTargetOutputLayerFlag ); 
+  vps.setMoreOutputLayerSetsThanDefaultFlag( numAddOuputLayerSets       != 0 );   
+  vps.setNumAddOutputLayerSetsMinus1       ( numAddOuputLayerSets - 1        ); 
+
+  for (Int lsIdx = 1; lsIdx < m_vpsNumLayerSets; lsIdx++)
+  {
+    vps.setProfileLevelTierIdx( lsIdx, m_profileLevelTierIdx[ lsIdx ] ); 
+  }
+
+  for (Int addOutLs = 0; addOutLs < numAddOuputLayerSets; addOutLs++ )
+  {
+    vps.setProfileLevelTierIdx( m_vpsNumLayerSets + addOutLs, m_profileLevelTierIdx[ addOutLs ] ); 
+
+    Int refLayerSetIdx = m_outputLayerSetIdx[ addOutLs ];     
+    vps.setOutputLayerSetIdxMinus1( m_vpsNumLayerSets + addOutLs, refLayerSetIdx - 1 ); 
+
+    for (Int i = 0; i < m_layerIdsInSets[ refLayerSetIdx].size(); i++ )
+    {
+      Bool outputLayerFlag = false; 
+      for (Int j = 0; j < m_layerIdsInAddOutputLayerSet[ addOutLs ].size(); j++ )
+      {
+        if (  m_layerIdsInAddOutputLayerSet[addOutLs][ j ] == m_layerIdsInSets[ refLayerSetIdx][ i ] )
+        {
+          outputLayerFlag = true; 
+          break; 
+        }
+      }
+      vps.setOutputLayerFlag( m_vpsNumLayerSets + addOutLs, i, outputLayerFlag );       
+    }
+  }
 }
 #endif
Index: branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h	(revision 532)
+++ branches/HTM-DEV-0.3-dev2/source/App/TAppEncoder/TAppEncTop.h	(revision 534)
@@ -118,5 +118,7 @@
   Void xSetLayerIds               ( TComVPS& vps );  
   Void xSetDimensionIdAndLength   ( TComVPS& vps );
-  Void xSetDirectDependencyFlags  ( TComVPS& vps );
+  Void xSetDependencies           ( TComVPS& vps );
+  Void xSetLayerSets              ( TComVPS& vps );
+  Void xSetProfileTierLevel       ( TComVPS& vps );
   Int  xGetMax( std::vector<Int>& vec);
 #endif
