Index: /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 269)
@@ -153,4 +153,12 @@
     }
   }
+
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
+    {
+      delete [] m_acLayerCfg[layer].m_predLayerIds;
+    }
+  }
 #endif
 }
@@ -329,6 +337,10 @@
 #if VPS_EXTN_DIRECT_REF_LAYERS
   Int*    cfg_numDirectRefLayers [MAX_LAYERS];
-  string cfg_refLayerIds   [MAX_LAYERS];
-  string* cfg_refLayerIdsPtr   [MAX_LAYERS];
+  string  cfg_refLayerIds        [MAX_LAYERS];
+  string* cfg_refLayerIdsPtr     [MAX_LAYERS];
+
+  Int*    cfg_numActiveRefLayers [MAX_LAYERS];
+  string  cfg_predLayerIds       [MAX_LAYERS];
+  string* cfg_predLayerIdsPtr    [MAX_LAYERS];
 #endif
 #if SCALED_REF_LAYER_OFFSETS
@@ -360,4 +372,6 @@
     cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
     cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
+    cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
+    cfg_predLayerIdsPtr     [layer]  = &cfg_predLayerIds[layer];
 #endif
 #if SCALED_REF_LAYER_OFFSETS
@@ -422,4 +436,6 @@
   ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
   ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
+  ("NumActiveRefLayers%d",    cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers")
+  ("PredLayerIds%d",          cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
 #endif
   ("NumLayers",               m_numLayers, 1, "Number of layers to code")
@@ -890,5 +906,5 @@
         if( i >= m_acLayerCfg[layer].m_numDirectRefLayers )
         {
-          printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+          printf( "NumDirectRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
           exit( EXIT_FAILURE );
         }
@@ -899,5 +915,5 @@
       if( i < m_acLayerCfg[layer].m_numDirectRefLayers )
       {
-        printf( "The width of some columns is not defined.\n" );
+        printf( "NumDirectRefLayers: The width of some columns is not defined.\n" );
         exit( EXIT_FAILURE );
       }
@@ -906,4 +922,36 @@
     {
       m_acLayerCfg[layer].m_refLayerIds = NULL;
+    }
+  }
+
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Char* pPredLayerIds = cfg_predLayerIds[layer].empty() ? NULL: strdup(cfg_predLayerIds[layer].c_str());
+    if( m_acLayerCfg[layer].m_numActiveRefLayers > 0 )
+    {
+      char *refLayerId;
+      int  i=0;
+      m_acLayerCfg[layer].m_predLayerIds = new Int[m_acLayerCfg[layer].m_numActiveRefLayers];
+      refLayerId = strtok(pPredLayerIds, " ,-");
+      while(refLayerId != NULL)
+      {
+        if( i >= m_acLayerCfg[layer].m_numActiveRefLayers )
+        {
+          printf( "NumActiveRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+          exit( EXIT_FAILURE );
+        }
+        *( m_acLayerCfg[layer].m_predLayerIds + i ) = atoi( refLayerId );
+        refLayerId = strtok(NULL, " ,-");
+        i++;
+      }
+      if( i < m_acLayerCfg[layer].m_numActiveRefLayers )
+      {
+        printf( "NumActiveRefLayers: The width of some columns is not defined.\n" );
+        exit( EXIT_FAILURE );
+      }
+    }
+    else
+    {
+      m_acLayerCfg[layer].m_predLayerIds = NULL;
     }
   }
@@ -1840,4 +1888,15 @@
     }
   }
+
+  xConfirmPara( (m_acLayerCfg[0].m_numActiveRefLayers != 0) && (m_acLayerCfg[0].m_numActiveRefLayers != -1), "Layer 0 cannot have any active reference layers" );
+  // NOTE: m_numActiveRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
+  for(Int layer = 1; layer < MAX_LAYERS; layer++)
+  {
+    xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference more layers than NumDirectRefLayers");
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numActiveRefLayers; i++)
+    {
+      xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers");
+    }
+  }
 #endif
 #undef xConfirmPara
Index: /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 269)
@@ -45,4 +45,6 @@
   Int       *m_refLayerIds;
   Int       m_numDirectRefLayers;
+  Int       *m_predLayerIds;
+  Int       m_numActiveRefLayers;
 #endif
 
@@ -108,4 +110,8 @@
   Int*    getRefLayerIds()            {return m_refLayerIds;      }
   Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
+
+  Int     getNumActiveRefLayers()     {return m_numActiveRefLayers;}
+  Int*    getPredLayerIds()           {return m_predLayerIds;     }
+  Int     getPredLayerId(Int i)       {return m_predLayerIds[i];  }
 #endif
 #if RC_SHVC_HARMONIZATION
Index: /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 269)
@@ -159,5 +159,22 @@
         {
           m_acTEncTop[layer].setRefLayerId             ( i, m_acLayerCfg[layer].getRefLayerId(i));
-        }        
+        }
+      }
+
+      if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
+      {
+        m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() );
+        for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
+        {
+          m_acTEncTop[layer].setPredLayerId(i, i);
+        }
+      }
+      else
+      {
+        m_acTEncTop[layer].setNumActiveRefLayers       ( m_acLayerCfg[layer].getNumActiveRefLayers() );      
+        for(Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++)
+        {
+          m_acTEncTop[layer].setPredLayerId             ( i, m_acLayerCfg[layer].getPredLayerId(i));
+        }
       }
     }
Index: /branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TypeDef.h	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TypeDef.h	(revision 269)
@@ -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
Index: /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 269)
@@ -145,4 +145,7 @@
   Int       m_numDirectRefLayers;
   Int       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
+
+  Int       m_numActiveRefLayers;
+  Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
 #endif
   //======= Transform =============
@@ -405,4 +408,10 @@
   Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
   Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
+
+  Int       getNumActiveRefLayers           ()                              { return m_numActiveRefLayers;      }
+  Void      setNumActiveRefLayers           (Int num)                       { m_numActiveRefLayers = num;       }
+
+  Int       getPredLayerId                  (Int i)                         { return m_predLayerId[i];          }
+  Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
 #endif
   //======== Transform =============
Index: /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 268)
+++ /branches/SHM-2.1-multilayers-dev/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 269)
@@ -493,8 +493,8 @@
     if( rpcSlice->getNumILRRefIdx() > 0 )
     {
-      rpcSlice->setActiveNumILRRefIdx( rpcSlice->getNumILRRefIdx() );
+      rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() );
       for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
       {
-        rpcSlice->setInterLayerPredLayerIdc(i, i);
+        rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i );
       }
       rpcSlice->setInterLayerPredEnabledFlag(1);
