Index: branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 520)
+++ branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 521)
@@ -69,4 +69,7 @@
   string cfg_ReconFile [MAX_LAYERS];
   Int nLayerNum;
+#if OUTPUT_LAYER_SET_INDEX
+  Int olsIdx;
+#endif
 #if AVC_BASE
   string cfg_BLReconFile;
@@ -110,4 +113,7 @@
 #if SVC_EXTENSION
   ("LayerNum,-ls", nLayerNum, 1, "Number of layers to be decoded.")
+#if OUTPUT_LAYER_SET_INDEX
+  ("OutpuLayerSetIdx,-olsidx", olsIdx, -1, "Index of output layer set to be decoded.")
+#endif
 #endif 
   ("MaxTemporalLayer,t", m_iMaxTemporalLayer, -1, "Maximum Temporal Layer to be decoded. -1 to decode all layers")
@@ -138,4 +144,8 @@
   m_tgtLayerId = nLayerNum - 1;
   assert( m_tgtLayerId >= 0 );
+#if OUTPUT_LAYER_SET_INDEX  
+  this->getCommonDecoderParams()->setOutputLayerSetIdx( olsIdx       );
+  this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
+#endif
   for(UInt layer=0; layer<= m_tgtLayerId; layer++)
   {
@@ -201,4 +211,7 @@
       fprintf(stderr, "File %s could not be opened. Using all LayerIds as default.\n", cfg_TargetDecLayerIdSetFile.c_str() );
     }
+#if OUTPUT_LAYER_SET_INDEX  
+    this->getCommonDecoderParams()->setTargetDecLayerIdSet( &m_targetDecLayerIdSet );
+#endif
   }
 
Index: branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.h
===================================================================
--- branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 520)
+++ branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecCfg.h	(revision 521)
@@ -91,4 +91,7 @@
   std::vector<Int> m_targetDecLayerIdSet;             ///< set of LayerIds to be included in the sub-bitstream extraction process.
   Int           m_respectDefDispWindow;               ///< Only output content inside the default display window 
+#if OUTPUT_LAYER_SET_INDEX
+  CommonDecoderParams             m_commonDecoderParams;
+#endif
 
 public:
@@ -120,4 +123,7 @@
   
   Bool  parseCfg        ( Int argc, Char* argv[] );   ///< initialize option class from configuration
+#if OUTPUT_LAYER_SET_INDEX
+  CommonDecoderParams* getCommonDecoderParams() {return &m_commonDecoderParams;}
+#endif
 };
 
Index: branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 520)
+++ branches/SHM-4.1-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 521)
@@ -494,4 +494,7 @@
     m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
+#if OUTPUT_LAYER_SET_INDEX
+    m_acTDecTop[layer].setCommonDecoderParams( this->getCommonDecoderParams() );
+#endif
   }
 
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/CommonDef.h	(revision 520)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/CommonDef.h	(revision 521)
@@ -40,5 +40,5 @@
 
 #include <algorithm>
-
+#include <vector>
 #if _MSC_VER > 1000
 // disable "signed and unsigned mismatch"
@@ -280,4 +280,33 @@
 };
 
+#if OUTPUT_LAYER_SET_INDEX
+class CommonDecoderParams
+{
+  Int m_targetLayerId;
+  Int m_outputLayerSetIdx;
+  std::vector<Int> *m_targetDecLayerIdSet; 
+  Bool m_valueCheckedFlag;
+public:
+  CommonDecoderParams(): 
+    m_targetLayerId(0)
+    , m_outputLayerSetIdx(-1)
+    , m_targetDecLayerIdSet(NULL)
+    , m_valueCheckedFlag(false)
+ {}
+
+  Void setTargetLayerId(const Int x) { m_targetLayerId = x;   }
+  Int  getTargetLayerId()            { return m_targetLayerId;}
+  
+  Void setOutputLayerSetIdx(const Int x) { m_outputLayerSetIdx = x;   }
+  Int  getOutputLayerSetIdx()            { return m_outputLayerSetIdx;}
+
+  Void               setTargetDecLayerIdSet(std::vector<Int> *x) { m_targetDecLayerIdSet = x;   }
+  std::vector<Int>*  getTargetDecLayerIdSet()                    { return m_targetDecLayerIdSet;}
+  
+  Void setValueCheckedFlag(const Bool x) { m_valueCheckedFlag = x;   }
+  Bool getValueCheckedFlag()            { return m_valueCheckedFlag;}
+  
+};
+#endif
 //! \}
 
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 520)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 521)
@@ -193,4 +193,7 @@
 
 #define VPS_DPB_SIZE_TABLE               1      ///< JCTVC-O0217: DPB operations: signaling DPB-related parameters
+#if VPS_DPB_SIZE_TABLE 
+#define OUTPUT_LAYER_SET_INDEX           1      ///< JCTVC-O0217: DPB operations: Inference/input of output layer set index
+#endif
 #else
 #define SYNTAX_OUTPUT                    0
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 520)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 521)
@@ -694,4 +694,8 @@
 #if SVC_EXTENSION
   m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) );
+#if OUTPUT_LAYER_SET_INDEX
+  // Following check should go wherever the VPS is activated
+  checkValueOfOutputLayerSetIdx( m_apcSlicePilot->getVPS());
+#endif
   m_apcSlicePilot->initSlice( nalu.m_layerId );
 #else
@@ -805,5 +809,4 @@
   }
 #endif 
-
 #if REPN_FORMAT_IN_VPS
   // Initialize ILRP if needed, only for the current layer  
@@ -1860,4 +1863,100 @@
 }
 #endif
-
+#if OUTPUT_LAYER_SET_INDEX
+Void TDecTop::checkValueOfOutputLayerSetIdx(TComVPS *vps)
+{
+  CommonDecoderParams* params = this->getCommonDecoderParams();
+  if( params->getValueCheckedFlag() )
+  {
+    return; // Already checked
+  }
+  if( params->getOutputLayerSetIdx() == -1 )  // Output layer set index not specified
+  {
+    Bool layerSetMatchFound = false;
+    // Output layer set index not assigned.
+    // Based on the value of targetLayerId, check if any of the output layer matches
+    // Currently, the target layer ID in the encoder assumes that all the layers are decoded    
+    // Check if any of the output layer sets match this description
+    for(Int i = 0; i < vps->getNumOutputLayerSets(); i++)
+    {
+      Bool layerSetMatchFlag = true;
+      Int layerSetIdx = vps->getOutputLayerSetIdx( i );
+      if( vps->getNumLayersInIdList( layerSetIdx ) == params->getTargetLayerId() + 1 )
+      {
+        for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++)
+        {
+          if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j )
+          {
+            layerSetMatchFlag = false;
+            break;
+          }
+        }
+      }
+      else
+      {
+        layerSetMatchFlag = false;
+      }
+      
+      if( layerSetMatchFlag ) // Potential output layer set candidate found
+      {
+        // If target dec layer ID list is also included - check if they match
+        if( params->getTargetDecLayerIdSet() )
+        {
+          if( params->getTargetDecLayerIdSet()->size() )  
+          {
+            for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++)
+            {
+              if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j )))
+              {
+                layerSetMatchFlag = false;
+              }
+            }
+          }
+        }
+        if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present
+        {
+          // Match found
+          layerSetMatchFound = true;
+          params->setOutputLayerSetIdx( i );
+          params->setValueCheckedFlag( true );
+          break;
+        }
+      }
+    }
+    assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist
+  }   
+  else // Output layer set index is assigned - check if the values match
+  {
+    // Check if the target decoded layer is the highest layer in the list
+    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getOutputLayerSetIdx() );  // Index to the layer set
+    assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
+
+    Bool layerSetMatchFlag = true;
+    for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++)
+    {
+      if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j )
+      {
+        layerSetMatchFlag = false;
+        break;
+      }
+    }
+
+    assert(layerSetMatchFlag);    // Signaled output layer set index does not match targetOutputLayerId.
+    
+    // Check if the targetdeclayerIdlist matches the output layer set
+    if( params->getTargetDecLayerIdSet() )
+    {
+      if( params->getTargetDecLayerIdSet()->size() )  
+      {
+        for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++)
+        {
+          assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i )));
+        }
+      }
+    }
+    params->setValueCheckedFlag( true );
+
+  }
+}
+#endif
 //! \}
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 520)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 521)
@@ -134,4 +134,7 @@
   TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
 #endif 
+#if OUTPUT_LAYER_SET_INDEX
+  CommonDecoderParams*    m_commonDecoderParams;
+#endif
 #if AVC_SYNTAX || SYNTAX_OUTPUT
   fstream*               m_pBLSyntaxFile;
@@ -240,5 +243,10 @@
   TComPic*  getMotionPredIlp(TComSlice* pcSlice);
 #endif
-
+public:
+#if OUTPUT_LAYER_SET_INDEX
+  CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
+  Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
+  Void      checkValueOfOutputLayerSetIdx(TComVPS *vps);
+#endif
 };// END CLASS DEFINITION TDecTop
 
