Index: branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 1483)
@@ -460,9 +460,4 @@
 
   memset( m_skipFlag          , false,                      m_uiNumPartition * sizeof( *m_skipFlag ) );
-
-#if SVC_EXTENSION
-  m_layerId           = pcPic->getLayerId();
-#endif
-
   memset( m_pePartSize        , NUMBER_OF_PART_SIZES,       m_uiNumPartition * sizeof( *m_pePartSize ) );
   memset( m_pePredMode        , NUMBER_OF_PREDICTION_MODES, m_uiNumPartition * sizeof( *m_pePredMode ) );
@@ -3290,5 +3285,5 @@
   UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
   // the right reference layerIdc should be specified, currently it is set to m_layerId-1
-  TComDataCU* pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, posScalingFactor, false );
+  TComDataCU* pcTempCU = getBaseColCU(m_pcPic->getLayerId() - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, posScalingFactor, false );
 
   if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
@@ -3363,5 +3358,5 @@
     TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_0, refIdxL0);
 
-    if(refPic->isILR(m_layerId))
+    if(refPic->isILR(m_pcPic->getLayerId()))
     {
       checkZeroMVILR &= (cMvFieldL0.getHor() == 0 && cMvFieldL0.getVer() == 0);
@@ -3369,5 +3364,5 @@
       // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
       // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
-      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( getLayerIdx(), refPic->getLayerIdx() );
+      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
     }
   }
@@ -3377,5 +3372,5 @@
     TComPic* refPic = m_pcSlice->getRefPic(REF_PIC_LIST_1, refIdxL1);
 
-    if(refPic->isILR(m_layerId))
+    if(refPic->isILR(m_pcPic->getLayerId()))
     {
       checkZeroMVILR &= (cMvFieldL1.getHor() == 0 && cMvFieldL1.getVer() == 0);
@@ -3383,5 +3378,5 @@
       // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
       // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
-      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( getLayerIdx(), refPic->getLayerIdx() );
+      checkZeroMVILR &= m_pcSlice->getVPS()->isSamplePredictionType( m_pcPic->getLayerIdx(), refPic->getLayerIdx() );
     }
   }
@@ -3397,5 +3392,5 @@
   Bool checkZeroMVILR = true;
 
-  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_layerId))
+  if(getSlice()->getRefPic(eRefPicList, iRefIdx)->isILR(m_pcPic->getLayerId()))
   {
     AMVPInfo* pcAMVPInfo = getCUMvField(eRefPicList)->getAMVPInfo();
@@ -3416,10 +3411,10 @@
   {
     Int refIdxL0 = cMvFieldL0.getRefIdx();
-    checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_layerId);
+    checkILR = getSlice()->getRefPic(REF_PIC_LIST_0, refIdxL0)->isILR(m_pcPic->getLayerId());
   }
   if(uhInterDir&0x2)  //list1
   {
     Int refIdxL1  = cMvFieldL1.getRefIdx();
-    checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_layerId);
+    checkILR = checkILR || getSlice()->getRefPic(REF_PIC_LIST_1, refIdxL1)->isILR(m_pcPic->getLayerId());
   }
 
Index: branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1483)
@@ -88,5 +88,4 @@
 
 #if SVC_EXTENSION
-  UInt          m_layerId;                              ///< layer id
 #if FAST_INTRA_SHVC
   UChar         m_reducedSetIntraModes[NUM_INTRA_MODE-1];
@@ -481,7 +480,4 @@
 
 #if SVC_EXTENSION
-  Void          setLayerId                    ( UInt layerId )                                             { m_layerId = layerId;        }
-  UInt          getLayerId                    ( ) const                                                    { return m_layerId;           }
-  UInt          getLayerIdx                   ( ) const                                                    { return m_pcSlice->getVPS()->getLayerIdxInVps(m_layerId); }
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
   Bool          isInterLayerReference         ( UChar uhInterDir, TComMvField& cMvFieldL0, TComMvField& cMvFieldL1 ) const;
Index: branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 1483)
@@ -580,13 +580,13 @@
 
 #if SVC_EXTENSION
-  if( pcCU->getLayerId() > 0 )
+  if( pcCU->getPic()->getLayerId() > 0 )
   {
     TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, iRefIdx);
 
-    if( refPic->isILR(pcCU->getLayerId()) )
+    if( refPic->isILR(pcCU->getPic()->getLayerId()) )
     {
       // It is a requirement of bitstream conformance that when the reference picture represented by the variable refIdxLX is an inter-layer reference picture, 
       // VpsInterLayerSamplePredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture
-      assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerIdx(), refPic->getLayerIdx() ) );
+      assert( pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), refPic->getLayerIdx() ) );
 
 #if REF_IDX_ME_ZEROMV
Index: branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1483)
@@ -3594,10 +3594,6 @@
 
       pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false );
-      pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();
-      for (Int j=0; j<pcIlpPic[refLayerIdc]->getPicSym()->getNumberOfCtusInFrame(); j++)    // set reference CU layerId
-      {
-        pcIlpPic[refLayerIdc]->getPicSym()->getCtu(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() );
-      }
-      pcIlpPic[refLayerIdc]->setIsLongTerm(1);
+      pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();      
+      pcIlpPic[refLayerIdc]->setIsLongTerm(true);
 
       // assign PPS to ILRP to be used for reference location offsets
Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1483)
@@ -71,9 +71,4 @@
   m_layerId = layerId; 
 
-  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
-  {
-    m_ppcCU     [ui]->setLayerId(layerId);
-  }
-  
 #if LAYER_CTB
   memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
@@ -171,9 +166,5 @@
     setIsChromaQpAdjCoded(true);
   }
-
-#if SVC_EXTENSION
-  pCtu->setLayerId(m_layerId);
-#endif
-
+  
   // start from the top level CU
   xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment);
@@ -311,8 +302,8 @@
 #if SVC_EXTENSION
   // Check CU skip for higher layer IRAP skip flag
-  if( pcCU->getSlice()->getVPS()->getHigherLayerIrapSkipFlag() && pcCU->getSlice()->getVPS()->getSingleLayerForNonIrapFlag() && pcCU->getLayerId() > 0 )
+  if( pcCU->getSlice()->getVPS()->getHigherLayerIrapSkipFlag() && pcCU->getSlice()->getVPS()->getSingleLayerForNonIrapFlag() && pcCU->getPic()->getLayerId() > 0 )
   {
     Bool lowerLayerExist = false;
-    for(int i=0;i<pcCU->getLayerId();i++)
+    for( Int i = 0; i < pcCU->getPic()->getLayerId(); i++ )
     {
       if(pcCU->getSlice()->getBaseColPic(pcCU->getSlice()->getInterLayerPredLayerIdc(i)))
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1483)
@@ -212,10 +212,5 @@
   
 #if SVC_EXTENSION
-  m_ppcTEncTop         = pcEncTop->getLayerEnc();
-  for(UInt i=0 ; i< m_uhTotalDepth-1 ; i++)
-  {    
-    m_ppcBestCU[i]->setLayerId(pcEncTop->getLayerId());
-    m_ppcTempCU[i]->setLayerId(pcEncTop->getLayerId());
-  }
+  m_ppcTEncTop         = pcEncTop->getLayerEnc();  
 #endif
   
@@ -465,5 +460,5 @@
 #if ENCODER_FAST_MODE
     Bool testInter = true;
-    if( rpcBestCU->getLayerId() > 0 )
+    if( rpcBestCU->getPic()->getLayerId() > 0 )
     {
       if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx())
@@ -1832,5 +1827,5 @@
   Bool disableILP = false;
 
-  if (rpcCU->getLayerId() == (m_pcEncCfg->getNumLayer() - 1)  && m_pcEncCfg->getInterLayerConstrainedTileSetsSEIEnabled() && rpcCU->getPic()->getPicSym()->getTileSetIdxMap(rpcCU->getCtuRsAddr()) >= 0)
+  if (rpcCU->getPic()->getLayerId() == (m_pcEncCfg->getNumLayer() - 1)  && m_pcEncCfg->getInterLayerConstrainedTileSetsSEIEnabled() && rpcCU->getPic()->getPicSym()->getTileSetIdxMap(rpcCU->getCtuRsAddr()) >= 0)
   {
     if (rpcCU->getPic()->getPicSym()->getTileSetType(rpcCU->getCtuRsAddr()) == 2)
@@ -1868,6 +1863,6 @@
 Void TEncCu::xVerifyTileSetConstraint( TComDataCU*& rpcCU )
 {
-  if (rpcCU->getLayerId() == (m_pcEncCfg->getNumLayer() - 1)  && m_pcEncCfg->getInterLayerConstrainedTileSetsSEIEnabled() && rpcCU->getPic()->getPicSym()->getTileSetIdxMap(rpcCU->getCtuRsAddr()) >= 0 &&
-      m_disableILP)
+  if( rpcCU->getPic()->getLayerId() == (m_pcEncCfg->getNumLayer() - 1)  && m_pcEncCfg->getInterLayerConstrainedTileSetsSEIEnabled() && 
+      rpcCU->getPic()->getPicSym()->getTileSetIdxMap(rpcCU->getCtuRsAddr()) >= 0 && m_disableILP )
   {
     UInt numPartitions = rpcCU->getPic()->getNumPartitionsInCtu();
@@ -1883,5 +1878,5 @@
             if (mvField->getRefIdx(i) >= 0)
             {
-              assert(!(rpcCU->getSlice()->getRefPic(RefPicList(refList), mvField->getRefIdx(i))->isILR(rpcCU->getLayerId())));
+              assert(!(rpcCU->getSlice()->getRefPic(RefPicList(refList), mvField->getRefIdx(i))->isILR(rpcCU->getPic()->getLayerId())));
             }
           }
Index: branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1482)
+++ branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1483)
@@ -2265,5 +2265,5 @@
       pcCU->getIntraDirPredictor( uiPartOffset, uiPreds, COMPONENT_Y, &iMode );
 
-      if( m_pcEncCfg->getUseFastIntraScalable() && pcCU->getLayerId() > 0 )
+      if( m_pcEncCfg->getUseFastIntraScalable() && pcCU->getPic()->getLayerId() > 0 )
       {
         numModesAvailable = pcCU->reduceSetOfIntraModes(uiPartOffset, uiPreds, pcCU->getPic()->getPosScalingFactor(), iMode );
@@ -3098,5 +3098,5 @@
         
         // motion search only for the ILRP with sample prediction type
-        if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerIdx(), pcPic->getLayerIdx() ) )
+        if( pcPic->isILR( pcCU->getPic()->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), pcPic->getLayerIdx() ) )
         {
           continue;
@@ -3104,5 +3104,5 @@
 
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-        if( pcPic->isILR(pcCU->getLayerId()) && m_disableILP )
+        if( pcPic->isILR(pcCU->getPic()->getLayerId()) && m_disableILP )
         {
           continue;
@@ -3110,5 +3110,5 @@
 #endif
 #if ENCODER_FAST_MODE        
-        if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) ) 
+        if( pcPic->isILR(pcCU->getPic()->getLayerId()) && (ePartSize == SIZE_2Nx2N) ) 
         {
           continue;
@@ -3202,5 +3202,5 @@
 
 #if SVC_EXTENSION
-    if( pcCU->getLayerId() && !doneUniPred )
+    if( pcCU->getPic()->getLayerId() && !doneUniPred )
     {
       // there is no valid reference pictures for inter prediction
@@ -3313,10 +3313,10 @@
         Bool     testIter = true;
         TComPic* pcPic    = pcCU->getSlice()->getRefPic( RefPicList(1 - iRefList), iRefIdxBi[1 - iRefList] );
-        if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
+        if(pcPic->isILR(pcCU->getPic()->getLayerId()) && (ePartSize == SIZE_2Nx2N))
         {
           testIter = false;  //the fixed part is ILR, skip this iteration       
         }
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-        if (pcPic->isILR(pcCU->getLayerId()) && m_disableILP)
+        if (pcPic->isILR(pcCU->getPic()->getLayerId()) && m_disableILP)
         {
           testIter = false;
@@ -3336,15 +3336,15 @@
 
           // motion search only for the ILRP with sample prediction type
-          if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerIdx(), pcPic->getLayerIdx() ) )
+          if( pcPic->isILR( pcCU->getPic()->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), pcPic->getLayerIdx() ) )
           {
             continue;
           }
 
-          if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
+          if(pcPic->isILR(pcCU->getPic()->getLayerId()) && (ePartSize == SIZE_2Nx2N))
           {
             testRefIdx = false;  //the refined part is ILR, skip this reference pic           
           }
 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI
-          if (pcPic->isILR(pcCU->getLayerId()) && m_disableILP)
+          if (pcPic->isILR(pcCU->getPic()->getLayerId()) && m_disableILP)
           {
             testRefIdx = false;
@@ -3919,5 +3919,5 @@
   //  Do integer search
 #if REF_IDX_ME_ZEROMV
-  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic 
+  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()))  //ILR reference pic 
   {
     rcMv.setZero();  //use Mv(0, 0) for integer ME 
@@ -3955,5 +3955,5 @@
 
 #if REF_IDX_ME_ZEROMV
-  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getLayerId()))  //ILR reference pic
+  if( pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->isILR(pcCU->getPic()->getLayerId()))  //ILR reference pic
   {
     xPatternSearchFracDIFMv0( pcPatternKey, piRefY, iRefStride, &rcMv, cMvHalf, cMvQter, ruiCost );
@@ -6026,5 +6026,5 @@
 
       // ILRP has to be for the sample prediction type
-      if( refPic->isILR(pcCU->getLayerId()) && refPic->getLayerId() == refLayerId && pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerIdx(), pcCU->getSlice()->getVPS()->getLayerIdxInVps(refLayerId) ) )
+      if( refPic->isILR(pcCU->getPic()->getLayerId()) && refPic->getLayerId() == refLayerId && pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getPic()->getLayerIdx(), pcCU->getSlice()->getVPS()->getLayerIdxInVps(refLayerId) ) )
       {
         iRefIdxTemp = refIdx;
