Index: branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 396)
+++ branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 397)
@@ -73,4 +73,7 @@
 , m_scalingListFile()
 , m_elRapSliceBEnabled(0)
+#if N0120_MAX_TID_REF_CFG
+, m_maxTidIlRefPicsPlus1PresentFlag(1)
+#endif 
 {
   for(UInt layer=0; layer<MAX_LAYERS; layer++)
@@ -397,4 +400,7 @@
   Bool*   cfg_RCForceIntraQP       [MAX_LAYERS];
 #endif
+#if N0120_MAX_TID_REF_CFG
+  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS]; 
+#endif 
   for(UInt layer = 0; layer < MAX_LAYERS; layer++)
   {
@@ -442,4 +448,7 @@
     cfg_RCForceIntraQP[layer]        = &m_acLayerCfg[layer].m_RCForceIntraQP;
 #endif
+#if N0120_MAX_TID_REF_CFG
+    cfg_maxTidIlRefPicsPlus1[layer] = &m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1; 
+#endif 
   }
 #if AVC_BASE
@@ -514,4 +523,8 @@
                                                                  " bottom-right luma sample of the EL picture, in units of two luma samples")
 #endif
+#if N0120_MAX_TID_REF_CFG
+  ("MaxTidIlRefPicsPlus1Present", m_maxTidIlRefPicsPlus1PresentFlag, true, "max_tid_il_ref_pics_plus1_present_flag (0: not present, 1: present(default)) " )
+  ("MaxTidIlRefPicsPlus1%d", cfg_maxTidIlRefPicsPlus1, 1, MAX_LAYERS, "allowed maximum temporal_id for inter-layer prediction")
+#endif 
 #if AVC_BASE
   ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
@@ -2087,4 +2100,10 @@
   }
 #endif
+#if N0120_MAX_TID_REF_CFG
+  for (UInt layer=0; layer < MAX_LAYERS-1; layer++)
+  {
+    xConfirmPara(m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 < 0 || m_acLayerCfg[layer].m_maxTidIlRefPicsPlus1 > 7, "MaxTidIlRefPicsPlus1 must be in range 0 to 7");
+  }
+#endif 
 #undef xConfirmPara
   if (check_failed)
Index: branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.h
===================================================================
--- branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 396)
+++ branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncCfg.h	(revision 397)
@@ -76,4 +76,7 @@
   Int       m_ilSampleOnlyPred[ MAX_LAYERS ];
 #endif
+#if N0120_MAX_TID_REF_CFG
+  Bool      m_maxTidIlRefPicsPlus1PresentFlag; 
+#endif 
 #else
   Char*     m_pchInputFile;                                   ///< source file name
Index: branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h
===================================================================
--- branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 396)
+++ branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncLayerCfg.h	(revision 397)
@@ -66,4 +66,7 @@
 #endif
 
+#if N0120_MAX_TID_REF_CFG
+  Int       m_maxTidIlRefPicsPlus1;
+#endif 
 #if SVC_EXTENSION
   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
@@ -155,4 +158,7 @@
   Void    setSourceHeight(Int x)           {m_iSourceHeight = x;    }
 #endif
+#if N0120_MAX_TID_REF_CFG
+  Int     getMaxTidIlRefPicsPlus1()   { return m_maxTidIlRefPicsPlus1; }
+#endif 
 }; // END CLASS DEFINITION TAppEncLayerCfg
 
Index: branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 396)
+++ branches/SHM-3.1-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 397)
@@ -195,4 +195,10 @@
     m_acTEncTop[layer].setMaxTempLayer                 ( m_maxTempLayer );
     m_acTEncTop[layer].setUseAMP( m_enableAMP );
+#if N0120_MAX_TID_REF_CFG
+    if (layer<m_numLayers-1)
+    {
+       m_acTEncTop[layer].setMaxTidIlRefPicsPlus1 ( m_acLayerCfg[layer].getMaxTidIlRefPicsPlus1()); 
+    }
+#endif 
 #if VPS_EXTN_DIRECT_REF_LAYERS
     if(layer)
@@ -925,10 +931,18 @@
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
+#if N0120_MAX_TID_REF_CFG
+  vps->setMaxTidIlRefPicsPlus1PresentFlag(m_maxTidIlRefPicsPlus1PresentFlag);
+#else 
   vps->setMaxTidIlRefPicsPlus1PresentFlag(true);
+#endif 
   if (vps->getMaxTidIlRefPicsPlus1PresentFlag())
   {
     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
     {
+#if N0120_MAX_TID_REF_CFG
+      vps->setMaxSublayerForIlpPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1()); 
+#else 
       vps->setMaxSublayerForIlpPlus1(i, vps->getMaxTLayers()+1);
+#endif 
     }
   }
Index: branches/SHM-3.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 396)
+++ branches/SHM-3.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 397)
@@ -126,4 +126,5 @@
 #define EARLY_REF_PIC_MARKING            1      ///< Decoded picture marking of sub-layer non-reference pictures
 #define N0120_MAX_TID_REF_PRESENT_FLAG   1      ///< JCTVC-N0120 max_tid_ref_pics_plus1_present_flag
+#define N0120_MAX_TID_REF_CFG            1      ///< set max_tid_il_ref_pics_plus1 and max_tid_ref_present_flag in the config. file (configuration setting)
 #endif
 #if REF_IDX_MFM
Index: branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 396)
+++ branches/SHM-3.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 397)
@@ -1004,5 +1004,9 @@
     {
       READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode);
+#if N0120_MAX_TID_REF_CFG
+      assert( uiCode <= vps->getMaxTLayers());
+#else 
       assert( uiCode <= vps->getMaxTLayers()+ 1 );
+#endif 
     }
   }
Index: branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 396)
+++ branches/SHM-3.1-dev/source/Lib/TLibEncoder/TEncCfg.h	(revision 397)
@@ -187,4 +187,7 @@
 #endif
 #endif
+#if N0120_MAX_TID_REF_CFG
+  Int       m_maxTidIlRefPicsPlus1;
+#endif 
   //======= Transform =============
   UInt      m_uiQuadtreeTULog2MaxSize;
@@ -468,4 +471,8 @@
 #endif
 #endif
+#if N0120_MAX_TID_REF_CFG
+  Int       getMaxTidIlRefPicsPlus1         ()                              { return m_maxTidIlRefPicsPlus1; }
+  Void      setMaxTidIlRefPicsPlus1         (Int num)                       { m_maxTidIlRefPicsPlus1 = num;  }
+#endif 
   //======== Transform =============
   Void      setQuadtreeTULog2MaxSize        ( UInt  u )      { m_uiQuadtreeTULog2MaxSize = u; }
