Index: branches/0.3-ericsson/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/SEI.h	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/SEI.h	(revision 40)
@@ -41,4 +41,9 @@
 class SEI
 {
+#if BITSTREAM_EXTRACTION
+protected:
+  UInt m_uiLayerId;
+#endif
+
 public:
   enum PayloadType {
@@ -51,4 +56,9 @@
   
   virtual PayloadType payloadType() const = 0;
+
+#if BITSTREAM_EXTRACTION
+  Void      setLayerId              ( UInt u )       { m_uiLayerId = u; }
+  UInt      getLayerId              ()         const { return m_uiLayerId; }
+#endif
 };
 
Index: branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.cpp
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.cpp	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.cpp	(revision 40)
@@ -61,4 +61,8 @@
   m_auiSliceByteLocation = NULL;
   m_uiSliceCount         = 0;
+#if BITSTREAM_EXTRACTION
+  m_apulPacketPayloadBuffer = new UInt[uiSize];
+  m_uiPacketPayloadSize = 0;
+#endif  
 }
 
@@ -66,4 +70,7 @@
 {
   delete [] m_apulStreamPacketBegin;     m_apulStreamPacketBegin = NULL;
+#if BITSTREAM_EXTRACTION
+  delete [] m_apulPacketPayloadBuffer;   m_apulPacketPayloadBuffer = NULL;
+#endif
 }
 
@@ -148,4 +155,14 @@
   xReadNextWord();
 }
+
+#if BITSTREAM_EXTRACTION
+UInt TComBitstream::reinitParsing()
+{
+  rewindStreamPacket();
+  memcpy( m_apulStreamPacketBegin, m_apulPacketPayloadBuffer, m_uiPacketPayloadSize );
+  initParsing( m_uiPacketPayloadSize );
+  return m_uiPacketPayloadSize;
+}
+#endif
 
 #if LCEC_INTRA_MODE || QC_LCEC_INTER_MODE
@@ -319,4 +336,9 @@
   UChar* pucWrite      = reinterpret_cast<UChar*> (getBuffer());
   
+#if BITSTREAM_EXTRACTION
+  memcpy( m_apulPacketPayloadBuffer, m_apulStreamPacketBegin, uiBytesRead );
+  m_uiPacketPayloadSize = uiBytesRead;
+#endif
+
   for( ; uiReadOffset < uiBytesRead; uiReadOffset++ )
   {
Index: branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.h
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.h	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/TComBitStream.h	(revision 40)
@@ -85,4 +85,9 @@
   UInt        m_uiSliceProcessed;
 
+#if BITSTREAM_EXTRACTION
+  UInt*       m_apulPacketPayloadBuffer;
+  UInt        m_uiPacketPayloadSize;
+#endif  
+
   UInt xSwap ( UInt ui )
   {
@@ -164,4 +169,8 @@
 
   void insertAt(const TComBitstream& src, unsigned pos);
+
+#if BITSTREAM_EXTRACTION
+  UInt        reinitParsing();
+#endif  
 };
 
Index: branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.cpp	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.cpp	(revision 40)
@@ -66,4 +66,8 @@
   m_iViewIdx = 0 ;
 
+#if BITSTREAM_EXTRACTION
+  m_uiLayerId = 0;
+#endif
+
 #if SONY_COLPIC_AVAILABILITY
   m_iViewOrderIdx = 0;
@@ -659,5 +663,8 @@
   m_bUseMVI = false;
 #endif
-  
+
+#if BITSTREAM_EXTRACTION
+  m_uiLayerId             = 0;
+#endif
   m_uiViewId              = 0;
   m_iViewOrderIdx         = 0;
@@ -698,4 +705,7 @@
 TComPPS::TComPPS()
 {
+#if BITSTREAM_EXTRACTION
+  m_uiLayerId             = 0;
+#endif
 #if CONSTRAINED_INTRA_PRED
   m_bConstrainedIntraPred = false;
Index: branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.h	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/TComSlice.h	(revision 40)
@@ -76,4 +76,7 @@
   UInt        m_uiMaxTrDepth;
 
+#if BITSTREAM_EXTRACTION
+  UInt        m_uiLayerId;
+#endif
   UInt        m_uiViewId;
   Int         m_iViewOrderIdx;
@@ -311,4 +314,9 @@
   TComResidualGenerator*  getResidualGenerator()                                              { return m_pcResidualGenerator; }
 #endif
+
+#if BITSTREAM_EXTRACTION
+  Void      setLayerId              ( UInt u ) { m_uiLayerId = u; }
+  UInt      getLayerId              ()         { return m_uiLayerId; }
+#endif
 };
 
@@ -326,4 +334,7 @@
   UInt        m_uiPPSId;
   UInt        m_uiSPSId;
+#if BITSTREAM_EXTRACTION
+  UInt        m_uiLayerId;
+#endif
 
 public:
@@ -346,4 +357,9 @@
   Void setUseWP                     ( Bool b )  { m_bUseWeightPred = b;       }
   Void setWPBiPredIdc               ( UInt u )  { m_uiBiPredIdc = u;          }
+#endif
+
+#if BITSTREAM_EXTRACTION
+  Void      setLayerId              ( UInt u ) { m_uiLayerId = u; }
+  UInt      getLayerId              ()         { return m_uiLayerId; }
 #endif
 };
@@ -376,4 +392,7 @@
   UInt        m_uiPPSId;
   Int         m_iPOC;
+#if BITSTREAM_EXTRACTION
+  UInt        m_uiLayerId;
+#endif
 #if SONY_COLPIC_AVAILABILITY
   Int         m_iViewOrderIdx;
@@ -540,4 +559,9 @@
   Void      setLambda( Double d ) { m_dLambda = d; }
   Double    getLambda() { return m_dLambda;        }
+
+#if BITSTREAM_EXTRACTION
+  Void      setLayerId( UInt u )                        { m_uiLayerId = u; }
+  UInt      getLayerId()                                { return m_uiLayerId; }
+#endif
 
   Void      setViewIdx(Int i)                           { m_iViewIdx = i; }
Index: branches/0.3-ericsson/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/0.3-ericsson/source/Lib/TLibCommon/TypeDef.h	(revision 36)
+++ branches/0.3-ericsson/source/Lib/TLibCommon/TypeDef.h	(revision 40)
@@ -40,4 +40,6 @@
 
 
+#define BITSTREAM_EXTRACTION            1
+
 #define FLEX_CODING_ORDER				        1
 
