Index: /branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 484)
@@ -1098,8 +1098,22 @@
     {
 #if N0120_MAX_TID_REF_CFG
+#if O0225_MAX_TID_FOR_REF_LAYERS
+      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
+      {
+        vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
+      }
+#else
       vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
+#endif 
+#else
+#if O0225_MAX_TID_FOR_REF_LAYERS
+      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
+      {
+        vps->setMaxTidIlRefPicsPlus1(i, j, vps->getMaxTLayers()+1);
+      }
 #else
       vps->setMaxTidIlRefPicsPlus1(i, vps->getMaxTLayers()+1);
 #endif
+#endif
     }
   }
@@ -1108,5 +1122,12 @@
     for( i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++ )
     {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+      for( Int j = i+1; j <= MAX_VPS_LAYER_ID_PLUS1 - 1; j++)
+      {
+        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
+      }
+#else
       vps->setMaxTidIlRefPicsPlus1(i, 7);
+#endif 
     }
   }
Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 484)
@@ -456,6 +456,9 @@
     UInt refLayerIdc = m_interLayerPredLayerIdc[i];
     //inter-layer reference picture
-
+#if O0225_MAX_TID_FOR_REF_LAYERS
+    Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId) : 0;
+#else
     Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
+#endif 
     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  ) 
     {
@@ -491,5 +494,9 @@
     for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ )
     {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+      Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId(),m_layerId);
+#else
       Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId());
+#endif 
       if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
       {
@@ -634,5 +641,9 @@
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
+#if O0225_MAX_TID_FOR_REF_LAYERS
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId);
+#else
         Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+#endif
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -662,5 +673,9 @@
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
+#if O0225_MAX_TID_FOR_REF_LAYERS
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId);
+#else
         Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+#endif 
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -699,5 +714,9 @@
       {
         Int refLayerIdc = m_interLayerPredLayerIdc[i];
+#if O0225_MAX_TID_FOR_REF_LAYERS
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId);
+#else
         Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId());
+#endif 
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -2013,5 +2032,12 @@
   for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
   {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+  for( Int j = 0; j < MAX_VPS_LAYER_ID_PLUS1; j++)
+  {
+    m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1;
+  }
+#else
     m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1;
+#endif 
   }
 #endif
Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 484)
@@ -573,5 +573,9 @@
 #endif
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if O0225_MAX_TID_FOR_REF_LAYERS
+  UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1][MAX_VPS_LAYER_ID_PLUS1];
+#else
   UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
+#endif
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
@@ -792,6 +796,11 @@
 #endif 
 #if JCTVC_M0203_INTERLAYER_PRED_IDC
+#if O0225_MAX_TID_FOR_REF_LAYERS
+  UInt   getMaxTidIlRefPicsPlus1(Int layerId, Int refLayerId)                     { return m_maxTidIlRefPicsPlus1[layerId][refLayerId];           }
+  Void   setMaxTidIlRefPicsPlus1(Int layerId, Int refLayerId, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[layerId][refLayerId] = maxSublayer;    }
+#else
   UInt   getMaxTidIlRefPicsPlus1(Int layerId)                     { return m_maxTidIlRefPicsPlus1[layerId];                   }
   Void   setMaxTidIlRefPicsPlus1(Int layerId, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[layerId] = maxSublayer;            }
+#endif
 #endif
 #if N0120_MAX_TID_REF_PRESENT_FLAG
Index: /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 484)
@@ -123,4 +123,5 @@
 #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)
+#define O0225_MAX_TID_FOR_REF_LAYERS     1
 #endif
 #if REF_IDX_MFM
Index: /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 484)
@@ -1098,4 +1098,14 @@
     for(i = 0; i < vps->getMaxLayers() - 1; i++)
     {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+       for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+       {
+         if(vps->getDirectDependencyFlag(j, i))
+         {
+           READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode);
+           assert( uiCode <= vps->getMaxTLayers());
+         }
+       }
+#else
       READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
 #if N0120_MAX_TID_REF_CFG
@@ -1104,4 +1114,5 @@
       assert( uiCode <= vps->getMaxTLayers()+ 1 );
 #endif
+#endif 
     }
   }
@@ -1110,5 +1121,12 @@
     for(i = 0; i < vps->getMaxLayers() - 1; i++)
     {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+       for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+       {
+          vps->setMaxTidIlRefPicsPlus1(i, j, 7);
+       }
+#else
       vps->setMaxTidIlRefPicsPlus1(i, 7);
+#endif
     }
   }
@@ -1116,6 +1134,17 @@
   for(i = 0; i < vps->getMaxLayers() - 1; i++)
   {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+       for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+       {
+         if(vps->getDirectDependencyFlag(j, i))
+         {
+           READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode);
+           assert( uiCode <= vps->getMaxTLayers() );
+         }
+       }
+#else
     READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
     assert( uiCode <= vps->getMaxTLayers() );
+#endif   
   }
 #endif
Index: /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 484)
@@ -498,8 +498,16 @@
 
   Int remainingInterLayerReferencesFlag = 0;
+#if O0225_MAX_TID_FOR_REF_LAYERS
+  for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
+  {
+    Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]);
+    if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 )
+    {
+#else
   if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 )
   {
     for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
     {
+#endif 
       for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ )
       {
Index: /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 484)
@@ -899,5 +899,15 @@
      for( i = 0; i < vps->getMaxLayers() - 1; i++)
      {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+       for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+       {
+         if(vps->getDirectDependencyFlag(j, i))
+         {
+           WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i,j), 3, "max_tid_il_ref_pics_plus1[i][j]" );
+         }
+       }
+#else
        WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" );
+#endif 
      }
    }
@@ -905,5 +915,15 @@
   for( i = 0; i < vps->getMaxLayers() - 1; i++)
   {
+#if O0225_MAX_TID_FOR_REF_LAYERS
+       for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
+       {
+         if(vps->getDirectDependencyFlag(j, i))
+         {
+           WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i,j), 3, "max_tid_il_ref_pics_plus1[i][j]" );
+         }
+       }
+#else
     WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" );
+#endif 
   }
 #endif
Index: /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 483)
+++ /branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 484)
@@ -769,5 +769,9 @@
 
         // Apply temporal layer restriction to inter-layer prediction
+#if O0225_MAX_TID_FOR_REF_LAYERS
+        Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerId(),m_layerId);
+#else
         Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerId());
+#endif 
         if( ((Int)(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getRapPicFlag()) )
         {
