Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1043)
@@ -1347,5 +1347,5 @@
 #if N0065_LAYER_POC_ALIGNMENT
 #if O0062_POC_LSB_NOT_PRESENT_FLAG
-    if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() )
+    if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() )
 #else
     if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() )
@@ -1536,8 +1536,8 @@
           if(chkAssert)
           {
-            // There may be something wrong here (layer id assumed to be layer idx?)
-            assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
-            assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures());
-            assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
+            UInt layerIdx = pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId());
+            assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
+            assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures());
+            assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
           }
         }
@@ -1601,9 +1601,9 @@
             {
 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
-              if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
-                (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >=  pcSlice->getTLayer()) )
+              if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
+                (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #else 
-              if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
-                (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >=  pcSlice->getTLayer()) )
+              if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
+                (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #endif 
               {          
@@ -1664,9 +1664,9 @@
       {
 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
-        if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
-          (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >=  pcSlice->getTLayer()) )
+        if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
+          (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #else 
-        if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
-          (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >=  pcSlice->getTLayer()) )
+        if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
+          (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #endif 
         {          
@@ -1714,5 +1714,5 @@
       else
       {
-        format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx( pcSlice->getVPS()->getLayerIdInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc();
+        format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx( pcSlice->getVPS()->getLayerIdxInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc();
 #if Q0195_REP_FORMAT_CLEANUP
         assert( (sps->getUpdateRepFormatFlag()==false && pcSlice->getVPS()->getVpsNumRepFormats()==1) || pcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check
@@ -2062,5 +2062,5 @@
     }
 #if Q0142_POC_LSB_NOT_PRESENT
-    if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && iPOClsb > 0 )
+    if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId()) ) && iPOClsb > 0 )
     {
       assert( pcSlice->getPocResetIdc() != 2 );
@@ -2082,5 +2082,5 @@
       READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode);
 #if Q0142_POC_LSB_NOT_PRESENT
-      if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && pcSlice->getFullPocResetFlag() )
+      if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId()) ) && pcSlice->getFullPocResetFlag() )
       {
         assert( pcSlice->getPocLsbVal() == 0 );
@@ -2854,5 +2854,5 @@
   READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false);
   vps->setLayerIdInNuh(0, 0);
-  vps->setLayerIdInVps(0, 0);
+  vps->setLayerIdxInVps(0, 0);
   for(i = 1; i < vps->getMaxLayers(); i++)
   {
@@ -2866,5 +2866,5 @@
       vps->setLayerIdInNuh(i, i);
     }
-    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
+    vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i);
 
     if( !vps->getSplittingFlag() )
@@ -2881,13 +2881,9 @@
 #endif
 #if VIEW_ID_RELATED_SIGNALING
-  // if ( pcVPS->getNumViews() > 1 )
-  //   However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val.
-  {
 #if O0109_VIEW_ID_LEN
-    READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode );
-#else
-    READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode );
-#endif
-  }
+  READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode );
+#else
+  READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode );
+#endif
 
 #if O0109_VIEW_ID_LEN
@@ -2910,6 +2906,7 @@
   vps->setNumDirectRefLayers(0, 0);
   // For other layers
-  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
-  {
+  for( Int layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++)
+  {
+    UInt layerId = vps->getLayerIdInNuh(layerCtr); 
     UInt numDirectRefLayers = 0;
     for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
@@ -2918,9 +2915,9 @@
       if(uiCode)
       {
-        vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr);
+        vps->setRefLayerId(layerId, numDirectRefLayers, vps->getLayerIdInNuh(refLayerCtr));
         numDirectRefLayers++;
       }
     }
-    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
+    vps->setNumDirectRefLayers(layerId, numDirectRefLayers);
   }
 #endif
@@ -3673,5 +3670,5 @@
   {
     vps->setLayerIdInNuh(i, i);
-    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
+    vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i);
   }
 
@@ -3868,5 +3865,5 @@
     for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
       Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
-      maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId)));
+      maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdxInVps(lId)));
     }
     MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
@@ -4229,5 +4226,5 @@
       {
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
-        layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j));
+        layerIdx = vps->getLayerIdxInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j));
         if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) {
           READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1));
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h	(revision 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.h	(revision 1043)
@@ -103,5 +103,5 @@
  
 #if SVC_EXTENSION
-  TDecTop*   getLayerDec        ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; }
+  TDecTop*   getLayerDec        ( UInt layerIdx )  { return m_ppcTDecTop[layerIdx]; }
 #endif
 protected:
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp	(revision 1043)
@@ -252,8 +252,8 @@
   }
 #if CONFORMANCE_BITSTREAM_MODE
-  if( this->getLayerDec(pcPic->getLayerId())->getConfModeFlag() ) 
+  if( this->getLayerDec(pcPic->getLayerIdx())->getConfModeFlag() )
   {
     // Add this reconstructed picture to the parallel buffer.
-    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerId()))->getConfListPic();
+    std::vector<TComPic> *thisLayerBuffer = (this->getLayerDec(pcPic->getLayerIdx()))->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 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.h	(revision 1043)
@@ -118,5 +118,5 @@
 #endif
 #if SVC_EXTENSION
-  TDecTop*   getLayerDec(UInt LayerId)  { return m_ppcTDecTop[LayerId]; }
+  TDecTop*   getLayerDec(UInt layerIdx)  { return m_ppcTDecTop[layerIdx]; }
 #endif 
 
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1043)
@@ -483,5 +483,5 @@
 
 #if FIX_NON_OUTPUT_LAYER
-  if( this->getLayerDec(pcPic->getLayerId())->m_isOutputLayerFlag == false )
+  if( this->getLayerDec(pcPic->getLayerIdx())->m_isOutputLayerFlag == false )
   {
     pcPic->setOutputMark( false );
@@ -764,5 +764,5 @@
 
 #if P0182_VPS_VUI_PS_FLAG
-    UInt layerIdx = activeVPS->getLayerIdInVps( m_layerId );
+    UInt layerIdx = activeVPS->getLayerIdxInVps( m_layerId );
 
     if( activeVPS->getBaseLayerPSCompatibilityFlag(layerIdx) )
@@ -788,5 +788,5 @@
 
 #if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer
-  UInt layerIdx = activeVPS->getLayerIdInVps(m_apcSlicePilot->getLayerId());
+  UInt layerIdx = activeVPS->getLayerIdxInVps(m_apcSlicePilot->getLayerId());
 
   if ( activeVPS->getVpsExtensionFlag() == 1 && (m_apcSlicePilot->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
@@ -2849,5 +2849,5 @@
 
 #if VPS_EXTN_DIRECT_REF_LAYERS
-TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc )
+TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdx )
 {
   TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS();
@@ -2857,5 +2857,5 @@
   }
   
-  return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) );
+  return (TDecTop *)getLayerDec( vps->getLayerIdxInVps( vps->getRefLayerId( m_layerId, refLayerIdx ) ) );
 }
 #endif
@@ -2897,6 +2897,5 @@
   {
     Int mIdx = 0, sIdx = 0;
-    Int iNuhLId = vps->getLayerIdInNuh(i);
-    TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId);
+    TDecTop *decTop = (TDecTop *)getLayerDec(i);
     for ( Int j = 0; j < i; j++ )
     {
@@ -2961,5 +2960,5 @@
   for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
   {
-    Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]);
+    Int jLidx = pcSlice->getVPS()->getLayerIdxInVps(targetDecLayerIdList[j]);
     if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 )
     {
@@ -3109,5 +3108,5 @@
     if( vps->getOutputLayerFlag( targetOlsIdx, i ) )
     {
-      this->getLayerDec( vps->getLayerSetLayerIdList( targetLsIdx, i ) )->m_isOutputLayerFlag = true;
+      this->getLayerDec( vps->getLayerIdxInVps( vps->getLayerSetLayerIdList( targetLsIdx, i ) ) )->m_isOutputLayerFlag = true;
     }
   }
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1042)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 1043)
@@ -242,26 +242,26 @@
 #endif
 #if POC_RESET_IDC_DECODER
-  Int getParseIdc() { return m_parseIdc;}
-  Void        setParseIdc(Int x) { m_parseIdc = x;}
-  Void        markAllPicsAsNoCurrAu();
-
-  Int   getLastPocPeriodId() { return m_lastPocPeriodId; }
-  Void  setLastPocPeriodId(Int x)    { m_lastPocPeriodId = x; }
-
-  Int   getPrevPicOrderCnt() { return m_prevPicOrderCnt; }
-  Void  setPrevPicOrderCnt(Int const x) { m_prevPicOrderCnt = x; }
-#endif
-  UInt      getLayerId            () { return m_layerId;              }
-  Void      setLayerId            (UInt layer) { m_layerId = layer; }
-  UInt      getNumLayer           () { return m_numLayer;             }
-  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
-  TComList<TComPic*>*      getListPic() { return &m_cListPic; }
-  Void      setLayerDec(TDecTop **p)    { m_ppcTDecTop = p; }
-  TDecTop*  getLayerDec(UInt layer)     { return m_ppcTDecTop[layer]; }
+  Int       getParseIdc                     ()                              { return m_parseIdc;               }
+  Void      setParseIdc                     (Int x)                         { m_parseIdc = x;                  }
+  Void      markAllPicsAsNoCurrAu();
+
+  Int       getLastPocPeriodId              ()                              { return m_lastPocPeriodId;        }
+  Void      setLastPocPeriodId              (Int x)                         { m_lastPocPeriodId = x;           }
+
+  Int       getPrevPicOrderCnt              ()                              { return m_prevPicOrderCnt;        }
+  Void      setPrevPicOrderCnt              (Int const x)                   { m_prevPicOrderCnt = x;           }
+#endif
+  UInt      getLayerId                      ()                              { return m_layerId;                }
+  Void      setLayerId                      (UInt layer)                    { m_layerId = layer;               }
+  UInt      getNumLayer                     ()                              { return m_numLayer;               }
+  Void      setNumLayer                     (UInt uiNum)                    { m_numLayer = uiNum;              }
+  TComList<TComPic*>*  getListPic           ()                              { return &m_cListPic;              }
+  Void      setLayerDec                     (TDecTop **p)                   { m_ppcTDecTop = p;                }
+  TDecTop*  getLayerDec                     (UInt layerIdx)                 { return m_ppcTDecTop[layerIdx];   }
 #if R0235_SMALLEST_LAYER_ID
   Void      xDeriveSmallestLayerId(TComVPS* vps);
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
-  TDecTop*  getRefLayerDec(UInt refLayerIdc);
+  TDecTop*  getRefLayerDec                  (UInt refLayerIdx);
   Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
   Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
