Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.cpp	(revision 282)
@@ -1750,8 +1750,11 @@
   // check BL mode
   UInt          uiCUAddrBase, uiAbsPartAddrBase;
-  TComDataCU*   pcTempCU = getBaseColCU( uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
+  // the right reference layerIdc should be specified, currently it is set to m_layerId-1
+  TComDataCU*   pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase );
 
   if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
+  {
     return( NUM_INTRA_MODE-1 );
+  }
 
   // compute set of enabled modes g_reducedSetIntraModes[...]
@@ -4182,5 +4185,5 @@
 
 #if SVC_COL_BLK
-TComDataCU*  TComDataCU::getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
+TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
 {
 #if 1 // it should provide identical resutls
@@ -4188,5 +4191,5 @@
   UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
 
-  return getBaseColCU( uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase );
+  return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase );
 #else
   TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
@@ -4237,7 +4240,7 @@
 }
 
-TComDataCU*  TComDataCU::getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
-{
-  TComPic* cBaseColPic = m_pcSlice->getBaseColPic();
+TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase )
+{
+  TComPic* cBaseColPic = m_pcSlice->getBaseColPic(refLayerIdc);
 
 #if !SIMPLIFIED_MV_POS_SCALING
@@ -4269,9 +4272,9 @@
   Int leftStartL = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowLeftOffset();
   Int topStartL  = this->getSlice()->getSPS()->getScaledRefLayerWindow().getWindowTopOffset();
-  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
-  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
+  Int iBX = ((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
+  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
 #else
-  Int iBX = (uiPelX*g_posScalingFactor[m_layerId][0] + (1<<15)) >> 16;
-  Int iBY = (uiPelY*g_posScalingFactor[m_layerId][1] + (1<<15)) >> 16;
+  Int iBX = (uiPelX*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16;
+  Int iBY = (uiPelY*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
 #endif
 #else
@@ -4295,6 +4298,6 @@
   const Window &confEL = m_pcPic->getPicYuvRec()->getConformanceWindow();
 
-  Int widthBL   = m_pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
-  Int heightBL  = m_pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
+  Int widthBL   = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
+  Int heightBL  = m_pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
 #endif
   if( iBX >= widthBL || iBY >= heightBL ) //outside of the reference layer cropped picture
@@ -4316,10 +4319,10 @@
 }
 
-Void TComDataCU::scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase )
+Void TComDataCU::scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase )
 {
   TComMvField cMvFieldBase;
   TComMv cMv;
 #if SIMPLIFIED_MV_POS_SCALING
-  cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[m_layerId][0], g_mvScalingFactor[m_layerId][1] );
+  cMv = rcMvFieldBase.getMv().scaleMv( g_mvScalingFactor[refLayerIdc][0], g_mvScalingFactor[refLayerIdc][1] );
 #else
   const Window &confBL = m_pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 282)
@@ -554,7 +554,7 @@
 
 #if SVC_COL_BLK 
-  TComDataCU*   getBaseColCU( UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
-  TComDataCU*   getBaseColCU( UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
-  Void          scaleBaseMV( TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
+  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
+  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase );
+  Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
 #endif
 };
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 282)
@@ -67,9 +67,9 @@
 , m_pNDBFilterYuvTmp                      (NULL)
 , m_bCheckLTMSB                           (false)
+{
 #if SVC_EXTENSION
-, m_bSpatialEnhLayer( false )
-, m_pcFullPelBaseRec( NULL )
-#endif
-{
+  memset( m_pcFullPelBaseRec, 0, sizeof( m_pcFullPelBaseRec ) );
+  memset( m_bSpatialEnhLayer, false, sizeof( m_bSpatialEnhLayer ) );
+#endif
   m_apcPicYuv[0]      = NULL;
   m_apcPicYuv[1]      = NULL;
@@ -91,7 +91,10 @@
   m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
 
-  if (m_bSpatialEnhLayer)
-  {
-    m_pcFullPelBaseRec = new TComPicYuv;  m_pcFullPelBaseRec->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+  for( Int i = 0; i < MAX_LAYERS; i++ )
+  {
+    if( m_bSpatialEnhLayer[i] )
+    {
+      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
+    }
   }
 
@@ -173,9 +176,12 @@
   deleteSEIs(m_SEIs);
 #if SVC_EXTENSION && SVC_UPSAMPLING
-  if (m_bSpatialEnhLayer)
-  {
-    m_pcFullPelBaseRec->destroy();
-    delete m_pcFullPelBaseRec;
-    m_pcFullPelBaseRec  = NULL;
+  for( Int i = 0; i < MAX_LAYERS; i++ )
+  {
+    if( m_bSpatialEnhLayer[i] )
+    {
+      m_pcFullPelBaseRec[i]->destroy();
+      delete m_pcFullPelBaseRec[i];
+      m_pcFullPelBaseRec[i]  = NULL;
+    }
   }
 #endif 
@@ -562,5 +568,5 @@
 
 #if REF_IDX_MFM
-Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
+Void TComPic::copyUpsampledMvField(UInt refLayerIdc, TComPic* pcPicBase)
 {
 #if AVC_SYNTAX && !ILP_DECODED_PICTURE
@@ -592,5 +598,5 @@
 
       TComDataCU *pcColCU = 0;
-      pcColCU = pcCUDes->getBaseColCU(pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
+      pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx);
 
 #if AVC_SYNTAX && !ILP_DECODED_PICTURE
@@ -607,5 +613,5 @@
           TComMvField sMvFieldBase, sMvField;
           pcColCU->getMvField( pcColCU, baseAbsPartIdx, (RefPicList)refPicList, sMvFieldBase);
-          pcCUDes->scaleBaseMV( sMvField, sMvFieldBase );
+          pcCUDes->scaleBaseMV( refLayerIdc, sMvField, sMvFieldBase );
 
           pcCUDes->getCUMvField((RefPicList)refPicList)->setMvField(sMvField, absPartIdx);
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPic.h	(revision 282)
@@ -92,6 +92,6 @@
   SEIMessages  m_SEIs; ///< Any SEI messages that have been received.  If !NULL we own the object.
 #if SVC_EXTENSION
-  Bool                  m_bSpatialEnhLayer;       // whether current layer is a spatial enhancement layer,
-  TComPicYuv*           m_pcFullPelBaseRec;    // upsampled base layer recontruction for difference domain inter prediction
+  Bool                  m_bSpatialEnhLayer[MAX_LAYERS];       // whether current layer is a spatial enhancement layer,
+  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
 #endif
 
@@ -114,8 +114,8 @@
   Void          setLayerId (UInt layerId) { m_layerId = layerId; }
   UInt          getLayerId ()               { return m_layerId; }
-  Bool          isSpatialEnhLayer()             { return m_bSpatialEnhLayer; }
-  Void          setSpatialEnhLayerFlag (Bool b) { m_bSpatialEnhLayer = b; }
-  Void          setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
-  TComPicYuv*   getFullPelBaseRec   ()  { return  m_pcFullPelBaseRec;  }
+  Bool          isSpatialEnhLayer(UInt refLayerIdc)             { return m_bSpatialEnhLayer[refLayerIdc]; }
+  Void          setSpatialEnhLayerFlag (UInt refLayerIdc, Bool b) { m_bSpatialEnhLayer[refLayerIdc] = b; }
+  Void          setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
+  TComPicYuv*   getFullPelBaseRec   (UInt refLayerIdc)  { return  m_pcFullPelBaseRec[refLayerIdc];  }
 #endif
 #if REF_IDX_ME_ZEROMV || ENCODER_FAST_MODE || REF_IDX_MFM
@@ -124,5 +124,5 @@
 
 #if REF_IDX_MFM
-  Void          copyUpsampledMvField  (  TComPic* pcPicBase );
+  Void          copyUpsampledMvField  ( UInt refLayerIdc, TComPic* pcPicBase );
   Void          initUpsampledMvField  ();
 #endif
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.cpp	(revision 282)
@@ -774,12 +774,12 @@
 #if SVC_UPSAMPLING
 #if SCALED_REF_LAYER_OFFSETS
-Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
-{
-  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic, window);
+Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
+{
+  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic, window);
 }
 #else
-Void TComPrediction::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
-{
-  m_cUsf.upsampleBasePic( pcUsPic, pcBasePic, pcTempPic);
+Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic)
+{
+  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic);
 }
 #endif
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComPrediction.h	(revision 282)
@@ -123,7 +123,7 @@
 #if SVC_UPSAMPLING
 #if SCALED_REF_LAYER_OFFSETS
-  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
+  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
 #else
-  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
+  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
 #endif
 #endif
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 282)
@@ -92,5 +92,4 @@
 #if SVC_EXTENSION
 , m_layerId                     ( 0 )
-, m_pcBaseColPic                  ( NULL )
 #endif
 , m_bTLayerSwitchingFlag          ( false )
@@ -122,5 +121,7 @@
   m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0;
 #endif
-  
+
+#if SVC_EXTENSION
+  memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
 #if REF_IDX_FRAMEWORK
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
@@ -131,4 +132,5 @@
   m_numILRRefIdx = 0;
 #endif 
+#endif
 #endif
 
@@ -518,33 +520,37 @@
 
 #if REF_IDX_FRAMEWORK
-  //inter-layer reference picture
+  for( i = 0; i < m_activeNumILRRefIdx; i++ )
+  {
+    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
+    //inter-layer reference picture
 #if REF_IDX_MFM
 
 #if ILR_RESTR
-  Int maxSubLayerForILPPlus1 = (getLayerId() > 0 && m_activeNumILRRefIdx > 0)? getVPS()->getMaxSublayerForIlpPlus1(ilpPic[0]->getSlice(0)->getLayerId()) : 0;
+    Int maxSubLayerForILPPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
 #if ZERO_NUM_DIRECT_LAYERS
-  if( getLayerId() > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  ) 
-#else
-  if( getLayerId() && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  )
+    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  ) 
+#else
+    if( m_layerId > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
 #endif
 
 #else
 #if ZERO_NUM_DIRECT_LAYERS
-  if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
-#else
-  if (getLayerId())
-#endif
-#endif
-  {
-    if(!(getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && getSPS()->getMFMEnabledFlag())
-    { 
-      ilpPic[0]->copyUpsampledMvField(getBaseColPic());
-    }
-    else
-    {
-      ilpPic[0]->initUpsampledMvField();
-    }
-  #endif
-    ilpPic[0]->setIsLongTerm(1);
+    if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
+#else
+    if( m_layerId > 0 )
+#endif
+#endif
+    {
+      if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag())
+      { 
+        ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
+      }
+      else
+      {
+        ilpPic[refLayerIdc]->initUpsampledMvField();
+      }
+#endif
+      ilpPic[refLayerIdc]->setIsLongTerm(1);
+    }
   }
 #endif
@@ -555,9 +561,9 @@
 #if ILR_RESTR
   Int numInterLayerRPSPics = 0;
-  if (getLayerId()>0)
-  {
-    for (i=0; i < getVPS()->getNumDirectRefLayers(getLayerId()); i++)
-    {
-      maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
+  if( m_layerId > 0 )
+  {
+    for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ )
+    {
+      Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
       if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
       {
@@ -570,6 +576,6 @@
       m_activeNumILRRefIdx = numInterLayerRPSPics;
     }
-#if MAX_ONE_RESAMPLING_DIRECT_LAYERS
-    if(getVPS()->getScalabilityMask(1))
+#if MAX_ONE_RESAMPLING_DIRECT_LAYERS && SIMPLIFIED_MV_POS_SCALING
+    if( m_pcVPS->getScalabilityMask(1) )
     {
       Int numResampler = 0;
@@ -581,12 +587,8 @@
                           );
 
-      Int widthEL   = getPic()->getPicYuvRec()->getWidth();
-      Int heightEL  = getPic()->getPicYuvRec()->getHeight();      
-      for (i=0; i < m_activeNumILRRefIdx; i++)
-      {
-        Int widthBL   =  ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getWidth();
-        Int heightBL  =  ilpPic[getInterLayerPredLayerIdc(i)]->getSlice(0)->getBaseColPic()->getPicYuvRec()->getHeight();
-
-        if(!(widthEL == widthBL && heightEL == heightBL && (scalingOffset)))
+      for( i=0; i < m_activeNumILRRefIdx; i++ )
+      {
+        UInt refLayerIdc = m_interLayerPredLayerIdc[i];
+        if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) && (scalingOffset)) // ratio 1x
         {
           numResampler++;
@@ -660,5 +662,5 @@
     }
 #if REF_IDX_FRAMEWORK
-    if(getLayerId())
+    if( m_layerId > 0 )
     {
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
@@ -668,9 +670,10 @@
 #endif 
       {
+        Int refLayerIdc = m_interLayerPredLayerIdc[i];
 #if ILR_RESTR
-         maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
-        if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
-#endif
-        rpsCurrList0[cIdx] = ilpPic[i];
+         Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+#endif
+        rpsCurrList0[cIdx] = ilpPic[refLayerIdc];
       }
     }
@@ -692,5 +695,5 @@
     }
 #if REF_IDX_FRAMEWORK
-    if(getLayerId())
+    if( m_layerId > 0 )
     {
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
@@ -700,9 +703,10 @@
 #endif 
       {
+        Int refLayerIdc = m_interLayerPredLayerIdc[i];
 #if ILR_RESTR
-        maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
-        if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
-#endif
-        rpsCurrList1[cIdx] = ilpPic[i];
+        Int maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
+#endif
+        rpsCurrList1[cIdx] = ilpPic[refLayerIdc];
       }
     }
@@ -737,15 +741,15 @@
 Void TComSlice::setRefPicListModificationSvc()
 {
-  if( !this->getPPS()->getListsModificationPresentFlag()) 
+  if( !m_pcPPS->getListsModificationPresentFlag()) 
   {
     return;
   }
 
-  if(this->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && this->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)
+  if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA)
   {
     return;
   }
 
-  TComRefPicListModification* refPicListModification = this->getRefPicListModification();
+  TComRefPicListModification* refPicListModification = &m_RefPicListModification;
   Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList();  // total number of ref pics in listTemp0 including inter-layer ref pics
 
@@ -821,7 +825,7 @@
 
 #if REF_IDX_FRAMEWORK
-  if( m_eSliceType == I_SLICE || ( getSPS()->getLayerId() && 
-    (getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
-    (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) ) )
+  if( m_eSliceType == I_SLICE || ( m_pcSPS->getLayerId() && 
+    (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
+    (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) )
 #else
   if (m_eSliceType == I_SLICE) 
@@ -846,5 +850,5 @@
   }
 #if REF_IDX_FRAMEWORK
-  if(getLayerId())
+  if( m_layerId > 0 )
   {
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
@@ -2592,48 +2596,54 @@
 #endif
 
-Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt layerID )
+Void TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt refLayerIdc )
 {  
-  if (layerID == 0)
-  {
-    m_pcBaseColPic = NULL;
+  if(m_layerId == 0)
+  {
+    memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) );
     return;
   }        
-  setBaseColPic(xGetRefPic(rcListPic, getPOC())); 
+  setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); 
 }
 #endif 
 
 #if REF_IDX_MFM
-Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic *pcRefPicBL )
-{
-  //set reference picture POC of each ILP reference 
-  Int thePoc = ilpPic[0]->getPOC(); 
-  assert(thePoc >= 0); 
-  assert(thePoc == pcRefPicBL->getPOC());
-
-  ilpPic[0]->getSlice(0)->setBaseColPic( pcRefPicBL );
-
-  //copy reference pictures marking from the reference layer
-  ilpPic[0]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
-  
-  for( Int refList = 0; refList < 2; refList++ )
-  {
-    RefPicList refPicList = RefPicList( refList );
-    
-    //set reference POC of ILP
-    ilpPic[0]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
-    assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
-    assert(ilpPic[0]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
-
-    //initialize reference POC of ILP
-    for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
-    {
-      ilpPic[0]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
-      ilpPic[0]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
-    }
-
-    for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) 
-    { 
-      ilpPic[0]->getSlice(0)->setRefPOC(0, refPicList, refIdx); 
-      ilpPic[0]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); 
+Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL )
+{
+  for( UInt i = 0; i < m_activeNumILRRefIdx; i++ )
+  {
+    UInt refLayerIdc = m_interLayerPredLayerIdc[i];
+
+    TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc];
+    //set reference picture POC of each ILP reference 
+    Int thePoc = ilpPic[refLayerIdc]->getPOC(); 
+    assert(thePoc >= 0); 
+    assert(thePoc == pcRefPicBL->getPOC());
+
+    ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
+
+    //copy reference pictures marking from the reference layer
+    ilpPic[refLayerIdc]->getSlice(0)->copySliceInfo(pcRefPicBL->getSlice(0));
+
+    for( Int refList = 0; refList < 2; refList++ )
+    {
+      RefPicList refPicList = RefPicList( refList );
+
+      //set reference POC of ILP
+      ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
+      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
+      assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
+
+      //initialize reference POC of ILP
+      for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
+      {
+        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
+        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
+      }
+
+      for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) 
+      { 
+        ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); 
+        ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); 
+      }
     }
   }
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 282)
@@ -1494,6 +1494,6 @@
 #if SVC_EXTENSION
   UInt        m_layerId;
-  TComPic*    m_pcBaseColPic;
-  TComPicYuv* m_pcFullPelBaseRec;
+  TComPic*    m_pcBaseColPic[MAX_LAYERS];
+  TComPicYuv* m_pcFullPelBaseRec[MAX_LAYERS];
 #endif 
   Bool        m_bTLayerSwitchingFlag;
@@ -1775,13 +1775,14 @@
 
 #if SVC_EXTENSION
-  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt layerID );
-  Void      setBaseColPic       ( TComPic* p)     { m_pcBaseColPic = p; }
-  TComPic*  getBaseColPic       ()                { return m_pcBaseColPic; }
+  Void      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt refLayerIdc );
+  Void      setBaseColPic       (UInt refLayerIdc, TComPic* p)     { m_pcBaseColPic[refLayerIdc] = p; }
+  TComPic*  getBaseColPic       (UInt refLayerIdc)                { return m_pcBaseColPic[refLayerIdc]; }
+  TComPic** getBaseColPic       ()                { return &m_pcBaseColPic[0]; }
 
   Void      setLayerId (UInt layerId)   { m_layerId = layerId; }
   UInt      getLayerId ()               { return m_layerId;    }
 
-  Void        setFullPelBaseRec   ( TComPicYuv* p) { m_pcFullPelBaseRec = p; }
-  TComPicYuv* getFullPelBaseRec   ()               { return  m_pcFullPelBaseRec;  }
+  Void        setFullPelBaseRec   (UInt refLayerIdc, TComPicYuv* p) { m_pcFullPelBaseRec[refLayerIdc] = p; }
+  TComPicYuv* getFullPelBaseRec   (UInt refLayerIdc)               { return  m_pcFullPelBaseRec[refLayerIdc];  }
 
 #if AVC_SYNTAX
@@ -1794,5 +1795,5 @@
 
 #if REF_IDX_MFM
-  Void      setRefPOCListILP(TComPic** ilpPic, TComPic *pcRefPicBL);
+  Void      setRefPOCListILP(TComPic** ilpPic, TComPic** pcRefPicRL);
 #endif
 
@@ -1801,14 +1802,15 @@
   Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     }  
 
-  Int       getInterLayerPredLayerIdc (UInt Idx )               { return  m_interLayerPredLayerIdc[Idx];}
-  Void      setInterLayerPredLayerIdc (UInt val, UInt Idx)      { m_interLayerPredLayerIdc[Idx] = val;  }
+  Int       getInterLayerPredLayerIdc (UInt layerIdx)                        { return  m_interLayerPredLayerIdc[layerIdx];}
+  Void      setInterLayerPredLayerIdc (UInt refLayerIdc, UInt layerIdx)      { m_interLayerPredLayerIdc[layerIdx] = refLayerIdc;  }
 
   Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
   Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;}
-
 #else
   Void      setNumILRRefIdx     ( Int i )               { m_numILRRefIdx = i;     }
 #endif 
 #endif
+
+TComPic* getRefPic(TComList<TComPic*>& rcListPic, Int poc) { return xGetRefPic( rcListPic, poc ); } 
 
 #endif //SVC_EXTENSION
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 282)
@@ -74,7 +74,7 @@
 
 #if SCALED_REF_LAYER_OFFSETS
-Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
-#else
-Void TComUpsampleFilter::upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
+Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
+#else
+Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
 #endif
 {
@@ -127,5 +127,13 @@
   Pel* piDstV;
 
-  if( widthEL == widthBL && heightEL == heightBL )
+#if SIMPLIFIED_MV_POS_SCALING
+  Int scaleX = g_posScalingFactor[refLayerIdc][0];
+  Int scaleY = g_posScalingFactor[refLayerIdc][1];
+#else
+  Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
+  Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
+#endif
+
+  if( scaleX == 65536 && scaleY == 65536 ) // ratio 1x
   {
     piSrcY = piSrcBufY - scalEL.getWindowLeftOffset() - scalEL.getWindowTopOffset() * strideEL;
@@ -196,7 +204,4 @@
     Int shiftYM4 = shiftY - 4;
 
-    Int   scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
-    Int   scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
-
 #if ILP_DECODED_PICTURE
     widthEL   = pcUsPic->getWidth ();
@@ -334,6 +339,8 @@
     shiftYM4 = shiftY - 4;
 
+#if !SIMPLIFIED_MV_POS_SCALING
     scaleX     = ( ( widthBL << shiftX ) + ( widthEL >> 1 ) ) / widthEL;
     scaleY     = ( ( heightBL << shiftY ) + ( heightEL >> 1 ) ) / heightEL;
+#endif
 
 #if ILP_DECODED_PICTURE
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TComUpsampleFilter.h	(revision 282)
@@ -44,7 +44,7 @@
 
 #if SCALED_REF_LAYER_OFFSETS
-  Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
+  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
 #else
- Void upsampleBasePic( TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
+ Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
 #endif
 };
Index: branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 258)
+++ branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 282)
@@ -47,5 +47,5 @@
 #define SCALED_REF_LAYER_OFFSET_FLAG     1      ///< M0309: Signal scaled reference layer offsets in SPS
 #define SCALED_REF_LAYER_OFFSETS         1      ///< M0309: Signal scaled reference layer offsets in SPS
-#define MAX_LAYERS                       2      ///< max number of layers the codec is supposed to handle
+#define MAX_LAYERS                       3      ///< max number of layers the codec is supposed to handle
 
 #define VPS_RENAME                       1      ///< Rename variables max_layer_id and num_layer_sets_minus1 in VPS
