Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 528)
@@ -2374,4 +2374,8 @@
 #endif
 #endif
+#if SCALINGLIST_INFERRING
+, m_inferScalingListFlag ( false )
+, m_scalingListRefLayerId ( 0 )
+#endif
 #endif //SVC_EXTENSION
 {
@@ -2397,4 +2401,7 @@
 TComSPS::~TComSPS()
 {
+#if SCALINGLIST_INFERRING
+  if( !m_inferScalingListFlag )
+#endif
   delete m_scalingList;
   m_RPSList.destroy();
@@ -2574,4 +2581,8 @@
 , m_listsModificationPresentFlag(  0)
 , m_numExtraSliceHeaderBits(0)
+#if SCALINGLIST_INFERRING
+, m_inferScalingListFlag ( false )
+, m_scalingListRefLayerId ( 0 )
+#endif
 {
   m_scalingList = new TComScalingList;
@@ -2590,4 +2601,8 @@
     m_puiRowHeight = NULL;
   }
+
+#if SCALINGLIST_INFERRING
+  if( !m_inferScalingListFlag )
+#endif
   delete m_scalingList;
 }
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TComSlice.h	(revision 528)
@@ -1316,4 +1316,8 @@
   UInt m_updateRepFormatIndex;
 #endif
+#endif
+#if SCALINGLIST_INFERRING
+  Bool       m_inferScalingListFlag;
+  UInt       m_scalingListRefLayerId;
 #endif
 #endif //SVC_EXTENSION
@@ -1449,5 +1453,9 @@
 #endif
 
+#if SCALINGLIST_INFERRING
+  Void setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
+#else
   Void setScalingList      ( TComScalingList *scalingList);
+#endif
   TComScalingList* getScalingList ()       { return m_scalingList; }               //!< get ScalingList class pointer in SPS
 
@@ -1508,4 +1516,10 @@
   Void     setUpdateRepFormatIndex(UInt index)  { m_updateRepFormatIndex = index; }
 #endif
+#endif
+#if SCALINGLIST_INFERRING
+  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
+  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
+  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
+  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
 #endif
 #endif //SVC_EXTENSION
@@ -1609,4 +1623,9 @@
   UInt m_log2ParallelMergeLevelMinus2;
   Int m_numExtraSliceHeaderBits;
+
+#if SCALINGLIST_INFERRING
+  Bool     m_inferScalingListFlag;
+  UInt     m_scalingListRefLayerId;
+#endif
 
 public:
@@ -1720,4 +1739,12 @@
   Void     setScalingListPresentFlag( Bool b ) { m_scalingListPresentFlag  = b;       }
 
+#if SCALINGLIST_INFERRING
+  UInt     getLayerId() { return m_layerId; }
+  Void     setLayerId( UInt layerId ) { m_layerId = layerId;            }
+  Bool     getInferScalingListFlag()  { return m_inferScalingListFlag;  }
+  UInt     getScalingListRefLayerId() { return m_scalingListRefLayerId; }
+  Void     setInferScalingListFlag( Bool flag )     { m_inferScalingListFlag = flag;     }
+  Void     setScalingListRefLayerId( UInt layerId ) { m_scalingListRefLayerId = layerId; }
+#endif
 #if IL_SL_SIGNALLING_N0371
   Void     setLayerId(UInt layerId) { m_layerId = layerId; }
@@ -1733,5 +1760,9 @@
 #endif
 
+#if SCALINGLIST_INFERRING
+  Void     setScalingList( TComScalingList *scalingList ) { m_scalingList = scalingList; }
+#else
   Void     setScalingList      ( TComScalingList *scalingList);
+#endif
   TComScalingList* getScalingList ()          { return m_scalingList; }         //!< get ScalingList class pointer in PPS
   Bool getListsModificationPresentFlag ()          { return m_listsModificationPresentFlag; }
Index: branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibCommon/TypeDef.h	(revision 528)
@@ -64,4 +64,5 @@
 
 #define IL_SL_SIGNALLING_N0371           0      ///< JCTVC-N0371: inter-layer scaling list
+#define SCALINGLIST_INFERRING            1      ///< JCTVC-N0371: inter-layer scaling list
 #define M0463_VUI_EXT_ILP_REF            0      ///< JCTVC-M0463: VUI extension inter-layer dependency offset signalling
 #define SPS_EXTENSION                    1      ///< Define sps_extension() syntax structure
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 528)
@@ -290,4 +290,25 @@
     }
   }
+
+#if SCALINGLIST_INFERRING
+  if( pcPPS->getLayerId() > 0 )
+  {
+    READ_FLAG( uiCode, "pps_infer_scaling_list_flag" );
+    pcPPS->setInferScalingListFlag( uiCode );
+  }
+
+  if( pcPPS->getInferScalingListFlag() )
+  {
+    READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode );
+
+    // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+    assert( pcPPS->getScalingListRefLayerId() <= 62 );
+
+    pcPPS->setScalingListPresentFlag( false );
+  }
+  else
+  {
+#endif
+
   READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" );           pcPPS->setScalingListPresentFlag( uiCode ? true : false );
 
@@ -343,4 +364,8 @@
 #endif
   }
+
+#if SCALINGLIST_INFERRING
+  }
+#endif
 
   READ_FLAG( uiCode, "lists_modification_present_flag");
@@ -716,4 +741,22 @@
   if(pcSPS->getScalingListFlag())
   {
+#if SCALINGLIST_INFERRING
+    if( pcSPS->getLayerId() > 0 )
+    {
+      READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode );
+    }
+
+    if( pcSPS->getInferScalingListFlag() )
+    {
+      READ_UVLC( uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode );
+
+      // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+      assert( pcSPS->getScalingListRefLayerId() <= 62 );
+
+      pcSPS->setScalingListPresentFlag( false );
+    }
+    else
+    {
+#endif
     READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
     if(pcSPS->getScalingListPresentFlag ())
@@ -766,4 +809,7 @@
 
     }
+#if SCALINGLIST_INFERRING
+    }
+#endif
   }
   READ_FLAG( uiCode, "amp_enabled_flag" );                          pcSPS->setUseAMP( uiCode );
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 528)
@@ -551,24 +551,20 @@
   printf("\ninserting lost poc : %d\n",iLostPoc);
   TComSlice cFillSlice;
-#if SVC_EXTENSION
-  cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
-  cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
-  cFillSlice.setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
-  cFillSlice.initSlice( m_layerId );
-#else
   cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
   cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
+#if SVC_EXTENSION
+  cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
+  cFillSlice.initSlice( m_layerId );
+#else
   cFillSlice.initSlice();
 #endif
   TComPic *cFillPic;
   xGetNewPicBuffer(&cFillSlice,cFillPic);
-#if SVC_EXTENSION
-  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
-  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
-  cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder[m_layerId].getFirstVPS() );
-  cFillPic->getSlice(0)->initSlice( m_layerId );
-#else
   cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
   cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
+#if SVC_EXTENSION
+  cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() );
+  cFillPic->getSlice(0)->initSlice( m_layerId );
+#else
   cFillPic->getSlice(0)->initSlice();
 #endif
@@ -613,15 +609,4 @@
 Void TDecTop::xActivateParameterSets()
 {
-#if SVC_EXTENSION
-  m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS();
-  
-  TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId());
-  assert (pps != 0);
-
-  TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId());
-  assert (sps != 0);
-
-  if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->isIRAP()) )
-#else
   m_parameterSetManagerDecoder.applyPrefetchedPS();
   
@@ -633,9 +618,74 @@
 
   if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
-#endif
   {
     printf ("Parameter set activation failed!");
     assert (0);
   }
+
+#if SCALINGLIST_INFERRING
+  // scaling list settings and checks
+  TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS();
+  TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS();
+  TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS();
+
+  if( activeSPS->getInferScalingListFlag() )
+  {
+    UInt refLayerId = activeSPS->getScalingListRefLayerId();
+    TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL );
+
+    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
+    if( activeVPS->getAvcBaseLayerFlag() )
+    {
+      assert( refLayerId > 0 );
+    }
+
+    // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
+    // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id
+    assert( refSps->getInferScalingListFlag() == false );
+
+    // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
+    // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
+    assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true );
+    
+    if( activeSPS->getScalingList() != refSps->getScalingList() )
+    {
+      // delete created instance of scaling list since it will be inferred
+      delete activeSPS->getScalingList();
+
+      // infer scaling list
+      activeSPS->setScalingList( refSps->getScalingList() );
+    }
+  }
+
+  if( activePPS->getInferScalingListFlag() )
+  {
+    UInt refLayerId = activePPS->getScalingListRefLayerId();
+    TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL );
+
+    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
+    if( activeVPS->getAvcBaseLayerFlag() )
+    {
+      assert( refLayerId > 0 );
+    }
+
+    // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and
+    // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id
+    assert( refPps->getInferScalingListFlag() == false );
+
+    // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB,
+    // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB
+    assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true );
+    
+    if( activePPS->getScalingList() != refPps->getScalingList() )
+    {
+      // delete created instance of scaling list since it will be inferred
+      delete activePPS->getScalingList();
+
+      // infer scaling list
+      activePPS->setScalingList( refPps->getScalingList() );
+    }
+
+  }
+#endif
 
   if( pps->getDependentSliceSegmentsEnabledFlag() )
@@ -709,5 +759,5 @@
   TComPic*&   pcPic         = m_pcPic;
 #if SVC_EXTENSION
-  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder[m_layerId].getPrefetchedVPS(0) );
+  m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) );
 #if OUTPUT_LAYER_SET_INDEX
   // Following check should go wherever the VPS is activated
@@ -751,8 +801,6 @@
   m_apcSlicePilot->setNumSamplePredRefLayers( getNumSamplePredRefLayers() );
 #endif
-  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]);
-#else
+#endif
   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
-#endif
 
   // set POC for dependent slices in skipped pictures
@@ -950,5 +998,5 @@
   {
 #if AVC_BASE
-    if( m_layerId == 1 && m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
+    if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     {
       TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
@@ -1187,5 +1235,5 @@
         UInt refLayerIdc = i;
 #if AVC_BASE
-        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
+        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
         {
           pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
@@ -1278,5 +1326,5 @@
         UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
 #if AVC_BASE
-        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder[0].getActiveVPS()->getAvcBaseLayerFlag() )
+        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
         {
           pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
@@ -1431,4 +1479,7 @@
       pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
     }
+#if SCALINGLIST_INFERRING
+    if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) )
+#endif
     if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
     {
@@ -1466,9 +1517,5 @@
   
   m_cEntropyDecoder.decodeVPS( vps );
-#if SVC_EXTENSION
-  m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps);
-#else
   m_parameterSetManagerDecoder.storePrefetchedVPS(vps);  
-#endif
 }
 
@@ -1478,6 +1525,6 @@
 #if SVC_EXTENSION
   sps->setLayerId(m_layerId);
-  m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder[0] );
-  m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps);
+  m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder );
+  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
 #if !REPN_FORMAT_IN_VPS   // ILRP can only be initialized at activation  
   if(m_numLayer>0)
@@ -1496,14 +1543,10 @@
   TComPPS* pps = new TComPPS();
 
-#if IL_SL_SIGNALLING_N0371
-  pps->setLayerId(m_layerId);
+#if SCALINGLIST_INFERRING || IL_SL_SIGNALLING_N0371
+  pps->setLayerId( m_layerId );
 #endif
 
   m_cEntropyDecoder.decodePPS( pps );
-#if SVC_EXTENSION
-  m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps );
-#else
   m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
-#endif
 
   if( pps->getDependentSliceSegmentsEnabledFlag() )
@@ -1533,7 +1576,7 @@
 #endif
 #if M0043_LAYERS_PRESENT_SEI
-    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
-#else
-    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
+    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
+#else
+    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
 #endif
   }
@@ -1541,7 +1584,7 @@
   {
 #if M0043_LAYERS_PRESENT_SEI
-    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveVPS(), m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
-#else
-    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
+    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() );
+#else
+    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
 #endif
     SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
@@ -1549,7 +1592,7 @@
     {
       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
-      m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS();
+      m_parameterSetManagerDecoder.applyPrefetchedPS();
       assert(seiAps->activeSeqParamSetId.size()>0);
-      if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
+      if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParamSetId[0] ) )
       {
         printf ("Warning SPS activation with Active parameter set SEI failed");
@@ -1606,5 +1649,5 @@
       xDecodeVPS();
 #if AVC_BASE
-      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
+      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
       {
         if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
@@ -1632,5 +1675,5 @@
       xDecodeSPS();
 #if AVC_BASE
-      if( m_parameterSetManagerDecoder[0].getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
+      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
       {
         TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
@@ -1638,5 +1681,5 @@
         {
           // using EL SPS with spsId = 1
-          TComSPS* sps = m_parameterSetManagerDecoder[nalu.m_layerId].getPrefetchedSPS(1);
+          TComSPS* sps = m_parameterSetManagerDecoder.getPrefetchedSPS(1);
           Int  numReorderPics[MAX_TLAYER];
           Window &conformanceWindow = sps->getConformanceWindow();
@@ -1787,5 +1830,5 @@
 TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc )
 {
-  TComVPS* vps = m_parameterSetManagerDecoder[0].getActiveVPS();
+  TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS();
   if( vps->getNumDirectRefLayers( m_layerId ) <= 0 )
   {
Index: branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibDecoder/TDecTop.h	(revision 528)
@@ -72,9 +72,5 @@
 
   TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
-#if SVC_EXTENSION
-  ParameterSetManagerDecoder m_parameterSetManagerDecoder[MAX_LAYERS];  // storage for parameter sets 
-#else
   ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
-#endif
 
   TComSlice*              m_apcSlicePilot;
@@ -249,4 +245,7 @@
   Void      checkValueOfOutputLayerSetIdx(TComVPS *vps);
 #endif
+#if SCALINGLIST_INFERRING
+  ParameterSetManagerDecoder* getParameterSetManager() { return &m_parameterSetManagerDecoder; }
+#endif
 };// END CLASS DEFINITION TDecTop
 
Index: branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 528)
@@ -220,4 +220,22 @@
     }
   }
+
+#if SCALINGLIST_INFERRING
+  if( pcPPS->getLayerId() > 0 )
+  {
+    WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" );
+  }
+
+  if( pcPPS->getInferScalingListFlag() )
+  {
+    // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+    assert( pcPPS->getScalingListRefLayerId() <= 62 );
+
+    WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "pps_scaling_list_ref_layer_id" );
+  }
+  else
+  {
+#endif
+
   WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0,                          "pps_scaling_list_data_present_flag" ); 
 
@@ -275,6 +293,10 @@
     codeScalingList( m_pcSlice->getScalingList() );
 #endif
-
-  }
+  }
+
+#if SCALINGLIST_INFERRING
+  }
+#endif
+
   WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag");
   WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2");
@@ -553,4 +575,20 @@
   if(pcSPS->getScalingListFlag())
   {
+#if SCALINGLIST_INFERRING
+    if( pcSPS->getLayerId() > 0 )
+    {
+      WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" );
+    }
+
+    if( pcSPS->getInferScalingListFlag() )
+    {
+      // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
+      assert( pcSPS->getScalingListRefLayerId() <= 62 );
+
+      WRITE_UVLC( pcSPS->getScalingListRefLayerId(), "sps_scaling_list_ref_layer_id" );
+    }
+    else
+    {
+#endif
     WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0,                          "sps_scaling_list_data_present_flag" ); 
     if(pcSPS->getScalingListPresentFlag())
@@ -606,4 +644,7 @@
 
     }
+#if SCALINGLIST_INFERRING
+    }
+#endif
   }
   WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0,                                            "amp_enabled_flag" );
Index: branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 528)
@@ -683,4 +683,21 @@
     else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_DEFAULT)
     {
+#if SCALINGLIST_INFERRING
+      // inferring of the scaling list can be moved to the config file
+      UInt refLayerId = 0;
+      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
+      {
+        m_pcEncTop->getSPS()->setInferScalingListFlag( true );
+        m_pcEncTop->getSPS()->setScalingListRefLayerId( refLayerId );
+        m_pcEncTop->getSPS()->setScalingListPresentFlag( false );
+        m_pcEncTop->getPPS()->setInferScalingListFlag( false );
+        m_pcEncTop->getPPS()->setScalingListPresentFlag( false );
+
+        // infer the scaling list from the reference layer
+        pcSlice->setScalingList ( m_ppcTEncTop[refLayerId]->getScalingList() );
+      }
+      else
+      {
+#endif
 #if IL_SL_SIGNALLING_N0371
       pcSlice->getScalingList()->setLayerId( m_layerId );
@@ -695,4 +712,9 @@
       m_pcEncTop->getSPS()->setScalingListPresentFlag(false);
       m_pcEncTop->getPPS()->setScalingListPresentFlag(false);
+
+#if SCALINGLIST_INFERRING
+      }
+#endif
+
       m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList());
       m_pcEncTop->getTrQuant()->setUseScalingList(true);
@@ -704,4 +726,22 @@
 #endif
 
+#if SCALINGLIST_INFERRING
+      // inferring of the scaling list can be moved to the config file
+      UInt refLayerId = 0;
+      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
+      {
+        m_pcEncTop->getSPS()->setInferScalingListFlag( true );
+        m_pcEncTop->getSPS()->setScalingListRefLayerId( refLayerId );
+        m_pcEncTop->getSPS()->setScalingListPresentFlag( false );
+        m_pcEncTop->getPPS()->setInferScalingListFlag( false );
+        m_pcEncTop->getPPS()->setScalingListPresentFlag( false );
+
+        // infer the scaling list from the reference layer
+        pcSlice->setScalingList ( m_ppcTEncTop[refLayerId]->getScalingList() );
+      }
+      else
+      {
+#endif
+
       if(pcSlice->getScalingList()->xParseScalingList(m_pcCfg->getScalingListFile()))
       {
@@ -735,4 +775,8 @@
         m_pcEncTop->getPPS()->setScalingListRefLayerId( 0   ); 
       }
+#endif
+
+#if SCALINGLIST_INFERRING
+    }
 #endif
 
Index: branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 527)
+++ branches/SHM-4.1-dev/source/Lib/TLibEncoder/TEncTop.cpp	(revision 528)
@@ -1074,6 +1074,6 @@
 Void TEncTop::xInitPPS()
 {
-#if IL_SL_SIGNALLING_N0371
-  m_cPPS.setLayerId(m_layerId);
+#if SCALINGLIST_INFERRING ||  IL_SL_SIGNALLING_N0371
+  m_cPPS.setLayerId( m_layerId );
 #endif
 
