Index: branches/0.3-nokia/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- branches/0.3-nokia/source/App/TAppDecoder/TAppDecTop.cpp	(revision 35)
+++ branches/0.3-nokia/source/App/TAppDecoder/TAppDecTop.cpp	(revision 50)
@@ -272,5 +272,5 @@
 
       }
-      if (bCountDepthViewIdx == false )
+      if (m_bUsingDepth && bCountDepthViewIdx == false )
       {
         bCountDepthViewIdx = true;
@@ -298,5 +298,5 @@
         }
 
-        if (iViewIdx >= m_acTDecTopList.size() || iDepthViewIdx >= m_acTDecDepthTopList.size())
+        if (iViewIdx >= m_acTDecTopList.size() || (m_bUsingDepth && iDepthViewIdx >= m_acTDecDepthTopList.size()))
         {
           bFirstDepth = false;
Index: branches/0.3-nokia/source/App/TAppEncoder/TAppEncCfg.cpp
===================================================================
--- branches/0.3-nokia/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 35)
+++ branches/0.3-nokia/source/App/TAppEncoder/TAppEncCfg.cpp	(revision 50)
@@ -203,8 +203,8 @@
 
 #if FLEX_CODING_ORDER
-  ("3DVFlexOrder",          m_b3DVFlexOrder,   false, "flexible coding order flag" )
-  ("3DVCodingOrder",		cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
-
-#endif
+  ("FCO",               m_b3DVFlexOrder,   false, "flexible coding order flag" )
+  ("CodingOrder",   		cfg_JointCodingOrdering,  string(""), "The coding order for joint texture-depth coding")
+#endif
+
   /* Unit definition parameters */
   ("MaxCUWidth",          m_uiMaxCUWidth,  64u)
@@ -394,7 +394,10 @@
   m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
 
-#if FLEX_CODING_ORDER && HHI_VSO
+
+#if FLEX_CODING_ORDER
   m_pchMVCJointCodingOrder	= cfg_JointCodingOrdering.empty()?NULL:strdup(cfg_JointCodingOrdering.c_str());
   // If flexible order is enabled and if depth comes before the texture for a view, disable VSO
+
+#if HHI_VSO && DISABLE_FCO_FOR_VSO
   Bool depthComesFirst = false;
   if ( m_b3DVFlexOrder )
@@ -425,5 +428,5 @@
   }
 #endif
-
+#endif
 
 // GT FIX
Index: branches/0.3-nokia/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- branches/0.3-nokia/source/App/TAppEncoder/TAppEncTop.cpp	(revision 35)
+++ branches/0.3-nokia/source/App/TAppEncoder/TAppEncTop.cpp	(revision 50)
@@ -145,4 +145,7 @@
 #endif
 
+#if BITSTREAM_EXTRACTION
+    m_acTEncTopList[iViewIdx]->setLayerId                      ( ( (UInt)iViewIdx ) << 1 );
+#endif
     m_acTEncTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
     m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
@@ -337,4 +340,7 @@
 #endif
 
+#if BITSTREAM_EXTRACTION
+      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( ( ( (UInt)iViewIdx ) << 1 ) + 1 );
+#endif
       m_acTEncDepthTopList[iViewIdx]->setViewId                       ( (UInt)iViewIdx );
       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
Index: branches/0.3-nokia/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/CommonDef.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/CommonDef.h	(revision 50)
@@ -58,5 +58,5 @@
 
 #define HM_VERSION        "3.0rc2"                 ///< Current software version
-#define NV_VERSION        "0.3"                    ///< Current software version
+#define NV_VERSION        "0.4"                    ///< Current software version
 
 // ====================================================================================================================
Index: branches/0.3-nokia/source/Lib/TLibCommon/SEI.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/SEI.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/SEI.h	(revision 50)
@@ -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-nokia/source/Lib/TLibCommon/TComBitStream.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/TComBitStream.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/TComBitStream.cpp	(revision 50)
@@ -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-nokia/source/Lib/TLibCommon/TComBitStream.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/TComBitStream.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/TComBitStream.h	(revision 50)
@@ -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-nokia/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/TComSlice.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/TComSlice.cpp	(revision 50)
@@ -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-nokia/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/TComSlice.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/TComSlice.h	(revision 50)
@@ -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-nokia/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibCommon/TypeDef.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibCommon/TypeDef.h	(revision 50)
@@ -40,7 +40,9 @@
 
 
-#define FLEX_CODING_ORDER				        1
-
-#define SONY_COLPIC_AVAILABILITY  		  1
+#define BITSTREAM_EXTRACTION            1
+#define FLEX_CODING_ORDER               1
+#define DISABLE_FCO_FOR_VSO             0
+
+#define SONY_COLPIC_AVAILABILITY        1
 
 //>>>>> HHI 3DV tools >>>>>
@@ -55,4 +57,5 @@
 #define HHI_VSO_DIST_INT                1   // view synthesis optimization integer distorition in rdo process
 #define HHI_VSO_LS_TABLE                1   // table based lambda scaling
+#define HHI_VSO_PRINT_DIST              0   // print VSO distortion instead of depth distrotion
 
 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE && !HHI_INTERVIEW_SKIP
Index: branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 50)
@@ -82,4 +82,21 @@
 // ====================================================================================================================
 
+#if BITSTREAM_EXTRACTION
+Void  TDecCavlc::parseNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId )
+{
+  UInt  uiCode;
+
+  xReadCode ( 1, uiCode ); assert( 0 == uiCode); // forbidden_zero_bit
+  xReadCode ( 1, uiCode );                       // nal_ref_flag
+  xReadCode ( 6, uiCode );                       // nal_unit_type
+  eNalUnitType = (NalUnitType) uiCode;
+
+  xReadCode(3, uiCode); // temporal_id
+  TemporalId = uiCode;
+  xReadCode(5, uiCode); // layer_id_plus1
+  assert( 1 <= uiCode );
+  uiLayerId = uiCode - 1;
+}
+#else
 Void  TDecCavlc::parseNalUnitHeader ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag )
 {
@@ -105,4 +122,5 @@
   }
 }
+#endif
 
 /**
Index: branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 50)
@@ -182,5 +182,10 @@
 #endif
   
+#if BITSTREAM_EXTRACTION
+  Void  parseNalUnitHeader  ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId );
+#else
   Void  parseNalUnitHeader  ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag );
+#endif
+
   
   Void  parseSPS            ( TComSPS* pcSPS );
Index: branches/0.3-nokia/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibDecoder/TDecEntropy.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibDecoder/TDecEntropy.h	(revision 50)
@@ -67,5 +67,9 @@
   virtual Void  setBitstream          ( TComBitstream* p )  = 0;
 
+#if BITSTREAM_EXTRACTION
+  virtual Void  parseNalUnitHeader    ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId )  = 0;
+#else
   virtual Void  parseNalUnitHeader    ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag )  = 0;
+#endif
 
   virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
@@ -147,7 +151,11 @@
   Void    resetEntropy                ( TComSlice* p)           { m_pcEntropyDecoderIf->resetEntropy(p);                    }
 
+#if BITSTREAM_EXTRACTION
+  Void    decodeNalUnitHeader         ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId )
+                                                                { m_pcEntropyDecoderIf->parseNalUnitHeader( eNalUnitType, TemporalId, uiLayerId ); }
+#else
   Void    decodeNalUnitHeader         ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag )
                                                                 { m_pcEntropyDecoderIf->parseNalUnitHeader(eNalUnitType, TemporalId, bOutputFlag ); }
-
+#endif
 
   Void    decodeSPS                   ( TComSPS* pcSPS     )    { m_pcEntropyDecoderIf->parseSPS(pcSPS);                    }
Index: branches/0.3-nokia/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibDecoder/TDecSbac.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibDecoder/TDecSbac.h	(revision 50)
@@ -75,5 +75,9 @@
   Void  setMaxAlfCtrlDepth        ( UInt uiMaxAlfCtrlDepth ) { m_uiMaxAlfCtrlDepth = uiMaxAlfCtrlDepth; }
   
+#if BITSTREAM_EXTRACTION
+  Void  parseNalUnitHeader    ( NalUnitType& eNalUnitType, UInt& TemporalId, UInt& uiLayerId ) {}
+#else
   Void  parseNalUnitHeader    ( NalUnitType& eNalUnitType, UInt& TemporalId, Bool& bOutputFlag ) {}
+#endif
   
   Void  parseSPS                  ( TComSPS* pcSPS         ) {}
Index: branches/0.3-nokia/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibDecoder/TDecTop.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibDecoder/TDecTop.cpp	(revision 50)
@@ -535,7 +535,15 @@
   NalUnitType eNalUnitType;
   UInt        TemporalId;
+
+#if BITSTREAM_EXTRACTION
+  UInt        uiLayerId;
+
+  m_cEntropyDecoder.decodeNalUnitHeader(eNalUnitType, TemporalId, uiLayerId);
+#else
   Bool        OutputFlag;
 
   m_cEntropyDecoder.decodeNalUnitHeader(eNalUnitType, TemporalId, OutputFlag);
+#endif
+
   reNalUnitType = eNalUnitType;
 
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 50)
@@ -39,4 +39,5 @@
 
 #include "TEncCavlc.h"
+#include "../TLibCommon/SEI.h"
 #include "SEIwrite.h"
 
@@ -228,5 +229,9 @@
 void TEncCavlc::codeSEI(const SEI& sei)
 {
+#if BITSTREAM_EXTRACTION
+  codeNALUnitHeader( NAL_UNIT_SEI, NAL_REF_IDC_PRIORITY_LOWEST, 0, sei.getLayerId() );
+#else
   codeNALUnitHeader(NAL_UNIT_SEI, NAL_REF_IDC_PRIORITY_LOWEST);
+#endif
   writeSEImessage(*m_pcBitIf, sei);
 }
@@ -235,5 +240,9 @@
 {
   // uiFirstByte
+#if BITSTREAM_EXTRACTION
+  codeNALUnitHeader( NAL_UNIT_PPS, NAL_REF_IDC_PRIORITY_HIGHEST, 0, pcPPS->getLayerId() );
+#else
   codeNALUnitHeader( NAL_UNIT_PPS, NAL_REF_IDC_PRIORITY_HIGHEST );
+#endif
 
   xWriteUvlc( pcPPS->getPPSId() );
@@ -249,4 +258,16 @@
 }
 
+#if BITSTREAM_EXTRACTION
+Void TEncCavlc::codeNALUnitHeader( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId, UInt uiLayerId )
+{
+  // uiFirstByte
+  xWriteCode( 0, 1);                    // forbidden_zero_flag
+  xWriteCode( eNalRefIdc==0 ? 0:1, 1);  // nal_ref_flag
+  xWriteCode( eNalUnitType, 6);         // nal_unit_type
+
+  xWriteCode( TemporalId, 3);           // temporal_id
+  xWriteCode( uiLayerId+1, 5);          // layer_id_plus1
+}
+#else
 Void TEncCavlc::codeNALUnitHeader( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId, Bool bOutputFlag )
 {
@@ -263,9 +284,14 @@
   }
 }
+#endif
 
 Void TEncCavlc::codeSPS( TComSPS* pcSPS )
 {
   // uiFirstByte
+#if BITSTREAM_EXTRACTION
+  codeNALUnitHeader( NAL_UNIT_SPS, NAL_REF_IDC_PRIORITY_HIGHEST, 0, pcSPS->getLayerId() );
+#else
   codeNALUnitHeader( NAL_UNIT_SPS, NAL_REF_IDC_PRIORITY_HIGHEST );
+#endif
 
   // Structure
@@ -385,7 +411,15 @@
   // here someone can add an appropriated NalRefIdc type
 #if DCM_DECODING_REFRESH
+#if BITSTREAM_EXTRACTION
+  codeNALUnitHeader (pcSlice->getNalUnitType(), NAL_REF_IDC_PRIORITY_HIGHEST, 1, pcSlice->getLayerId());
+#else
   codeNALUnitHeader (pcSlice->getNalUnitType(), NAL_REF_IDC_PRIORITY_HIGHEST, 1, true);
+#endif
+#else
+#if BITSTREAM_EXTRACTION
+  codeNALUnitHeader (NAL_UNIT_CODED_SLICE, NAL_REF_IDC_PRIORITY_HIGHEST, 0, pcSlice->getLayerId());
 #else
   codeNALUnitHeader (NAL_UNIT_CODED_SLICE, NAL_REF_IDC_PRIORITY_HIGHEST);
+#endif
 #endif
 
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncCavlc.h	(revision 50)
@@ -206,5 +206,9 @@
   UInt  getCoeffCost          ()                { return  m_uiCoeffCost;  }
   
+#if BITSTREAM_EXTRACTION
+  Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, UInt uiLayerId = 0 );
+#else
   Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true );
+#endif
   
   Void  codeSPS                 ( TComSPS* pcSPS );
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncCfg.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncCfg.h	(revision 50)
@@ -187,4 +187,7 @@
   //std::vector<int>  m_aiLayerQPOffset;
 
+#if BITSTREAM_EXTRACTION
+  UInt        m_uiLayerId;
+#endif
   UInt        m_uiViewId;
   Int         m_iViewOrderIdx;
@@ -238,4 +241,8 @@
   Void      setRateGOPSize                  ( Int   i )      { m_iRateGOPSize = i; }
 
+#if BITSTREAM_EXTRACTION
+  Void      setLayerId                      ( UInt  u )      { m_uiLayerId              = u; }
+  UInt      getLayerId                      ( )              { return m_uiLayerId; }
+#endif
   Void      setViewId                       ( UInt  u )      { m_uiViewId               = u; }
   Void      setViewOrderIdx                 ( Int   i )      { m_iViewOrderIdx          = i; }
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncEntropy.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncEntropy.h	(revision 50)
@@ -72,5 +72,9 @@
   virtual UInt  getCoeffCost          ()                = 0;
   
+#if BITSTREAM_EXTRACTION
+  virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, UInt uiLayerId = 0 ) = 0;
+#else
   virtual Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true ) = 0;
+#endif
 
   virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 50)
@@ -639,4 +639,7 @@
         seiBs.create(1024);
         /* write the SEI messages */
+#if BITSTREAM_EXTRACTION
+        sei_recon_picture_digest.setLayerId( pcSlice->getLayerId() );
+#endif
         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
         m_pcEntropyCoder->setBitstream(&seiBs);
@@ -824,5 +827,5 @@
   }
 
-#if HHI_VSO
+#if HHI_VSO_PRINT_DIST
   if ( m_pcRdCost->getUseRenModel() )
   {
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 50)
@@ -177,5 +177,9 @@
 }
 
+#if BITSTREAM_EXTRACTION
+Void TEncSbac::codeNALUnitHeader( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId, UInt uiLayerId )
+#else
 Void TEncSbac::codeNALUnitHeader( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId, Bool bOutputFlag )
+#endif
 {
   assert (0);
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.h	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncSbac.h	(revision 50)
@@ -89,5 +89,9 @@
   //--SBAC RD
   
+#if BITSTREAM_EXTRACTION
+  Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, UInt uiLayerId = 0 );
+#else
   Void  codeNALUnitHeader       ( NalUnitType eNalUnitType, NalRefIdc eNalRefIdc, UInt TemporalId = 0, Bool bOutputFlag = true );
+#endif
 
   Void  codeSPS                 ( TComSPS* pcSPS     );
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncSlice.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncSlice.cpp	(revision 50)
@@ -149,4 +149,7 @@
   rpcSlice->initSlice();
   rpcSlice->setPOC( pcPic->getPOC() );
+#if BITSTREAM_EXTRACTION
+  rpcSlice->setLayerId( m_pcCfg->getLayerId() );
+#endif
 #if SONY_COLPIC_AVAILABILITY
   rpcSlice->setViewOrderIdx(m_pcCfg->getViewOrderIdx());
Index: branches/0.3-nokia/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/0.3-nokia/source/Lib/TLibEncoder/TEncTop.cpp	(revision 35)
+++ branches/0.3-nokia/source/Lib/TLibEncoder/TEncTop.cpp	(revision 50)
@@ -546,4 +546,8 @@
   m_cSPS.setMaxTrSize   ( 1 << m_uiQuadtreeTULog2MaxSize );
 
+#if BITSTREAM_EXTRACTION
+  m_cSPS.setLayerId( m_uiLayerId );
+#endif
+
   if( m_bIsDepth )
   {
@@ -632,4 +636,8 @@
 Void TEncTop::xInitPPS()
 {
+#if BITSTREAM_EXTRACTION
+  m_cPPS.setLayerId( m_uiLayerId );
+#endif
+
   m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
   m_cPPS.setPPSId( ( m_uiViewId << 1 ) + ( m_bIsDepth ? 1 : 0 ) );
