Index: /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 883)
+++ /branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp	(revision 884)
@@ -2030,4 +2030,31 @@
       }
     }
+#if R0247_SEI_ACTIVE
+    if(bFirstFrame)
+    {
+      list<AccessUnit>::iterator first_au = outputAccessUnits.begin();
+      AccessUnit::iterator it_sps;
+      for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++)
+      {
+        if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS )
+        {
+          break;
+        }
+      }
+
+      for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++)
+      {
+        for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++)
+        {
+          if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS )
+          {
+            first_au->insert(++it_sps, *it_nalu);
+            it_nalu = it_au->erase(it_nalu);
+          }
+        }
+      }
+    }
+
+#endif
 
 #if RC_SHVC_HARMONIZATION
Index: /branches/SHM-dev/source/Lib/TLibCommon/SEI.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 884)
@@ -175,4 +175,7 @@
   Int numSpsIdsMinus1;
   std::vector<Int> activeSeqParameterSetId; 
+#if R0247_SEI_ACTIVE
+  std::vector<Int> layerSpsIdx; 
+#endif
 };
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 884)
@@ -301,5 +301,5 @@
 #define Q0189_TMVP_CONSTRAINTS           1      ///< JCTVC-Q0189: indicate constraints on TMVP
 #define Q0247_FRAME_FIELD_INFO           1      ///< JCTVC-Q0247: field_frame_info SEI message
-
+#define R0247_SEI_ACTIVE                 1      ///< JCTVC-R0247: active parameter sets SEI message
 
 #endif // SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp	(revision 884)
@@ -584,9 +584,17 @@
 
   sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
+#if R0247_SEI_ACTIVE
+  sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1);
+#endif
   for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
   {
     READ_UVLC(val, "active_seq_parameter_set_id");      sei.activeSeqParameterSetId[i] = val; 
   }
-
+#if R0247_SEI_ACTIVE
+  for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++)
+  {
+    READ_UVLC(val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; 
+  }
+#endif
   xParseByteAlign();
 }
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp	(revision 884)
@@ -2398,4 +2398,5 @@
     {
       SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
+#if !R0247_SEI_ACTIVE
       m_parameterSetManagerDecoder.applyPrefetchedPS();
       assert(seiAps->activeSeqParameterSetId.size()>0);
@@ -2404,4 +2405,21 @@
         printf ("Warning SPS activation with Active parameter set SEI failed");
       }
+#else
+      getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS();
+      assert(seiAps->activeSeqParameterSetId.size()>0);
+      if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
+      {
+        printf ("Warning SPS activation with Active parameter set SEI failed");
+      }
+      for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++)
+      {
+        Int layerIdx = seiAps->layerSpsIdx[c];
+        getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS();
+        if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
+        {
+          printf ("Warning SPS activation with Active parameter set SEI failed");
+        }
+      }
+#endif
     }
   }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp	(revision 884)
@@ -394,4 +394,10 @@
     WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); 
   }
+#if R0247_SEI_ACTIVE
+  for (Int i = 1; i < sei.activeSeqParameterSetId.size(); i++)
+  {
+    WRITE_UVLC(sei.layerSpsIdx[i], "layer_sps_idx"); 
+  }
+#endif
   xWriteByteAlign();
 }
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 883)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 884)
@@ -202,7 +202,21 @@
   seiActiveParameterSets->m_selfContainedCvsFlag = false;
   seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
+#if !R0247_SEI_ACTIVE
   seiActiveParameterSets->numSpsIdsMinus1 = 0;
   seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); 
   seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
+#else
+  seiActiveParameterSets->numSpsIdsMinus1 = m_pcCfg->getNumLayer()-1;
+  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); 
+  seiActiveParameterSets->layerSpsIdx.resize(seiActiveParameterSets->numSpsIdsMinus1+ 1);  
+  for (Int c=0; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
+  {
+     seiActiveParameterSets->activeSeqParameterSetId[c] = c;
+  }
+  for (Int c=1; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
+  {
+     seiActiveParameterSets->layerSpsIdx[c] = c;
+  }
+#endif
   return seiActiveParameterSets;
 }
@@ -429,5 +443,9 @@
   OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
 
-  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
+  if(m_pcCfg->getActiveParameterSetsSEIEnabled()
+#if R0247_SEI_ACTIVE
+    && m_layerId == 0
+#endif
+    )
   {
     SEIActiveParameterSets *sei = xCreateSEIActiveParameterSets (sps);
