Index: branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 259)
@@ -910,7 +910,10 @@
 #if VPS_EXTN_DIRECT_REF_LAYERS
   // Direct reference layers
+  UInt maxDirectRefLayers = 0;
   for(UInt layerCtr = 1;layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
   {
     vps->setNumDirectRefLayers( layerCtr, m_acTEncTop[layerCtr].getNumDirectRefLayers() );
+    maxDirectRefLayers = max<UInt>( maxDirectRefLayers, vps->getNumDirectRefLayers( layerCtr ) );
+
     for(i = 0; i < vps->getNumDirectRefLayers(layerCtr); i++)
     {
@@ -930,5 +933,5 @@
 #endif
 #if JCTVC_M0458_INTERLAYER_RPS_SIG        
-    vps->setMaxOneActiveRefLayerFlag(true); 
+    vps->setMaxOneActiveRefLayerFlag(maxDirectRefLayers > 1 ? false : true); 
 #endif 
 #else
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.cpp	(revision 259)
@@ -568,7 +568,6 @@
 
 #if REF_IDX_MFM
-Void TComPic::copyUpsampledMvField(TComPic* pcPicBase)
-{
-  UInt refLayerIdc = pcPicBase->getLayerId();
+Void TComPic::copyUpsampledMvField(UInt refLayerIdc, TComPic* pcPicBase)
+{
 #if AVC_SYNTAX && !ILP_DECODED_PICTURE
   const Window &confBL = pcPicBase->getConformanceWindow();
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.h
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.h	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComPic.h	(revision 259)
@@ -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-multilayers-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 259)
@@ -544,5 +544,5 @@
       if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && m_pcSPS->getMFMEnabledFlag())
       { 
-        ilpPic[refLayerIdc]->copyUpsampledMvField( m_pcBaseColPic[refLayerIdc] );
+        ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
       }
       else
@@ -1094,5 +1094,4 @@
   m_activeNumILRRefIdx         = pSrc->m_activeNumILRRefIdx;
   m_interLayerPredEnabledFlag  = pSrc->m_interLayerPredEnabledFlag;
-  m_numInterLayerRefPics       = pSrc->m_numInterLayerRefPics;
   memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) );
 #elif REF_IDX_FRAMEWORK
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComSlice.h	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComSlice.h	(revision 259)
@@ -1532,5 +1532,4 @@
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
   Bool       m_interLayerPredEnabledFlag;
-  Int        m_numInterLayerRefPics;
 #endif 
 public:
@@ -1803,12 +1802,9 @@
   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;}
-
-  Void      setNumInterLayerRefPics          ( UInt   val )    { m_numInterLayerRefPics = val; }
-  UInt      getNumInterLayerRefPics          ()                { return m_numInterLayerRefPics;}  
+  Bool      getInterLayerPredEnabledFlag     ()                { return m_interLayerPredEnabledFlag;} 
 #else
   Void      setNumILRRefIdx     ( Int i )               { m_numILRRefIdx = i;     }
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 259)
@@ -1067,5 +1067,5 @@
           if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 
           {
-            WRITE_CODE(pcSlice->getNumInterLayerRefPics(), numBits,"num_inter_layer_ref_pics_minus1");
+            WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
           }       
           for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 259)
@@ -458,6 +458,7 @@
     if (rpcBestCU->getLayerId() > 0)
     {
-      // the right reference layerIdc should be specified, currently it is set to 0
-      if (rpcBestCU->getSlice()->getBaseColPic(0)->getSlice(0)->getSliceType() == I_SLICE)
+      TComList<TComPic*> *cListPic = m_ppcTEncTop[rpcBestCU->getLayerId()]->getRefLayerEnc(rpcBestCU->getLayerId()-1)->getListPic();
+      TComPic* picLowerLayer = pcSlice->getRefPic( *cListPic, pcSlice->getPOC() );
+      if(picLowerLayer->getSlice(0)->getSliceType() == I_SLICE)
       {
         testInter = false;
Index: branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 258)
+++ branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 259)
@@ -491,9 +491,11 @@
   {
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
-  // currently only one reference layer is supported in software and no decision logic to select yet.
-  // hence num of active inter layer references is set to one always
     if( rpcSlice->getNumILRRefIdx() > 0 )
     {
-      rpcSlice->setActiveNumILRRefIdx(1);
+      rpcSlice->setActiveNumILRRefIdx( rpcSlice->getNumILRRefIdx() );
+      for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
+      {
+        rpcSlice->setInterLayerPredLayerIdc(i, i);
+      }
       rpcSlice->setInterLayerPredEnabledFlag(1);
     }
