Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 215)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 216)
@@ -520,8 +520,19 @@
   //inter-layer reference picture
 #if REF_IDX_MFM
+
+#if ILR_RESTR
+  Int maxSubLayerForILPPlus1 = (getLayerId() > 0)? getVPS()->getMaxSublayerForIlpPlus1(ilpPic[0]->getSlice(0)->getLayerId()) : 0;
+#if ZERO_NUM_DIRECT_LAYERS
+  if( getLayerId() > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=  maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  ) 
+#else
+  if( getLayerId() && ( ( (Int)(ilpPic[0]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[0]->getSlice(0)->getRapPicFlag()) )  )
+#endif
+
+#else
 #if ZERO_NUM_DIRECT_LAYERS
   if( m_layerId > 0 && m_activeNumILRRefIdx > 0 )
 #else
   if (getLayerId())
+#endif
 #endif
   {
@@ -542,4 +553,29 @@
   TComPic*  rpsCurrList1[MAX_NUM_REF+1];
 #if REF_IDX_FRAMEWORK
+#if ILR_RESTR
+  Int numInterLayerRPSPics = 0;
+  if (getLayerId()>0)
+  {
+    for (i=0; i < getVPS()->getNumDirectRefLayers(getLayerId()); i++)
+    {
+      maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
+      if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) )
+      {
+        numInterLayerRPSPics++;
+      }
+    }
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
+    if (numInterLayerRPSPics < m_activeNumILRRefIdx)
+    {
+      m_activeNumILRRefIdx = numInterLayerRPSPics;
+    }
+#else
+    if (numInterLayerRPSPics < m_numILRRefIdx)
+    {
+      m_numILRRefIdx = numInterLayerRPSPics;
+    }
+#endif
+  }
+#endif
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx;
@@ -604,4 +640,8 @@
 #endif 
       {
+#if ILR_RESTR
+         maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
+#endif
         rpsCurrList0[cIdx] = ilpPic[i];
       }
@@ -632,4 +672,8 @@
 #endif 
       {
+#if ILR_RESTR
+        maxSubLayerForILPPlus1 = getVPS()->getMaxSublayerForIlpPlus1(ilpPic[i]->getSlice(0)->getLayerId());
+        if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<=maxSubLayerForILPPlus1-1) || (maxSubLayerForILPPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag()) )
+#endif
         rpsCurrList1[cIdx] = ilpPic[i];
       }
@@ -1603,4 +1647,10 @@
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
   m_maxOneActiveRefLayerFlag = true;
+#endif
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+  for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++)
+  {
+    m_maxSublayerForIlpPlus1[i] = m_uiMaxTLayers + 1;
+  }
 #endif
 }
Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 215)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 216)
@@ -560,4 +560,7 @@
   Bool       m_maxOneActiveRefLayerFlag;
 #endif
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+  UInt       m_maxSublayerForIlpPlus1[MAX_VPS_LAYER_ID_PLUS1 - 1];
+#endif
 public:
   TComVPS();
@@ -712,4 +715,8 @@
   Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
 #endif 
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+  Bool   getMaxSublayerForIlpPlus1(Int layerId)                     { return m_maxSublayerForIlpPlus1[layerId];                   }
+  Void   setMaxSublayerForIlpPlus1(Int layerId, UInt maxSublayer)   { m_maxSublayerForIlpPlus1[layerId] = maxSublayer;            }
+#endif
 };
 
Index: /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 215)
+++ /branches/SHM-2.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 216)
@@ -95,4 +95,9 @@
 #define ZERO_NUM_DIRECT_LAYERS           1      ///< support of zero direct reference layers
 #endif
+#define JCTVC_M0203_INTERLAYER_PRED_IDC  1      ///< implementation of JCTVC-M0203 Inter-layer Prediction Indication
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+#define ILR_RESTR                        1     ///< JCTVC-M0209 Inter-layer RPS and RPL
+#endif
+
 #else
 #define INTRA_BL                         1      ///< inter-layer texture prediction
Index: /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 215)
+++ /branches/SHM-2.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 216)
@@ -2,5 +2,5 @@
 * License, included below. This software may be subject to other third party
 * and contributor rights, including patent rights, and no such rights are
-* granted under this license.  
+* granted under this license.
 *
 * Copyright (c) 2010-2013, ITU/ISO/IEC
@@ -93,5 +93,5 @@
   }
 
-  if (interRPSPred) 
+  if (interRPSPred)
   {
     UInt bit;
@@ -114,7 +114,7 @@
     for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++)
     {
-      READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 
+      READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1
       Int refIdc = bit;
-      if (refIdc == 0) 
+      if (refIdc == 0)
       {
         READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise.
@@ -131,13 +131,13 @@
           k0++;
         }
-        else 
+        else
         {
           k1++;
         }
         k++;
-      }  
-      rps->setRefIdc(j,refIdc);  
-    }
-    rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1);  
+      }
+      rps->setRefIdc(j,refIdc);
+    }
+    rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1);
     rps->setNumberOfPictures(k);
     rps->setNumberOfNegativePictures(k0);
@@ -176,6 +176,6 @@
 
 /** copy SAO parameter
-* \param dst  
-* \param src 
+* \param dst
+* \param src
 */
 inline Void copySaoOneLcuParam(SaoLcuParam* dst,  SaoLcuParam* src)
@@ -205,5 +205,5 @@
 Void TDecCavlc::parsePPS(TComPPS* pcPPS)
 {
-#if ENC_DEC_TRACE  
+#if ENC_DEC_TRACE
   xTracePPSHeader (pcPPS);
 #endif
@@ -228,5 +228,5 @@
   assert(uiCode <= 14);
   pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
-  
+
   READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");
   assert(uiCode <= 14);
@@ -236,9 +236,9 @@
   READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");       pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
 #endif
-  
+
   READ_SVLC(iCode, "init_qp_minus26" );                            pcPPS->setPicInitQPMinus26(iCode);
   READ_FLAG( uiCode, "constrained_intra_pred_flag" );              pcPPS->setConstrainedIntraPred( uiCode ? true : false );
-  READ_FLAG( uiCode, "transform_skip_enabled_flag" );               
-  pcPPS->setUseTransformSkip ( uiCode ? true : false ); 
+  READ_FLAG( uiCode, "transform_skip_enabled_flag" );
+  pcPPS->setUseTransformSkip ( uiCode ? true : false );
 
   READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" );            pcPPS->setUseDQP( uiCode ? true : false );
@@ -278,9 +278,9 @@
   READ_FLAG( uiCode, "tiles_enabled_flag"               );    pcPPS->setTilesEnabledFlag            ( uiCode == 1 );
   READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" );    pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 );
-  
+
   if( pcPPS->getTilesEnabledFlag() )
   {
-    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumColumnsMinus1( uiCode );  
-    READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumRowsMinus1( uiCode );  
+    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumColumnsMinus1( uiCode );
+    READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumRowsMinus1( uiCode );
     READ_FLAG ( uiCode, "uniform_spacing_flag" );                   pcPPS->setUniformSpacingFlag( uiCode );
 
@@ -289,6 +289,6 @@
       UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));
       for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
-      { 
-        READ_UVLC( uiCode, "column_width_minus1" );  
+      {
+        READ_UVLC( uiCode, "column_width_minus1" );
         columnWidth[i] = uiCode+1;
       }
@@ -303,5 +303,5 @@
       }
       pcPPS->setRowHeight(rowHeight);
-      free(rowHeight);  
+      free(rowHeight);
     }
 
@@ -425,5 +425,5 @@
       READ_UVLC(   uiCode, "vui_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
     }
-#endif  
+#endif
   READ_FLAG(     uiCode, "hrd_parameters_present_flag");              pcVUI->setHrdParametersPresentFlag(uiCode);
   if( pcVUI->getHrdParametersPresentFlag() )
@@ -520,10 +520,10 @@
 #if L0372
     else
-    {      
+    {
       READ_FLAG( uiCode, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false  );
     }
     if (!hrd->getLowDelayHrdFlag( i ))
     {
-      READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );      
+      READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );
     }
 #else
@@ -556,5 +556,5 @@
 Void TDecCavlc::parseSPS(TComSPS* pcSPS)
 {
-#if ENC_DEC_TRACE  
+#if ENC_DEC_TRACE
   xTraceSPSHeader (pcSPS);
 #endif
@@ -569,5 +569,5 @@
     assert( uiCode == 1 );
   }
-  
+
   parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
   READ_UVLC(     uiCode, "sps_seq_parameter_set_id" );           pcSPS->setSPSId( uiCode );
@@ -636,5 +636,5 @@
   pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
   Int maxCUDepthDelta = uiCode;
-  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 
+  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
   pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
   READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" );   pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
@@ -647,5 +647,5 @@
 
   Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
-  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); 
+  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth );
 
   READ_FLAG( uiCode, "scaling_list_enabled_flag" );                 pcSPS->setScalingListFlag ( uiCode );
@@ -683,5 +683,5 @@
   }
   READ_FLAG( uiCode, "long_term_ref_pics_present_flag" );          pcSPS->setLongTermRefsPresent(uiCode);
-  if (pcSPS->getLongTermRefsPresent()) 
+  if (pcSPS->getLongTermRefsPresent())
   {
     READ_UVLC( uiCode, "num_long_term_ref_pic_sps" );
@@ -737,5 +737,5 @@
 {
   UInt  uiCode;
-  
+
   READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
@@ -854,5 +854,5 @@
 #endif
   }
-  
+
   return;
 }
@@ -860,5 +860,5 @@
 #if VPS_EXTNS
 Void TDecCavlc::parseVPSExtension(TComVPS *vps)
-{  
+{
   UInt uiCode;
   // ... More syntax elements to be parsed here
@@ -939,5 +939,11 @@
 #endif
 #endif
-
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+  for(i = 0; i < vps->getMaxLayers() - 1; i++)
+  {
+    READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode);
+    assert( uiCode <= vps->getMaxTLayers() );
+  }
+#endif
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling
@@ -961,7 +967,7 @@
 #endif
       assert( vps->getProfileLayerSetRef(idx) < idx );
-      // Copy profile information as indicated 
+      // Copy profile information as indicated
       vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) );
-    }    
+    }
     parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
   }
@@ -1048,11 +1054,11 @@
       }
     }
-  } 
+  }
 #endif
 #endif
 #if JCTVC_M0458_INTERLAYER_RPS_SIG
    READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
-   vps->setMaxOneActiveRefLayerFlag(uiCode);   
-#endif 
+   vps->setMaxOneActiveRefLayerFlag(uiCode);
+#endif
 
 #if !VPS_MOVE_DIR_DEPENDENCY_FLAG
@@ -1094,5 +1100,5 @@
   READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" );
   if( rpcSlice->getRapPicFlag())
-  { 
+  {
     READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
   }
@@ -1145,5 +1151,5 @@
     rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts);
   }
-  
+
   if(!rpcSlice->getDependentSliceSegmentFlag())
   {
@@ -1179,5 +1185,5 @@
     else
     {
-      READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");  
+      READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");
       Int iPOClsb = uiCode;
       Int iPrevPOC = rpcSlice->getPrevPOC();
@@ -1190,5 +1196,5 @@
         iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
       }
-      else if( (iPOClsb  >  iPrevPOClsb )  && ( (iPOClsb - iPrevPOClsb )  >  ( iMaxPOClsb / 2 ) ) ) 
+      else if( (iPOClsb  >  iPrevPOClsb )  && ( (iPOClsb - iPrevPOClsb )  >  ( iMaxPOClsb / 2 ) ) )
       {
         iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
@@ -1276,5 +1282,5 @@
           READ_FLAG(uiCode,"delta_poc_msb_present_flag");
           Bool mSBPresentFlag = uiCode ? true : false;
-          if(mSBPresentFlag)                  
+          if(mSBPresentFlag)
           {
             READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
@@ -1291,12 +1297,12 @@
             else
             {
-              deltaPocMSBCycleLT = uiCode + prevDeltaMSB;              
+              deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
             }
 
-            Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 
+            Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
                                         - iPOClsb + pocLsbLt;
-            rps->setPOC     (j, pocLTCurr); 
+            rps->setPOC     (j, pocLTCurr);
             rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr);
-            rps->setCheckLTMSBPresent(j,true);  
+            rps->setCheckLTMSBPresent(j,true);
           }
           else
@@ -1304,11 +1310,11 @@
             rps->setPOC     (j, pocLsbLt);
             rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
-            rps->setCheckLTMSBPresent(j,false);  
+            rps->setCheckLTMSBPresent(j,false);
           }
           prevDeltaMSB = deltaPocMSBCycleLT;
         }
         offset += rps->getNumberOfLongtermPictures();
-        rps->setNumberOfPictures(offset);        
-      }  
+        rps->setNumberOfPictures(offset);
+      }
       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
@@ -1328,5 +1334,5 @@
       {
         READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" );
-        rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 
+        rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
       }
       else
@@ -1337,13 +1343,13 @@
 
 #if REF_IDX_FRAMEWORK
-#if JCTVC_M0458_INTERLAYER_RPS_SIG    
+#if JCTVC_M0458_INTERLAYER_RPS_SIG
     rpcSlice->setActiveNumILRRefIdx(0);
-    if((sps->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) ) 
-    {      
+    if((sps->getLayerId() > 0)  &&  (rpcSlice->getNumILRRefIdx() > 0) )
+    {
       READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
       rpcSlice->setInterLayerPredEnabledFlag(uiCode);
       if( rpcSlice->getInterLayerPredEnabledFlag())
       {
-        if(rpcSlice->getNumILRRefIdx() > 1) 
+        if(rpcSlice->getNumILRRefIdx() > 1)
         {
           Int numBits = 1;
@@ -1352,23 +1358,23 @@
             numBits++;
           }
-          if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 
+          if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
           {
             READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );
-            rpcSlice->setActiveNumILRRefIdx(uiCode + 1);          
+            rpcSlice->setActiveNumILRRefIdx(uiCode + 1);
           }
           else
           {
-            rpcSlice->setActiveNumILRRefIdx(1);          
+            rpcSlice->setActiveNumILRRefIdx(1);
           }
-          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 
+          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
           {
-            READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );  
-            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);          
+            READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
+            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
           }
         }
         else
         {
-          rpcSlice->setActiveNumILRRefIdx(1);          
-          rpcSlice->setInterLayerPredLayerIdc(0,0);      
+          rpcSlice->setActiveNumILRRefIdx(1);
+          rpcSlice->setInterLayerPredLayerIdc(0,0);
         }
       }
@@ -1443,5 +1449,5 @@
           Int length = 1;
           numRpsCurrTempList0 --;
-          while ( numRpsCurrTempList0 >>= 1) 
+          while ( numRpsCurrTempList0 >>= 1)
           {
             length ++;
@@ -1485,5 +1491,5 @@
           Int length = 1;
           numRpsCurrTempList1 --;
-          while ( numRpsCurrTempList1 >>= 1) 
+          while ( numRpsCurrTempList1 >>= 1)
           {
             length ++;
@@ -1503,5 +1509,5 @@
         }
       }
-    }  
+    }
     else
     {
@@ -1585,5 +1591,5 @@
       }
       else
-      {  
+      {
         rpcSlice->setDeblockingFilterOverrideFlag(0);
       }
@@ -1609,5 +1615,5 @@
     }
     else
-    {  
+    {
       rpcSlice->setDeblockingFilterDisable       ( false );
       rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
@@ -1629,5 +1635,5 @@
 
   }
-  
+
     UInt *entryPointOffset          = NULL;
     UInt numEntryPointOffsets, offsetLenMinus1;
@@ -1679,5 +1685,5 @@
       for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
       {
-        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 
+        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
              m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
         {
@@ -1727,5 +1733,5 @@
   return;
 }
-  
+
 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 )
 {
@@ -1746,5 +1752,5 @@
     READ_FLAG( uiCode, "sub_layer_level_present_flag[i]"   ); rpcPTL->setSubLayerLevelPresentFlag  (i, uiCode);
   }
-  
+
   if (maxNumSubLayersMinus1 > 0)
   {
@@ -1756,5 +1762,5 @@
   }
 #endif
-  
+
   for(Int i = 0; i < maxNumSubLayersMinus1; i++)
   {
@@ -1793,11 +1799,11 @@
   READ_FLAG(uiCode, "general_interlaced_source_flag");
   ptl->setInterlacedSourceFlag(uiCode ? true : false);
-  
+
   READ_FLAG(uiCode, "general_non_packed_constraint_flag");
   ptl->setNonPackedConstraintFlag(uiCode ? true : false);
-  
+
   READ_FLAG(uiCode, "general_frame_only_constraint_flag");
   ptl->setFrameOnlyConstraintFlag(uiCode ? true : false);
-  
+
   READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]");
   READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]");
@@ -1831,5 +1837,5 @@
   }
 }
-#endif  
+#endif
 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit )
 {
@@ -1876,5 +1882,5 @@
 }
 
-/** Parse I_PCM information. 
+/** Parse I_PCM information.
 * \param pcCU pointer to CU
 * \param uiAbsPartIdx CU index
@@ -1882,5 +1888,5 @@
 * \returns Void
 *
-* If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes.  
+* If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes.
 */
 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
@@ -1890,5 +1896,5 @@
 
 Void TDecCavlc::parseIntraDirLumaAng  ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
-{ 
+{
   assert(0);
 }
@@ -1981,10 +1987,10 @@
   UInt            uiLog2WeightDenomLuma, uiLog2WeightDenomChroma;
   UInt            uiTotalSignalledWeightFlags = 0;
-  
+
   Int iDeltaDenom;
   // decode delta_luma_log2_weight_denom :
   READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
   assert( uiLog2WeightDenomLuma <= 7 );
-  if( bChroma ) 
+  if( bChroma )
   {
     READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
@@ -1994,8 +2000,8 @@
   }
 
-  for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 
+  for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ )
   {
     RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
-    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 
+    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
     {
       pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
@@ -2010,8 +2016,8 @@
       uiTotalSignalledWeightFlags += wp[0].bPresentFlag;
     }
-    if ( bChroma ) 
+    if ( bChroma )
     {
       UInt  uiCode;
-      for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 
+      for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
       {
         pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
@@ -2022,8 +2028,8 @@
       }
     }
-    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 
+    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
     {
       pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
-      if ( wp[0].bPresentFlag ) 
+      if ( wp[0].bPresentFlag )
       {
         Int iDeltaWeight;
@@ -2036,14 +2042,14 @@
         assert( wp[0].iOffset <=  127 );
       }
-      else 
+      else
       {
         wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom);
         wp[0].iOffset = 0;
       }
-      if ( bChroma ) 
-      {
-        if ( wp[1].bPresentFlag ) 
-        {
-          for ( Int j=1 ; j<3 ; j++ ) 
+      if ( bChroma )
+      {
+        if ( wp[1].bPresentFlag )
+        {
+          for ( Int j=1 ; j<3 ; j++ )
           {
             Int iDeltaWeight;
@@ -2061,7 +2067,7 @@
           }
         }
-        else 
-        {
-          for ( Int j=1 ; j<3 ; j++ ) 
+        else
+        {
+          for ( Int j=1 ; j<3 ; j++ )
           {
             wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom);
@@ -2072,5 +2078,5 @@
     }
 
-    for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
+    for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
     {
       pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
@@ -2148,5 +2154,5 @@
 
 Bool TDecCavlc::xMoreRbspData()
-{ 
+{
   Int bitsLeft = m_pcBitstream->getNumBitsLeft();
 
Index: /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 215)
+++ /branches/SHM-2.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 216)
@@ -726,4 +726,10 @@
 #endif
 #endif
+#if JCTVC_M0203_INTERLAYER_PRED_IDC
+  for( i = 0; i < vps->getMaxLayers() - 1; i++)
+  {
+    WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );
+  }
+#endif
 #if VPS_EXTN_PROFILE_INFO
   // Profile-tier-level signalling
