Index: /branches/SHM-2.1-dev/cfg/layers.cfg
===================================================================
--- /branches/SHM-2.1-dev/cfg/layers.cfg	(revision 289)
+++ /branches/SHM-2.1-dev/cfg/layers.cfg	(revision 290)
@@ -19,6 +19,8 @@
 #============= LAYER 1 ==================
 QP1                           : 20
-NumDirectRefLayers1           : 1           # number of direct reference layers
-RefLayerIds1                  : 0           # reference layer id
+NumSamplePredRefLayers1       : 1           # number of sample pred reference layers
+SamplePredRefLayerIds1        : 0           # reference layer id
+NumMotionPredRefLayers1       : 1           # number of motion pred reference layers
+MotionPredRefLayerIds1        : 0           # reference layer id
 NumActiveRefLayers1           : 1           # number of active reference layers
 PredLayerIds1                 : 0           # inter-layer prediction layer id
Index: /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 290)
@@ -146,6 +146,22 @@
 {
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
+    if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
+    {
+      delete [] m_acLayerCfg[layer].m_samplePredRefLayerIds;
+    }
+  }
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
+    {
+      delete [] m_acLayerCfg[layer].m_motionPredRefLayerIds;
+    }
+  }
+#else
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
     if( m_acLayerCfg[layer].m_numDirectRefLayers > 0 )
     {
@@ -153,5 +169,5 @@
     }
   }
-
+#endif
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -336,8 +352,16 @@
   Int*    cfg_conformanceMode  [MAX_LAYERS];
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  Int*    cfg_numSamplePredRefLayers  [MAX_LAYERS];
+  string  cfg_samplePredRefLayerIds   [MAX_LAYERS];
+  string* cfg_samplePredRefLayerIdsPtr[MAX_LAYERS];
+  Int*    cfg_numMotionPredRefLayers  [MAX_LAYERS];
+  string  cfg_motionPredRefLayerIds   [MAX_LAYERS];
+  string* cfg_motionPredRefLayerIdsPtr[MAX_LAYERS];
+#else
   Int*    cfg_numDirectRefLayers [MAX_LAYERS];
   string  cfg_refLayerIds        [MAX_LAYERS];
   string* cfg_refLayerIdsPtr     [MAX_LAYERS];
-
+#endif
   Int*    cfg_numActiveRefLayers [MAX_LAYERS];
   string  cfg_predLayerIds       [MAX_LAYERS];
@@ -376,6 +400,13 @@
     cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+    cfg_numSamplePredRefLayers  [layer] = &m_acLayerCfg[layer].m_numSamplePredRefLayers;
+    cfg_samplePredRefLayerIdsPtr[layer] = &cfg_samplePredRefLayerIds[layer];
+    cfg_numMotionPredRefLayers  [layer] = &m_acLayerCfg[layer].m_numMotionPredRefLayers;
+    cfg_motionPredRefLayerIdsPtr[layer] = &cfg_motionPredRefLayerIds[layer];
+#else
     cfg_numDirectRefLayers  [layer] = &m_acLayerCfg[layer].m_numDirectRefLayers;
     cfg_refLayerIdsPtr      [layer]  = &cfg_refLayerIds[layer];
+#endif
     cfg_numActiveRefLayers  [layer] = &m_acLayerCfg[layer].m_numActiveRefLayers;
     cfg_predLayerIdsPtr     [layer]  = &cfg_predLayerIds[layer];
@@ -444,6 +475,13 @@
   ("LambdaModifier%d,-LM%d",  m_adLambdaModifier, ( double )1.0, MAX_TLAYER, "Lambda modifier for temporal layer %d")
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  ("NumSamplePredRefLayers%d",cfg_numSamplePredRefLayers, -1, MAX_LAYERS, "Number of sample prediction reference layers")
+  ("SamplePredRefLayerIds%d", cfg_samplePredRefLayerIdsPtr, string(""), MAX_LAYERS, "sample pred reference layer IDs")
+  ("NumMotionPredRefLayers%d",cfg_numMotionPredRefLayers, -1, MAX_LAYERS, "Number of motion prediction reference layers")
+  ("MotionPredRefLayerIds%d", cfg_motionPredRefLayerIdsPtr, string(""), MAX_LAYERS, "motion pred reference layer IDs")
+#else
   ("NumDirectRefLayers%d",    cfg_numDirectRefLayers, -1, MAX_LAYERS, "Number of direct reference layers")
   ("RefLayerIds%d",           cfg_refLayerIdsPtr, string(""), MAX_LAYERS, "direct reference layer IDs")
+#endif
   ("NumActiveRefLayers%d",    cfg_numActiveRefLayers, -1, MAX_LAYERS, "Number of active reference layers")
   ("PredLayerIds%d",          cfg_predLayerIdsPtr, string(""), MAX_LAYERS, "inter-layer prediction layer IDs")
@@ -975,4 +1013,68 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Char* pSamplePredRefLayerIds = cfg_samplePredRefLayerIds[layer].empty() ? NULL: strdup(cfg_samplePredRefLayerIds[layer].c_str());
+    if( m_acLayerCfg[layer].m_numSamplePredRefLayers > 0 )
+    {
+      char *samplePredRefLayerId;
+      int  i=0;
+      m_acLayerCfg[layer].m_samplePredRefLayerIds = new Int[m_acLayerCfg[layer].m_numSamplePredRefLayers];
+      samplePredRefLayerId = strtok(pSamplePredRefLayerIds, " ,-");
+      while(samplePredRefLayerId != NULL)
+      {
+        if( i >= m_acLayerCfg[layer].m_numSamplePredRefLayers )
+        {
+          printf( "NumSamplePredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+          exit( EXIT_FAILURE );
+        }
+        *( m_acLayerCfg[layer].m_samplePredRefLayerIds + i ) = atoi( samplePredRefLayerId );
+        samplePredRefLayerId = strtok(NULL, " ,-");
+        i++;
+      }
+      if( i < m_acLayerCfg[layer].m_numSamplePredRefLayers )
+      {
+        printf( "NumSamplePredRefLayers: The width of some columns is not defined.\n" );
+        exit( EXIT_FAILURE );
+      }
+    }
+    else
+    {
+      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
+    }
+  }
+  for(Int layer = 0; layer < MAX_LAYERS; layer++)
+  {
+    Char* pMotionPredRefLayerIds = cfg_motionPredRefLayerIds[layer].empty() ? NULL: strdup(cfg_motionPredRefLayerIds[layer].c_str());
+    if( m_acLayerCfg[layer].m_numMotionPredRefLayers > 0 )
+    {
+      char *motionPredRefLayerId;
+      int  i=0;
+      m_acLayerCfg[layer].m_motionPredRefLayerIds = new Int[m_acLayerCfg[layer].m_numMotionPredRefLayers];
+      motionPredRefLayerId = strtok(pMotionPredRefLayerIds, " ,-");
+      while(motionPredRefLayerId != NULL)
+      {
+        if( i >= m_acLayerCfg[layer].m_numMotionPredRefLayers )
+        {
+          printf( "NumMotionPredRefLayers: The number of columns whose width are defined is larger than the allowed number of columns.\n" );
+          exit( EXIT_FAILURE );
+        }
+        *( m_acLayerCfg[layer].m_motionPredRefLayerIds + i ) = atoi( motionPredRefLayerId );
+        motionPredRefLayerId = strtok(NULL, " ,-");
+        i++;
+      }
+      if( i < m_acLayerCfg[layer].m_numMotionPredRefLayers )
+      {
+        printf( "NumMotionPredRefLayers: The width of some columns is not defined.\n" );
+        exit( EXIT_FAILURE );
+      }
+    }
+    else
+    {
+      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
+    }
+  }
+#else
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -1006,5 +1108,5 @@
     }
   }
-
+#endif
   for(Int layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -1959,4 +2061,28 @@
 #endif
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  xConfirmPara( (m_acLayerCfg[0].m_numSamplePredRefLayers != 0) && (m_acLayerCfg[0].m_numSamplePredRefLayers != -1), "Layer 0 cannot have any reference layers" );
+  // NOTE: m_numSamplePredRefLayers  (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_numSamplePredRefLayers > layer, "Cannot reference more layers than before current layer");
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++)
+    {
+      xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] > layer, "Cannot reference higher layers");
+      xConfirmPara(m_acLayerCfg[layer].m_samplePredRefLayerIds[i] == layer, "Cannot reference the current layer itself");
+    }
+  }
+  xConfirmPara( (m_acLayerCfg[0].m_numMotionPredRefLayers != 0) && (m_acLayerCfg[0].m_numMotionPredRefLayers != -1), "Layer 0 cannot have any reference layers" );
+  // NOTE: m_numMotionPredRefLayers  (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_numMotionPredRefLayers > layer, "Cannot reference more layers than before current layer");
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++)
+    {
+      xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] > layer, "Cannot reference higher layers");
+      xConfirmPara(m_acLayerCfg[layer].m_motionPredRefLayerIds[i] == layer, "Cannot reference the current layer itself");
+    }
+  }
+#else
   xConfirmPara( (m_acLayerCfg[0].m_numDirectRefLayers != 0) && (m_acLayerCfg[0].m_numDirectRefLayers != -1), "Layer 0 cannot have any reference layers" );
   // NOTE: m_numDirectRefLayers  (for any layer) could be -1 (not signalled in cfg), in which case only the "previous layer" would be taken for reference
@@ -1970,9 +2096,34 @@
     }
   }
-
+#endif
   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++)
   {
+#if M0457_PREDICTION_INDICATIONS
+    Bool predEnabledFlag[MAX_LAYERS];
+    for (Int refLayer = 0; refLayer < layer; refLayer++)
+    {
+      predEnabledFlag[refLayer] = false;
+    }
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numSamplePredRefLayers; i++)
+    {
+      predEnabledFlag[m_acLayerCfg[layer].m_samplePredRefLayerIds[i]] = true;
+    }
+    for(Int i = 0; i < m_acLayerCfg[layer].m_numMotionPredRefLayers; i++)
+    {
+      predEnabledFlag[m_acLayerCfg[layer].m_motionPredRefLayerIds[i]] = true;
+    }
+    Int numDirectRefLayers = 0;
+    for (Int refLayer = 0; refLayer < layer; refLayer++)
+    {
+      if (predEnabledFlag[refLayer] == true) numDirectRefLayers++;
+    }
+    xConfirmPara(m_acLayerCfg[layer].m_numActiveRefLayers > 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] > numDirectRefLayers, "Cannot reference higher layers");
+    }
+#else
     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++)
@@ -1980,4 +2131,5 @@
       xConfirmPara(m_acLayerCfg[layer].m_predLayerIds[i] > m_acLayerCfg[layer].m_numDirectRefLayers, "Cannot reference higher layers");
     }
+#endif
   }
 #endif
Index: /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 289)
+++ /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 290)
@@ -43,6 +43,13 @@
   Double    m_fQP;                                            ///< QP value of key-picture (floating point)
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  Int       *m_samplePredRefLayerIds;
+  Int       m_numSamplePredRefLayers;
+  Int       *m_motionPredRefLayerIds;
+  Int       m_numMotionPredRefLayers;
+#else
   Int       *m_refLayerIds;
   Int       m_numDirectRefLayers;
+#endif
   Int       *m_predLayerIds;
   Int       m_numActiveRefLayers;
@@ -108,7 +115,16 @@
   Int*    getdQPs()                   {return m_aidQP;            }
 #if VPS_EXTN_DIRECT_REF_LAYERS
+#if M0457_PREDICTION_INDICATIONS
+  Int     getNumSamplePredRefLayers()    {return m_numSamplePredRefLayers;   }
+  Int*    getSamplePredRefLayerIds()     {return m_samplePredRefLayerIds;    }
+  Int     getSamplePredRefLayerId(Int i) {return m_samplePredRefLayerIds[i]; }
+  Int     getNumMotionPredRefLayers()    {return m_numMotionPredRefLayers;   }
+  Int*    getMotionPredRefLayerIds()     {return m_motionPredRefLayerIds;    }
+  Int     getMotionPredRefLayerId(Int i) {return m_motionPredRefLayerIds[i]; }
+#else
   Int     getNumDirectRefLayers()     {return m_numDirectRefLayers;}
   Int*    getRefLayerIds()            {return m_refLayerIds;      }
   Int     getRefLayerId(Int i)        {return m_refLayerIds[i];   }
+#endif
 
   Int     getNumActiveRefLayers()     {return m_numActiveRefLayers;}
Index: /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 290)
@@ -147,4 +147,53 @@
     if(layer)
     {
+#if M0457_PREDICTION_INDICATIONS
+      for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++)
+      {
+        m_acTEncTop[layer].setSamplePredEnabledFlag(i, false);
+        m_acTEncTop[layer].setMotionPredEnabledFlag(i, false);
+      }
+      if(m_acLayerCfg[layer].getNumSamplePredRefLayers() == -1)
+      {
+        // Not included in the configuration file; assume that each layer depends on previous layer
+        m_acTEncTop[layer].setNumSamplePredRefLayers   (1);      // One sample pred ref. layer
+        m_acTEncTop[layer].setSamplePredRefLayerId     (0, layer - 1);   // Previous layer
+        m_acTEncTop[layer].setSamplePredEnabledFlag    (layer - 1, true);
+      }
+      else
+      {
+        m_acTEncTop[layer].setNumSamplePredRefLayers   ( m_acLayerCfg[layer].getNumSamplePredRefLayers() );      
+        for(Int i = 0; i < m_acTEncTop[layer].getNumSamplePredRefLayers(); i++)
+        {
+          m_acTEncTop[layer].setSamplePredRefLayerId   ( i, m_acLayerCfg[layer].getSamplePredRefLayerId(i));
+          m_acTEncTop[layer].setSamplePredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
+        }        
+      }
+      if(m_acLayerCfg[layer].getNumMotionPredRefLayers() == -1)
+      {
+        // Not included in the configuration file; assume that each layer depends on previous layer
+        m_acTEncTop[layer].setNumMotionPredRefLayers   (1);      // One motion pred ref. layer
+        m_acTEncTop[layer].setMotionPredRefLayerId     (0, layer - 1);   // Previous layer
+        m_acTEncTop[layer].setMotionPredEnabledFlag    (layer - 1, true);
+      }
+      else
+      {
+        m_acTEncTop[layer].setNumMotionPredRefLayers   ( m_acLayerCfg[layer].getNumMotionPredRefLayers() );      
+        for(Int i = 0; i < m_acTEncTop[layer].getNumMotionPredRefLayers(); i++)
+        {
+          m_acTEncTop[layer].setMotionPredRefLayerId   ( i, m_acLayerCfg[layer].getMotionPredRefLayerId(i));
+          m_acTEncTop[layer].setMotionPredEnabledFlag  (m_acLayerCfg[layer].getSamplePredRefLayerId(i), true);
+        }        
+      }
+      Int numDirectRefLayers = 0;
+      for (Int i = 0; i < layer; i++)
+      {
+        if (m_acTEncTop[layer].getSamplePredEnabledFlag(i) || m_acTEncTop[layer].getMotionPredEnabledFlag(i))
+        {
+          m_acTEncTop[layer].setRefLayerId(numDirectRefLayers, i);
+          numDirectRefLayers++;
+        }
+      }
+      m_acTEncTop[layer].setNumDirectRefLayers(numDirectRefLayers);
+#else
       if(m_acLayerCfg[layer].getNumDirectRefLayers() == -1)
       {
@@ -161,8 +210,12 @@
         }
       }
-
+#endif
       if(m_acLayerCfg[layer].getNumActiveRefLayers() == -1)
       {
+#if M0457_PREDICTION_INDICATIONS
+        m_acTEncTop[layer].setNumActiveRefLayers( m_acTEncTop[layer].getNumDirectRefLayers() );
+#else
         m_acTEncTop[layer].setNumActiveRefLayers( m_acLayerCfg[layer].getNumDirectRefLayers() );
+#endif
         for( Int i = 0; i < m_acTEncTop[layer].getNumActiveRefLayers(); i++ )
         {
@@ -951,4 +1004,20 @@
       vps->setDirectDependencyFlag( layerCtr, vps->getLayerIdInVps(m_acTEncTop[layerCtr].getRefLayerId(i)), true);
     }
+#if M0457_PREDICTION_INDICATIONS
+    vps->setDirectDepTypeLen(2); // sample and motion types are encoded
+    for(Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
+    {
+      if (vps->getDirectDependencyFlag( layerCtr, refLayerCtr))
+      {
+        assert(m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) || m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr));
+        vps->setDirectDependencyType( layerCtr, refLayerCtr, ((m_acTEncTop[layerCtr].getSamplePredEnabledFlag(refLayerCtr) ? 1 : 0) |
+                                                              (m_acTEncTop[layerCtr].getMotionPredEnabledFlag(refLayerCtr) ? 2 : 0)) - 1);
+      }
+      else
+      {
+        vps->setDirectDependencyType( layerCtr, refLayerCtr, 0 );
+      }
+    }
+#endif
   }
 #endif
Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 290)
@@ -1671,4 +1671,8 @@
   ::memset(m_numDirectRefLayers,   0, sizeof(m_numDirectRefLayers  ));
   ::memset(m_refLayerId,           0, sizeof(m_refLayerId          ));
+#if M0457_PREDICTION_INDICATIONS
+  m_directDepTypeLen = 2;
+  ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType));
+#endif
 #endif
 #if DERIVE_LAYER_ID_LIST_VARIABLES
Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 290)
@@ -549,4 +549,8 @@
   UInt       m_numDirectRefLayers[MAX_VPS_LAYER_ID_PLUS1];
   UInt       m_refLayerId[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
+#if M0457_PREDICTION_INDICATIONS
+  UInt       m_directDepTypeLen;
+  UInt       m_directDependencyType[MAX_VPS_LAYER_ID_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
+#endif
 #endif
 #if VPS_PROFILE_OUTPUT_LAYERS
@@ -694,4 +698,12 @@
   UInt   getRefLayerId(Int layerId, Int refLayerIdx)                            { return m_refLayerId[layerId][refLayerIdx];              }
   Void   setRefLayerId(Int layerId, Int refLayerIdx, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdx] = refLayerId;        }
+
+#if M0457_PREDICTION_INDICATIONS
+  UInt   getDirectDepTypeLen()                                                  { return m_directDepTypeLen;                              }
+  Void   setDirectDepTypeLen(UInt x)                                            { m_directDepTypeLen = x;                                 }
+
+  UInt   getDirectDependencyType(Int currLayerId, Int refLayerId)               { return m_directDependencyType[currLayerId][refLayerId]; }
+  Void   setDirectDependencyType(Int currLayerId, Int refLayerId, UInt x)       { m_directDependencyType[currLayerId][refLayerId] = x;    }
+#endif
 #endif
 #if VPS_PROFILE_OUTPUT_LAYERS
Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 290)
@@ -61,4 +61,5 @@
 #define SPS_SUB_LAYER_INFO               1      ///< M0268: Do not signal sps_max_sub_layers_minus1 and sps_temporal_id_nesting_flag for nuh_layer_id greater than 0
 #define VPS_SPLIT_FLAG                   1      ///< M0163: Do not signal dimension_id and the last dimension_id_len_minus1, when splitting_flag is equal to 1. 
+#define M0457_PREDICTION_INDICATIONS     1
 #endif
 
Index: /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 290)
@@ -1143,4 +1143,17 @@
 #endif
 #endif
+#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  READ_UVLC( uiCode,           "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2);
+  for(i = 1; i < vps->getMaxLayers(); i++)
+  {
+    for(j = 0; j < i; j++)
+    {
+      if (vps->getDirectDependencyFlag(i, j))
+      {
+        READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode);
+      }
+    }
+  }
+#endif
 }
 #endif
Index: /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 290)
@@ -538,4 +538,7 @@
   m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
 
+#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  setRefLayerParams(m_apcSlicePilot->getVPS());
+#endif
 #if SVC_EXTENSION
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]);
@@ -1316,3 +1319,56 @@
 #endif
 
+#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+
+Void TDecTop::setRefLayerParams( TComVPS* vps )
+{
+  for(UInt layer = 0; layer < m_numLayer; layer++)
+  {
+    TDecTop *decTop = (TDecTop *)getLayerDec(layer);
+    decTop->setNumSamplePredRefLayers(0);
+    decTop->setNumMotionPredRefLayers(0);
+    decTop->setNumDirectRefLayers(0);
+    for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++)
+    {
+      decTop->setSamplePredEnabledFlag(i, false);
+      decTop->setMotionPredEnabledFlag(i, false);
+      decTop->setSamplePredRefLayerId(i, 0);
+      decTop->setMotionPredRefLayerId(i, 0);
+    }
+    for(Int j = 0; j < layer; j++)
+    {
+      if (vps->getDirectDependencyFlag(layer, j))
+      {
+        decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer));
+        decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1);
+
+        Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1;
+        decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false);
+        decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag);
+
+        Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1;
+        decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false);
+        decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag);
+      }
+    }
+  }
+  for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ )
+  {
+    Int iNuhLId = vps->getLayerIdInNuh(i);
+    TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId);
+    for ( Int j = 0; j < i; j++ )
+    {
+      if (decTop->getMotionPredEnabledFlag(j))
+      {
+        decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j));
+      }
+      if (decTop->getSamplePredEnabledFlag(j))
+      {
+        decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j));
+      }
+    }
+  }
+}
+
+#endif
 //! \}
Index: /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 290)
@@ -120,4 +120,14 @@
   Int                     m_iBLSourceHeight;
 #endif
+#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  Int                     m_numDirectRefLayers;
+  Int                     m_refLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int                     m_numSamplePredRefLayers;
+  Int                     m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int                     m_numMotionPredRefLayers;
+  Int                     m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Bool                    m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
+  Bool                    m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
+#endif
 #endif 
 #if AVC_SYNTAX || SYNTAX_OUTPUT
@@ -158,4 +168,34 @@
 #if VPS_EXTN_DIRECT_REF_LAYERS
   TDecTop*  getRefLayerDec(UInt refLayerIdc);
+#if M0457_PREDICTION_INDICATIONS
+  Int       getNumDirectRefLayers           ()                              { return m_numDirectRefLayers;      }
+  Void      setNumDirectRefLayers           (Int num)                       { m_numDirectRefLayers = num;       }
+
+  Int       getRefLayerId                   (Int i)                         { return m_refLayerId[i];           }
+  Void      setRefLayerId                   (Int i, Int refLayerId)         { m_refLayerId[i] = refLayerId;     }
+
+  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
+  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
+
+  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
+  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
+
+  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
+  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
+
+  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
+  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
+
+  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
+  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
+
+  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
+  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
+
+  TDecTop*  getSamplePredRefLayerDec        ( UInt layerId );
+  TDecTop*  getMotionPredRefLayerDec        ( UInt layerId );
+
+  Void      setRefLayerParams( TComVPS* vps );
+#endif
 #endif
 #if AVC_BASE
Index: /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 290)
@@ -864,4 +864,17 @@
 #endif
 #endif
+#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
+  WRITE_UVLC( vps->getDirectDepTypeLen()-2,                           "direct_dep_type_len_minus2");
+  for(i = 1; i < vps->getMaxLayers(); i++)
+  {
+    for(j = 0; j < i; j++)
+    {
+      if (vps->getDirectDependencyFlag(i, j))
+      {
+        WRITE_CODE( vps->getDirectDependencyType(i, j), vps->getDirectDepTypeLen(), "direct_dependency_type[i][j]" );
+      }
+    }
+  }
+#endif
 }
 #endif
Index: /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 289)
+++ /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 290)
@@ -148,4 +148,12 @@
   Int       m_numActiveRefLayers;
   Int       m_predLayerId[MAX_VPS_LAYER_ID_PLUS1];
+#if M0457_PREDICTION_INDICATIONS
+  Int       m_numSamplePredRefLayers;
+  Int       m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Int       m_numMotionPredRefLayers;
+  Int       m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1];
+  Bool      m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
+  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
+#endif
 #endif
   //======= Transform =============
@@ -414,4 +422,24 @@
   Int       getPredLayerId                  (Int i)                         { return m_predLayerId[i];          }
   Void      setPredLayerId                  (Int i, Int refLayerId)         { m_predLayerId[i] = refLayerId;    }
+
+#if M0457_PREDICTION_INDICATIONS
+  Int       getNumSamplePredRefLayers       ()                              { return m_numSamplePredRefLayers;  }
+  Void      setNumSamplePredRefLayers       (Int num)                       { m_numSamplePredRefLayers = num;   }
+
+  Int       getSamplePredRefLayerId         (Int i)                         { return m_samplePredRefLayerId[i];       }
+  Void      setSamplePredRefLayerId         (Int i, Int refLayerId)         { m_samplePredRefLayerId[i] = refLayerId; }
+
+  Int       getNumMotionPredRefLayers       ()                              { return m_numMotionPredRefLayers;  }
+  Void      setNumMotionPredRefLayers       (Int num)                       { m_numMotionPredRefLayers = num;   }
+
+  Int       getMotionPredRefLayerId         (Int i)                         { return m_motionPredRefLayerId[i];       }
+  Void      setMotionPredRefLayerId         (Int i, Int refLayerId)         { m_motionPredRefLayerId[i] = refLayerId; }
+
+  Bool      getSamplePredEnabledFlag        (Int i)                         { return m_samplePredEnabledFlag[i];  }
+  Void      setSamplePredEnabledFlag        (Int i,Bool flag)               { m_samplePredEnabledFlag[i] = flag;  }
+
+  Bool      getMotionPredEnabledFlag        (Int i)                         { return m_motionPredEnabledFlag[i];  }
+  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
+#endif
 #endif
   //======== Transform =============
