Index: /branches/SHM-5.0-dev/source/App/TAppDecoder/TAppDecCfg.cpp
===================================================================
--- /branches/SHM-5.0-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 583)
+++ /branches/SHM-5.0-dev/source/App/TAppDecoder/TAppDecCfg.cpp	(revision 584)
@@ -148,5 +148,5 @@
 #endif
 #if OUTPUT_LAYER_SET_INDEX  
-  this->getCommonDecoderParams()->setOutputLayerSetIdx( olsIdx       );
+  this->getCommonDecoderParams()->setTargetOutputLayerSetIdx( olsIdx       );
   this->getCommonDecoderParams()->setTargetLayerId    ( m_tgtLayerId );
 #endif
Index: /branches/SHM-5.0-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/SHM-5.0-dev/source/Lib/TLibCommon/CommonDef.h	(revision 583)
+++ /branches/SHM-5.0-dev/source/Lib/TLibCommon/CommonDef.h	(revision 584)
@@ -284,5 +284,5 @@
 {
   Int m_targetLayerId;
-  Int m_outputLayerSetIdx;
+  Int m_targetOutputLayerSetIdx;
   std::vector<Int> *m_targetDecLayerIdSet; 
   Bool m_valueCheckedFlag;
@@ -290,5 +290,5 @@
   CommonDecoderParams(): 
     m_targetLayerId(0)
-    , m_outputLayerSetIdx(-1)
+    , m_targetOutputLayerSetIdx(-1)
     , m_targetDecLayerIdSet(NULL)
     , m_valueCheckedFlag(false)
@@ -298,6 +298,6 @@
   Int  getTargetLayerId()            { return m_targetLayerId;}
   
-  Void setOutputLayerSetIdx(const Int x) { m_outputLayerSetIdx = x;   }
-  Int  getOutputLayerSetIdx()            { return m_outputLayerSetIdx;}
+  Void setTargetOutputLayerSetIdx(const Int x) { m_targetOutputLayerSetIdx = x;   }
+  Int  getTargetOutputLayerSetIdx()            { return m_targetOutputLayerSetIdx;}
 
   Void               setTargetDecLayerIdSet(std::vector<Int> *x) { m_targetDecLayerIdSet = x;   }
Index: /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 583)
+++ /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 584)
@@ -181,5 +181,5 @@
     {
 #if USE_DPB_SIZE_TABLE
-      if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+      if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
       {
         assert( this->getLayerId() == 0 );
@@ -190,5 +190,5 @@
         TComVPS *vps = slice->getVPS();
         // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
-        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer);
+        numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
       }
 #else
@@ -285,5 +285,5 @@
   {
 #if USE_DPB_SIZE_TABLE
-    if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+    if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
     {
       assert( this->getLayerId() == 0 );
@@ -294,5 +294,5 @@
       TComVPS *vps = pcSlice->getVPS();
       // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures.
-      numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getOutputLayerSetIdx() , temporalLayer);
+      numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer);
     }
 #else
@@ -302,5 +302,5 @@
 
 #if USE_DPB_SIZE_TABLE
-  if( getCommonDecoderParams()->getOutputLayerSetIdx() == 0 )
+  if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 )
   {
     assert( this->getLayerId() == 0 );
@@ -310,9 +310,9 @@
   {
 #if RESOLUTION_BASED_DPB
-    Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getOutputLayerSetIdx() );
+    Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() );
     Int layerIdx = pcSlice->getVPS()->findLayerIdxInLayerSet( layerSetIdxForOutputLayerSet, pcSlice->getLayerId() );  assert( layerIdx != -1 );
-    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
-#else
-    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
+#else
+    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
 #endif
   }
@@ -824,5 +824,5 @@
 #if OUTPUT_LAYER_SET_INDEX
   // Following check should go wherever the VPS is activated
-  checkValueOfOutputLayerSetIdx( m_apcSlicePilot->getVPS());
+  checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS());
 #endif
 #if RESOLUTION_BASED_DPB
@@ -2022,5 +2022,5 @@
 
 #if OUTPUT_LAYER_SET_INDEX
-Void TDecTop::checkValueOfOutputLayerSetIdx(TComVPS *vps)
+Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps)
 {
   CommonDecoderParams* params = this->getCommonDecoderParams();
@@ -2032,5 +2032,5 @@
     return; // Already checked
   }
-  if( params->getOutputLayerSetIdx() == -1 )  // Output layer set index not specified
+  if( params->getTargetOutputLayerSetIdx() == -1 )  // Output layer set index not specified
   {
     Bool layerSetMatchFound = false;
@@ -2079,5 +2079,5 @@
           // Match found
           layerSetMatchFound = true;
-          params->setOutputLayerSetIdx( i );
+          params->setTargetOutputLayerSetIdx( i );
           params->setValueCheckedFlag( true );
           break;
@@ -2090,5 +2090,6 @@
   {
     // 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->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() );
+    Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() );  // Index to the layer set
     assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1);
 
@@ -2126,5 +2127,5 @@
   if( m_subDpbIdx == -1 ) // Sub-DPB index is not already assigned
   {
-    Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getOutputLayerSetIdx() );
+    Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() );
 
     Int layerIdx = vps->findLayerIdxInLayerSet( lsIdx, getLayerId() );
Index: /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 583)
+++ /branches/SHM-5.0-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 584)
@@ -260,5 +260,5 @@
   CommonDecoderParams*    getCommonDecoderParams() { return m_commonDecoderParams; }
   Void                    setCommonDecoderParams(CommonDecoderParams* x) { m_commonDecoderParams = x; }
-  Void      checkValueOfOutputLayerSetIdx(TComVPS *vps);
+  Void      checkValueOfTargetOutputLayerSetIdx(TComVPS *vps);
 #endif
 #if SCALINGLIST_INFERRING
