Index: /branches/HTM-3.0-Vidyo/source/App/TAppDecoder/TAppDecTop.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/App/TAppDecoder/TAppDecTop.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/App/TAppDecoder/TAppDecTop.cpp	(revision 70)
@@ -140,7 +140,12 @@
     {
       read(nalu, nalUnit);
+#if VIDYO_VPS_INTEGRATION
+      viewDepthId = nalu.m_layerId;   // coding order T0D0T1D1T2D2
+#else
       Int viewId = nalu.m_viewId;
       Int depth = nalu.m_isDepth ? 1 : 0;
       viewDepthId = viewId * 2 + depth;   // coding order T0D0T1D1T2D2
+#endif
+      
       newPicture[viewDepthId] = false;
       if( viewDepthId >= m_tDecTop.size() )      
Index: /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.cpp	(revision 70)
@@ -67,4 +67,16 @@
 Void TAppEncTop::xInitLibCfg()
 {
+#if VIDYO_VPS_INTEGRATION
+  UInt layerId = 0;
+  // TODO: fix the assumption here that the temporal structures are all equal across all layers???
+  m_cVPS.setMaxTLayers( m_maxTempLayer[0] );
+  m_cVPS.setMaxLayers( m_iNumberOfViews * (m_bUsingDepthMaps ? 2:1) );
+  for(Int i = 0; i < MAX_TLAYER; i++)
+  {
+    m_cVPS.setNumReorderPics( m_numReorderPics[0][i], i );
+    m_cVPS.setMaxDecPicBuffering( m_maxDecPicBuffering[0][i], i );
+  }
+#endif
+  
   for(Int iViewIdx=0; iViewIdx<m_iNumberOfViews; iViewIdx++)
   {
@@ -90,4 +102,15 @@
     m_acTEncTopList[iViewIdx]->setIsDepth                      ( false );
     m_acTEncTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
+#if VIDYO_VPS_INTEGRATION
+    layerId = iViewIdx * (m_bUsingDepthMaps ? 2:1);
+    m_acTEncTopList[iViewIdx]->setLayerId                      ( layerId );
+    m_cVPS.setDepthFlag                                        ( false, layerId );
+    m_cVPS.setViewId                                           ( iViewIdx, layerId );
+    m_cVPS.setViewOrderIdx                                     ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
+    // TODO: set correct dependentFlag and dependentLayer
+    m_cVPS.setDependentFlag                                    ( iViewIdx ? true:false, layerId );
+    m_cVPS.setDependentLayer                                   ( layerId - (m_bUsingDepthMaps ? 2:1), layerId );
+#endif
+    
     m_acTEncTopList[iViewIdx]->setCamParPrecision              ( m_cCameraData.getCamParsCodedPrecision  () );
     m_acTEncTopList[iViewIdx]->setCamParInSliceHeader          ( m_cCameraData.getVaryingCameraParameters() );
@@ -364,4 +387,13 @@
       m_acTEncDepthTopList[iViewIdx]->setIsDepth                      ( true );
       m_acTEncDepthTopList[iViewIdx]->setViewOrderIdx                 ( m_cCameraData.getViewOrderIndex()[ iViewIdx ] );
+#if VIDYO_VPS_INTEGRATION
+      layerId = iViewIdx * 2 + 1;
+      m_acTEncDepthTopList[iViewIdx]->setLayerId                      ( layerId );
+      m_cVPS.setDepthFlag                                             ( true, layerId );
+      m_cVPS.setViewId                                                ( iViewIdx, layerId );
+      m_cVPS.setViewOrderIdx                                          ( m_cCameraData.getViewOrderIndex()[ iViewIdx ], layerId );
+      m_cVPS.setDependentFlag                                         ( true, layerId );
+      m_cVPS.setDependentLayer                                        ( layerId-1, layerId);
+#endif
       m_acTEncDepthTopList[iViewIdx]->setCamParPrecision              ( 0 );
       m_acTEncDepthTopList[iViewIdx]->setCamParInSliceHeader          ( false );
@@ -1134,4 +1166,7 @@
     case NAL_UNIT_SPS:
     case NAL_UNIT_PPS:
+#if VIDYO_VPS_INTEGRATION
+    case NAL_UNIT_VPS:
+#endif
       m_essentialBytes += *it_stats;
       break;
Index: /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/App/TAppEncoder/TAppEncTop.h	(revision 70)
@@ -84,4 +84,8 @@
 #endif
 
+#if VIDYO_VPS_INTEGRATION
+  TComVPS                     m_cVPS;
+#endif
+  
 #if HHI_VSO
   TRenTop                     m_cRendererTop; 
@@ -131,4 +135,8 @@
 #endif
   
+#if VIDYO_VPS_INTEGRATION
+  TComVPS*          getVPS()  { return &m_cVPS; }
+#endif
+  
 #if DEPTH_MAP_GENERATION
   TComSPSAccess*    getSPSAccess  () { return &m_cSPSAccess;   }
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/CommonDef.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/CommonDef.h	(revision 70)
@@ -168,4 +168,11 @@
 #define LOG2_DISP_PREC_LUT   				2		  		///< log2 of disparity precision used in integer disparity LUTs
 
+// ====================================================================================================================
+// VPS constants
+// ====================================================================================================================
+#if VIDYO_VPS_INTEGRATION
+#define MAX_LAYER_NUM                     MAX_VIEW_NUM
+#define VPS_EXTENSION_TYPE_MULTI_VIEW     0
+#endif
 
 // ====================================================================================================================
@@ -483,5 +490,9 @@
   NAL_UNIT_RESERVED_23,
   NAL_UNIT_UNSPECIFIED_24,
+#if VIDYO_VPS_INTEGRATION
+	NAL_UNIT_VPS,
+#else
   NAL_UNIT_UNSPECIFIED_25,
+#endif
   NAL_UNIT_UNSPECIFIED_26,
   NAL_UNIT_UNSPECIFIED_27,
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/NAL.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/NAL.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/NAL.h	(revision 70)
@@ -51,4 +51,8 @@
   NalRefIdc   m_nalRefIDC;   ///< nal_ref_idc
 #endif
+#if VIDYO_VPS_INTEGRATION
+	unsigned    m_layerId;
+  unsigned    m_temporalId;  ///< temporal_id
+#else
   Int         m_viewId;      ///< view_id
   Bool        m_isDepth;     ///< is_depth
@@ -56,4 +60,5 @@
 #if !H0388
   bool        m_OutputFlag;  ///< output_flag
+#endif
 #endif
 
@@ -64,11 +69,19 @@
     NalUnitType nalUnitType,
     Bool        nalRefFlag,
+#if !VIDYO_VPS_INTEGRATION    
     Int         viewId,
     Bool        isDepth,
-    Int         temporalId = 0)
+#else
+    unsigned    layerId,
+#endif
+    unsigned       temporalId = 0)
     :m_nalUnitType (nalUnitType)
     ,m_nalRefFlag  (nalRefFlag)
+#if !VIDYO_VPS_INTEGRATION
     ,m_viewId      (viewId)
     ,m_isDepth     (isDepth)
+#else
+    ,m_layerId     (layerId)
+#endif
     ,m_temporalId  (temporalId)
   {}
@@ -83,6 +96,10 @@
     m_nalUnitType = nalUnitType;
     m_nalRefIDC   = nalRefIDC;
+#if !VIDYO_VPS_INTEGRATION
     m_viewId      = viewId;
     m_isDepth     = isDepth;
+#else
+		m_layerId = layerId;
+#endif
     m_temporalId  = temporalID;
   }
@@ -92,6 +109,10 @@
     NalUnitType  nalUnitType,
     NalRefIdc    nalRefIDC,
-    Int          viewId,
-    Bool         isDepth,
+#if !VIDYO_VPS_INTEGRATION    
+    Int         viewId,
+    Bool        isDepth,
+#else
+    unsigned         layerId,
+#endif
     unsigned     temporalID = 0,
     bool         outputFlag = true)
@@ -99,6 +120,10 @@
     m_nalUnitType = nalUnitType;
     m_nalRefIDC   = nalRefIDC;
+#if !VIDYO_VPS_INTEGRATION
     m_viewId      = viewId;
     m_isDepth     = isDepth;
+#else
+		m_layerId = layerId;
+#endif
     m_temporalId  = temporalID;
     m_OutputFlag  = outputFlag;
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.cpp	(revision 70)
@@ -1305,4 +1305,40 @@
 }
 
+// ------------------------------------------------------------------------------------------------
+// Video parameter set (VPS)
+// ------------------------------------------------------------------------------------------------
+#if VIDYO_VPS_INTEGRATION
+TComVPS::TComVPS()
+: m_VPSId                     (  0)
+, m_uiMaxTLayers              (  1)
+, m_uiMaxLayers               (  1)
+, m_bTemporalIdNestingFlag    (false)
+, m_uiExtensionType           (  0)
+{
+  for( Int i = 0; i < MAX_LAYER_NUM; i++)
+  {
+    m_uiDependentLayer[i] = i? i-1: 0;
+    m_bDependentFlag[i] = false;
+    m_uiViewId[i] = 0;
+    m_bDepthFlag[i] = 0;
+    m_iViewOrderIdx[i] = 0;
+  }
+  
+  for( Int i = 0; i < MAX_TLAYER; i++)
+  {
+    m_numReorderPics[i] = 0;
+    m_uiMaxDecPicBuffering[i] = 0; 
+    m_uiMaxLatencyIncrease[i] = 0;
+  }
+}
+
+TComVPS::~TComVPS()
+{
+	
+	
+}
+
+#endif
+
 
 // ------------------------------------------------------------------------------------------------
@@ -1311,5 +1347,10 @@
 
 TComSPS::TComSPS()
+#if VIDYO_VPS_INTEGRATION
+: m_VPSId                     (  0)
+, m_SPSId                     (  0)
+#else
 : m_SPSId                     (  0)
+#endif
 , m_ProfileIdc                (  0)
 , m_LevelIdc                  (  0)
@@ -2155,4 +2196,7 @@
 , m_ppsMap(MAX_NUM_PPS)
 , m_apsMap(MAX_NUM_APS)
+#if VIDYO_VPS_INTEGRATION
+, m_vpsMap(MAX_NUM_VPS)
+#endif
 {
 }
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TComSlice.h	(revision 70)
@@ -144,8 +144,81 @@
 #endif
 
+#if VIDYO_VPS_INTEGRATION
+/// VPS class
+
+class TComVPS
+{
+private:
+  Int         m_VPSId;
+	UInt				m_uiMaxTLayers;
+	UInt				m_uiMaxLayers;
+	Bool				m_bTemporalIdNestingFlag;
+
+	UInt        m_uiExtensionType;
+  
+  Bool        m_bDependentFlag[MAX_LAYER_NUM];
+  UInt        m_uiViewId[MAX_LAYER_NUM];
+  Bool        m_bDepthFlag[MAX_LAYER_NUM];
+  Int         m_iViewOrderIdx[MAX_LAYER_NUM];
+  UInt        m_uiDependentLayer[MAX_LAYER_NUM];
+
+  UInt        m_numReorderPics[MAX_TLAYER];
+  UInt        m_uiMaxDecPicBuffering[MAX_TLAYER]; 
+  UInt        m_uiMaxLatencyIncrease[MAX_TLAYER];
+  
+public:
+  TComVPS();
+  virtual ~TComVPS();
+	
+  Int     getVPSId       ()                   { return m_VPSId;          }
+  Void    setVPSId       (Int i)              { m_VPSId = i;             }
+	
+  UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
+  Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
+    
+  UInt    getMaxLayers   ()                   { return m_uiMaxLayers;   }
+	Void    setMaxLayers   (UInt l)             { m_uiMaxLayers = l; }
+	
+  Bool    getTemporalNestingFlag   ()         { return m_uiMaxLayers;   }
+	Void    setTemporalNestingFlag   (UInt t)   { m_bTemporalIdNestingFlag = t; }
+  
+  Void    setExtensionType(UInt v)                     { m_uiExtensionType = v;    }
+  UInt    getExtensionType()                             { return m_uiExtensionType; }
+  
+  Void    setDependentFlag(Bool d, UInt layer)              { m_bDependentFlag[layer] = d;    }
+  Bool    getDependentFlag(UInt layer)                      { return m_bDependentFlag[layer]; }
+
+  Void    setViewId(UInt v, UInt layer)                     { m_uiViewId[layer] = v;    }
+  UInt    getViewId(UInt layer)                             { return m_uiViewId[layer]; }
+  
+  Void    setDepthFlag(Bool d, UInt layer)                  { m_bDepthFlag[layer] = d;    }
+  Bool    getDepthFlag(UInt layer)                          { return m_bDepthFlag[layer]; }
+
+  Void    setViewOrderIdx(Int v, UInt layer)                { m_iViewOrderIdx[layer] = v;    }
+  Int     getViewOrderIdx(UInt layer)                       { return m_iViewOrderIdx[layer]; }
+  
+  Void    setDependentLayer(UInt v, UInt layer)                     { m_uiDependentLayer[layer] = v;    }
+  UInt    getDependentLayer(UInt layer)                             { return m_uiDependentLayer[layer]; }
+  
+  Void    setNumReorderPics(UInt v, UInt tLayer)                { m_numReorderPics[tLayer] = v;    }
+  UInt    getNumReorderPics(UInt tLayer)                        { return m_numReorderPics[tLayer]; }
+  
+  Void    setMaxDecPicBuffering(UInt v, UInt tLayer)          { m_uiMaxDecPicBuffering[tLayer] = v;    }
+  UInt    getMaxDecPicBuffering(UInt tLayer)                  { return m_uiMaxDecPicBuffering[tLayer]; }
+  
+  Void    setMaxLatencyIncrease(UInt v, UInt tLayer)                { m_uiMaxLatencyIncrease[tLayer] = v;    }
+  UInt    getMaxLatencyIncrease(UInt tLayer)                        { return m_uiMaxLatencyIncrease[tLayer]; }
+  
+};
+
+#endif
+
 /// SPS class
 class TComSPS
 {
 private:
+#if VIDYO_VPS_INTEGRATION
+	Int					m_VPSId;
+#endif
   Int         m_SPSId;
   Int         m_ProfileIdc;
@@ -305,5 +378,8 @@
   TComSPS();
   virtual ~TComSPS();
-
+#if VIDYO_VPS_INTEGRATION
+	Int  getVPSId       ()         { return m_VPSId;          }
+  Void setVPSId       (Int i)    { m_VPSId = i;             }
+#endif
   Int  getSPSId       ()         { return m_SPSId;          }
   Void setSPSId       (Int i)    { m_SPSId = i;             }
@@ -1109,4 +1185,7 @@
   
   // access channel
+#if VIDYO_VPS_INTEGRATION
+  TComVPS*    m_pcVPS;
+#endif
   TComSPS*    m_pcSPS;
   TComPPS*    m_pcPPS;
@@ -1193,5 +1272,8 @@
   Void      initTiles();
 
-  
+#if VIDYO_VPS_INTEGRATION
+  Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
+  TComVPS*  getVPS          () { return m_pcVPS; }
+#endif
   Void      setSPS          ( TComSPS* pcSPS ) { m_pcSPS = pcSPS; }
   TComSPS*  getSPS          () { return m_pcSPS; }
@@ -1538,5 +1620,11 @@
   ParameterSetManager();
   virtual ~ParameterSetManager();
-
+#if VIDYO_VPS_INTEGRATION
+  //! store video parameter set and take ownership of it 
+  Void storeVPS(TComVPS *vps) { m_vpsMap.storePS( vps->getVPSId(), vps); };
+  //! get pointer to existing video parameter set  
+  TComVPS* getVPS(Int vpsId)  { return m_vpsMap.getPS(vpsId); };
+  TComVPS* getFirstVPS()      { return m_vpsMap.getFirstPS(); };
+#endif
   //! store sequence parameter set and take ownership of it 
   Void storeSPS(TComSPS *sps) { m_spsMap.storePS( sps->getSPSId(), sps); };
@@ -1560,4 +1648,7 @@
   ParameterSetMap<TComPPS> m_ppsMap; 
   ParameterSetMap<TComAPS> m_apsMap; 
+#if VIDYO_VPS_INTEGRATION
+  ParameterSetMap<TComVPS> m_vpsMap; 
+#endif
 };
 
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TypeDef.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibCommon/TypeDef.h	(revision 70)
@@ -351,4 +351,13 @@
 #define COMPLETE_SLICES_IN_TILE     1 // Among the constraints between slices and tiles, all slices within a tile shall be complete (JCTVC-H0348/JCTVC-H0463) for SliceMode 1&2
 #define WPP_SIMPLIFICATION          1 // JCTVC-H0349/JCTVC-0517
+
+// ====================================================================================================================
+// VPS INTEGRATION
+// ====================================================================================================================
+#define VIDYO_VPS_INTEGRATION       1
+#if VIDYO_VPS_INTEGRATION
+#define MAX_NUM_VPS 10
+#endif
+
 // ====================================================================================================================
 // Basic type redefinition
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/NALread.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/NALread.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/NALread.cpp	(revision 70)
@@ -136,7 +136,10 @@
  //  unsigned reserved_one_5bits = bs.read(5);
  //  assert(reserved_one_5bits == 1);
+#if VIDYO_VPS_INTEGRATION
+  nalu.m_layerId  = bs.read(5) - 1;
+#else
   nalu.m_viewId   = bs.read(4)-1;
   nalu.m_isDepth  = bs.read(1);
-
+#endif
 #if H0566_TLA
   if ( nalu.m_temporalId )
@@ -159,4 +162,7 @@
     {
       nalu.m_temporalId = bs.read(3);
+#if VIDYO_VPS_INTEGRATION
+      nalu.m_layerId    = bs.read(5) - 1;
+#else
       nalu.m_OutputFlag = bs.read(1);
   //    unsigned reserved_one_4bits = bs.read(4);
@@ -164,5 +170,6 @@
       nalu.m_viewId   = bs.read(3)-1;
       nalu.m_isDepth  = bs.read(1);
-
+#endif
+      
 #if H0566_TLA
       if (nalu.m_temporalId == 0)
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 70)
@@ -1339,4 +1339,55 @@
 }
 
+#if VIDYO_VPS_INTEGRATION
+Void TDecCavlc::parseVPS(TComVPS* pcVPS)
+{
+  UInt  uiCode;
+  Int   iCode;
+  
+  READ_CODE( 3, uiCode, "max_temporal_layers_minus1" );   pcVPS->setMaxTLayers( uiCode + 1 );
+  READ_CODE( 5, uiCode, "max_layers_minus1" );            pcVPS->setMaxLayers( uiCode + 1 );
+  READ_FLAG( uiCode,  "temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
+  READ_UVLC( uiCode,  "video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
+  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
+  {
+    READ_UVLC( uiCode,  "max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
+    READ_UVLC( uiCode,  "num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
+    READ_UVLC( uiCode,  "max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
+  }
+  
+  READ_CODE( 1, uiCode, "bit_equal_to_one" );             assert( uiCode );
+  
+  if( pcVPS->getMaxLayers() - 1 > 0 )
+  {
+    READ_UVLC( uiCode,  "extension_type" );               pcVPS->setExtensionType( uiCode );
+    
+    if( pcVPS->getExtensionType() == 0)
+      READ_SVLC( iCode,  "view_order_idx[0]" );           pcVPS->setViewOrderIdx( iCode, 0 );
+    
+    for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++)
+    {
+      READ_FLAG( uiCode, "dependent_flag[i]" );           pcVPS->setDependentFlag( uiCode ? true:false, i);
+      if( pcVPS->getDependentFlag(i) )
+      {
+        READ_UVLC( uiCode,  "delta_reference_layer_id_minus1[i]" ); pcVPS->setDependentLayer( i - uiCode + 1, i );
+        if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW )
+        {
+          READ_UVLC( uiCode,  "view_id[i]" );             pcVPS->setViewId( uiCode, i );
+          READ_FLAG( uiCode,  "depth_flag[i]" );          pcVPS->setDepthFlag( uiCode ? true:false, i ); 
+          READ_SVLC( iCode,  "view_order_idx[i]" );       pcVPS->setViewOrderIdx( iCode, i );
+        }
+        
+      }
+    }
+  }
+  
+  READ_FLAG( uiCode,  "vps_extension_flag" );          assert(!uiCode);
+  //future extensions go here..
+  
+  return;
+}
+
+#endif
+
 #if HHI_MPI
 Void TDecCavlc::parseSPS(TComSPS* pcSPS, Bool bIsDepth)
@@ -1356,4 +1407,7 @@
   READ_CODE( 8,  uiCode, "level_idc" );                          pcSPS->setLevelIdc( uiCode );
   READ_UVLC(     uiCode, "seq_parameter_set_id" );               pcSPS->setSPSId( uiCode );
+#if VIDYO_VPS_INTEGRATION
+  READ_UVLC(     uiCode, "video_parameter_set_id" );             pcSPS->setVPSId( uiCode );
+#endif
   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
   READ_CODE( 3,  uiCode, "max_temporal_layers_minus1" );         pcSPS->setMaxTLayers( uiCode+1 );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 70)
@@ -113,4 +113,7 @@
   Void  parseQtRootCbf      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf );
 
+#if VIDYO_VPS_INTEGRATION
+  Void  parseVPS            ( TComVPS* pcVPS );
+#endif
 #if HHI_MPI
   Void  parseSPS            ( TComSPS* pcSPS, Bool bIsDepth );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecEntropy.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecEntropy.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecEntropy.h	(revision 70)
@@ -71,4 +71,7 @@
 #endif
 
+#if VIDYO_VPS_INTEGRATION
+  virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
+#endif
 #if HHI_MPI
   virtual Void  parseSPS                  ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
@@ -163,4 +166,8 @@
   Void    resetEntropy                ( TComSlice* p)           { m_pcEntropyDecoderIf->resetEntropy(p);                    }
 
+#if VIDYO_VPS_INTEGRATION
+  Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
+#endif
+  
 #if HHI_MPI
   Void    decodeSPS                   ( TComSPS* pcSPS, Bool bIsDepth ) { m_pcEntropyDecoderIf->parseSPS(pcSPS, bIsDepth); }
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSbac.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSbac.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSbac.h	(revision 70)
@@ -87,4 +87,7 @@
   Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
   
+#if VIDYO_VPS_INTEGRATION
+  Void  parseVPS                  ( TComVPS* pcVPS )  {}
+#endif
 #if HHI_MPI
   Void  parseSPS                  ( TComSPS* pcSPS, Bool bIsDepth ) {}
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 70)
@@ -446,4 +446,7 @@
 , m_ppsBuffer(16)
 , m_apsBuffer(64)
+#if VIDYO_VPS_INTEGRATION 
+, m_vpsBuffer(16)
+#endif
 {
 
@@ -454,4 +457,18 @@
 
 }
+
+#if VIDYO_VPS_INTEGRATION
+TComVPS* ParameterSetManagerDecoder::getPrefetchedVPS  (Int vpsId)
+{
+  if (m_vpsBuffer.getPS(vpsId) != NULL )
+  {
+    return m_vpsBuffer.getPS(vpsId);
+  }
+  else
+  {
+    return getVPS(vpsId);
+  }
+}
+#endif
 
 TComSPS* ParameterSetManagerDecoder::getPrefetchedSPS  (Int spsId)
@@ -496,4 +513,7 @@
   m_ppsMap.mergePSList(m_ppsBuffer);
   m_spsMap.mergePSList(m_spsBuffer);
+#if VIDYO_VPS_INTEGRATION
+  m_vpsMap.mergePSList(m_vpsBuffer);
+#endif
 }
 
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecSlice.h	(revision 70)
@@ -96,5 +96,8 @@
   Void     storePrefetchedAPS(TComAPS *aps)  { m_apsBuffer.storePS( aps->getAPSID(), aps); };
   TComAPS* getPrefetchedAPS  (Int apsId);
-
+#if VIDYO_VPS_INTEGRATION
+  Void     storePrefetchedVPS(TComVPS *vps)  { m_vpsBuffer.storePS( vps->getVPSId(), vps); };
+  TComVPS* getPrefetchedVPS  (Int vpsId);
+#endif
   Void     applyPrefetchedPS();
 
@@ -103,4 +106,7 @@
   ParameterSetMap<TComPPS> m_ppsBuffer; 
   ParameterSetMap<TComAPS> m_apsBuffer; 
+#if VIDYO_VPS_INTEGRATION
+	ParameterSetMap<TComVPS> m_vpsBuffer;
+#endif
 };
 
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.cpp	(revision 70)
@@ -571,7 +571,13 @@
   TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
   assert (sps != 0);
-
+#if VIDYO_VPS_INTEGRATION
+  TComVPS *vps = m_parameterSetManagerDecoder.getVPS(sps->getVPSId());
+  assert (vps != 0);
+#endif
   m_apcSlicePilot->setPPS(pps);
   m_apcSlicePilot->setSPS(sps);
+#if VIDYO_VPS_INTEGRATION
+  m_apcSlicePilot->setVPS(vps);
+#endif
   pps->setSPS(sps);
 
@@ -613,4 +619,7 @@
   m_apcSlicePilot->setPPS(m_parameterSetManagerDecoder.getPrefetchedPPS(0));
   m_apcSlicePilot->setSPS(m_parameterSetManagerDecoder.getPrefetchedSPS(0));
+#if VIDYO_VPS_INTEGRATION
+  m_apcSlicePilot->setVPS(m_parameterSetManagerDecoder.getPrefetchedVPS(0));
+#endif
   m_apcSlicePilot->initTiles();
 
@@ -629,6 +638,12 @@
   if( m_bFirstSliceInPicture )
   {
+#if VIDYO_VPS_INTEGRATION
+    if( m_apcSlicePilot->getVPS()->getViewId(nalu.m_layerId) == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
+    else { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId) )->getNalUnitTypeBaseView(); }
+#else
     if( nalu.m_viewId == 0 ) { m_nalUnitTypeBaseView = nalu.m_nalUnitType; }
     else                     { m_nalUnitTypeBaseView = m_tAppDecTop->getTDecTop( 0, nalu.m_isDepth )->getNalUnitTypeBaseView(); }
+#endif
+    
     m_apcSlicePilot->setNalUnitTypeBaseViewMvc( m_nalUnitTypeBaseView );
   }
@@ -929,9 +944,18 @@
 
     // Set reference list 
+#if VIDYO_VPS_INTEGRATION
+    pcSlice->setViewId( pcSlice->getVPS()->getViewId(nalu.m_layerId) );
+    pcSlice->setIsDepth( pcSlice->getVPS()->getDepthFlag(nalu.m_layerId) );
+#else
     pcSlice->setViewId(m_viewId);
     pcSlice->setIsDepth(m_isDepth);
-
+#endif
+    
 #if SONY_COLPIC_AVAILABILITY
+#if VIDYO_VPS_INTEGRATION
+    pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) );
+#else
     pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() );
+#endif
 #endif
 
@@ -1051,4 +1075,14 @@
 }
 
+#if VIDYO_VPS_INTEGRATION
+Void TDecTop::xDecodeVPS()
+{
+  TComVPS* vps = new TComVPS();
+  
+  m_cEntropyDecoder.decodeVPS( vps );
+  m_parameterSetManagerDecoder.storePrefetchedVPS(vps);  
+
+}
+#endif
 
 Void TDecTop::xDecodeSPS()
@@ -1114,4 +1148,9 @@
   switch (nalu.m_nalUnitType)
   {
+#if VIDYO_VPS_INTEGRATION
+    case NAL_UNIT_VPS:
+      xDecodeVPS();
+      return false;
+#endif
     case NAL_UNIT_SPS:
       xDecodeSPS();
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibDecoder/TDecTop.h	(revision 70)
@@ -208,4 +208,7 @@
   Bool      xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay);
 #endif
+#if VIDYO_VPS_INTEGRATION
+	Void      xDecodeVPS();
+#endif
   Void      xDecodeSPS();
   Void      xDecodePPS();
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.cpp	(revision 70)
@@ -64,4 +64,8 @@
 #endif
 
+#if VIDYO_VPS_INTEGRATION
+  bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id
+  bsNALUHeader.write(nalu.m_layerId + 1, 5); // layer_id_plus1
+#else
 #if H0388
   bsNALUHeader.write(nalu.m_temporalId, 3); // temporal_id
@@ -90,4 +94,6 @@
   }
 #endif
+#endif
+  
   out.write(bsNALUHeader.getByteStream(), bsNALUHeader.getByteStreamLength());
 
@@ -201,10 +207,17 @@
   naluDest.m_nalRefIDC   = naluSrc.m_nalRefIDC;
 #endif
+#if !VIDYO_VPS_INTEGRATION
   naluDest.m_viewId      = naluSrc.m_viewId;
   naluDest.m_isDepth     = naluSrc.m_isDepth;
+#endif
   naluDest.m_temporalId  = naluSrc.m_temporalId;
+#if VIDYO_VPS_INTEGRATION
+  naluDest.m_layerId = naluSrc.m_layerId;
+#else
+  
 #if !H0388
   naluDest.m_OutputFlag  = naluSrc.m_OutputFlag;
 #endif
+#endif
   naluDest.m_Bitstream   = naluSrc.m_Bitstream;
 }
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/NALwrite.h	(revision 70)
@@ -62,11 +62,23 @@
     NalRefIdc nalRefIDC,
 #endif
+#if VIDYO_VPS_INTEGRATION
+    unsigned layerId,
+#else
     Int viewId,
     Bool isDepth,
+#endif
     unsigned temporalID = 0)
 #if NAL_REF_FLAG
+#if VIDYO_VPS_INTEGRATION
+  : NALUnit(nalUnitType, nalRefFlag, layerId, temporalID)
+#else
   : NALUnit(nalUnitType, nalRefFlag, viewId, isDepth, temporalID)
+#endif
+#else
+#if VIDYO_VPS_INTEGRATION
+  : NALUnit(nalUnitType, nalRefIDC, layerId, temporalID)
 #else
   : NALUnit(nalUnitType, nalRefIDC, viewId, isDepth, temporalID)
+#endif
 #endif
   , m_Bitstream()
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 70)
@@ -375,4 +375,52 @@
 }
 
+#if VIDYO_VPS_INTEGRATION
+Void TEncCavlc::codeVPS( TComVPS* pcVPS )
+{
+	WRITE_CODE( pcVPS->getMaxTLayers() - 1,     3,        "max_temporal_layers_minus1" );
+  WRITE_CODE( pcVPS->getMaxLayers() - 1,      5,        "max_layers_minus1" );
+  WRITE_FLAG( pcVPS->getTemporalNestingFlag() - 1,      "temporal_id_nesting_flag" );
+  WRITE_UVLC( pcVPS->getVPSId(),                        "video_parameter_set_id" );
+  for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++)
+  {
+    WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i),           "max_dec_pic_buffering[i]" );
+    WRITE_UVLC( pcVPS->getNumReorderPics(i),               "num_reorder_pics[i]" );
+    WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i),           "max_latency_increase[i]" );
+  }
+  
+  WRITE_CODE( 1,      1,        "bit_equal_to_one" );
+  
+  if( pcVPS->getMaxLayers() - 1 > 0 )
+  {
+    WRITE_UVLC( pcVPS->getExtensionType(),                        "extension_type" );
+    
+    if( pcVPS->getExtensionType() == 0)
+      WRITE_SVLC( pcVPS->getViewOrderIdx(0),                      "view_order_idx[0]" );
+    
+    for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++)
+    {
+      WRITE_FLAG( pcVPS->getDependentFlag(i),                     "dependent_flag[i]" );
+      if( pcVPS->getDependentFlag(i) )
+      {
+        WRITE_UVLC( i - pcVPS->getDependentLayer(i) - 1,          "delta_reference_layer_id_minus1[i]" );
+        if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW )
+        {
+          WRITE_UVLC( pcVPS->getViewId(i),                        "view_id[i]" );
+          WRITE_FLAG( pcVPS->getDepthFlag(i),                     "depth_flag[i]" );
+          WRITE_SVLC( pcVPS->getViewOrderIdx(i),                  "view_order_idx[i]" );
+        }
+        
+      }
+    }
+  }
+  
+  WRITE_FLAG( 0,                     "vps_extension_flag" );
+  
+  //future extensions here..
+  
+  return;
+}
+#endif
+
 #if HHI_MPI
 Void TEncCavlc::codeSPS( TComSPS* pcSPS, Bool bIsDepth )
@@ -388,4 +436,7 @@
   WRITE_CODE( pcSPS->getLevelIdc (),       8,       "level_idc" );
   WRITE_UVLC( pcSPS->getSPSId (),                   "seq_parameter_set_id" );
+#if VIDYO_VPS_INTEGRATION
+  WRITE_UVLC( pcSPS->getVPSId (),                   "video_parameter_set_id" );
+#endif
   WRITE_UVLC( pcSPS->getChromaFormatIdc (),         "chroma_format_idc" );
   WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "max_temporal_layers_minus1" );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCavlc.h	(revision 70)
@@ -113,5 +113,9 @@
   UInt  getNumberOfWrittenBits()                { return  m_pcBitIf->getNumberOfWrittenBits();  }
   UInt  getCoeffCost          ()                { return  m_uiCoeffCost;  }
-  
+
+#if VIDYO_VPS_INTEGRATION
+  Void  codeVPS                 ( TComVPS* pcVPS );
+#endif
+
 #if HHI_MPI
   Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCfg.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCfg.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncCfg.h	(revision 70)
@@ -290,4 +290,8 @@
 #endif
 
+#if VIDYO_VPS_INTEGRATION
+  UInt     m_layerId;
+#endif
+  
   Int      m_viewId;
   Bool     m_isDepth;
@@ -765,5 +769,9 @@
   Int       getTSIG()                            { return m_signHidingThreshold; }
 #endif
-
+#if VIDYO_VPS_INTEGRATION
+  Void      setLayerId             ( UInt layerId )   { m_layerId = layerId; }
+  UInt      getLayerId             ()               { return m_layerId; }
+#endif
+  
   Void      setViewId             ( Int viewId )   { m_viewId = viewId; }
   Int       getViewId             ()               { return m_viewId; }
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 70)
@@ -121,4 +121,16 @@
 }
 
+#if VIDYO_VPS_INTEGRATION
+Void TEncEntropy::encodeVPS( TComVPS* pcVPS )
+{
+  m_pcEntropyCoderIf->codeVPS( pcVPS );
+  return;
+}
+#endif
+
+#if VIDYO_VPS_INTEGRATION
+Void  codeVPS                 ( TComVPS* pcVPS );
+#endif
+
 #if HHI_MPI
 Void TEncEntropy::encodeSPS( TComSPS* pcSPS, Bool bIsDepth )
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncEntropy.h	(revision 70)
@@ -76,4 +76,8 @@
   virtual UInt  getCoeffCost          ()                = 0;
 
+#if VIDYO_VPS_INTEGRATION
+	virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
+#endif
+	
 #if HHI_MPI
   virtual Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth )                       = 0;
@@ -229,4 +233,7 @@
   
 public:
+#if VIDYO_VPS_INTEGRATION
+	Void encodeVPS               ( TComVPS* pcVPS);
+#endif
   // SPS
 #if HHI_MPI
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 70)
@@ -809,6 +809,19 @@
       if ( m_bSeqFirst )
       {
+#if VIDYO_VPS_INTEGRATION
+        {
+          OutputNALUnit nalu(NAL_UNIT_VPS, true, m_pcEncTop->getLayerId());
+          m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
+          m_pcEntropyCoder->encodeVPS(m_pcEncTop->getEncTop()->getVPS());
+          writeRBSPTrailingBits(nalu.m_Bitstream);
+          accessUnit.push_back(new NALUnitEBSP(nalu));
+        }
+#endif
 #if NAL_REF_FLAG
+#if VIDYO_VPS_INTEGRATION
+        OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getLayerId());
+#else
         OutputNALUnit nalu(NAL_UNIT_SPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
+#endif
 #else
         OutputNALUnit nalu(NAL_UNIT_SPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
@@ -827,5 +840,9 @@
 
 #if NAL_REF_FLAG
+#if VIDYO_VPS_INTEGRATION 
+        nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getLayerId());
+#else
         nalu = NALUnit(NAL_UNIT_PPS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
+#endif
 #else
         nalu = NALUnit(NAL_UNIT_PPS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
@@ -954,11 +971,28 @@
 #if H0388
 #if NAL_REF_FLAG
-        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(), m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
-#else
-        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
-#endif
-#else
-        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer(), true);
-#endif
+        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced(),
+#if !VIDYO_VPS_INTEGRATION
+                           m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
+#else
+                           m_pcEncTop->getLayerId(), pcSlice->getTLayer() );
+#endif
+#else
+        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, 
+#if !VIDYO_VPS_INTEGRATION
+                           m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer() );
+#else
+                           m_pcEncTop->getLayerId(), pcSlice->getTLayer() );
+#endif
+#endif
+#else
+        OutputNALUnit nalu( pcSlice->getNalUnitType(), pcSlice->isReferenced() ? NAL_REF_IDC_PRIORITY_HIGHEST: NAL_REF_IDC_PRIORITY_LOWEST, 
+#if !VIDYO_VPS_INTEGRATION
+                           m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth(), pcSlice->getTLayer(), true );
+#else
+                           m_pcEncTop->getLayerId(), pcSlice->getTLayer(), true );
+#endif
+
+#endif
+            
         Bool bEntropySlice = (!pcSlice->isNextSlice());
         if (!bEntropySlice)
@@ -1414,5 +1448,9 @@
           {
 #if NAL_REF_FLAG
+#if VIDYO_VPS_INTEGRATION
+            OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getLayerId());
+#else
             OutputNALUnit nalu(NAL_UNIT_APS, true, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
+#endif
 #else
             OutputNALUnit nalu(NAL_UNIT_APS, NAL_REF_IDC_PRIORITY_HIGHEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
@@ -1476,5 +1514,9 @@
 
 #if NAL_REF_FLAG
+#if VIDYO_VPS_INTEGRATION
+        OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getLayerId());
+#else
         OutputNALUnit nalu(NAL_UNIT_SEI, false, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
+#endif
 #else
         OutputNALUnit nalu(NAL_UNIT_SEI, NAL_REF_IDC_PRIORITY_LOWEST, m_pcEncTop->getViewId(), m_pcEncTop->getIsDepth());
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.cpp	(revision 70)
@@ -342,4 +342,12 @@
 }
 
+#if VIDYO_VPS_INTEGRATION
+Void TEncSbac::codeVPS( TComVPS* pcVPS )
+{
+	assert (0);
+  return;
+}
+#endif
+
 #if HHI_MPI
 Void TEncSbac::codeSPS( TComSPS* pcSPS, Bool bIsDepth )
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibEncoder/TEncSbac.h	(revision 70)
@@ -98,4 +98,8 @@
   //--SBAC RD
 
+#if VIDYO_VPS_INTEGRATION
+  Void  codeVPS                 ( TComVPS* pcVPS );
+#endif
+	
 #if HHI_MPI
   Void  codeSPS                 ( TComSPS* pcSPS, Bool bIsDepth );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.cpp
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.cpp	(revision 70)
@@ -55,10 +55,23 @@
 Bool TExtrTop::extract( InputNALUnit& nalu, std::set<UInt>& rsuiExtractLayerIds )
 {
+#if VIDYO_VPS_INTEGRATION
+	//extraction now has to be done using layer_id
+  UInt uiLayerId = nalu.m_layerId;
+#else
   UInt uiLayerId = xGetLayerId( nalu.m_viewId, nalu.m_isDepth );
-
+#endif
   // Initialize entropy decoder
   m_cEntropyDecoder.setEntropyDecoder( &m_cCavlcDecoder );
   m_cEntropyDecoder.setBitstream     ( nalu.m_Bitstream );
   
+#if VIDYO_VPS_INTEGRATION
+  if ( nalu.m_nalUnitType == NAL_UNIT_VPS )
+  {
+    // a hack for now assuming there's only one VPS in the bitstream
+    m_cEntropyDecoder.decodeVPS( &m_cVPS );
+      
+  }
+#endif
+
   if ( nalu.m_nalUnitType == NAL_UNIT_SPS )
   {
@@ -69,5 +82,9 @@
 #endif
 #if HHI_MPI
+#if VIDYO_VPS_INTEGRATION
+     m_cEntropyDecoder.decodeSPS( &cSPS, m_cVPS.getDepthFlag(uiLayerId) );
+#else
      m_cEntropyDecoder.decodeSPS( &cSPS, nalu.m_isDepth );
+#endif
 #else
      m_cEntropyDecoder.decodeSPS( &cSPS );
Index: /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.h
===================================================================
--- /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.h	(revision 69)
+++ /branches/HTM-3.0-Vidyo/source/Lib/TLibExtractor/TExtrTop.h	(revision 70)
@@ -54,5 +54,8 @@
 {
 private:
-   std::list<TComSPS>      m_acSPSBuffer;
+#if VIDYO_VPS_INTEGRATION
+  TComVPS                 m_cVPS;
+#endif
+  std::list<TComSPS>      m_acSPSBuffer;
 
   // functional classes
