Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 170)
@@ -126,4 +126,12 @@
   m_aiNumILRRefIdx = 0;
 #endif
+#if JCTVC_M0458
+  m_aiActiveNumILRRefIdx      = 0; 
+  m_InterLayerPredEnabledFlag = 0;
+
+  for ( Int idx = 0; idx < MAX_VPS_LAYER_ID_PLUS1; idx++ )
+    m_interLayerPredLayerIdc[idx] = 0; 
+#endif 
+
   initEqualRef();
   
@@ -178,8 +186,16 @@
   {
     m_aiNumILRRefIdx      = 1;  // to be set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]]
+#if JCTVC_M0458
+    m_aiActiveNumILRRefIdx      = 1;         
+    m_InterLayerPredEnabledFlag = 1;   
+#endif 
   }
   else
   {
     m_aiNumILRRefIdx = 0;
+#if JCTVC_M0458
+    m_aiActiveNumILRRefIdx      = 0;
+    m_InterLayerPredEnabledFlag = 0;
+#endif 
   }
 #endif
@@ -528,5 +544,9 @@
   TComPic*  rpsCurrList1[MAX_NUM_REF+1];
 #if REF_IDX_FRAMEWORK
+#if JCTVC_M0458
+  Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_aiActiveNumILRRefIdx;
+#else
   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_aiNumILRRefIdx;
+#endif 
 #else
   Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr;
@@ -574,5 +594,9 @@
     if(getLayerId())
     {
+#if JCTVC_M0458
+      for( i = 0; i < m_aiActiveNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)      
+#else
       for( i = 0; i < m_aiNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
+#endif 
       {
         rpsCurrList0[cIdx] = ilpPic[i];
@@ -598,5 +622,9 @@
     if(getLayerId())
     {
+#if JCTVC_M0458
+      for( i = 0; i < m_aiActiveNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
+#else
       for( i = 0; i < m_aiNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++)
+#endif 
       {
         rpsCurrList1[cIdx] = ilpPic[i];
@@ -668,5 +696,9 @@
     else
     {
+#if JCTVC_M0458
+      for(Int i = m_aiActiveNumILRRefIdx; i > 0; i-- )
+#else
       for(Int i = m_aiNumILRRefIdx; i > 0; i-- )
+#endif 
       {
         refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i);
@@ -694,5 +726,9 @@
     else
     {
+#if JCTVC_M0458
+      for(Int i = m_aiActiveNumILRRefIdx; i > 0; i-- )
+#else
       for(Int i = m_aiNumILRRefIdx; i > 0; i-- )
+#endif 
       {
         refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i);
@@ -717,5 +753,9 @@
   {
 #if REF_IDX_FRAMEWORK
+#if JCTVC_M0458
+    return m_aiActiveNumILRRefIdx;
+#else
     return m_aiNumILRRefIdx;
+#endif 
 #else
     return 0;
@@ -732,5 +772,9 @@
   if(getLayerId())
   {
+#if JCTVC_M0458
+    numRpsCurrTempList += getActiveNumILRRefIdx();
+#else
     numRpsCurrTempList += getNumILRRefIdx();
+#endif
   }
 #endif
@@ -1541,4 +1585,7 @@
 #if VPS_PROFILE_OUTPUT_LAYERS
   ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
+#endif
+#if JCTVC_M0458
+  m_maxOneActiveRefLayerFlag = true;
 #endif
 }
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TComSlice.h	(revision 170)
@@ -557,4 +557,7 @@
   Int        m_profileLevelTierIdx[64];     
 #endif
+#if JCTVC_M0458
+  Bool       m_maxOneActiveRefLayerFlag;
+#endif
 public:
   TComVPS();
@@ -705,4 +708,8 @@
   Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
 #endif
+#if JCTVC_M0458
+  Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
+  Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
+#endif 
 };
 
@@ -1413,4 +1420,8 @@
   Int         m_aiNumILRRefIdx;       //< for inter-layer reference picture ser
 #endif
+#if JCTVC_M0458
+  UInt         m_aiActiveNumILRRefIdx;        //< Active inter-layer reference pictures
+  UInt         m_interLayerPredLayerIdc  [MAX_VPS_LAYER_ID_PLUS1];
+#endif 
 #if L0034_COMBINED_LIST_CLEANUP
   Int         m_list1IdxToList0Idx[MAX_NUM_REF];
@@ -1505,4 +1516,8 @@
 
   Bool       m_enableTMVPFlag;
+#if JCTVC_M0458
+  Bool       m_InterLayerPredEnabledFlag;
+  UInt       m_NumInterLayerRefPics;
+#endif 
 public:
   TComSlice();
@@ -1564,4 +1579,11 @@
   Void      setNumILRRefIdx     ( Int i )                     { m_aiNumILRRefIdx = i; }
 #endif
+#if JCTVC_M0458
+  Int       getActiveNumILRRefIdx     ( )               { return  m_aiActiveNumILRRefIdx; }
+  Void      setActiveNumILRRefIdx     ( Int i )         { m_aiActiveNumILRRefIdx = i; }  
+
+  Int       getInterLayerPredLayerIdc (UInt Idx )               { return  m_interLayerPredLayerIdc[Idx];       }
+  Void      setInterLayerPredLayerIdc (UInt val,UInt Idx)       { m_interLayerPredLayerIdc[Idx] = val;         }
+#endif 
   Int       getNumRefIdx        ( RefPicList e )                { return  m_aiNumRefIdx[e];             }
   TComPic*  getPic              ()                              { return  m_pcPic;                      }
@@ -1767,4 +1789,11 @@
   Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
   Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
+#if JCTVC_M0458
+  Void      setInterLayerPredEnabledFlag     ( Bool   val )    { m_InterLayerPredEnabledFlag = val; }
+  Bool      getInterLayerPredEnabledFlag     ()                { return m_InterLayerPredEnabledFlag;}
+
+  Void      setNumInterLayerRefPics          ( UInt   val )    { m_NumInterLayerRefPics = val; }
+  UInt      getNumInterLayerRefPics          ()                { return m_NumInterLayerRefPics;}  
+#endif 
 protected:
   TComPic*  xGetRefPic  (TComList<TComPic*>& rcListPic,
Index: branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibCommon/TypeDef.h	(revision 170)
@@ -88,4 +88,5 @@
 #define ENCODER_FAST_MODE                1      ///< L0174: enable encoder fast mode. TestMethod 1 is enabled by setting to 1 and TestMethod 2 is enable by setting to 2. By default it is set to 1.
 #define REF_IDX_MFM                      1      ///< L0336: motion vector mapping of inter-layer reference picture
+#define JCTVC_M0458                      1      ///< implementation of JCTVC-L0178 (currently only one reference layer is supported )
 #else
 #define INTRA_BL                         1      ///< inter-layer texture prediction
Index: branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 170)
@@ -1039,4 +1039,8 @@
 #endif
 #endif
+#if JCTVC_M0458
+   READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
+   vps->setMaxOneActiveRefLayerFlag(uiCode);   
+#endif 
 
 #if !VPS_MOVE_DIR_DEPENDENCY_FLAG
@@ -1591,4 +1595,39 @@
   }
 
+  #if JCTVC_M0458    
+    rpcSlice->setActiveNumILRRefIdx(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->getVPS()->getMaxOneActiveRefLayerFlag()) 
+          {
+            READ_UVLC(uiCode,"num_inter_layer_ref_pics_minus1");   
+            rpcSlice->setActiveNumILRRefIdx(uiCode + 1);          
+          }
+          else
+          {
+            rpcSlice->setActiveNumILRRefIdx(1);          
+            rpcSlice->setInterLayerPredLayerIdc(0,0);          
+          }
+          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 
+          {
+            READ_UVLC(uiCode,"inter_layer_pred_layer_idc[i]");          
+            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);          
+          }
+        }
+        else
+        {
+          rpcSlice->setActiveNumILRRefIdx(1);          
+          rpcSlice->setInterLayerPredLayerIdc(0,0);      
+        }
+      }
+    }     
+#endif
+
   if(pps->getSliceHeaderExtensionPresentFlag())
   {
Index: branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 170)
@@ -1257,4 +1257,8 @@
   // currently only one reference layer is supported
   assert( vps->getNumDirectRefLayers( m_layerId ) == 1 );
+#if JCTVC_M0458
+  assert( vps->getMaxOneActiveRefLayerFlag() == 1 );
+#endif 
+
 
   return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, 0 ) );
Index: branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 169)
+++ branches/SHM-2.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 170)
@@ -797,4 +797,7 @@
 #endif
 #endif
+#if JCTVC_M0458
+      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
+#endif 
 #if !VPS_MOVE_DIR_DEPENDENCY_FLAG
 #if VPS_EXTN_DIRECT_REF_LAYERS
@@ -1163,4 +1166,22 @@
     }
   }
+#if JCTVC_M0458    
+    if((pcSlice->getSPS()->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) ) 
+    {
+      WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
+      if( pcSlice->getInterLayerPredEnabledFlag())
+      {
+        if(pcSlice->getNumILRRefIdx() > 1)
+        {
+          if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 
+          {
+            WRITE_UVLC(pcSlice->getNumInterLayerRefPics(),"num_inter_layer_ref_pics_minus1");                     
+          }       
+          for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 
+            WRITE_UVLC(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_layer_idc[i]");          
+        }
+      }
+    }     
+#endif 
   if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
   {
