Index: /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view+depth.cfg	(revision 492)
@@ -30,4 +30,15 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 3           # Number of layer sets    
+LayerIdsInSet_0               : 0           # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1         # LayerIds of Layer set
+LayerIdsInSet_2               : 0 1 2 3     # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 2            # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
 
 #========== Camera parameters ==========
Index: /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_2view.cfg	(revision 492)
@@ -22,4 +22,13 @@
 SplittingFlag                 : 0           # Splitting Flag 
 
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 2            # Number of layer sets    
+LayerIdsInSet_0               : 0            # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0          # Indices to profile level tier (TBD)
 
 #========== Camera parameters ==========
Index: /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view+depth.cfg	(revision 492)
@@ -30,4 +30,18 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 5           # Number of layer sets    
+LayerIdsInSet_0               : 0           # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1         # LayerIds of Layer set
+LayerIdsInSet_2               : 0 1 2 3     # LayerIds of Layer set
+LayerIdsInSet_3               : 0 1 4 5     # LayerIds of Layer set
+LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
 
 #========== Camera parameters ==========
Index: /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/baseCfg_3view.cfg	(revision 492)
@@ -23,4 +23,17 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 4            # Number of layer sets    
+LayerIdsInSet_0               : 0            # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
+LayerIdsInSet_2               : 0 2          # LayerIds of Layer set
+LayerIdsInSet_3               : 0 1 2        # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
 
 #========== Camera parameters ==========
Index: /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/fullCfg.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/fullCfg.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/3D-HEVC/fullCfg.cfg	(revision 492)
@@ -34,4 +34,19 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 5           # Number of layer sets    
+LayerIdsInSet_0               : 0           # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1         # LayerIds of Layer set
+LayerIdsInSet_2               : 0 1 2 3     # LayerIds of Layer set
+LayerIdsInSet_3               : 0 1 4 5     # LayerIds of Layer set
+LayerIdsInSet_4               : 0 1 2 3 4 5 # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 2 3          # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 2 3          # LayerIds of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 4 5          # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0 0 0  # Indices to profile level tier (TBD)
+
 
 #========== Camera parameters ==========
Index: /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_2view.cfg	(revision 492)
@@ -21,4 +21,14 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 2            # Number of layer sets    
+LayerIdsInSet_0               : 0            # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 1            # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0            # Indices to profile level tier (TBD)
 
 #======== Unit definition ================
Index: /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/baseCfg_3view.cfg	(revision 492)
@@ -23,4 +23,17 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 4            # Number of layer sets    
+LayerIdsInSet_0               : 0            # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
+LayerIdsInSet_2               : 0 2          # LayerIds of Layer set
+LayerIdsInSet_3               : 0 1 2        # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+LayerIdsInAddOutputLayerSet_1 : 2            # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
 
 #======== Unit definition ================
Index: /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/fullCfg.cfg
===================================================================
--- /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/fullCfg.cfg	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/cfg/MV-HEVC/fullCfg.cfg	(revision 492)
@@ -27,4 +27,17 @@
 LayerIdInNuh                  : 0           # Layer Id in NAL unit header, (0: no explicit signalling ) (m)
 SplittingFlag                 : 0           # Splitting Flag 
+
+#======== VPS/ Layer sets ================
+VpsNumLayerSets               : 4            # Number of layer sets    
+LayerIdsInSet_0               : 0            # LayerIds of Layer set
+LayerIdsInSet_1               : 0 1          # LayerIds of Layer set
+LayerIdsInSet_2               : 0 2          # LayerIds of Layer set
+LayerIdsInSet_3               : 0 1 2        # LayerIds of Layer set
+
+DefaultOneTargetOutputLayerFlag: 0           # Output highest layer of layer sets by default
+OutputLayerSetIdx             : 1 2          # Indices of layer sets used as additional output layer sets
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+LayerIdsInAddOutputLayerSet_0 : 1            # LayerIds of additional output layers
+ProfileLevelTierIdx           : 0 0 0 0      # Indices to profile level tier (TBD)
 
 #======== Unit definition ================
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 492)
@@ -392,4 +392,12 @@
   ("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>(1,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")
 #endif
   ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
@@ -1283,5 +1291,5 @@
   xConfirmPara( m_layerIdInNuh[0] != 0      , "LayerIdInNuh must be 0 for the first layer. ");
   xConfirmPara( (m_layerIdInNuh.size()!=1) && (m_layerIdInNuh.size() < m_numberOfLayers) , "LayerIdInNuh must be given for all layers. ");
-  
+
 #if H_3D
   xConfirmPara( m_scalabilityMask != 1 && m_scalabilityMask != 3, "Scalability Mask must be equal to 1 or 3. ");
@@ -1289,5 +1297,5 @@
   xConfirmPara( m_scalabilityMask != 1 , "Scalability Mask must be equal to 1. ");
 #endif
- 
+
   m_dimIds.push_back( m_viewId ); 
   const Int viewDimPosition = 0; 
@@ -1299,52 +1307,88 @@
   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_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. " ); 
-   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. " );
-   }
- }
-
- for( Int i = 0; i < m_numberOfLayers; i++ )
- {
-   for( Int j = 0; j < i; j++ )
-   {     
-     Int numDiff  = 0; 
-     Int lastDiff = -1; 
-     for( Int dim = 0; dim < m_dimIds.size(); dim++ )
-     {
-       if ( m_dimIds[dim][i] != m_dimIds[dim][j] )
-       {
-         numDiff ++; 
-         lastDiff = dim; 
-       }
-     }
-
-     Bool allEqual = ( numDiff == 0 ); 
-
-     if ( allEqual ) 
-     {
-       printf( "\nError: Positions of Layers %d and %d are identical in scalability space\n", i, j);
-     }
-
-     xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
-
-     if ( numDiff  == 1 ) 
-     {
-       Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ]; 
-       Bool shallBeButIsNotIncreasing = ( !inc && ( lastDiff != viewDimPosition ) ) ; 
-       if ( shallBeButIsNotIncreasing )
-       {       
-         printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);        
-       }
-       xConfirmPara( shallBeButIsNotIncreasing && ( lastDiff != viewDimPosition ),  "DimensionIds shall be increasing within one dimension. " );
-     }
-   }
- }
-
+  for( Int dim = 0; dim < m_dimIds.size(); dim++ )
+  {
+    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. " ); 
+    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. " );
+    }
+  }
+
+  for( Int i = 0; i < m_numberOfLayers; i++ )
+  {
+    for( Int j = 0; j < i; j++ )
+    {     
+      Int numDiff  = 0; 
+      Int lastDiff = -1; 
+      for( Int dim = 0; dim < m_dimIds.size(); dim++ )
+      {
+        if ( m_dimIds[dim][i] != m_dimIds[dim][j] )
+        {
+          numDiff ++; 
+          lastDiff = dim; 
+        }
+      }
+
+      Bool allEqual = ( numDiff == 0 ); 
+
+      if ( allEqual ) 
+      {
+        printf( "\nError: Positions of Layers %d and %d are identical in scalability space\n", i, j);
+      }
+
+      xConfirmPara( allEqual , "Each layer shall have a different position in scalability space." );
+
+      if ( numDiff  == 1 ) 
+      {
+        Bool inc = m_dimIds[ lastDiff ][ i ] > m_dimIds[ lastDiff ][ j ]; 
+        Bool shallBeButIsNotIncreasing = ( !inc && ( lastDiff != viewDimPosition ) ) ; 
+        if ( shallBeButIsNotIncreasing )
+        {       
+          printf( "\nError: Positions of Layers %d and %d is not increasing in dimension %d \n", i, j, lastDiff);        
+        }
+        xConfirmPara( shallBeButIsNotIncreasing && ( lastDiff != viewDimPosition ),  "DimensionIds shall be increasing within one dimension. " );
+      }
+    }
+  }
+
+  /// 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() < 0 || 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 must 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" );
 #endif
   xConfirmPara( m_iGOPSize < 1 ,                                                            "GOP Size must be greater or equal to 1" );
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncCfg.h	(revision 492)
@@ -86,4 +86,14 @@
   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 of Layer set
+  Bool                   m_defaultOneTargetOutputLayerFlag;   ///< Output highest layer of layer sets by default
+  Int                    numAddOuputLayerSets;              ///< Number of additional output layer sets
+  std::vector<Int>       m_outputLayerSetIdx;                 ///< Indices of layer sets used as additional output layer sets  
+  std::vector< std::vector<Int> > m_layerIdsInAddOutputLayerSet; ///< LayerIds of additional output layers  
+  std::vector<Int>       m_profileLevelTierIdx;               ///< Indices of of profile level tier
+
 #endif
   Double    m_adLambdaModifier[ MAX_TLAYER ];                 ///< Lambda modifier array for each temporal layer
Index: /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.cpp	(revision 492)
@@ -119,4 +119,5 @@
   xSetDimensionIdAndLength ( vps );
   xSetDirectDependencyFlags( vps );
+  xSetLayerSets            ( vps ); 
 #if H_3D
   vps.initViewIndex(); 
@@ -1031,4 +1032,56 @@
   return maxVec;
 }
+
+Void TAppEncTop::xSetLayerSets( TComVPS& vps )
+{   
+  // Layer sets
+  vps.setVpsNumLayerSetsMinus1   ( m_vpsNumLayerSets ); 
+  vps.setVpsNumberLayerSetsMinus1( m_vpsNumLayerSets ); 
+    
+  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, m_layerIdsInSets[lsIdx][i] ); 
+    } 
+  }
+
+  Int numAddOuputLayerSets = 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-dev0/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/App/TAppEncoder/TAppEncTop.h	(revision 492)
@@ -119,4 +119,5 @@
   Void xSetDimensionIdAndLength   ( TComVPS& vps );
   Void xSetDirectDependencyFlags  ( TComVPS& vps );
+  Void xSetLayerSets( TComVPS& vps );
   Int  xGetMax( std::vector<Int>& vec);
 #endif
@@ -130,4 +131,5 @@
 #else
   TEncTop&    getTEncTop  ()   { return  m_cTEncTop; }      ///< return encoder class pointer reference
+ 
 #endif
 };// END CLASS DEFINITION TAppEncTop
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 492)
@@ -494,8 +494,10 @@
   UInt*       m_hrdOpSetIdx;
   Bool*       m_cprmsPresentFlag;
-  UInt        m_numOpSets;
-#if H_MV
+  
+#if H_MV
+  UInt        m_vpsNumLayerSetsMinus1;
   Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_LAYER_ID_PLUS1];
 #else
+  UInt        m_numOpSets;
   Bool        m_layerIdIncludedFlag[MAX_VPS_OP_SETS_PLUS1][MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1];
 #endif
@@ -607,11 +609,15 @@
   UInt    getVpsMaxLayerId()                                    { return m_maxLayerId; }
   Void    setVpsMaxLayerId(UInt v)                              { m_maxLayerId = v;    }
+
+  UInt    getVpsNumLayerSetsMinus1()                            { return m_vpsNumLayerSetsMinus1; }
+  Void    setVpsNumLayerSetsMinus1(UInt v)                      { m_vpsNumLayerSetsMinus1 = v;    }
 #else
   UInt    getMaxNuhReservedZeroLayerId()                        { return m_maxNuhReservedZeroLayerId; }
   Void    setMaxNuhReservedZeroLayerId(UInt v)                  { m_maxNuhReservedZeroLayerId = v;    }
-#endif
 
   UInt    getMaxOpSets()                                        { return m_numOpSets; }
   Void    setMaxOpSets(UInt v)                                  { m_numOpSets = v;    }
+#endif
+
   Bool    getLayerIdIncludedFlag(UInt opsIdx, UInt id)          { return m_layerIdIncludedFlag[opsIdx][id]; }
   Void    setLayerIdIncludedFlag(Bool v, UInt opsIdx, UInt id)  { m_layerIdIncludedFlag[opsIdx][id] = v;    }
@@ -729,5 +735,5 @@
   {
     assert( lsIdx >= 0 ); 
-    assert( lsIdx < getMaxOpSets() ); 
+    assert( lsIdx <= getVpsNumLayerSetsMinus1() ); 
     Int numLayersInIdList = 0; 
     for (Int layerId = 0; layerId < getVpsMaxLayerId(); layerId++ )
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 492)
@@ -840,15 +840,17 @@
   assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
   READ_CODE( 6, uiCode, "vps_max_nuh_layer_id" );   pcVPS->setVpsMaxLayerId( uiCode );
+
+  READ_UVLC(    uiCode, "vps_max_num_layer_sets_minus1" );               pcVPS->setVpsNumLayerSetsMinus1( uiCode );
+  for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ )
+  {
+    for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ )
 #else
   assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
   READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" );   pcVPS->setMaxNuhReservedZeroLayerId( uiCode );
-#endif
+
   READ_UVLC(    uiCode, "vps_max_op_sets_minus1" );               pcVPS->setMaxOpSets( uiCode + 1 );
   for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
   {
     // Operation point set
-#if H_MV
-    for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ )
-#else
     for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
 #endif
@@ -948,5 +950,5 @@
     READ_CODE( 6,  uiCode, "vps_num_profile_tier_level_minus1" );  pcVPS->setVpsNumProfileTierLevelMinus1( uiCode );
 
-    for( Int i = 1; i <= pcVPS->getMaxOpSets() - 1; i++ )
+    for( Int i = 1; i <= pcVPS->getVpsNumberLayerSetsMinus1(); i++ )
     {
       READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
Index: /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 491)
+++ /branches/HTM-DEV-0.3-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 492)
@@ -649,9 +649,15 @@
 #if H_MV
   assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 );
-  WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6,                 "vps_max_layer_id" );
+  WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6,                 "vps_max_layer_id" );  
+  
+  WRITE_UVLC( pcVPS->getVpsNumLayerSetsMinus1(),  "vps_max_num_layer_sets_minus1" );
+  for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ )
+  {
+    // Operation point set
+    for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ )
 #else
   assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
   WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6,     "vps_max_nuh_reserved_zero_layer_id" );
-#endif
+
   pcVPS->setMaxOpSets(1);
   WRITE_UVLC( pcVPS->getMaxOpSets() - 1,                    "vps_max_op_sets_minus1" );
@@ -659,7 +665,4 @@
   {
     // Operation point set
-#if H_MV
-    for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ )
-#else
     for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
 #endif
