Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1048)
@@ -851,5 +851,5 @@
 #if SVC_EXTENSION
   assert( pcVPS->getNumHrdParameters() <= MAX_VPS_LAYER_SETS_PLUS1 );
-  assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 );
+  assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_IDX_PLUS1 );
 #if !VPS_EXTN_OP_LAYER_SETS     // num layer sets set in TAppEncTop.cpp
   pcVPS->setNumLayerSets(1);
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 1048)
@@ -388,14 +388,14 @@
 #if VPS_EXTN_DIRECT_REF_LAYERS
   Int       m_numDirectRefLayers;
-  Int       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int       m_refLayerId[MAX_VPS_LAYER_IDX_PLUS1];
 
   Int       m_numActiveRefLayers;
-  Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int       m_predLayerId[MAX_VPS_LAYER_IDX_PLUS1];
   Int       m_numSamplePredRefLayers;
-  Int       m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int       m_samplePredRefLayerId[MAX_VPS_LAYER_IDX_PLUS1];
   Int       m_numMotionPredRefLayers;
-  Int       m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
-  Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
-  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
+  Int       m_motionPredRefLayerId[MAX_VPS_LAYER_IDX_PLUS1];
+  Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_IDX_PLUS1];
+  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_IDX_PLUS1];
 #endif
   Int       m_maxTidIlRefPicsPlus1;
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.h	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.h	(revision 1048)
@@ -182,5 +182,5 @@
 
 #if SVC_EXTENSION
-  TEncTop*   getLayerEnc(UInt LayerId)  {return m_ppcTEncTop[LayerId]; }
+  TEncTop*   getLayerEnc(UInt LayerIdx)  {return m_ppcTEncTop[LayerIdx]; }
 #if ENCODER_FAST_MODE
   Void  xCheckRDCostILRUni  ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId);
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1048)
@@ -1300,5 +1300,5 @@
     if (m_layerId > 0)
     {
-      Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
+      Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_IDX_PLUS1];
       Int activeNumILRRefIdxTmp = 0;
 
@@ -1308,7 +1308,7 @@
         UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
 #if VPS_EXTN_DIRECT_REF_LAYERS
-        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic();
-#else
-        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();
+        TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getRefLayerEnc(refLayerIdc)->getListPic();
+#else
+        TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)-1]->getListPic();
 #endif
         pcSlice->setBaseColPic( *cListPic, refLayerIdc );
@@ -1412,5 +1412,5 @@
         {
           // check for the sample prediction picture type
-          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) )
+          if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag(pcSlice->getVPS()->getLayerIdxInVps(refLayerId)) )
           {
 #if P0312_VERT_PHASE_ADJ
@@ -1491,5 +1491,5 @@
         if(pcSlice->getVPS()->getCrossLayerIrapAlignFlag())
         {
-          TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
+          TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getRefLayerEnc(0)->getListPic();
           TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
           if(picLayer0)
@@ -1533,5 +1533,5 @@
       if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R &&
 #if SVC_EXTENSION
-        ( m_iGopSize != 1 || m_ppcTEncTop[m_layerId]->getIntraPeriod() > 1 ) )
+        ( m_iGopSize != 1 || m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getIntraPeriod() > 1 ) )
 #else
           !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE))
@@ -1838,5 +1838,5 @@
         for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
         {
-          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
+          if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
           {
             foundSamplePredPicture = true;
@@ -1872,5 +1872,5 @@
         for( Int i = 0; i < pcSlice->getLayerId(); i++)
         {
-          TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();
+          TComList<TComPic *> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(i)]->getListPic();
           TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
           if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
@@ -1966,7 +1966,7 @@
           // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, 
           // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
-          if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
+          if( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag( refPic->getLayerId() )
 #if MFM_ENCCONSTRAINT
-            && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true 
+            && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(refPic->getLayerId())]->getListPic() )->checkSameRefInfo() == true 
 #endif
             ) 
@@ -1988,7 +1988,7 @@
             // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, 
             // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
-            if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
+            if( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag( refPic->getLayerId() )
 #if MFM_ENCCONSTRAINT
-              && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true 
+              && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(refPic->getLayerId())]->getListPic() )->checkSameRefInfo() == true 
 #endif
               ) 
@@ -2107,5 +2107,5 @@
         // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, 
         // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
-        if( refPic->isILR(m_layerId) && !m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) )
+        if( refPic->isILR(m_layerId) && !m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag(refPic->getLayerId()) )
         {
           pcSlice->setEnableTMVPFlag(false);
@@ -2125,5 +2125,5 @@
           TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
 
-          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
+          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
           {
             break;
@@ -2149,5 +2149,5 @@
           TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
 
-          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
+          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
           {
             break;
@@ -4820,16 +4820,16 @@
   for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
   {
-    if (!m_ppcTEncTop[affectedLayerList[layerIdx]]->getPocDecrementedInDPBFlag())
-    {
-      m_ppcTEncTop[affectedLayerList[layerIdx]]->setPocDecrementedInDPBFlag(true);
+    if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getPocDecrementedInDPBFlag())
+    {
+      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->setPocDecrementedInDPBFlag(true);
 
       // Decrement value of associatedIrapPoc of the TEncGop object
-      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
+      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
 
       // Decrememnt the value of m_pocCRA
-      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
-
-      TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->begin();
-      while (iterPic != m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->end())
+      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
+
+      TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getListPic()->begin();
+      while (iterPic != m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getListPic()->end())
 #else
   // Decrement value of associatedIrapPoc of the TEncGop object
@@ -5334,10 +5334,10 @@
       {
         Int iLayerId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
-        m_ppcTEncTop[iLayerId]->setLayerInitializedFlag(false);
-        m_ppcTEncTop[iLayerId]->setFirstPicInLayerDecodedFlag(false);
+        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(iLayerId)]->setLayerInitializedFlag(false);
+        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(iLayerId)]->setFirstPicInLayerDecodedFlag(false);
       }
 
       // Each picture that is in the DPB and has nuh_layer_id equal to dolLayerId is marked as "unused for reference".
-      for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[dolLayerId]->getListPic()->begin(); pic != m_ppcTEncTop[dolLayerId]->getListPic()->end(); pic++)
+      for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(dolLayerId)]->getListPic()->begin(); pic != m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(dolLayerId)]->getListPic()->end(); pic++)
       {
         if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
@@ -5352,5 +5352,5 @@
       {
         UInt predLId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
-        for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[predLId]->getListPic()->begin(); pic != m_ppcTEncTop[predLId]->getListPic()->end(); pic++)
+        for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[predLId]->getListPic()->begin(); pic != m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(predLId)]->getListPic()->end(); pic++)
         {
           if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
@@ -5373,11 +5373,11 @@
       m_noRaslOutputFlag = true;
     }
-    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag())
+    else if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->getLayerInitializedFlag())
     {
       Bool refLayersInitialized = true;
-      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(m_layerId); j++)
+      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(slice->getVPS()->getLayerIdxInVps(m_layerId)); j++)
       {
         UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
-        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
+        if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(refLayerId)]->getLayerInitializedFlag())
         {
           refLayersInitialized = false;
@@ -5398,11 +5398,11 @@
     if (m_layerId == 0)
     {
-      m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
-    }
-    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag() && slice->getVPS()->getNumDirectRefLayers(m_layerId) == 0)
-    {
-      m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
-    }
-    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag())
+      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->setLayerInitializedFlag(true);
+    }
+    else if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->getLayerInitializedFlag() && slice->getVPS()->getNumDirectRefLayers(m_layerId) == 0)
+    {
+      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->setLayerInitializedFlag(true);
+    }
+    else if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->getLayerInitializedFlag())
     {
       Bool refLayersInitialized = true;
@@ -5410,5 +5410,5 @@
       {
         UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
-        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
+        if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(refLayerId)]->getLayerInitializedFlag())
         {
           refLayersInitialized = false;
@@ -5417,5 +5417,5 @@
       if (refLayersInitialized)
       {
-        m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
+        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->setLayerInitializedFlag(true);
       }
     }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1048)
@@ -139,10 +139,10 @@
 {
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getLayerId()]->getNumActiveRefLayers() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
-  {
-    Int nCurLayer = slice->getLayerId();
-    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
-      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
-      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
+  if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(slice->getLayerId())]->getNumActiveRefLayers() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
+  {
+    Int nCurLayerId = slice->getLayerId();
+    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)-1]->getQP() - m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)]->getQP() ,
+      1.0 * m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)]->getSourceWidth() * m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)]->getSourceHeight()
+      / m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)-1]->getSourceWidth() / m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(nCurLayerId)-1]->getSourceHeight() );
     dLambda *= gamma;
   }
@@ -163,5 +163,5 @@
 
 #if JCTVC_M0259_LAMBDAREFINEMENT
-    if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getLayerId()]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && slice->isIntra() == false && depth == 0 )
+    if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(slice->getLayerId())]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && slice->isIntra() == false && depth == 0 )
     {
       dLambdas[0] = dLambda * 1.1;
@@ -555,12 +555,12 @@
     if( rpcSlice->getNumILRRefIdx() > 0 )
     {
-      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() );
+      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getNumActiveRefLayers() );
       for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
       {
-        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i );
+        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getPredLayerId(i), i );
       }
       rpcSlice->setInterLayerPredEnabledFlag(1);
     }
-    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
+    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getMFMEnabledFlag());
   }
 
@@ -762,5 +762,5 @@
   }
 #if O0194_WEIGHTED_PREDICTION_CGS
-  else if( m_ppcTEncTop[pcSlice->getLayerId()]->getInterLayerWeightedPredFlag() )
+  else if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())]->getInterLayerWeightedPredFlag() )
   {
     // Calculate for the base layer to be used in EL as Inter layer reference
@@ -1135,5 +1135,5 @@
 
 #if SVC_EXTENSION
-        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, m_ppcTEncTop[pcSlice->getLayerId()]->getSAO()->getSaoMaxOffsetQVal(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
+        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())]->getSAO()->getSaoMaxOffsetQVal(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
 #else
         m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail);
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1048)
@@ -1531,12 +1531,12 @@
 #if SVC_EXTENSION
 #if VPS_EXTN_DIRECT_REF_LAYERS
-TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdc )
-{
-  if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
+TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdx )
+{
+  if( m_ppcTEncTop[m_cVPS.getLayerIdxInVps(m_layerId)]->getNumDirectRefLayers() <= 0 )
   {
     return (TEncTop *)getLayerEnc( 0 );
   }
 
-  return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) );
+  return (TEncTop *)getLayerEnc( m_cVPS.getLayerIdxInVps(m_cVPS.getRefLayerId( m_layerId, refLayerIdx )));
 }
 #endif
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 1047)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 1048)
@@ -117,5 +117,5 @@
   static Int              m_iPPSIdCnt;                    ///< next Id number for PPS    
   TEncTop**               m_ppcTEncTop;
-  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
+  TEncTop*                getLayerEnc(UInt layerIdx)   { return m_ppcTEncTop[layerIdx]; }
   TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture 
 #if REF_IDX_MFM
@@ -275,5 +275,5 @@
   Void      encodePrep( TComPicYuv* pcPicYuvOrg, TComPicYuv* pcPicYuvTrueOrg, Bool isTff );
 #if VPS_EXTN_DIRECT_REF_LAYERS
-  TEncTop*  getRefLayerEnc(UInt refLayerIdc);
+  TEncTop*  getRefLayerEnc(UInt refLayerIdx);
 #endif
 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
