Index: /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1048)
+++ /branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp	(revision 1049)
@@ -1545,17 +1545,17 @@
     for( Int dpbLayerCtr = 0; dpbLayerCtr < dpbStatus.m_numLayers; dpbLayerCtr++)
     {
-      Int layerIdx  = dpbStatus.m_targetDecLayerIdList[dpbLayerCtr];
+      Int layerId = dpbStatus.m_targetDecLayerIdList[dpbLayerCtr];
       // Output all picutres "decoded" in that layer that have POC less than the current picture
-      std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(layerIdx))->getConfListPic();
+      std::vector<TComPic> *layerBuffer = (m_acTDecTop->getLayerDec(layerId))->getConfListPic();
       // Write all pictures to the file.
-      if( this->getDecodedYuvLayerRefresh(layerIdx) )
-      {
-        m_outputBitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerIdx];
-        m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerIdx];
+      if( this->getDecodedYuvLayerRefresh(layerId) )
+      {
+        m_outputBitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId];
+        m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId];
 
         char tempFileName[256];
-        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerIdx ).c_str());
-        m_confReconFile[layerIdx].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
-        this->setDecodedYuvLayerRefresh( layerIdx, false );
+        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerId ).c_str());
+        m_confReconFile[layerId].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
+        this->setDecodedYuvLayerRefresh( layerId, false );
       }
 
@@ -1575,5 +1575,5 @@
         {
           TComPicYuv* pPicCYuvRec = checkPic.getPicYuvRec();
-          m_confReconFile[layerIdx].write( pPicCYuvRec, m_outputColourSpaceConvert,
+          m_confReconFile[layerId].write( pPicCYuvRec, m_outputColourSpaceConvert,
             conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
             conf.getWindowRightOffset() * xScal + defDisp.getWindowRightOffset(),
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPic.h	(revision 1049)
@@ -200,5 +200,4 @@
   Void          setLayerId (UInt layerId)   { m_layerId = layerId; }
   UInt          getLayerId ()               { return m_layerId; }
-  UInt          getLayerIdx ()              { return this->getSlice(0)->getVPS()->getLayerIdxInVps(m_layerId); }
   Bool          isSpatialEnhLayer(UInt refLayerIdc)             { return m_bSpatialEnhLayer[refLayerIdc]; }
   Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1049)
@@ -1089,6 +1089,6 @@
   Void   setNuhLayerIdPresentFlag(Bool x)                       { m_nuhLayerIdPresentFlag = x;     }
 
-  UInt   getLayerIdInNuh(Int id)                                { return m_layerIdInNuh[id];       }
-  Void   setLayerIdInNuh(Int id, UInt x)                        { m_layerIdInNuh[id] = x;          }
+  UInt   getLayerIdInNuh(Int layerIdx)                          { return m_layerIdInNuh[id];       }
+  Void   setLayerIdInNuh(Int layerIdx, UInt x)                  { m_layerIdInNuh[id] = x;          }
 
   UInt   getDimensionId(Int lyrId, Int id)                      { return m_dimensionId[lyrId][id]; }
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1049)
@@ -2991,5 +2991,5 @@
     {
 #if O0225_MAX_TID_FOR_REF_LAYERS
-      for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+      for( j = i+1; j < vps->getMaxLayers(); j++)
       {
         if(vps->getDirectDependencyFlag(j, i))
@@ -3009,5 +3009,5 @@
     {
 #if O0225_MAX_TID_FOR_REF_LAYERS
-      for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+      for( j = i+1; j < vps->getMaxLayers(); j++)
       {
         vps->setMaxTidIlRefPicsPlus1(i, j, 7);
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h	(revision 1049)
@@ -103,5 +103,5 @@
  
 #if SVC_EXTENSION
-  TDecTop*   getLayerDec        ( UInt layerIdx )  { return m_ppcTDecTop[layerIdx]; }
+  TDecTop*   getLayerDec        ( UInt layerId )  { return m_ppcTDecTop[layerId]; }
 #endif
 protected:
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1049)
@@ -252,8 +252,8 @@
   }
 #if CONFORMANCE_BITSTREAM_MODE
-  if( this->getLayerDec(pcPic->getLayerIdx())->getConfModeFlag() )
+  if( this->getLayerDec(pcPic->getLayerId())->getConfModeFlag() )
   {
     // Add this reconstructed picture to the parallel buffer.
-    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerIdx()))->getConfListPic();
+    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerId()))->getConfListPic();
     thisLayerBuffer->push_back(*pcPic);
     std::sort( thisLayerBuffer->begin(), thisLayerBuffer->end(), pocCompareFunction );
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h	(revision 1049)
@@ -118,5 +118,5 @@
 #endif
 #if SVC_EXTENSION
-  TDecTop*   getLayerDec(UInt layerIdx)  { return m_ppcTDecTop[layerIdx]; }
+  TDecTop*   getLayerDec(UInt layerId)  { return m_ppcTDecTop[layerId]; }
 #endif 
 
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1049)
@@ -483,5 +483,5 @@
 
 #if FIX_NON_OUTPUT_LAYER
-  if( this->getLayerDec(pcPic->getLayerIdx())->m_isOutputLayerFlag == false )
+  if( this->getLayerDec(pcPic->getLayerId())->m_isOutputLayerFlag == false )
   {
     pcPic->setOutputMark( false );
@@ -1096,9 +1096,9 @@
       resetPocRestrictionCheckParameters();
 #endif
-      markAllPicsAsNoCurrAu();
+      markAllPicsAsNoCurrAu(m_apcSlicePilot->getVPS());
 #if P0297_VPS_POC_LSB_ALIGNED_FLAG
       for (UInt i = 0; i < MAX_LAYERS; i++)
       {
-        m_ppcTDecTop[i]->m_pocDecrementedInDPBFlag = false;
+        m_ppcTDecTop[m_apcSlicePilot->getVPS()->getLayerIdInNuh(i)]->m_pocDecrementedInDPBFlag = false;
       }
 #endif
@@ -2857,5 +2857,5 @@
   }
   
-  return (TDecTop *)getLayerDec( vps->getLayerIdxInVps( vps->getRefLayerId( m_layerId, refLayerIdx ) ) );
+  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdx ) );
 }
 #endif
@@ -2864,7 +2864,7 @@
 Void TDecTop::setRefLayerParams( TComVPS* vps )
 {
-  for(UInt layer = 0; layer < m_numLayer; layer++)
-  {
-    TDecTop *decTop = (TDecTop *)getLayerDec(layer);
+  for(UInt layerIdx = 0; layerIdx < m_numLayer; layerIdx++)
+  {
+    TDecTop *decTop = (TDecTop *)getLayerDec(vps->getLayerIdInNuh(layerIdx));
     decTop->setNumSamplePredRefLayers(0);
     decTop->setNumMotionPredRefLayers(0);
@@ -2877,16 +2877,16 @@
       decTop->setMotionPredRefLayerId(i, 0);
     }
-    for(Int j = 0; j < layer; j++)
-    {
-      if (vps->getDirectDependencyFlag(layer, j))
-      {
-        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer));
+    for(Int j = 0; j < layerIdx; j++)
+    {
+      if (vps->getDirectDependencyFlag(layerIdx, j))
+      {
+        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layerIdx));
         decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1);
 
-        Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1;
+        Int samplePredEnabledFlag = (vps->getDirectDependencyType(layerIdx, j) + 1) & 1;
         decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false);
         decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag);
 
-        Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1;
+        Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layerIdx, j) + 1) & 2) >> 1;
         decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false);
         decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag);
@@ -3108,5 +3108,5 @@
     if( vps->getOutputLayerFlag( targetOlsIdx, i ) )
     {
-      this->getLayerDec( vps->getLayerIdxInVps( vps->getLayerSetLayerIdList( targetLsIdx, i ) ) )->m_isOutputLayerFlag = true;
+      this->getLayerDec( vps->getLayerSetLayerIdList( targetLsIdx, i ) )->m_isOutputLayerFlag = true;
     }
   }
@@ -3130,9 +3130,9 @@
 #endif
 #if POC_RESET_IDC_DECODER
-Void TDecTop::markAllPicsAsNoCurrAu()
+Void TDecTop::markAllPicsAsNoCurrAu(TComVPS *vps)
 {
   for(Int i = 0; i < MAX_LAYERS; i++)
   {
-    TComList<TComPic*>* listPic = this->getLayerDec(i)->getListPic();
+    TComList<TComPic*>* listPic = this->getLayerDec(vps->getLayerIdInNuh(i))->getListPic();
     TComList<TComPic*>::iterator  iterPic = listPic->begin();
     while ( iterPic != listPic->end() )
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1048)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1049)
@@ -244,5 +244,5 @@
   Int       getParseIdc                     ()                              { return m_parseIdc;               }
   Void      setParseIdc                     (Int x)                         { m_parseIdc = x;                  }
-  Void      markAllPicsAsNoCurrAu();
+  Void      markAllPicsAsNoCurrAu           (TComVPS *vps);
 
   Int       getLastPocPeriodId              ()                              { return m_lastPocPeriodId;        }
@@ -258,5 +258,5 @@
   TComList<TComPic*>*  getListPic           ()                              { return &m_cListPic;              }
   Void      setLayerDec                     (TDecTop **p)                   { m_ppcTDecTop = p;                }
-  TDecTop*  getLayerDec                     (UInt layerIdx)                 { return m_ppcTDecTop[layerIdx];   }
+  TDecTop*  getLayerDec                     (UInt layerId)                  { return m_ppcTDecTop[layerId];    }
 #if R0235_SMALLEST_LAYER_ID
   Void      xDeriveSmallestLayerId(TComVPS* vps);
