Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1048)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1051)
@@ -192,6 +192,8 @@
   if( pcTEncTop->getLayerId() )
   {
-    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()-1] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()-1] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
-    m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()-1] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()-1] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
+    UInt prevLayerId = pcTEncTop->getLayerId()-1; // it should be changed
+
+    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
+    m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     if(!m_pColorMappedPic)
     {
@@ -1170,6 +1172,7 @@
         for (UInt i = 0; i < m_pcCfg->getNumLayer(); i++)
         {
-          m_ppcTEncTop[i]->setLayerInitializedFlag(false);
-          m_ppcTEncTop[i]->setFirstPicInLayerDecodedFlag(false);
+          Int layerId = pcSlice->getVPS()->getLayerIdInNuh(i);
+          m_ppcTEncTop[layerId]->setLayerInitializedFlag(false);
+          m_ppcTEncTop[layerId]->setFirstPicInLayerDecodedFlag(false);
         }
       }
@@ -1308,5 +1311,5 @@
         UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
 #if VPS_EXTN_DIRECT_REF_LAYERS
-        TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getRefLayerEnc(refLayerIdc)->getListPic();
+        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic();
 #else
         TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)-1]->getListPic();
@@ -1412,5 +1415,5 @@
         {
           // check for the sample prediction picture type
-          if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag(pcSlice->getVPS()->getLayerIdxInVps(refLayerId)) )
+          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) )
           {
 #if P0312_VERT_PHASE_ADJ
@@ -1491,5 +1494,5 @@
         if(pcSlice->getVPS()->getCrossLayerIrapAlignFlag())
         {
-          TComList<TComPic*> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getRefLayerEnc(0)->getListPic();
+          TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
           TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
           if(picLayer0)
@@ -1533,5 +1536,5 @@
       if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R &&
 #if SVC_EXTENSION
-        ( m_iGopSize != 1 || m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getIntraPeriod() > 1 ) )
+        ( m_iGopSize != 1 || m_ppcTEncTop[m_layerId]->getIntraPeriod() > 1 ) )
 #else
           !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE))
@@ -1838,5 +1841,5 @@
         for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
         {
-          if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
+          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
           {
             foundSamplePredPicture = true;
@@ -1872,7 +1875,7 @@
         for( Int i = 0; i < pcSlice->getLayerId(); i++)
         {
-          TComList<TComPic *> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(i)]->getListPic();
+          TComList<TComPic *> *cListPic = m_ppcTEncTop[pcSlice->getVPS()->getLayerIdInNuh(i)]->getListPic();
           TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
-          if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
+          if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerIdx(), i) )
           {
             if( lowerLayerPic->getSlice(0)->getSliceType() == I_SLICE)
@@ -1966,7 +1969,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[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag( refPic->getLayerId() )
+          if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
 #if MFM_ENCCONSTRAINT
-            && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(refPic->getLayerId())]->getListPic() )->checkSameRefInfo() == true 
+            && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true 
 #endif
             ) 
@@ -1988,7 +1991,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[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag( refPic->getLayerId() )
+            if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
 #if MFM_ENCCONSTRAINT
-              && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(refPic->getLayerId())]->getListPic() )->checkSameRefInfo() == true 
+              && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true 
 #endif
               ) 
@@ -2107,5 +2110,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[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getMotionPredEnabledFlag(refPic->getLayerId()) )
+        if( refPic->isILR(m_layerId) && !m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) )
         {
           pcSlice->setEnableTMVPFlag(false);
@@ -2125,5 +2128,5 @@
           TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
 
-          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
+          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
           {
             break;
@@ -2149,5 +2152,5 @@
           TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
 
-          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(m_layerId)]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
+          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
           {
             break;
@@ -4661,6 +4664,7 @@
         for(Int i = 1; i < slice->getVPS()->getMaxLayers(); i++)
         {
-          Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 );
-          Bool refreshTypeFlag     = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() );
+          UInt layerId = slice->getVPS()->getLayerIdInNuh(i);
+          Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshInterval() == 0 );
+          Bool refreshTypeFlag     = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshType() );
           if( !(refreshIntervalFlag && refreshTypeFlag) )
           {
@@ -4678,6 +4682,7 @@
       for(Int i = 1; i < slice->getVPS()->getMaxLayers() && !needReset; i++)
       {
-        Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2) 
-                        && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
+        UInt layerId = slice->getVPS()->getLayerIdInNuh(i);
+        Bool idrFlag = ( (m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshType() == 2) 
+                        && ( pocCurr % m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
                         );
         for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++)
@@ -4687,6 +4692,8 @@
             continue;
           }
-          Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2) 
-                                  && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
+
+          layerId = slice->getVPS()->getLayerIdInNuh(j);
+          Bool idrOtherPicFlag = ( (m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshType() == 2) 
+                                  && ( pocCurr % m_ppcTEncTop[layerId]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
                                   );
 
@@ -4732,5 +4739,6 @@
         for (UInt i = 0; i < MAX_LAYERS; i++)
         {
-          m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false);
+          UInt layerId = slice->getVPS()->getLayerIdInNuh(i);
+          m_ppcTEncTop[layerId]->setPocDecrementedInDPBFlag(false);
         }
 #endif
@@ -4820,16 +4828,16 @@
   for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
   {
-    if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getPocDecrementedInDPBFlag())
-    {
-      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->setPocDecrementedInDPBFlag(true);
+    if (!m_ppcTEncTop[affectedLayerList[layerIdx]]->getPocDecrementedInDPBFlag())
+    {
+      m_ppcTEncTop[affectedLayerList[layerIdx]]->setPocDecrementedInDPBFlag(true);
 
       // Decrement value of associatedIrapPoc of the TEncGop object
-      m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx])]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
+      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
 
       // Decrememnt the value of m_pocCRA
-      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())
+      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())
 #else
   // Decrement value of associatedIrapPoc of the TEncGop object
@@ -5334,10 +5342,10 @@
       {
         Int iLayerId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
-        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(iLayerId)]->setLayerInitializedFlag(false);
-        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(iLayerId)]->setFirstPicInLayerDecodedFlag(false);
+        m_ppcTEncTop[iLayerId]->setLayerInitializedFlag(false);
+        m_ppcTEncTop[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[slice->getVPS()->getLayerIdxInVps(dolLayerId)]->getListPic()->begin(); pic != m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(dolLayerId)]->getListPic()->end(); pic++)
+      for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[dolLayerId]->getListPic()->begin(); pic != m_ppcTEncTop[dolLayerId]->getListPic()->end(); pic++)
       {
         if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
@@ -5352,5 +5360,5 @@
       {
         UInt predLId = slice->getVPS()->getPredictedLayerId(dolLayerId, i);
-        for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[predLId]->getListPic()->begin(); pic != m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(predLId)]->getListPic()->end(); pic++)
+        for (TComList<TComPic*>::iterator pic = m_ppcTEncTop[predLId]->getListPic()->begin(); pic != m_ppcTEncTop[predLId]->getListPic()->end(); pic++)
         {
           if ((*pic)->getSlice(0)->getPOC() != slice->getPOC())
@@ -5373,11 +5381,11 @@
       m_noRaslOutputFlag = true;
     }
-    else if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->getLayerInitializedFlag())
+    else if (!m_ppcTEncTop[m_layerId]->getLayerInitializedFlag())
     {
       Bool refLayersInitialized = true;
-      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(slice->getVPS()->getLayerIdxInVps(m_layerId)); j++)
+      for (UInt j = 0; j < slice->getVPS()->getNumDirectRefLayers(m_layerId); j++)
       {
         UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
-        if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(refLayerId)]->getLayerInitializedFlag())
+        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
         {
           refLayersInitialized = false;
@@ -5398,11 +5406,11 @@
     if (m_layerId == 0)
     {
-      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())
+      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())
     {
       Bool refLayersInitialized = true;
@@ -5410,5 +5418,5 @@
       {
         UInt refLayerId = slice->getVPS()->getRefLayerId(m_layerId, j);
-        if (!m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(refLayerId)]->getLayerInitializedFlag())
+        if (!m_ppcTEncTop[refLayerId]->getLayerInitializedFlag())
         {
           refLayersInitialized = false;
@@ -5417,5 +5425,5 @@
       if (refLayersInitialized)
       {
-        m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(m_layerId)]->setLayerInitializedFlag(true);
+        m_ppcTEncTop[m_layerId]->setLayerInitializedFlag(true);
       }
     }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1048)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 1051)
@@ -139,10 +139,12 @@
 {
 #if JCTVC_M0259_LAMBDAREFINEMENT
-  if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(slice->getLayerId())]->getNumActiveRefLayers() && depth >= 3 && m_pcCfg->getGOPSize() == ( 1 << depth ) )
+  if( slice->getLayerId() > 0 && m_ppcTEncTop[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() );
+    UInt prevLayerId = slice->getVPS()->getLayerIdInNuh(slice->getVPS()->getLayerIdxInVps(nCurLayerId)-1);
+
+    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[prevLayerId]->getQP() - m_ppcTEncTop[nCurLayerId]->getQP() ,
+      1.0 * m_ppcTEncTop[nCurLayerId]->getSourceWidth() * m_ppcTEncTop[nCurLayerId]->getSourceHeight()
+      / m_ppcTEncTop[prevLayerId]->getSourceWidth() / m_ppcTEncTop[prevLayerId]->getSourceHeight() );
     dLambda *= gamma;
   }
@@ -163,5 +165,5 @@
 
 #if JCTVC_M0259_LAMBDAREFINEMENT
-    if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getVPS()->getLayerIdxInVps(slice->getLayerId())]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && slice->isIntra() == false && depth == 0 )
+    if( slice->getLayerId() > 0 && m_ppcTEncTop[slice->getLayerId()]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && slice->isIntra() == false && depth == 0 )
     {
       dLambdas[0] = dLambda * 1.1;
@@ -555,12 +557,12 @@
     if( rpcSlice->getNumILRRefIdx() > 0 )
     {
-      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getNumActiveRefLayers() );
+      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() );
       for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
       {
-        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getPredLayerId(i), i );
+        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i );
       }
       rpcSlice->setInterLayerPredEnabledFlag(1);
     }
-    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[rpcSlice->getVPS()->getLayerIdxInVps(layerId)]->getMFMEnabledFlag());
+    rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag());
   }
 
@@ -762,5 +764,5 @@
   }
 #if O0194_WEIGHTED_PREDICTION_CGS
-  else if( m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())]->getInterLayerWeightedPredFlag() )
+  else if( m_ppcTEncTop[pcSlice->getLayerId()]->getInterLayerWeightedPredFlag() )
   {
     // Calculate for the base layer to be used in EL as Inter layer reference
@@ -1135,5 +1137,5 @@
 
 #if SVC_EXTENSION
-        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, m_ppcTEncTop[pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId())]->getSAO()->getSaoMaxOffsetQVal(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
+        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, m_ppcTEncTop[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 1048)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 1051)
@@ -1533,10 +1533,10 @@
 TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdx )
 {
-  if( m_ppcTEncTop[m_cVPS.getLayerIdxInVps(m_layerId)]->getNumDirectRefLayers() <= 0 )
+  if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 )
   {
     return (TEncTop *)getLayerEnc( 0 );
   }
 
-  return (TEncTop *)getLayerEnc( m_cVPS.getLayerIdxInVps(m_cVPS.getRefLayerId( m_layerId, refLayerIdx )));
+  return (TEncTop *)getLayerEnc( 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 1048)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h	(revision 1051)
@@ -117,5 +117,5 @@
   static Int              m_iPPSIdCnt;                    ///< next Id number for PPS    
   TEncTop**               m_ppcTEncTop;
-  TEncTop*                getLayerEnc(UInt layerIdx)   { return m_ppcTEncTop[layerIdx]; }
+  TEncTop*                getLayerEnc(UInt layerId)       { return m_ppcTEncTop[layerId]; }
   TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture 
 #if REF_IDX_MFM
