Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1084)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 1085)
@@ -1498,12 +1498,8 @@
     for( i = 0; i < vps->getMaxLayers() - 1; i++ )
     {
-#if O0225_MAX_TID_FOR_REF_LAYERS
       for( Int j = i+1; j < vps->getMaxLayers(); j++)
       {
         vps->setMaxTidIlRefPicsPlus1(i, j, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
       }
-#else
-      vps->setMaxTidIlRefPicsPlus1(i, m_acTEncTop[i].getMaxTidIlRefPicsPlus1());
-#endif 
     }
   }
@@ -1512,12 +1508,8 @@
     for( i = 0; i < vps->getMaxLayers() - 1; i++ )
     {
-#if O0225_MAX_TID_FOR_REF_LAYERS
       for( Int j = i+1; j < vps->getMaxLayers(); j++)
       {
         vps->setMaxTidIlRefPicsPlus1(i, j, 7);
       }
-#else
-      vps->setMaxTidIlRefPicsPlus1(i, 7);
-#endif 
     }
   }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1085)
@@ -498,9 +498,6 @@
     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 
+      Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerIdx(), getLayerIdx());
+
       if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
       {
@@ -654,9 +651,5 @@
       {
         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
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx());
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -682,9 +675,5 @@
       {
         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 
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx());
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -719,9 +708,5 @@
       {
         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 
+        Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1( ilpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() );
         if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )
         {
@@ -2127,12 +2112,8 @@
   for( Int i = 0; i < MAX_VPS_LAYER_IDX_PLUS1 - 1; i++)
   {
-#if O0225_MAX_TID_FOR_REF_LAYERS
     for( Int j = 0; j < MAX_VPS_LAYER_IDX_PLUS1; j++)
     {
       m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1;
     }
-#else
-    m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1;
-#endif 
   }
 #if VPS_VUI_TILES_NOT_IN_USE__FLAG
@@ -4371,9 +4352,5 @@
 #endif
 
-#if O0225_MAX_TID_FOR_REF_LAYERS
-      Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId(), m_layerId );
-#else
-      Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId() );
-#endif
+      Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerIdx(), getLayerIdx() );
       assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) );
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1085)
@@ -750,9 +750,5 @@
   Bool       m_crossLayerAlignedIdrOnlyFlag;
 #endif
-#if O0225_MAX_TID_FOR_REF_LAYERS
   UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_IDX_PLUS1 - 1][MAX_VPS_LAYER_IDX_PLUS1];
-#else
-  UInt       m_maxTidIlRefPicsPlus1[MAX_VPS_LAYER_IDX_PLUS1 - 1];
-#endif
   Bool       m_maxTidRefPresentFlag;
 #if VPS_TSLAYERS
@@ -1140,6 +1136,6 @@
   Void   setNumDirectRefLayers(Int layerId, UInt refLayerNum)                   { m_numDirectRefLayers[layerId] = refLayerNum;            }
 
-  UInt   getRefLayerId(Int layerId, Int refLayerIdx)                            { return m_refLayerId[layerId][refLayerIdx];              }
-  Void   setRefLayerId(Int layerId, Int refLayerIdx, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdx] = refLayerId;        }
+  UInt   getRefLayerId(Int layerId, Int refLayerIdc)                            { return m_refLayerId[layerId][refLayerIdc];              }
+  Void   setRefLayerId(Int layerId, Int refLayerIdc, UInt refLayerId)           { m_refLayerId[layerId][refLayerIdc] = refLayerId;        }
 
   UInt   getDirectDepTypeLen()                                                  { return m_directDepTypeLen;                              }
@@ -1213,11 +1209,6 @@
   Bool   getCrossLayerIrapAlignFlag()                                           { return m_crossLayerIrapAlignFlag;                      }
   Void   setCrossLayerIrapAlignFlag(Bool x)                                     { m_crossLayerIrapAlignFlag = x;                         }
-#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
+  UInt   getMaxTidIlRefPicsPlus1(Int refLayerIdx, Int layerIdx)                     { return m_maxTidIlRefPicsPlus1[refLayerIdx][layerIdx];           }
+  Void   setMaxTidIlRefPicsPlus1(Int refLayerIdx, Int layerIdx, UInt maxSublayer)   { m_maxTidIlRefPicsPlus1[refLayerIdx][layerIdx] = maxSublayer;    }
   Bool   getMaxTidRefPresentFlag()                                  { return m_maxTidRefPresentFlag ;}
   Void   setMaxTidRefPresentFlag(Bool x)                            { m_maxTidRefPresentFlag = x;}
@@ -2726,6 +2717,6 @@
   Void      setActiveNumILRRefIdx     ( Int i )         { m_activeNumILRRefIdx = i;     }  
 
-  Int       getInterLayerPredLayerIdc (UInt layerIdx)                        { return  m_interLayerPredLayerIdc[layerIdx];}
-  Void      setInterLayerPredLayerIdc (UInt refLayerIdc, UInt layerIdx)      { m_interLayerPredLayerIdc[layerIdx] = refLayerIdc;  }
+  Int       getInterLayerPredLayerIdc (UInt layerIdc)                        { return  m_interLayerPredLayerIdc[layerIdc];}
+  Void      setInterLayerPredLayerIdc (UInt refLayerIdc, UInt layerIdc)      { m_interLayerPredLayerIdc[layerIdc] = refLayerIdc;  }
 
   Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_interLayerPredEnabledFlag = val; }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1085)
@@ -203,5 +203,4 @@
 #define EARLY_REF_PIC_MARKING            0      ///< Valencia meeting - remove early marking of inter-layer reference pictures
                                                 ///< Decoded picture marking of sub-layer non-reference pictures
-#define O0225_MAX_TID_FOR_REF_LAYERS     1
 #define O0225_TID_BASED_IL_RPS_DERIV     1
 #define VPS_TSLAYERS                     1      ///< JCTVC-O0120 signal max temporal sub-layers for each layer
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1085)
@@ -1610,8 +1610,8 @@
             {
 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
-              if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
+              if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i), pcSlice->getLayerIdx()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
                 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #else 
-              if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
+              if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i), pcSlice->getLayerIdx()) >  pcSlice->getTLayer() &&
                 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #endif 
@@ -1638,5 +1638,5 @@
             {
               READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
-              pcSlice->setInterLayerPredLayerIdc(uiCode,i);
+              pcSlice->setInterLayerPredLayerIdc(uiCode, i);
             }
           }
@@ -1645,15 +1645,17 @@
         {
 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
+          Int refLayerId = pcSlice->getVPS()->getRefLayerId(pcSlice->getLayerId(), 0);
+          Int refLayerIdx = pcSlice->getVPS()->getLayerIdxInVps(refLayerId);
 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
-          if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
-            (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  pcSlice->getTLayer()) )
-#else
-          if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) >  pcSlice->getTLayer()) &&
-            (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  pcSlice->getTLayer()) )
+          if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(refLayerIdx, pcSlice->getLayerIdx()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
+            (pcSlice->getVPS()->getMaxTSLayersMinus1(refLayerIdx) >=  pcSlice->getTLayer()) )
+#else
+          if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(refLayerIdx,pcSlice->getLayerIdx()) >  pcSlice->getTLayer()) &&
+            (pcSlice->getVPS()->getMaxTSLayersMinus1(refLayerIdx) >=  pcSlice->getTLayer()) )
 #endif 
           {
 #endif
             pcSlice->setActiveNumILRRefIdx(1);
-            pcSlice->setInterLayerPredLayerIdc(0,0);
+            pcSlice->setInterLayerPredLayerIdc(0, 0);
 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
           }
@@ -1673,8 +1675,8 @@
       {
 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
-        if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
+        if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i), pcSlice->getLayerIdx()) >  pcSlice->getTLayer() || pcSlice->getTLayer()==0) &&
           (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #else 
-        if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) >  pcSlice->getTLayer() &&
+        if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i), pcSlice->getLayerIdx()) >  pcSlice->getTLayer() &&
           (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >=  pcSlice->getTLayer()) )
 #endif 
@@ -1686,6 +1688,6 @@
       for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
       {
-        pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i);
-      }      
+        pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i], i);
+      }
 #else
       pcSlice->setActiveNumILRRefIdx(pcSlice->getNumILRRefIdx());
@@ -2999,5 +3001,4 @@
     for(i = 0; i < vps->getMaxLayers() - 1; i++)
     {
-#if O0225_MAX_TID_FOR_REF_LAYERS
       for( j = i+1; j < vps->getMaxLayers(); j++)
       {
@@ -3007,8 +3008,4 @@
         }
       }
-#else
-      READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
-      assert( uiCode <= vps->getMaxTLayers());
-#endif 
     }
   }
@@ -3017,12 +3014,8 @@
     for(i = 0; i < vps->getMaxLayers() - 1; i++)
     {
-#if O0225_MAX_TID_FOR_REF_LAYERS
       for( j = i+1; j < vps->getMaxLayers(); j++)
       {
         vps->setMaxTidIlRefPicsPlus1(i, j, 7);
       }
-#else
-      vps->setMaxTidIlRefPicsPlus1(i, 7);
-#endif
     }
   }
@@ -3691,12 +3684,8 @@
   for( i = 0; i < vps->getMaxLayers() - 1; i++ )
   {
-#if O0225_MAX_TID_FOR_REF_LAYERS
     for( j = i + 1; j < vps->getMaxLayers(); j++ )
     {
       vps->setMaxTidIlRefPicsPlus1(i, j, 7);
     }
-#else
-    vps->setMaxTidIlRefPicsPlus1(i, 7);
-#endif
   }
 
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1085)
@@ -2848,16 +2848,9 @@
 
   Int remainingInterLayerReferencesFlag = 0;
-#if O0225_MAX_TID_FOR_REF_LAYERS
   for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
   {
     Int jLidx = pcSlice->getVPS()->getLayerIdxInVps(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 
+    if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(latestDecLayerId),jLidx) - 1 )
+    {
       for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ )
       {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1085)
@@ -2251,5 +2251,4 @@
      for( i = 0; i < vps->getMaxLayers() - 1; i++)
      {
-#if O0225_MAX_TID_FOR_REF_LAYERS
        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
        {
@@ -2259,7 +2258,4 @@
          }
        }
-#else
-       WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" );
-#endif 
      }
    }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1084)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 1085)
@@ -1323,9 +1323,5 @@
 
         // 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 
+        Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerIdx(), pcSlice->getLayerIdx());
         if( ((Int)(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getRapPicFlag()) )
         {
