Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/CommonDef.h	(revision 730)
@@ -121,7 +121,6 @@
 #define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
 #define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
-#if H_3D
 #define MIN_INT                     (-2147483647-1) // < min. value of signed 32-bit integer
-#endif
+
 #define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  ///< max. value of signed 64-bit integer
 #define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComPic.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComPic.cpp	(revision 730)
@@ -503,7 +503,7 @@
 {
   if ( legend )
-    std::cout  << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            << std::endl;
+    std::cout  << std::endl << "LId"        << "\t" << "POC"   << "\t" << "Rec"          << "\t" << "Ref"                       << "\t" << "LT"            <<  "\t" << "OutMark" <<  "\t" << "OutFlag" << std::endl;
   else
-    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << std::endl;
+    std::cout  << getLayerId() << "\t" << getPOC()<< "\t" << getReconMark() << "\t" << getSlice(0)->isReferenced() << "\t" << getIsLongTerm() << "\t" << getOutputMark() << "\t" << getSlice(0)->getPicOutputFlag() <<std::endl;
 }
 
@@ -524,5 +524,4 @@
   return pcPic;
 }
-
 #if H_3D
 TComPic* TComPicLists::getPic( Int viewIndex, Bool depthFlag, Int poc )
@@ -530,5 +529,5 @@
   return getPic   ( m_vps->getLayerIdInNuh( viewIndex, depthFlag ), poc );
 }
-
+#endif
 Void TComPicLists::print()
 {
@@ -571,4 +570,5 @@
 }
 
+#if H_3D
 TComPicYuv* TComPicLists::getPicYuv( Int viewIndex, Bool depthFlag, Int poc, Bool recon )
 {  
@@ -576,4 +576,5 @@
   return getPicYuv( layerIdInNuh, poc, recon );
 }
+
 #if H_3D_ARP
 TComList<TComPic*>* TComPicLists::getPicList( Int layerIdInNuh )
@@ -593,5 +594,5 @@
 }
 #endif
-#endif // H_3D
+#endif
 #endif // H_MV
 
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.cpp	(revision 730)
@@ -573,5 +573,9 @@
 #if H_MV_ENC_DEC_TRAC
 #if ENC_DEC_TRACE
+#if H_MV_FIX_TRACE_FILE
+Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt )
+#else
 Void writeToTraceFile( Char* symbolName, Int val, Bool doIt )
+#endif
 {
   if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  ) 
@@ -588,5 +592,9 @@
 }
 
+#if H_MV_FIX_TRACE_FILE
+Void writeToTraceFile( const Char* symbolName, Bool doIt )
+#else
 Void writeToTraceFile( Char* symbolName, Bool doIt )
+#endif
 {
   if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  ) 
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComRom.h	(revision 730)
@@ -236,6 +236,11 @@
 
 
+#if H_MV_FIX_TRACE_FILE
+ Void           writeToTraceFile( const Char* symbolName, Int val, Bool doIt );
+ Void           writeToTraceFile( const Char* symbolName, Bool doIt );
+#else
  Void           writeToTraceFile( Char* symbolName, Int val, Bool doIt );
  Void           writeToTraceFile( Char* symbolName, Bool doIt );
+#endif
 #endif
 #else
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.cpp	(revision 730)
@@ -110,4 +110,7 @@
 #endif
 , m_pocResetFlag                  (false)
+#if H_MV_6_RALS_O0149_11
+, m_crossLayerBlaFlag             (false)
+#endif
 , m_discardableFlag               (false)
 , m_interLayerPredEnabledFlag     (false)
@@ -148,5 +151,5 @@
   for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
   {
-   m_interLayerPredLayerIdc[ i ] = i;
+    m_interLayerPredLayerIdc[ i ] = -1;
   }
 #endif
@@ -1709,6 +1712,9 @@
 , m_hrdOpSetIdx               (NULL)
 , m_cprmsPresentFlag          (NULL)
+#if H_MV_6_HRD_O0217_13
+, m_dpbSize                   (NULL)
+#endif
 #if H_MV
-, m_vpsVUI                 (  NULL )
+, m_vpsVUI                    (NULL)
 #endif
 {
@@ -1724,5 +1730,9 @@
     for( Int layerId = 0; layerId < MAX_VPS_NUH_LAYER_ID_PLUS1; layerId++ )
     {
+#if H_MV_6_HRD_O0217_13
+      m_layerIdIncludedFlag[lsIdx][layerId] = (( lsIdx == 0 ) && ( layerId == 0 )) ; 
+#else
       m_layerIdIncludedFlag[lsIdx][layerId] = false; 
+#endif
     }
   } 
@@ -1738,5 +1748,9 @@
   m_moreOutputLayerSetsThanDefaultFlag = false;   
   m_numAddOutputLayerSetsMinus1        = -1;   
+#if H_MV_6_PS_0109_25
+  m_defaultOneTargetOutputLayerIdc     = 0; 
+#else
   m_defaultOneTargetOutputLayerFlag    = false; 
+#endif
   
   for ( Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++)
@@ -1748,6 +1762,8 @@
       m_outputLayerFlag[i][j] = false; 
     }
-  }
-  
+  }  
+#if H_MV_6_GEN_0153_28
+  m_altOutputLayerFlag       = false; 
+#endif
   m_maxOneActiveRefLayerFlag = false; 
   m_directDepTypeLenMinus2   = 0;         
@@ -1786,6 +1802,11 @@
     m_layerIdInNuh      [i] = ( i == 0 ) ? 0 : -1; 
     m_numDirectRefLayers[i] = 0; 
+#if !H_MV_6_ILDDS_O0225_30
     m_maxTidIlRefPicPlus1[i] = 7;
+#endif
     m_vpsRepFormatIdx    [i] = 0; 
+#if H_MV_6_MISC_O0062_31
+    m_pocLsbNotPresentFlag[i] = 0;
+#endif
     m_repFormat          [i] = NULL; 
     m_viewIdVal          [i] = 0; 
@@ -1821,4 +1842,7 @@
       m_directDependencyType[i][j] = -1; 
       m_refLayerId[i][j]           = -1; 
+#if H_MV_6_ILDDS_O0225_30      
+      m_maxTidIlRefPicsPlus1[i][j]  = 7;
+#endif
     }
 
@@ -1833,4 +1857,8 @@
   }
   m_vpsVUI = new TComVPSVUI; 
+#if H_MV_6_HRD_O0217_13
+  m_dpbSize = new TComDpbSize; 
+#endif
+#
 #if H_3D
   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
@@ -1866,4 +1894,8 @@
 #if H_MV
   if ( m_vpsVUI          != NULL )     delete m_vpsVUI; 
+#if H_MV_6_HRD_O0217_13
+  if ( m_dpbSize         != NULL )     delete m_dpbSize; 
+#endif
+
   for( Int i = 0; i < MAX_NUM_LAYERS; i++ )
   {
@@ -2068,4 +2100,7 @@
   assert( lsIdx >= 0 ); 
   assert( lsIdx <= getVpsNumLayerSetsMinus1() ); 
+#if H_MV_6_HRD_O0217_13
+  return (Int) m_layerSetLayerIdList[ lsIdx ].size(); 
+#else
   Int numLayersInIdList = 0; 
   for (Int layerId = 0; layerId < getVpsMaxLayerId(); layerId++ )
@@ -2073,6 +2108,21 @@
     numLayersInIdList += ( getLayerIdIncludedFlag( lsIdx, layerId ) ); 
   }
+
   return numLayersInIdList;
-}
+#endif
+}
+
+#if H_MV_6_HRD_O0217_13
+Int    TComVPS::getNumOutputLayerSets() 
+{
+  Int numOutputLayerSets = getVpsNumberLayerSetsMinus1( ) + 1; 
+  if ( getMoreOutputLayerSetsThanDefaultFlag( ) )
+  {      
+    numOutputLayerSets += (getNumAddOutputLayerSetsMinus1( ) + 1); 
+  }
+  return numOutputLayerSets; 
+}
+#endif
+
 Int TComVPS::getNumViews()
 {
@@ -2104,4 +2154,42 @@
   return dependentFlag;
 }
+
+#if H_MV_6_HRD_O0217_13
+Void TComVPS::deriveLayerSetLayerIdList()
+{
+  m_layerSetLayerIdList.resize( getVpsNumLayerSetsMinus1() + 1 ); 
+  for (Int i = 0; i <= getVpsNumLayerSetsMinus1(); i++ )
+  {
+    for( Int m = 0; m  <= getVpsMaxLayerId(); m++ )
+    {
+      if( getLayerIdIncludedFlag( i, m) ) 
+      {
+        m_layerSetLayerIdList[ i ].push_back( m );        
+      }
+    }
+  }
+}
+
+Void TComVPS::deriveTargetLayerIdLists()
+{
+  m_targetDecLayerIdLists.resize( getNumOutputLayerSets() ); 
+  m_targetOptLayerIdLists.resize( getNumOutputLayerSets() ); 
+
+  for (Int targetOptLayerSetIdx = 0; targetOptLayerSetIdx < getNumOutputLayerSets(); targetOptLayerSetIdx++ )
+  {
+    Int targetDecLayerSetIdx = getOutputLayerSetIdxMinus1( targetOptLayerSetIdx ) + 1;     
+    Int lsIdx                = targetDecLayerSetIdx;
+
+    for( Int j = 0; j < getNumLayersInIdList( lsIdx ); j++ )
+    {
+      m_targetDecLayerIdLists[targetOptLayerSetIdx].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] ); 
+      if( getOutputLayerFlag( targetOptLayerSetIdx, j  )) // This seems to be wrong in draft text
+      {
+        m_targetOptLayerIdLists[targetOptLayerSetIdx].push_back( m_layerSetLayerIdList[ lsIdx ][ j ] );
+      }
+    }  
+  }
+}
+#endif
 #endif // H_MV
 
@@ -2157,5 +2245,11 @@
 , m_spsInferScalingListFlag   ( false )
 , m_spsScalingListRefLayerId  ( 0 )
+
+#if !H_MV_6_PS_REP_FORM_18_19_20
 , m_updateRepFormatFlag       ( true ) 
+#else
+, m_updateRepFormatFlag       ( false ) 
+, m_spsRepFormatIdx           ( 0 )
+#endif
 , m_interViewMvVertConstraintFlag (false)
 #endif
@@ -2173,4 +2267,27 @@
   ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
   ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
+#if H_MV_6_PSEM_O0142_3
+  m_spsExtensionFlag = false; 
+  for( Int i = 0; i < PS_EX_T_MAX_NUM; i++ ) 
+  {
+    m_spsExtensionTypeFlag[ i ] = false;
+  }
+#endif
+#if H_MV_6_SHVC_O0098_36
+  m_numScaledRefLayerOffsets = 0; 
+
+  for (Int i = 0; i < MAX_NUM_SCALED_REF_LAYERS; i++ )
+  {
+    m_scaledRefLayerId             [i] = -1;
+  }
+
+  for (Int i = 0; i < MAX_NUM_LAYERS; i++ )
+  {
+    m_scaledRefLayerLeftOffset     [i] = 0;
+    m_scaledRefLayerTopOffset      [i] = 0;
+    m_scaledRefLayerRightOffset    [i] = 0;
+    m_scaledRefLayerBottomOffset   [i] = 0;
+  }
+#endif
 }
 
@@ -2353,7 +2470,13 @@
   if ( layerIdCurr > 0 )
   { 
+#if H_MV_6_PS_REP_FORM_18_19_20
+    Int            repFormatIdx = getUpdateRepFormatFlag() ?  getSpsRepFormatIdx() : vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ;
+    TComRepFormat* repFormat    = vps->getRepFormat( repFormatIdx ); 
+#else
     TComRepFormat* repFormat = vps->getRepFormat( vps->getVpsRepFormatIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); 
+
     if ( !getUpdateRepFormatFlag() )
     {        
+#endif
       setChromaFormatIdc( repFormat->getChromaFormatVpsIdc() );         
       //// ToDo: add when supported: 
@@ -2368,6 +2491,10 @@
       setBitDepthC             ( repFormat->getBitDepthVpsChromaMinus8() + 8 ); 
       setQpBDOffsetC           ( (Int) (6* ( getBitDepthC() -8 ) ) );
+#if !H_MV_6_PS_REP_FORM_18_19_20
     }
     else
+#else
+    if ( getLayerId() > 0 && getUpdateRepFormatFlag() )
+#endif
     {
       assert( getChromaFormatIdc()      <=  repFormat->getChromaFormatVpsIdc()         ); 
@@ -2398,4 +2525,5 @@
   }
 }
+
 #endif
 #if H_3D
@@ -2668,5 +2796,5 @@
 #if H_MV
 Void TComSlice::createInterLayerReferencePictureSet( TComPicLists* ivPicLists, std::vector<TComPic*>& refPicSetInterLayer0, std::vector<TComPic*>& refPicSetInterLayer1 )
-{
+{  
   refPicSetInterLayer0.clear(); 
   refPicSetInterLayer1.clear(); 
@@ -2713,7 +2841,9 @@
 
 }
+
+
 Void TComSlice::markIvRefPicsAsUnused( TComPicLists* ivPicLists, std::vector<Int> targetDecLayerIdSet, TComVPS* vps, Int curLayerId, Int curPoc )
 {
-  // Fill targetDecLayerIdSet with all layers if empty. 
+  // Fill targetDecLayerIdSet with all layers if empty (at encoder side) 
   if (targetDecLayerIdSet.size() == 0 )    
   {
@@ -2722,5 +2852,5 @@
       targetDecLayerIdSet.push_back( vps->getLayerIdInNuh( layerIdInVps ) ); 
     }
-  }     
+  }  
 
   Int numTargetDecLayers = (Int) targetDecLayerIdSet.size(); 
@@ -2731,6 +2861,6 @@
     {
       break; 
+    }        
   }        
-  }        
 
   for( Int i = 0; i <= latestDecIdx; i++ ) 
@@ -2739,28 +2869,35 @@
     {
       TComPic* pcPic = ivPicLists->getPic( targetDecLayerIdSet[ i ], curPoc ); 
-      if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() ) 
-      { 
-        Bool remainingInterLayerReferencesFlag = false; 
-        for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
+#if H_MV_LAYER_WISE_STARTUP
+      if ( pcPic )
+      {
+#endif
+        if( pcPic->getSlice(0)->isReferenced() && pcPic->getSlice(0)->getTemporalLayerNonReferenceFlag() ) 
         { 
-          TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS(); 
-          if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) )
+          Bool remainingInterLayerReferencesFlag = false; 
+          for( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ )
+          { 
+            TComVPS* vpsSlice = pcPic->getSlice(0)->getVPS(); 
+            if ( vps->nuhLayerIdIncluded( targetDecLayerIdSet[ j ] ) )
+            {
+              for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdSet[ j ] ); k++ )
+              {
+                if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdSet[ j ],  k  ) )
+                {
+                  remainingInterLayerReferencesFlag = true;
+                }
+              }
+            }
+          }
+          if( !remainingInterLayerReferencesFlag )
           {
-            for( Int k = 0; k < vpsSlice->getNumDirectRefLayers( targetDecLayerIdSet[ j ] ); k++ )
-            {
-              if ( targetDecLayerIdSet[ i ] == vpsSlice->getRefLayerId( targetDecLayerIdSet[ j ],  k  ) )
-              {
-                remainingInterLayerReferencesFlag = true;
+            pcPic->getSlice(0)->setReferenced( false );                   
           }
         }
-          }
-        }
-        if( !remainingInterLayerReferencesFlag )
-        {
-          pcPic->getSlice(0)->setReferenced( false );                   
-      }
-    }
-  }
-}
+#if H_MV_LAYER_WISE_STARTUP
+      }
+#endif
+    }
+  }
 }
 
@@ -2773,5 +2910,5 @@
     {      
       if (rIdx == 0 && li == 0) m_apcRefPicList[li][rIdx]->print( true );
-        
+
       m_apcRefPicList[li][rIdx]->print( false );
     }
@@ -2816,4 +2953,53 @@
   return pcPic;
 }
+
+
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+Int  TComSlice::getRefLayerPicFlag( Int i ) 
+{
+  TComVPS* vps = getVPS(); 
+  Int refLayerIdx = vps->getLayerIdInVps( vps->getRefLayerId( getLayerId(), i ) ); 
+
+  Bool refLayerPicFlag = ( vps->getSubLayersVpsMaxMinus1( refLayerIdx ) >=  getTLayer() )  && 
+    ( vps->getMaxTidIlRefPicsPlus1( refLayerIdx, vps->getLayerIdInVps( getLayerId() )) > getTLayer() ); 
+
+  return refLayerPicFlag;       
+}    
+
+Int TComSlice::getRefLayerPicIdc( Int j ) 
+{  
+  Int refLayerPicIdc = -1; 
+  Int curj = 0; 
+  for( Int i = 0;  i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ )
+  {
+    if( getRefLayerPicFlag( i ) )
+    {
+      if ( curj == j ) 
+      {
+        refLayerPicIdc = i;         
+        break;
+      }
+      curj++; 
+    }
+  }
+
+  assert( curj == j ); 
+  assert( refLayerPicIdc != -1 ); 
+  return refLayerPicIdc; 
+}
+
+Int  TComSlice::getNumRefLayerPics( )
+{  
+  Int numRefLayerPics = 0; 
+  for( Int i = 0;  i < getVPS()->getNumDirectRefLayers( getLayerId()) ; i++ )
+  {
+    numRefLayerPics += getRefLayerPicFlag( i ); 
+  }
+  return numRefLayerPics; 
+}
+#endif
+
+
+
 Int TComSlice::getNumActiveRefLayerPics()
 {
@@ -2826,5 +3012,9 @@
   else if (getVPS()->getAllRefLayersActiveFlag() )
   {
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    numActiveRefLayerPics = getNumRefLayerPics(); 
+#else
     numActiveRefLayerPics = getVPS()->getNumDirectRefLayers( getLayerId() );
+#endif
   }
   else if ( !getInterLayerPredEnabledFlag() )
@@ -2834,5 +3024,9 @@
   else if( getVPS()->getMaxOneActiveRefLayerFlag() || getVPS()->getNumDirectRefLayers( getLayerId() ) == 1 )
   {
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    numActiveRefLayerPics = getRefLayerPicFlag( 0 ) ? 1 : 0; 
+#else
     numActiveRefLayerPics = 1; 
+#endif
   }
   else
@@ -3434,4 +3628,7 @@
 TComVPSVUI::TComVPSVUI()
 {
+#if H_MV_6_PS_O0223_29
+  m_crossLayerIrapAlignedFlag = true; 
+#endif
   m_bitRatePresentVpsFlag = false;
   m_picRatePresentVpsFlag = false;
@@ -3461,4 +3658,80 @@
     }
   }
-}
-#endif
+#if H_MV_6_PS_O0118_33  
+  for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ )
+  {
+    m_videoSignalInfo          [i] = NULL;     
+  }
+#endif
+
+#if H_MV_6_HRD_O0164_15
+  m_vpsVuiBspHrdPresentFlag = false; 
+  m_vpsVuiBspHrdParameters  = new TComVpsVuiBspHrdParameters();
+#endif
+}
+
+#if H_MV_6_PS_O0118_33
+TComVPSVUI::~TComVPSVUI()
+{
+  for ( Int i = 0; i < MAX_NUM_VIDEO_SIGNAL_INFO; i++ )
+  {
+    if (m_videoSignalInfo[ i ] != NULL )      delete m_videoSignalInfo[ i ];    
+    m_videoSignalInfo    [ i ] = NULL; 
+  }
+
+#if H_MV_6_HRD_O0164_15
+  if ( m_vpsVuiBspHrdParameters ) delete m_vpsVuiBspHrdParameters;
+  m_vpsVuiBspHrdParameters = NULL; 
+#endif
+}
+#endif
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+Void TComRepFormat::inferChromaAndBitDepth( TComRepFormat* prevRepFormat, Bool encoderFlag )
+{
+  if ( !encoderFlag )
+  {
+    setChromaAndBitDepthVpsPresentFlag( prevRepFormat->getChromaAndBitDepthVpsPresentFlag() );
+    setSeparateColourPlaneVpsFlag     ( prevRepFormat->getSeparateColourPlaneVpsFlag     () );
+    setBitDepthVpsLumaMinus8          ( prevRepFormat->getBitDepthVpsLumaMinus8          () );
+    setBitDepthVpsChromaMinus8        ( prevRepFormat->getBitDepthVpsChromaMinus8        () );
+  }
+  else
+  {
+    assert( getChromaAndBitDepthVpsPresentFlag() == prevRepFormat->getChromaAndBitDepthVpsPresentFlag() );
+    assert( getSeparateColourPlaneVpsFlag     () == prevRepFormat->getSeparateColourPlaneVpsFlag     () );
+    assert( getBitDepthVpsLumaMinus8          () == prevRepFormat->getBitDepthVpsLumaMinus8          () );
+    assert( getBitDepthVpsChromaMinus8        () == prevRepFormat->getBitDepthVpsChromaMinus8        () );
+  }
+}
+#endif
+
+#if H_MV_6_HRD_O0164_15
+Void TComVpsVuiBspHrdParameters::checkLayerInBspFlag( TComVPS* vps, Int h )
+{
+  // It is a requirement of bitstream conformance that bitstream partition with index j shall not include 
+  // direct or indirect reference layers of any layers in bitstream partition i for any values of i and j 
+  // in the range of 0 to num_bitstream_partitions[ h ]  1, inclusive, such that i is less than j.
+
+  for ( Int partJ = 0; partJ < getNumBitstreamPartitions( h ); partJ++ )
+  {        
+    for ( Int partI = 0; partI < partJ; partI++ )
+    {
+      for ( Int layerJ = 0; layerJ < vps->getMaxLayersMinus1(); layerJ++ )
+      {
+        if ( m_layerInBspFlag[ h ][partJ][layerJ ] )
+        {
+          for ( Int layerI = 0; layerI < vps->getMaxLayersMinus1(); layerI++ )
+          {
+            if ( m_layerInBspFlag[ h ][partI][layerI] )
+            {
+              assert( !vps->getInDirectDependencyFlag( layerI, layerJ ) ); 
+            }
+          }
+        }
+      }
+    }
+  }
+}
+#endif
+#endif
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TComSlice.h	(revision 730)
@@ -36,4 +36,5 @@
 */
 
+
 #ifndef __TCOMSLICE__
 #define __TCOMSLICE__
@@ -62,4 +63,7 @@
 // ====================================================================================================================
 
+#if H_MV_6_HRD_O0164_15
+class TComVPS; 
+#endif
 /// Reference Picture Set class
 class TComReferencePictureSet
@@ -403,7 +407,79 @@
 
 #if H_MV
+
+#if H_MV_6_PS_O0118_33
+class TComVideoSignalInfo
+{
+private: 
+  Int  m_videoVpsFormat;
+  Bool m_videoFullRangeVpsFlag;
+  Int  m_colourPrimariesVps;
+  Int  m_transferCharacteristicsVps;
+  Int  m_matrixCoeffsVps;
+public: 
+  Void setVideoVpsFormat( Int  val ) { m_videoVpsFormat = val; } 
+  Int  getVideoVpsFormat(  ) { return m_videoVpsFormat; } 
+
+  Void setVideoFullRangeVpsFlag( Bool flag ) { m_videoFullRangeVpsFlag = flag; } 
+  Bool getVideoFullRangeVpsFlag(  ) { return m_videoFullRangeVpsFlag; } 
+
+  Void setColourPrimariesVps( Int  val ) { m_colourPrimariesVps = val; } 
+  Int  getColourPrimariesVps(  ) { return m_colourPrimariesVps; } 
+
+  Void setTransferCharacteristicsVps( Int  val ) { m_transferCharacteristicsVps = val; } 
+  Int  getTransferCharacteristicsVps(  ) { return m_transferCharacteristicsVps; } 
+
+  Void setMatrixCoeffsVps( Int  val ) { m_matrixCoeffsVps = val; } 
+  Int  getMatrixCoeffsVps(  ) { return m_matrixCoeffsVps; } 
+};
+#endif
+#if H_MV_6_HRD_O0164_15
+class TComVpsVuiBspHrdParameters
+{
+private: 
+  Int  m_vpsNumBspHrdParametersMinus1;
+  Bool m_bspCprmsPresentFlag[MAX_NUM_BSP_HRD_PARAMETERS];
+  Int  m_numBitstreamPartitions[MAX_VPS_OP_SETS_PLUS1];
+  Bool m_layerInBspFlag[MAX_VPS_OP_SETS_PLUS1][MAX_NUM_BSP_HRD_PARAMETERS][MAX_NUM_LAYERS];
+  Int  m_numBspSchedCombinations[MAX_VPS_OP_SETS_PLUS1];
+  Int  m_bspCombHrdIdx[MAX_VPS_OP_SETS_PLUS1][MAX_NUM_BSP_HRD_PARAMETERS][MAX_NUM_BSP_SCHED_COMBINATION];
+  Int  m_bspCombSchedIdx[MAX_VPS_OP_SETS_PLUS1][MAX_NUM_BSP_HRD_PARAMETERS][MAX_NUM_BSP_SCHED_COMBINATION];
+  TComHRD* m_hrdParameters[MAX_NUM_BSP_HRD_PARAMETERS]; 
+public: 
+
+  Void setVpsNumBspHrdParametersMinus1( Int  val ) { m_vpsNumBspHrdParametersMinus1 = val; } 
+  Int  getVpsNumBspHrdParametersMinus1(  ) { return m_vpsNumBspHrdParametersMinus1; } 
+
+  Void setBspCprmsPresentFlag( Int i, Bool flag ) { m_bspCprmsPresentFlag[i] = flag; } 
+  Bool getBspCprmsPresentFlag( Int i ) { return m_bspCprmsPresentFlag[i]; } 
+
+  Void setNumBitstreamPartitions( Int h, Int  val ) { m_numBitstreamPartitions[h] = val; } 
+  Int  getNumBitstreamPartitions( Int h ) { return m_numBitstreamPartitions[h]; } 
+
+  Void setLayerInBspFlag( Int h, Int i, Int j, Bool flag ) { m_layerInBspFlag[h][i][j] = flag; } 
+  Bool getLayerInBspFlag( Int h, Int i, Int j ) { return m_layerInBspFlag[h][i][j]; } 
+  Void checkLayerInBspFlag ( TComVPS* vps, Int h );  
+
+  Void setNumBspSchedCombinations( Int h, Int  val ) { m_numBspSchedCombinations[h] = val; } 
+  Int  getNumBspSchedCombinations( Int h ) { return m_numBspSchedCombinations[h]; } 
+
+  Void setBspCombHrdIdx( Int h, Int i, Int j, Int  val ) { m_bspCombHrdIdx[h][i][j] = val; } 
+  Int  getBspCombHrdIdx( Int h, Int i, Int j ) { return m_bspCombHrdIdx[h][i][j]; } 
+
+  Void setBspCombSchedIdx( Int h, Int i, Int j, Int  val ) { m_bspCombSchedIdx[h][i][j] = val; } 
+  Int  getBspCombSchedIdx( Int h, Int i, Int j ) { return m_bspCombSchedIdx[h][i][j]; } 
+
+  Void setHrdParametermeters( Int k, TComHRD* val  ) {  m_hrdParameters[k] = val; }; 
+  TComHRD* getHrdParametermeters( Int k ) {  return m_hrdParameters[k]; }; 
+};
+
+#endif
 class TComVPSVUI
-{
+{ 
 private:
+#if H_MV_6_PS_O0223_29
+  Bool m_crossLayerPicTypeAlignedFlag;
+  Bool m_crossLayerIrapAlignedFlag;
+#endif
   Bool m_bitRatePresentVpsFlag;
   Bool m_picRatePresentVpsFlag;
@@ -413,13 +489,40 @@
   Int  m_maxBitRate                  [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];
   Int  m_constantPicRateIdc          [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];
-  Int  m_avgPicRate                  [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];
+  Int  m_avgPicRate                  [MAX_VPS_OP_SETS_PLUS1][MAX_TLAYER];  
+#if H_MV_6_O0226_37
+  Bool m_tilesNotInUseFlag;
+  Bool m_tilesInUseFlag              [MAX_NUM_LAYERS];
+  Bool m_loopFilterNotAcrossTilesFlag[MAX_NUM_LAYERS];
+#endif  
   Bool m_tileBoundariesAlignedFlag   [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
+#if H_MV_6_O0226_37
+  Bool m_wppNotInUseFlag;
+  Bool m_wppInUseFlag                [MAX_NUM_LAYERS];
+#endif
   Bool m_ilpRestrictedRefLayersFlag;
   Int  m_minSpatialSegmentOffsetPlus1[MAX_NUM_LAYERS][MAX_NUM_LAYERS];
   Bool m_ctuBasedOffsetEnabledFlag   [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
   Int  m_minHorizontalCtuOffsetPlus1 [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
+#if H_MV_6_PS_O0118_33
+  Bool m_videoSignalInfoIdxPresentFlag;
+  Int  m_vpsNumVideoSignalInfoMinus1;
+  TComVideoSignalInfo* m_videoSignalInfo[MAX_NUM_VIDEO_SIGNAL_INFO];   
+  Int  m_vpsVideoSignalInfoIdx       [MAX_NUM_VIDEO_SIGNAL_INFO];
+#endif
+#if H_MV_6_HRD_O0164_15
+  Bool m_vpsVuiBspHrdPresentFlag;
+  TComVpsVuiBspHrdParameters* m_vpsVuiBspHrdParameters; 
+#endif
 
 public: 
-  TComVPSVUI();;
+  TComVPSVUI();
+  ~TComVPSVUI(); 
+#if H_MV_6_PS_O0223_29
+  Void setCrossLayerPicTypeAlignedFlag( Bool flag ) { m_crossLayerPicTypeAlignedFlag = flag; } 
+  Bool getCrossLayerPicTypeAlignedFlag(  ) { return m_crossLayerPicTypeAlignedFlag; } 
+
+  Void setCrossLayerIrapAlignedFlag( Bool flag ) { m_crossLayerIrapAlignedFlag = flag; } 
+  Bool getCrossLayerIrapAlignedFlag(  ) { return m_crossLayerIrapAlignedFlag; } 
+#endif
 
   Void setBitRatePresentVpsFlag( Bool flag ) { m_bitRatePresentVpsFlag = flag; } 
@@ -447,7 +550,26 @@
   Int  getAvgPicRate( Int i, Int j ) { return m_avgPicRate[i][j]; } 
 
+#if H_MV_6_O0226_37
+  Void setTilesNotInUseFlag( Bool flag ) { m_tilesNotInUseFlag = flag; } 
+  Bool getTilesNotInUseFlag(  ) { return m_tilesNotInUseFlag; } 
+
+  Void setTilesInUseFlag( Int i, Bool flag ) { m_tilesInUseFlag[i] = flag; } 
+  Bool getTilesInUseFlag( Int i ) { return m_tilesInUseFlag[i]; } 
+
+  Void setLoopFilterNotAcrossTilesFlag( Int i, Int  val ) { m_loopFilterNotAcrossTilesFlag[i] = val; } 
+  Bool getLoopFilterNotAcrossTilesFlag( Int i ) { return m_loopFilterNotAcrossTilesFlag[i]; } 
+#endif
+
   Void setTileBoundariesAlignedFlag( Int i, Int j, Bool flag ) { m_tileBoundariesAlignedFlag[i][j] = flag; } 
   Bool getTileBoundariesAlignedFlag( Int i, Int j ) { return m_tileBoundariesAlignedFlag[i][j]; } 
 
+#if H_MV_6_O0226_37
+  Void setWppNotInUseFlag( Bool flag ) { m_wppNotInUseFlag = flag; } 
+  Bool getWppNotInUseFlag(  ) { return m_wppNotInUseFlag; } 
+
+  Void setWppInUseFlag( Int i, Bool flag ) { m_wppInUseFlag[i] = flag; } 
+  Bool getWppInUseFlag( Int i ) { return m_wppInUseFlag[i]; } 
+#endif
+
   Void setIlpRestrictedRefLayersFlag( Bool flag ) { m_ilpRestrictedRefLayersFlag = flag; } 
   Bool getIlpRestrictedRefLayersFlag(  ) { return m_ilpRestrictedRefLayersFlag; } 
@@ -462,9 +584,34 @@
   Int  getMinHorizontalCtuOffsetPlus1( Int i, Int j ) { return m_minHorizontalCtuOffsetPlus1[i][j]; } 
 
+#if H_MV_6_PS_O0118_33
+  Void setVideoSignalInfoIdxPresentFlag( Bool flag ) { m_videoSignalInfoIdxPresentFlag = flag; } 
+  Bool getVideoSignalInfoIdxPresentFlag(  ) { return m_videoSignalInfoIdxPresentFlag; } 
+
+  Void    setVideoSignalInfo( Int i, TComVideoSignalInfo* val )                        { m_videoSignalInfo[i] = val;  }  
+  TComVideoSignalInfo* getVideoSignalInfo( Int i )                                     { return m_videoSignalInfo[i]; }
+
+  Void setVpsNumVideoSignalInfoMinus1( Int  val ) { m_vpsNumVideoSignalInfoMinus1 = val; } 
+  Int  getVpsNumVideoSignalInfoMinus1(  ) { return m_vpsNumVideoSignalInfoMinus1; } 
+
+  Void setVpsVideoSignalInfoIdx( Int i, Int  val ) { m_vpsVideoSignalInfoIdx[i] = val; } 
+  Int  getVpsVideoSignalInfoIdx( Int i ) { return m_vpsVideoSignalInfoIdx[i]; } 
+#endif
+
+#if H_MV_6_HRD_O0164_15
+  Void setVpsVuiBspHrdPresentFlag( Bool flag ) { m_vpsVuiBspHrdPresentFlag = flag; } 
+  Bool getVpsVuiBspHrdPresentFlag(  ) { return m_vpsVuiBspHrdPresentFlag; }
+
+  Void setVpsVuiBspHrdParameters( TComVpsVuiBspHrdParameters* val) {  m_vpsVuiBspHrdParameters = val; } 
+  TComVpsVuiBspHrdParameters* getVpsVuiBspHrdParameters(  ) { return m_vpsVuiBspHrdParameters; }
+#endif
 };
+
 
 class TComRepFormat
 {
 private:
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Bool m_chromaAndBitDepthVpsPresentFlag;
+#endif
   Int  m_chromaFormatVpsIdc;
   Bool m_separateColourPlaneVpsFlag;
@@ -477,4 +624,11 @@
   TComRepFormat() { };  
 
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Void setChromaAndBitDepthVpsPresentFlag( Bool flag ) { m_chromaAndBitDepthVpsPresentFlag = flag; } 
+  Bool getChromaAndBitDepthVpsPresentFlag(  ) { return m_chromaAndBitDepthVpsPresentFlag; } 
+  Void checkChromaAndBitDepthVpsPresentFlag( Int i ) { assert( i != 0 || m_chromaAndBitDepthVpsPresentFlag ); } // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1.  
+  Void inferChromaAndBitDepth( TComRepFormat* prevRepFormat, Bool encoderFlag );
+#endif
+
   Void setChromaFormatVpsIdc( Int  val ) { m_chromaFormatVpsIdc = val; } 
   Int  getChromaFormatVpsIdc(  ) { return m_chromaFormatVpsIdc; } 
@@ -494,4 +648,52 @@
   Void setBitDepthVpsChromaMinus8( Int  val ) { m_bitDepthVpsChromaMinus8 = val; } 
   Int  getBitDepthVpsChromaMinus8(  ) { return m_bitDepthVpsChromaMinus8; } 
+};
+#endif
+
+#if H_MV_6_HRD_O0217_13
+class TComDpbSize
+{
+private:
+  Bool  m_subLayerFlagInfoPresentFlag[MAX_VPS_OUTPUTLAYER_SETS];
+  Bool  m_subLayerDpbInfoPresentFlag [MAX_VPS_OUTPUTLAYER_SETS][MAX_TLAYER];
+  Int   m_maxVpsDecPicBufferingMinus1[MAX_VPS_OUTPUTLAYER_SETS][MAX_NUM_LAYER_IDS][MAX_TLAYER];; 
+  Int   m_maxVpsNumReorderPics       [MAX_VPS_OUTPUTLAYER_SETS][MAX_TLAYER];
+  Int   m_maxVpsLatencyIncreasePlus1 [MAX_VPS_OUTPUTLAYER_SETS][MAX_TLAYER];
+
+public: 
+  TComDpbSize( )
+  {
+    for (Int i = 0; i < MAX_VPS_OUTPUTLAYER_SETS; i++ )
+    {      
+      m_subLayerFlagInfoPresentFlag[i]  = false;
+
+      for (Int j = 0; j < MAX_TLAYER; j++  )
+      {        
+        m_subLayerDpbInfoPresentFlag [i][j] = ( j == 0) ;
+        m_maxVpsNumReorderPics       [i][j] = 0;
+        m_maxVpsLatencyIncreasePlus1 [i][j] = 0;
+
+        for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++ )
+        {
+          m_maxVpsDecPicBufferingMinus1[i][k][j] = 0; 
+        }
+      }
+    }  
+  }  
+
+  Void setSubLayerFlagInfoPresentFlag( Int i, Bool flag ) { m_subLayerFlagInfoPresentFlag[i] = flag; } 
+  Bool getSubLayerFlagInfoPresentFlag( Int i ) { return m_subLayerFlagInfoPresentFlag[i]; } 
+
+  Void setSubLayerDpbInfoPresentFlag( Int i, Int j, Bool flag ) { m_subLayerDpbInfoPresentFlag[i][j] = flag; } 
+  Bool getSubLayerDpbInfoPresentFlag( Int i, Int j ) { return m_subLayerDpbInfoPresentFlag[i][j]; } 
+
+  Void setMaxVpsDecPicBufferingMinus1( Int i, Int k, Int j, Int  val ) { m_maxVpsDecPicBufferingMinus1[i][k][j] = val; } 
+  Int  getMaxVpsDecPicBufferingMinus1( Int i, Int k, Int j ) { return m_maxVpsDecPicBufferingMinus1[i][k][j]; } 
+
+  Void setMaxVpsNumReorderPics( Int i, Int j, Int  val ) { m_maxVpsNumReorderPics[i][j] = val; } 
+  Int  getMaxVpsNumReorderPics( Int i, Int j ) { return m_maxVpsNumReorderPics[i][j]; } 
+
+  Void setMaxVpsLatencyIncreasePlus1( Int i, Int j, Int  val ) { m_maxVpsLatencyIncreasePlus1[i][j] = val; } 
+  Int  getMaxVpsLatencyIncreasePlus1( Int i, Int j ) { return m_maxVpsLatencyIncreasePlus1[i][j]; } 
 };
 #endif
@@ -547,9 +749,22 @@
   Int         m_layerIdInNuh             [MAX_NUM_LAYER_IDS];
   Int         m_dimensionId              [MAX_NUM_LAYER_IDS][MAX_NUM_SCALABILITY_TYPES];  
+
+#if H_MV_6_PS_O0109_22
+  Int         m_viewIdLen;
+#else
   Int         m_viewIdLenMinus1;
+#endif
   Int         m_viewIdVal                [MAX_NUM_LAYERS];
   Bool        m_directDependencyFlag     [MAX_NUM_LAYER_IDS][MAX_NUM_LAYER_IDS];
+#if H_MV_6_ILDSD_O0120_26
+  Bool        m_vpsSubLayersMaxMinus1PresentFlag;
+  Int         m_subLayersVpsMaxMinus1    [MAX_NUM_LAYERS];
+#endif
   Bool        m_maxTidRefPresentFlag;
+#if H_MV_6_ILDDS_O0225_30
+  Int         m_maxTidIlRefPicsPlus1     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
+#else
   Int         m_maxTidIlRefPicPlus1      [MAX_NUM_LAYERS];
+#endif
   Bool        m_allRefLayersActiveFlag;
   Int         m_vpsNumberLayerSetsMinus1; 
@@ -559,15 +774,35 @@
   Bool        m_moreOutputLayerSetsThanDefaultFlag;
   Int         m_numAddOutputLayerSetsMinus1;    
+#if H_MV_6_PS_0109_25
+  Int         m_defaultOneTargetOutputLayerIdc;
+#else
   Bool        m_defaultOneTargetOutputLayerFlag;
+#endif
   Int         m_outputLayerSetIdxMinus1  [MAX_VPS_OUTPUTLAYER_SETS];  
   Bool        m_outputLayerFlag          [MAX_VPS_OUTPUTLAYER_SETS][MAX_VPS_NUH_LAYER_ID_PLUS1];
   Int         m_profileLevelTierIdx      [MAX_VPS_OUTPUTLAYER_SETS ];
+#if H_MV_6_GEN_0153_28
+  Bool        m_altOutputLayerFlag;
+#endif
   Bool        m_repFormatIdxPresentFlag;
   Int         m_vpsNumRepFormatsMinus1;
   Int         m_vpsRepFormatIdx          [MAX_NUM_LAYERS];
   TComRepFormat* m_repFormat             [MAX_NUM_LAYERS]; 
-  Bool        m_maxOneActiveRefLayerFlag;       
+  Bool        m_maxOneActiveRefLayerFlag;
+#if H_MV_6_MISC_O0062_31
+  Bool        m_pocLsbNotPresentFlag     [MAX_NUM_LAYERS];
+#endif
+
+#if H_MV_6_HRD_O0217_13
+  TComDpbSize* m_dpbSize; 
+#endif
+#if !H_MV_6_PS_O0223_29       
   Bool        m_crossLayerIrapAlignedFlag;
+#endif
   Int         m_directDepTypeLenMinus2;         
+#if H_MV_6_PS_O0096_21
+  Bool        m_defaultDirectDependencyFlag;
+  Int         m_defaultDirectDependencyType;
+#endif
   Bool        m_vpsVuiPresentFlag;
   TComVPSVUI* m_vpsVUI; 
@@ -588,6 +823,14 @@
   Int         m_motionPredRefLayerId     [MAX_NUM_LAYERS][MAX_NUM_LAYERS];
   Int         m_viewIndex                [MAX_NUM_LAYERS   ];
+  
+#if H_MV_6_HRD_O0217_13
+  std::vector< std::vector< Int> >       m_targetDecLayerIdLists;   //[TargetOptLayerSetIdx][i]
+  std::vector< std::vector< Int> >       m_targetOptLayerIdLists; 
+  std::vector< std::vector< Int> >       m_layerSetLayerIdList; 
+#endif
+
+
   Int         xGetDimBitOffset( Int j );
-  
+
   // VPS EXTENSION 2 SYNTAX ELEMENTS
 #if H_3D_ARP
@@ -649,5 +892,7 @@
   UInt    getMaxTLayers  ()                   { return m_uiMaxTLayers;   }
   Void    setMaxTLayers  (UInt t)             { m_uiMaxTLayers = t; }
-  
+#if H_MV_6_HRD_O0164_15
+  UInt    getMaxSubLayersMinus1()             { return m_uiMaxTLayers - 1;  }  // For consistency with draft spec
+#endif
 #if H_MV    
   UInt    getMaxLayersMinus1()                { return m_uiMaxLayersMinus1;  }; 
@@ -724,6 +969,11 @@
   Int     getDimensionId( Int layerIdInVps, Int scalIdx )                  { return m_dimensionId[layerIdInVps][scalIdx]; }
 
+#if H_MV_6_PS_O0109_22
+  Void    setViewIdLen( Int  val )                                         { m_viewIdLen = val; } 
+  Int     getViewIdLen(  )                                                 { return m_viewIdLen; } 
+#else
   Void    setViewIdLenMinus1( Int  val )                                   { m_viewIdLenMinus1 = val; } 
   Int     getViewIdLenMinus1(  )                                           { return m_viewIdLenMinus1; } 
+#endif
 
   Void    setViewIdVal( Int viewOrderIndex, Int  val )                     { m_viewIdVal[viewOrderIndex] = val; } 
@@ -731,9 +981,20 @@
   Void    setDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps, Bool val ) { m_directDependencyFlag[depLayeridInVps][refLayeridInVps] = val;  }
   Bool    getDirectDependencyFlag( Int depLayeridInVps, Int refLayeridInVps )           { return m_directDependencyFlag[depLayeridInVps][refLayeridInVps]; }
-
+#if H_MV_6_ILDSD_O0120_26
+  Void    setVpsSubLayersMaxMinus1PresentFlag( Bool flag )                 { m_vpsSubLayersMaxMinus1PresentFlag = flag; } 
+  Bool    getVpsSubLayersMaxMinus1PresentFlag(  )                          { return m_vpsSubLayersMaxMinus1PresentFlag; } 
+  Void    setSubLayersVpsMaxMinus1( Int i, Int  val )                      { m_subLayersVpsMaxMinus1[i] = val; } 
+  Int     getSubLayersVpsMaxMinus1( Int i )                                { return m_subLayersVpsMaxMinus1[i]; } 
+  Void    checkSubLayersVpsMaxMinus1( Int i )                              { assert( m_subLayersVpsMaxMinus1[i] >= 0 && m_subLayersVpsMaxMinus1[i] <= m_uiMaxTLayers - 1 ); }
+#endif
   Void    setMaxTidRefPresentFlag( Bool flag )                             { m_maxTidRefPresentFlag = flag; } 
   Bool    getMaxTidRefPresentFlag(  )                                      { return m_maxTidRefPresentFlag; } 
+#if H_MV_6_ILDDS_O0225_30
+  Void    setMaxTidIlRefPicsPlus1( Int i, Int j, Int  val )                { m_maxTidIlRefPicsPlus1[i][j] = val; } 
+  Int     getMaxTidIlRefPicsPlus1( Int i, Int j )                          { return m_maxTidIlRefPicsPlus1[i][j]; } 
+#else
   Void    setMaxTidIlRefPicPlus1( Int layerIdInVps, Int val )              { m_maxTidIlRefPicPlus1[ layerIdInVps ] = val;  } 
   Int     getMaxTidIlRefPicPlus1( Int layerIdInVps )                       { return m_maxTidIlRefPicPlus1[ layerIdInVps ]; } 
+#endif
   Void    setAllRefLayersActiveFlag( Bool flag )                           { m_allRefLayersActiveFlag = flag; } 
   Bool    getAllRefLayersActiveFlag(  )                                    { return m_allRefLayersActiveFlag; } 
@@ -749,5 +1010,7 @@
   Void    setProfileRefMinus1( Int profileTierLevelIdx, Int val )          { m_profileRefMinus1[ profileTierLevelIdx ] = val;  } 
   Int     getProfileRefMinus1( Int profileTierLevelIdx )                   { return m_profileRefMinus1[ profileTierLevelIdx ]; } 
-
+#if H_MV_6_PS_O0109_23
+  Void    checkProfileRefMinus1( Int i )                                   { assert( getProfileRefMinus1( i ) + 1 <= i ); };  //  The value of profile_ref_minus1[ i ] + 1 shall be less than or equal to i.
+#endif
   Void    setMoreOutputLayerSetsThanDefaultFlag( Bool flag )               { m_moreOutputLayerSetsThanDefaultFlag = flag; } 
   Bool    getMoreOutputLayerSetsThanDefaultFlag()                          { return m_moreOutputLayerSetsThanDefaultFlag; } 
@@ -755,7 +1018,13 @@
   Void    setNumAddOutputLayerSetsMinus1( Int val )                        { m_numAddOutputLayerSetsMinus1 = val; } 
   Int     getNumAddOutputLayerSetsMinus1( )                                { return m_numAddOutputLayerSetsMinus1; } 
-  
+
+#if H_MV_6_PS_0109_25  
+  Void    setDefaultOneTargetOutputLayerIdc( Int  val )                    { m_defaultOneTargetOutputLayerIdc = val; } 
+  Int     getDefaultOneTargetOutputLayerIdc(  )                            { return m_defaultOneTargetOutputLayerIdc; } 
+  Void    checkDefaultOneTargetOutputLayerIdc( )                           { assert( m_defaultOneTargetOutputLayerIdc >= 0 && m_defaultOneTargetOutputLayerIdc <= 1 ); }
+#else
   Void    setDefaultOneTargetOutputLayerFlag( Bool flag )                  { m_defaultOneTargetOutputLayerFlag = flag; } 
   Bool    getDefaultOneTargetOutputLayerFlag( )                            { return m_defaultOneTargetOutputLayerFlag; } 
+#endif
   
   Void    setOutputLayerSetIdxMinus1( Int outLayerSetIdx, Int val )        { m_outputLayerSetIdxMinus1[ outLayerSetIdx ]  = val; } 
@@ -764,8 +1033,14 @@
   Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )       { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
   Bool    getOutputLayerFlag( Int outLayerSetIdx, Int i )                  { return m_outputLayerFlag[ outLayerSetIdx ][ i ]; } 
+#if H_MV_6_HRD_O0217_13
+  Bool    inferOutputLayerFlag( Int layerSetIdx, Int i )                   { return ( getDefaultOneTargetOutputLayerIdc( ) == 0 || ( ( getDefaultOneTargetOutputLayerIdc( ) == 1 ) && ( i == m_layerSetLayerIdList[layerSetIdx].size() - 1  ) ));  }
+#endif
 
   Void    setProfileLevelTierIdx( Int outLayerSetIdx, Int val )            { m_profileLevelTierIdx[ outLayerSetIdx  = val ]; } 
   Int     getProfileLevelTierIdx( Int outLayerSetIdx )                     { return m_profileLevelTierIdx[ outLayerSetIdx ]; } 
-
+#if H_MV_6_GEN_0153_28
+  Void    setAltOutputLayerFlag( Bool flag )                               { m_altOutputLayerFlag = flag; } 
+  Bool    getAltOutputLayerFlag(  )                                        { return m_altOutputLayerFlag; } 
+#endif
   Void    setRepFormatIdxPresentFlag( Bool flag )                          { m_repFormatIdxPresentFlag = flag; } 
   Bool    getRepFormatIdxPresentFlag(  )                                   { return m_repFormatIdxPresentFlag; } 
@@ -781,9 +1056,28 @@
   Void    setMaxOneActiveRefLayerFlag( Bool flag)                          { m_maxOneActiveRefLayerFlag = flag; } 
   Bool    getMaxOneActiveRefLayerFlag( )                                   { return m_maxOneActiveRefLayerFlag; } 
+
+#if H_MV_6_HRD_O0217_13
+  Void    setDpbSize( TComDpbSize* val )                                   { assert( m_dpbSize != 0 ); m_dpbSize = val; } 
+  TComDpbSize* getDpbSize( )                                               { return m_dpbSize;} 
+#endif
+
+#if H_MV_6_MISC_O0062_31
+  Void    setPocLsbNotPresentFlag( Int i, Bool flag )                      { m_pocLsbNotPresentFlag[i] = flag; } 
+  Bool    getPocLsbNotPresentFlag( Int i )                                 { return m_pocLsbNotPresentFlag[i]; } 
+#endif
+#if !H_MV_6_PS_O0223_29  
   Void    setCrossLayerIrapAlignedFlag( Bool flag )                        { m_crossLayerIrapAlignedFlag = flag; } 
   Bool    getCrossLayerIrapAlignedFlag(  )                                 { return m_crossLayerIrapAlignedFlag; } 
+#endif
   Void    setDirectDepTypeLenMinus2( Int val)                              { m_directDepTypeLenMinus2 = val; } 
   Int     getDirectDepTypeLenMinus2( )                                     { return m_directDepTypeLenMinus2; } 
 
+#if H_MV_6_PS_O0096_21
+  Void    setDefaultDirectDependencyFlag( Bool flag )                      { m_defaultDirectDependencyFlag = flag; } 
+  Bool    getDefaultDirectDependencyFlag(  )                               { return m_defaultDirectDependencyFlag; } 
+
+  Void    setDefaultDirectDependencyType( Int  val )                       { m_defaultDirectDependencyType = val; } 
+  Int     getDefaultDirectDependencyType(  )                               { return m_defaultDirectDependencyType; } 
+#endif
   Void    setDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps, Int val) { m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ] = val; } 
   Int     getDirectDependencyType( Int depLayeridInVps, Int refLayeridInVps)   { return m_directDependencyType[ depLayeridInVps ][ refLayeridInVps ]; } 
@@ -793,9 +1087,14 @@
   TComVPSVUI* getVPSVUI(  )                                                { return m_vpsVUI;  }
   // VPS EXTENSION SEMANTICS VARIABLES
+
   Void    setLayerIdInVps( Int layerIdInNuh, Int val )                     { m_layerIdInVps[layerIdInNuh] = val;  }
   Int     getLayerIdInVps( Int layerIdInNuh )                              { assert( m_layerIdInVps[layerIdInNuh] >= 0 ); return m_layerIdInVps[layerIdInNuh]; }
 
   Int     getScalabilityId ( Int layerIdInVps, ScalabilityType scalType );
+#if H_MV_6_FIX_GET_VIEW_ID
+  Int     getViewId        ( Int layerIdInNuh )                            { return m_viewIdVal[ getViewIndex( layerIdInNuh )]; }
+#else
   Int     getViewId        ( Int layerIdInNuh )                            { return m_viewIdVal[ getViewIndex( getLayerIdInVps( layerIdInNuh) )]; }
+#endif
   Void    setRefLayers(); 
 
@@ -808,7 +1107,20 @@
   Int     scalTypeToScalIdx   ( ScalabilityType scalType );
 
-Int     getProfileLevelTierIdxLen()                                      { return gCeilLog2( getVpsNumProfileTierLevelMinus1() + 1 ); };       
-
-  Int     getNumLayersInIdList              ( Int lsIdx );; 
+  Int     getProfileLevelTierIdxLen()                                      { return gCeilLog2( getVpsNumProfileTierLevelMinus1() + 1 ); };       
+
+  Int     getNumLayersInIdList ( Int lsIdx );
+
+#if H_MV_6_HRD_O0217_13
+  Int     getNumOutputLayerSets() ;   
+  Int     getNumSubDpbs( Int i )                                           { return getNumLayersInIdList( i ); };  
+  Bool    isOutputLayer( Int outLayerSetIdx, Int layerIdInNuh );   
+#if H_MV_6_HRD_O0217_13
+  Void    deriveLayerSetLayerIdList();
+  Void    deriveTargetLayerIdLists();
+  std::vector<Int> getTargetDecLayerIdList( Int targetOptLayerSetIdx )     { return m_targetDecLayerIdLists[targetOptLayerSetIdx]; }; 
+  std::vector<Int> getTargetOptLayerIdList( Int targetOptLayerSetIdx )     { return m_targetDecLayerIdLists[targetOptLayerSetIdx]; }; 
+#endif
+#endif
+
 
   // inference
@@ -1096,4 +1408,25 @@
   TimingInfo* getTimingInfo() { return &m_timingInfo; }
 
+#if H_MV_6_PS_O0118_33
+  Void inferVideoSignalInfo( TComVPS* vps, Int layerIdCurr )
+  {
+    if ( layerIdCurr == 0 || !vps->getVpsVuiPresentFlag() ) 
+    {
+      return; 
+    }
+
+    TComVPSVUI* vpsVUI = vps->getVPSVUI(); 
+    assert( vpsVUI != NULL );  
+
+    TComVideoSignalInfo* videoSignalInfo = vpsVUI->getVideoSignalInfo( vpsVUI->getVpsVideoSignalInfoIdx( vps->getLayerIdInVps( layerIdCurr ) ) ); 
+    assert( videoSignalInfo != NULL );
+
+    setVideoFormat            ( videoSignalInfo->getVideoVpsFormat            () ); 
+    setVideoFullRangeFlag     ( videoSignalInfo->getVideoFullRangeVpsFlag     () );
+    setColourPrimaries        ( videoSignalInfo->getColourPrimariesVps        () );
+    setTransferCharacteristics( videoSignalInfo->getTransferCharacteristicsVps() );
+    setMatrixCoefficients     ( videoSignalInfo->getMatrixCoeffsVps           () );     
+  }
+#endif
 };
 
@@ -1181,9 +1514,24 @@
   TComVPS*    m_pcVPS; 
   // SPS 
+#if H_MV_6_PSEM_O0142_3
+  Bool        m_spsExtensionFlag; 
+  Bool        m_spsExtensionTypeFlag[PS_EX_T_MAX_NUM];
+#endif
   Bool        m_spsInferScalingListFlag;
   Int         m_spsScalingListRefLayerId;
   Bool        m_updateRepFormatFlag;
+#if H_MV_6_PS_REP_FORM_18_19_20  
+  Int         m_spsRepFormatIdx;
+#endif
   // SPS Extension 
   Bool        m_interViewMvVertConstraintFlag;
+#if H_MV_6_SHVC_O0098_36
+  Int         m_numScaledRefLayerOffsets;
+  Int         m_scaledRefLayerId          [MAX_NUM_SCALED_REF_LAYERS];
+  Int         m_scaledRefLayerLeftOffset  [MAX_NUM_LAYERS];
+  Int         m_scaledRefLayerTopOffset   [MAX_NUM_LAYERS];
+  Int         m_scaledRefLayerRightOffset [MAX_NUM_LAYERS];
+  Int         m_scaledRefLayerBottomOffset[MAX_NUM_LAYERS];
+#endif
 #endif
 #if H_3D
@@ -1322,4 +1670,11 @@
   TComPTL* getPTL()     { return &m_pcPTL; }
 #if H_MV
+#if H_MV_6_PSEM_O0142_3
+  Void setSpsExtensionFlag( Bool flag ) { m_spsExtensionFlag = flag; } 
+  Bool getSpsExtensionFlag( )  { return m_spsExtensionFlag; }
+
+  Void setSpsExtensionTypeFlag( Int i, Bool flag ) { m_spsExtensionTypeFlag[i] = flag; } 
+  Bool getSpsExtensionTypeFlag( Int i ) { return m_spsExtensionTypeFlag[i]; }
+#endif
   Void      setVPS          ( TComVPS* pcVPS ) { m_pcVPS = pcVPS; }
   TComVPS*  getVPS          () { return m_pcVPS; }
@@ -1333,10 +1688,33 @@
   Void setUpdateRepFormatFlag( Bool flag )     { m_updateRepFormatFlag = flag; } 
   Bool getUpdateRepFormatFlag(  )              { return m_updateRepFormatFlag; } 
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Void setSpsRepFormatIdx( Int  val )          { m_spsRepFormatIdx = val; } 
+  Int  getSpsRepFormatIdx(  )                  { return m_spsRepFormatIdx; } 
+#endif
   // SPS Extension 
   Void setInterViewMvVertConstraintFlag(Bool val) { m_interViewMvVertConstraintFlag = val; }
   Bool getInterViewMvVertConstraintFlag()         { return m_interViewMvVertConstraintFlag;}
+
+#if H_MV_6_SHVC_O0098_36
+  Void setNumScaledRefLayerOffsets( Int  val )    { m_numScaledRefLayerOffsets = val; } 
+  Int  getNumScaledRefLayerOffsets(  )            { return m_numScaledRefLayerOffsets; } 
+
+  Void setScaledRefLayerId( Int i, Int  val )     { m_scaledRefLayerId[i] = val; } 
+  Int  getScaledRefLayerId( Int i )               { return m_scaledRefLayerId[i]; } 
+
+  Void setScaledRefLayerLeftOffset( Int j, Int  val ) { m_scaledRefLayerLeftOffset[j] = val; } 
+  Int  getScaledRefLayerLeftOffset( Int j )           { return m_scaledRefLayerLeftOffset[j]; } 
+
+  Void setScaledRefLayerTopOffset( Int j, Int  val )  { m_scaledRefLayerTopOffset[j] = val; } 
+  Int  getScaledRefLayerTopOffset( Int j )            { return m_scaledRefLayerTopOffset[j]; } 
+
+  Void setScaledRefLayerRightOffset( Int j, Int  val ) { m_scaledRefLayerRightOffset[j] = val; } 
+  Int  getScaledRefLayerRightOffset( Int j )           { return m_scaledRefLayerRightOffset[j]; } 
+
+  Void setScaledRefLayerBottomOffset( Int j, Int  val ) { m_scaledRefLayerBottomOffset[j] = val; } 
+  Int  getScaledRefLayerBottomOffset( Int j )           { return m_scaledRefLayerBottomOffset[j]; } 
+#endif
   // Inference 
   Void inferRepFormat( TComVPS* vps, Int layerIdCurr );
-
   Void inferScalingList( TComSPS* spsSrc );
 #endif
@@ -1736,4 +2114,7 @@
 // Additional slice header syntax elements 
   Bool       m_pocResetFlag; 
+#if H_MV_6_RALS_O0149_11
+  Bool       m_crossLayerBlaFlag;
+#endif
   Bool       m_discardableFlag;
   Bool       m_interLayerPredEnabledFlag;
@@ -2073,22 +2454,41 @@
 // Additional slice header syntax elements
 
+#if H_MV_6_RALS_O0149_11
+  Void setCrossLayerBlaFlag( Bool flag ) { m_crossLayerBlaFlag = flag; } 
+  Bool getCrossLayerBlaFlag(  ) { return m_crossLayerBlaFlag; } 
+  Void checkCrossLayerBlaFlag ( )
+  {
+    // cross_layer_bla_flag shall be equal to 0 for pictures with nal_unit_type not equal to IDR_W_RADL or IDR_N_LP or with nuh_layer_id not equal to 0.
+    if ( getLayerId() != 0 || getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
+    {
+      assert( m_crossLayerBlaFlag == 0 ); 
+    }
+  }
+#endif
+
   Void setPocResetFlag( Bool flag ) { m_pocResetFlag = flag; } 
   Bool getPocResetFlag(  ) { return m_pocResetFlag; } 
 
-Void setDiscardableFlag( Bool flag ) { m_discardableFlag = flag; } 
-Bool getDiscardableFlag(  ) { return m_discardableFlag; } 
-
-Void setInterLayerPredEnabledFlag( Bool flag ) { m_interLayerPredEnabledFlag = flag; } 
-Bool getInterLayerPredEnabledFlag(  ) { return m_interLayerPredEnabledFlag; } 
-
-Void setNumInterLayerRefPicsMinus1( Int  val ) { m_numInterLayerRefPicsMinus1 = val; } 
-Int  getNumInterLayerRefPicsMinus1(  ) { return m_numInterLayerRefPicsMinus1; } 
-
-Void setInterLayerPredLayerIdc( Int i, Int  val ) { m_interLayerPredLayerIdc[i] = val; } 
-Int  getInterLayerPredLayerIdc( Int i ) { return m_interLayerPredLayerIdc[i]; } 
+  Void setDiscardableFlag( Bool flag ) { m_discardableFlag = flag; } 
+  Bool getDiscardableFlag(  ) { return m_discardableFlag; } 
+
+  Void setInterLayerPredEnabledFlag( Bool flag ) { m_interLayerPredEnabledFlag = flag; } 
+  Bool getInterLayerPredEnabledFlag(  ) { return m_interLayerPredEnabledFlag; } 
+
+  Void setNumInterLayerRefPicsMinus1( Int  val ) { m_numInterLayerRefPicsMinus1 = val; } 
+  Int  getNumInterLayerRefPicsMinus1(  ) { return m_numInterLayerRefPicsMinus1; } 
+
+  Void setInterLayerPredLayerIdc( Int i, Int  val ) { m_interLayerPredLayerIdc[i] = val; } 
+  Int  getInterLayerPredLayerIdc( Int i ) { return m_interLayerPredLayerIdc[i]; } 
 
   // Additional variables derived in slice header semantics 
   Int  getNumInterLayerRefPicsMinus1Len( ) { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
   Int  getInterLayerPredLayerIdcLen    ( ) { return gCeilLog2(  getVPS()->getNumDirectRefLayers( getLayerId() )); }
+
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+  Int  getRefLayerPicFlag( Int i ); 
+  Int  getRefLayerPicIdc ( Int j ); 
+  Int  getNumRefLayerPics( ); 
+#endif
 
   Int  getNumActiveRefLayerPics( );
Index: branches/HTM-9.0-dev0/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibCommon/TypeDef.h	(revision 730)
@@ -243,5 +243,54 @@
 #endif
 
-
+/////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////   HTM-9.2 Integrations //////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+// !!! PLEASE PUT MACROS RELATED TO HTM-9.2 INTEGRATIONS HERE !!!
+// !!! PLEASE PUT MACROS RELATED TO HTM-9.2 INTEGRATIONS HERE !!!
+// !!! PLEASE PUT MACROS RELATED TO HTM-9.2 INTEGRATIONS HERE !!!
+// !!! PLEASE PUT MACROS RELATED TO HTM-9.2 INTEGRATIONS HERE !!!
+// !!! PLEASE PUT MACROS RELATED TO HTM-9.2 INTEGRATIONS HERE !!!
+
+/////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////   HTM-9.1 Integrations //////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#define H_MV_FIX_TRACE_FILE                     1  // Fix linux compilation error related const char conversion 
+
+#define H_MV_LAYER_WISE_STARTUP                 1  // Basic version of layer wise startup.
+#define H_MV_FIX_SKIP_PICTURES                  1  // Fix related to skipping pictures. 
+#define H_MV_6_HRD_O0164_15                     1  // (HRD/O0164/Multilayer HRD) #15 Decision: Adopt, modified as follows: It was suggested to constrain the stalling based on the relative cpb removal times, which must be in decoding order. The "du_based_bpb_sync_flag" is not needed, in view of this. SEI in the highest layer of the layer set or (inclusive "or") VPS VUI is used to carry the parameters (at encoder discretion). SEI in higher layer and SEI in VUI do not need to repeat information available in some lower layer. Shall be after APS SEI and buffering period SEI and before all other SEI of all layers except other HRD related SEI.
+#define H_MV_6_HRD_O0217_13                     1  // (HRD/O0217/Sub-DPB based DPB operations) #13 Decision: Adopt  Specify a separate DPB capacity for each layer  no sharing of capacity across layers  each layer has its own parameters (max pictures, max latency, max reordering). This proposal would specify distinct parameters for each "output layer set" and to change the definition of an operation point to be specific to an output layer set instead of a 'layer set". Decision: Adopted this aspect as well.
+#define H_MV_6_SHVC_O0098_36                    1  // (SHVC/O0098/Scaled ref layer offset) #36 Modify signalling of scaled reference layer offsets to allow signalling of any lower layer, rather than just a direct reference layer, in order to enable alignment of auxiliary pictures. In further JCT-VC and JCT-3V discussion, it was also agreed to use the same offset signalling for MV-HEVC as well as SHVC
+#define H_MV_6_GEN_0153_28                      1  //(Gen/O0153/output highest layer) #28 Add a flag in the VPS to indicate if startup process should output the highest available layer if the target output layer is not available.
+#define H_MV_6_PS_0109_25                       1  //XXX(PS/O0109/default_one_target_output_layer_idc) #25 To change default_one_target_output_layer_flag to a two-bit default_one_target_output_layer_idc, and reserve the values 2 and 3
+#define H_MV_6_O0226_37                         1  //(VUI/O0226/Mod tile WPP) #37 Modifications to the VUI indicators of tile and WPP alignment related syntax elements, from the r1.
+#define H_MV_6_RALS_O0149_11                    1  //XXX (RALS/O0149/Prop2): #11 Proposal: A new slice_reserved_flag is taken into use to indicate if a base-layer IDR picture initiates the layer-wise start-up process. Decision: Adopt (the bit should not be required to be present; if present should be the bit after the discardable_flag, and discardable_flag should be the first one of the three, and the poc reset flag is not required to be present).
+#define H_MV_6_PSEM_O0142_3                     1  // (PSEM/O0142/Conditional extension syntax) #3 Adopt JCTVC-O0142 (as a structure to be used to switch whatever extensions we define in SPS, not necessarily committing to having these extensions be separate for each extension, but the current plan unless decided otherwise is to use one flag for range extensions syntax presence and one flag for SHVC+MV-HEVC extension syntax presence) 
+#define H_MV_6_FIX_GET_VIEW_ID                  1  // Fix get view id
+#define H_MV_6_LAYER_ID_32                      1  // (Gen/O0137,O0200,O0223,Layer id) #32 Add (editorial equivalent of) "The value of nuh_layer_id shall be in the range of 0 to 62. The value of 63 for nuh_layer_id is reserved for future use by ITU-T | ISO/IEC. Decoders shall ignore all data that follow the value 63 for nuh_layer_id in a NAL unit." and specify that vps_max_layers_minus1 shall not be equal to 63, but decoders shall allow that value to appear in the bitstream. Specify that the value 63 is interpreted the same as the value 62 (e.g., MaxLayersMinus1 = Min( 62, vps_max_layers_minus1) and subsequently refer to MaxLayersMinus1 instead of vps_max_layers_minus1)
+#define H_MV_6_PS_O0118_33                      1  // (PS/O0118/visual signal info in vui per layer) #33 Add visual signal information (video_format, video_full_range_flag, colour_primaries, transfer_characteristics, matrix_coeffs) per layer to the VPS VUI, from v2 version of JCTVC-O0118.
+#define H_MV_6_POC_31_35_38                     1  //XXX  Various related to POC
+                                                   // (Misc/O0062/POC LSB present) (SH changes)
+                                                   // (POC/O0117/Modify PicOrderCntVal of prevTid0Pic) #35 Modification of the PicOrderCntVal of prevTid0Pic and modification to the decoding process for reference picture set, to address problems found for cross-layer POC alignment.
+                                                   // (POC/O0211/Fix ambiguity) #38 Modify POC derivation to correct an ambiguity in the spec.
+#define H_MV_6_MISC_O0062_31                    1  // (Misc/O0062/POC LSB present) (without SH changes ) #31 The proposal's "option 3" is to add a flag in the VPS for each EL to control whether these LSBs are present or not (for IDR pictures), and when not present, the LSBs are inferred to be equal to 0. Decision: Adopted (as described herein).
+#define H_MV_6_ILDDS_ILREFPICS_27_34            1  // Various inter layer reference picture derivation 
+                                                   // (ILDSD/O0225/max_tid_il_ref_pics RPL const.) #27 Change derivation of NumActiveRefLayerPics to consider max_tid_il_ref_pics.
+                                                   // (ILDSD/O0120/sub_layers_vps_max_minus1 RPL const) #34 Modify inter-layer reference picture list default construction to incorporate max temporal sub-layers per layer syntax elements in VPS extension, from r2 version of JCTVC-O0120
+#define H_MV_6_ILDDS_O0225_30                   1  // (ILDSD/O0225/signal max_tid_il_ref_pics per layer ) #30 2nd proposal of JCTVC-O0225 regarding signalling of max_tid_il_ref_pics per layer, based upon relation to SCE2 on single loop decoding. Decision: Adopted. 
+#define H_MV_6_ILDSD_O0120_26                   1  // (ILDSD/O0120/sub_layers_vps_max_minus1) #26 Add syntax elements to signal max temporal sub-layers for each layer in the VPS, with a gating flag, from JCTVC- option 2.
+#define H_MV_6_PS_O0223_29                      1  // (PS/O0223/Cross layer alignment type) #29 Add a flag in VPS VUI to indicate cross layer pic type alignment.  Move cross_layer_irap_aligned_flag to VPS VUI and make presence condition on added flag
+#define H_MV_6_PS_0092_17                       1  // (PS/O0092/Sharing SPS PPS) #17 Restrict sharing of SPS and PPS across layers to avoid creating problems during sub-bitstream extraction, based on modification of proposals in JCTVC-O0059 and JCTVC-O0092, reflected in the v2 version of O0092.
+#define H_MV_6_PS_REP_FORM_18_19_20             1  //  Various Rep format
+                                                   // (PS/O0096/rep format syntax element length ) #20 Modification of length to 8 bit as decided later in trac. 
+                                                   // (PS/O0179/Rep. Format) #18 Add flag in rep_format( ) syntax structure to control sending of chroma and bit depth related parameters, as proposed in the v2 version of JCTVC-O0179. 
+                                                   // (PS/O0096/rep format) #20 Modify the SPS syntax for layers with nuh_layer_id > 0 to signal a reference to a rep_format index in the VPS, rather than signalling explicit representation format data in the SPS, from the v2 version of JCTVC-O0096. 
+                                                   // (PS/FIX/N0092/Rep. Format) #19 Inferences. 
+#define H_MV_6_PS_O0096_21                      1  // (PS/O0096/direct_dependency_type gating flag) #21 Add a gating flag in VPS extension to condition the presence of direct dependency type, with a default type signalled, from JCTVC-O0096 
+#define H_MV_6_PS_O0109_22                      1  // (PS/O0109/view_id_len) #22 Modify the VPS extension syntax and semantics to replace view_id_len_minus1 with view_id_len, always signal that syntax element, add a constraint that (1<<view_id_len) >= NumViews, and modify view_id_val semantics to infer value of 0 when not present, from discussion of JCTVC-O0109 
+#define H_MV_6_PS_O0109_23                      1  // (PS/O0109/profile_ref_minus1 constraint) #23 Modify the semantics of profile_ref_minus1[ i ] to replace shall be less than i with shall be less than or equal to i, from discussion of JCTVC-O0109 
+#define H_MV_6_PS_O0109_24                      1  // (PS/O0109/vps_vui_present_flag move) #24 Move the vps_vui_present_flag to precede vps_vui_offset, and make vps_vui_offset conditional on that flag, from JCTVC-O0109
 /////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////   HTM-9.0 Integrations //////////////////////////////
@@ -305,5 +354,9 @@
 #define MAX_VPS_OP_SETS_PLUS1                     1024
 #if H_MV
+#if H_MV_6_LAYER_ID_32
+#define MAX_VPS_NUH_LAYER_ID_PLUS1  63
+#else
 #define MAX_VPS_NUH_LAYER_ID_PLUS1  64
+#endif
 #define MAX_NUM_SCALABILITY_TYPES   16
 #define ENC_CFG_CONSOUT_SPACE       29           
@@ -328,10 +381,26 @@
 
 #define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
+#if H_MV
+#if H_MV_6_LAYER_ID_32
+#define MAX_NUM_LAYER_IDS               63
+#define MAX_NUM_LAYERS                  63
+#else
 #define MAX_NUM_LAYER_IDS               64
-#if H_MV
 #define MAX_NUM_LAYERS                  64
+#endif
 #define MAX_VPS_PROFILE_TIER_LEVEL      64
 #define MAX_VPS_ADD_OUTPUT_LAYER_SETS   1024
 #define MAX_VPS_OUTPUTLAYER_SETS        ( MAX_VPS_ADD_OUTPUT_LAYER_SETS + MAX_VPS_OP_SETS_PLUS1 )
+#if H_MV_6_PS_O0118_33
+#define  MAX_NUM_VIDEO_SIGNAL_INFO      16
+#endif
+#if H_MV_6_SHVC_O0098_36
+#define MAX_NUM_SCALED_REF_LAYERS       MAX_NUM_LAYERS-1
+#endif
+#if H_MV_6_HRD_O0164_15
+#define MAX_NUM_BSP_HRD_PARAMETERS      100 ///< Maximum value is actually not specified
+#define MAX_NUM_BITSTREAM_PARTITIONS    100 ///< Maximum value is actually not specified 
+#define MAX_NUM_BSP_SCHED_COMBINATION   100 ///< Maximum value is actually not specified 
+#endif
 #endif
 
@@ -810,4 +879,17 @@
 
 #if H_MV
+
+#if H_MV_6_PSEM_O0142_3
+  enum PsExtensionTypes
+  {
+    PS_EX_T_MV   = 1,
+#if H_3D
+    PS_EX_T_3D   = 3,
+#endif
+    PS_EX_T_ESC  = 7,
+    PS_EX_T_MAX_NUM = 8
+  };
+#endif
+
 /// scalability types
   enum ScalabilityType
Index: branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 730)
@@ -396,4 +396,8 @@
 
   READ_FLAG(     uiCode, "video_signal_type_present_flag");           pcVUI->setVideoSignalTypePresentFlag(uiCode);
+#if H_MV_6_PS_O0118_33
+  assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 
+#endif
+
   if (pcVUI->getVideoSignalTypePresentFlag())
   {
@@ -582,8 +586,18 @@
   {
     READ_FLAG( uiCode, "update_rep_format_flag" );               pcSPS->setUpdateRepFormatFlag( uiCode == 1 );
+#if H_MV_6_PS_REP_FORM_18_19_20
+    if ( pcSPS->getUpdateRepFormatFlag() )
+    { 
+      READ_CODE( 8, uiCode, "sps_rep_format_idx" );                pcSPS->setSpsRepFormatIdx( uiCode );
+    }
+  }
+  else
+  {
+#else
   }
   
   if ( pcSPS->getUpdateRepFormatFlag() )
   { 
+#endif
 #endif
   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
@@ -621,6 +635,10 @@
 
 #if H_MV
-  if ( pcSPS->getUpdateRepFormatFlag() )
-  { 
+#if H_MV_6_PS_REP_FORM_18_19_20
+  if ( pcSPS->getLayerId() == 0 )
+#else
+  if ( pcSPS->getUpdateRepFormatFlag() )   
+#endif
+  {
 #endif
   READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
@@ -770,6 +788,10 @@
 
   READ_FLAG( uiCode, "sps_extension_flag");
-  if (uiCode)
-  {
+#if H_MV_6_PSEM_O0142_3
+  pcSPS->setSpsExtensionFlag( uiCode ); 
+#endif
+  if (pcSPS->getSpsExtensionFlag( ) )
+  {
+#if !H_MV_6_PSEM_O0142_3
 #if H_MV
     parseSPSExtension( pcSPS ); 
@@ -784,8 +806,37 @@
 #endif
 #endif
-        while ( xMoreRbspData() )
-        {
-          READ_FLAG( uiCode, "sps_extension_data_flag");
-        }
+#else    
+    for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
+    {
+      READ_FLAG( uiCode, "sps_extension_type_flag" ); pcSPS->setSpsExtensionTypeFlag( i, uiCode );
+#if H_3D
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D || i == PS_EX_T_ESC ); 
+#else
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_ESC ); 
+#endif
+    }  
+
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV ))
+    {
+      parseSPSExtension( pcSPS ); 
+    }
+
+#if H_3D
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D ))
+    {
+      parseSPSExtension2( pcSPS, viewIndex, depthFlag  ); 
+    }
+#endif
+
+    if ( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_ESC ))
+    {   
+#endif
+      while ( xMoreRbspData() )
+      {
+        READ_FLAG( uiCode, "sps_extension_data_flag");
+      }
+#if H_MV_6_PSEM_O0142_3
+    }
+#else
 #if H_MV      
 #if H_3D
@@ -794,4 +845,5 @@
     }
 #endif
+#endif
   }
 }
@@ -802,5 +854,22 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" );    pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);
+#if !H_MV_6_SHVC_O0098_36
   READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); 
+#else
+  
+  READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets( uiCode );
+
+  for( Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets( ); i++)
+  {    
+    READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 
+
+    Int j = pcSPS->getScaledRefLayerId( i ); 
+    Int iCode; 
+    READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); pcSPS->setScaledRefLayerLeftOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); pcSPS->setScaledRefLayerTopOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode );
+    READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode );
+  }
+#endif  
 }
 
@@ -850,5 +919,9 @@
   READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
 #if H_MV
+#if H_MV_6_LAYER_ID_32
+  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) )  );
+#else
   READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayersMinus1( uiCode  );
+#endif
 #else
   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
@@ -867,6 +940,6 @@
   for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
   {
-    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
-    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
+    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );    pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
+    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );                pcVPS->setNumReorderPics( uiCode, i );
     READ_UVLC( uiCode,  "vps_max_latency_increase_plus1[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
 
@@ -876,5 +949,5 @@
       {
         pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i);
-        pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i);
+        pcVPS->setNumReorderPics    (pcVPS->getNumReorderPics(0), i);
         pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i);
       }
@@ -905,4 +978,7 @@
     }
   }
+#if H_MV_6_HRD_O0217_13
+  pcVPS->deriveLayerSetLayerIdList(); 
+#endif
   TimingInfo *timingInfo = pcVPS->getTimingInfo();
   READ_FLAG(       uiCode, "vps_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
@@ -968,5 +1044,13 @@
   UInt uiCode; 
   READ_FLAG( uiCode, "avc_base_layer_flag" );                     pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false );
+#if H_MV_6_PS_O0109_24
+  READ_FLAG( uiCode, "vps_vui_present_flag" );                    pcVPS->setVpsVuiPresentFlag( uiCode == 1 );  if ( pcVPS->getVpsVuiPresentFlag() )
+  {  
+#endif
   READ_CODE( 16, uiCode, "vps_vui_offset" );                      pcVPS->setVpsVuiOffset( uiCode );
+#if H_MV_6_PS_O0109_24
+  }
+#endif
+
   READ_FLAG( uiCode, "splitting_flag" );                          pcVPS->setSplittingFlag( uiCode == 1 ? true : false );
 
@@ -1014,4 +1098,22 @@
   }
 
+#if H_MV_6_PS_O0109_22
+  READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode );
+
+  if ( pcVPS->getViewIdLen( ) > 0 )
+  {    
+    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+    {
+      READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode );
+    }
+  }
+  else
+  {
+    for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+    {
+      pcVPS->setViewIdVal( i, 0 );  
+    }
+  }
+#else
   // GT spec says: trac #39
   // if ( pcVPS->getNumViews() > 1 )  
@@ -1025,4 +1127,6 @@
     READ_CODE( pcVPS->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode );
   }
+#endif
+
 
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
@@ -1033,5 +1137,26 @@
     }
   }
-
+#if H_MV_6_MISC_O0062_31
+  pcVPS->setRefLayers(); 
+#endif
+#if H_MV_6_ILDSD_O0120_26
+  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 );
+  if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode );    
+      pcVPS->checkSubLayersVpsMaxMinus1( i ); 
+
+    }
+  }  
+  else
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1);    
+    }
+  }
+#endif
   READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 );
 
@@ -1040,5 +1165,15 @@
     for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
     {
+#if H_MV_6_ILDDS_O0225_30
+      for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ )
+      {
+        if ( pcVPS->getDirectDependencyFlag(j,i) )
+        {
+          READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode );
+        }
+      }
+#else
       READ_CODE( 3, uiCode,       "max_tid_il_ref_pics_plus1[i]" );      pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); 
+#endif
     }
   }
@@ -1054,4 +1189,7 @@
     {
       READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode );
+#if H_MV_6_PS_O0109_23
+      pcVPS->checkProfileRefMinus1( i );      
+#endif
     }
     parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
@@ -1076,7 +1214,16 @@
   if( numOutputLayerSets > 1)
   {
+#if H_MV_6_PS_0109_25
+    READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); pcVPS->setDefaultOneTargetOutputLayerIdc( uiCode );
+    pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
+#else
     READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag(  uiCode == 1); 
+#endif
   }  
 
+#if H_MV_6_HRD_O0217_13
+  pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); 
+  pcVPS->setOutputLayerSetIdxMinus1(0, -1); 
+#endif
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
@@ -1089,4 +1236,15 @@
       }        
     }
+#if H_MV_6_HRD_O0217_13
+    else
+    { // These inference rules would also be helpful in spec text
+      pcVPS->setOutputLayerSetIdxMinus1(i, i - 1 ); 
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
+      {              
+        pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }
+#endif
+
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
@@ -1094,5 +1252,13 @@
     }
   }
-
+#if H_MV_6_GEN_0153_28
+  if( pcVPS->getMaxLayersMinus1() > 0 )
+  {
+    READ_FLAG( uiCode, "alt_output_layer_flag" ); pcVPS->setAltOutputLayerFlag( uiCode == 1 );
+  }
+#endif
+#if H_MV_6_HRD_O0217_13
+  pcVPS->deriveTargetLayerIdLists(); 
+#endif
   READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
@@ -1103,8 +1269,16 @@
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
   { 
+#if H_MV_6_PS_REP_FORM_18_19_20
+    assert( pcVPS->getRepFormat(i) == NULL ); 
+    TComRepFormat* curRepFormat = new TComRepFormat(); 
+    TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 
+    parseRepFormat( i, curRepFormat ,  prevRepFormat); 
+    pcVPS->setRepFormat(i, curRepFormat ); 
+#else
     assert( pcVPS->getRepFormat(i) == NULL ); 
     TComRepFormat* repFormat = new TComRepFormat(); 
     parseRepFormat( repFormat );
     pcVPS->setRepFormat(i, repFormat ); 
+#endif
   }
 
@@ -1115,5 +1289,9 @@
       if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
       {
+#if H_MV_6_PS_REP_FORM_18_19_20
+        READ_CODE( 8, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
+#else
         READ_CODE( 4, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode );
+#endif
       }
     }
@@ -1121,7 +1299,48 @@
 
   READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); 
+#if H_MV_6_MISC_O0062_31
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) )  ==  0 )
+    {      
+      READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 );
+    }
+  }
+#endif
+
+#if H_MV_6_HRD_O0217_13
+  parseDpbSize( pcVPS ); 
+#endif
+
+#if !H_MV_6_PS_O0223_29
   READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPS->setCrossLayerIrapAlignedFlag( uiCode == 1 );
+#endif
   READ_UVLC( uiCode, "direct_dep_type_len_minus2")    ; pcVPS->setDirectDepTypeLenMinus2   ( uiCode ); 
-
+  
+#if H_MV_6_PS_O0096_21
+  READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 );
+  if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+  {  
+    READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode );
+  }
+
+  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    for( Int j = 0; j < i; j++ )
+    {
+      if (pcVPS->getDirectDependencyFlag( i, j) )
+      {        
+        if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+        {  
+          pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) );
+        }
+        else
+        {
+          READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2,  uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode);
+        }
+      }
+    }
+  }  
+#else
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1134,7 +1353,10 @@
     }
   }
+#endif
 
   READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); 
+#if !H_MV_6_PS_O0109_24
   READ_FLAG( uiCode, "vps_vui_present_flag" )       ; pcVPS->setVpsVuiPresentFlag( uiCode == 1 );
+#endif
 
   if( pcVPS->getVpsVuiPresentFlag() )
@@ -1145,12 +1367,29 @@
 
   pcVPS->checkVPSExtensionSyntax(); 
+#if !H_MV_6_MISC_O0062_31
   pcVPS->setRefLayers(); 
-}
-
+#endif
+}
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat )
+#else
 Void TDecCavlc::parseRepFormat( TComRepFormat* pcRepFormat )
+#endif
 {
   assert( pcRepFormat ); 
 
   UInt uiCode; 
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+  READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );  pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode );
+  READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode );
+  READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 );
+
+  pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); 
+
+  if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() )
+  {  
+#endif
   READ_CODE( 2,  uiCode, "chroma_format_vps_idc" );          pcRepFormat->setChromaFormatVpsIdc       ( uiCode );
   if ( pcRepFormat->getChromaFormatVpsIdc() == 3 )
@@ -1158,8 +1397,17 @@
     READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); 
   }
+#if !H_MV_6_PS_REP_FORM_18_19_20
   READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" );  pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode );
   READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode );
+#endif
   READ_CODE( 4,  uiCode, "bit_depth_vps_luma_minus8" );      pcRepFormat->setBitDepthVpsLumaMinus8    ( uiCode );
   READ_CODE( 4,  uiCode, "bit_depth_vps_chroma_minus8" );    pcRepFormat->setBitDepthVpsChromaMinus8  ( uiCode );
+#if H_MV_6_PS_REP_FORM_18_19_20
+  }
+  else
+  {
+    pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, false ); 
+  }
+#endif
 }
 
@@ -1174,4 +1422,11 @@
 
   UInt uiCode; 
+#if H_MV_6_PS_O0223_29
+  READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 );
+  if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )
+  {  
+    READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 );
+  }
+#endif
   READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 );
   READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 );
@@ -1201,7 +1456,43 @@
         }
       }
-    }
-  }
-
+    }   
+  }
+
+#if H_MV_6_O0226_37
+  READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
+  if( !pcVPSVUI->getTilesNotInUseFlag() ) 
+  {      
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 );
+      if( pcVPSVUI->getTilesInUseFlag( i ) )  
+      {
+        READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 );
+      }
+    }  
+
+    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
+      {  
+        Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getRefLayerId(pcVPS->getLayerIdInNuh( i ) , j  ));  
+        if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) )  
+        {
+          READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 );
+        }
+      }  
+    }
+  }  
+  
+  READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 );
+  
+  if( !pcVPSVUI->getWppNotInUseFlag( ))
+  {
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 );
+    }
+  }
+#else
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -1211,4 +1502,5 @@
     }
   }
+#endif
 
   READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 );
@@ -1232,5 +1524,162 @@
     }
   }
-}
+
+#if H_MV_6_PS_O0118_33
+  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 );
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode );
+  }
+  else
+  {
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); 
+  }
+
+  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
+  {
+    assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); 
+    TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo();     
+    parseVideoSignalInfo( curVideoSignalInfo ); 
+    pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); 
+  }
+  
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() );
+    }
+  }
+  else
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ); 
+    }
+  }
+#endif
+#if H_MV_6_HRD_O0164_15
+  READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 );
+  if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
+  {
+    parseVpsVuiBspHrdParameters( pcVPS ); 
+  }
+#endif
+}
+
+#if H_MV_6_HRD_O0164_15
+Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS )
+{
+  assert( pcVPS ); 
+
+  TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+
+  assert( pcVPSVUI ); 
+
+  TComVpsVuiBspHrdParameters*  vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 
+  
+  assert ( vpsVuiBspHrdP );
+
+  UInt uiCode; 
+  READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vpsVuiBspHrdP->setVpsNumBspHrdParametersMinus1( uiCode );
+  for( Int i = 0; i <= vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ); i++ )
+  {  
+    if( i > 0 )
+    {
+      READ_FLAG( uiCode, "bsp_cprms_present_flag" ); vpsVuiBspHrdP->setBspCprmsPresentFlag( i, uiCode == 1 );
+    }
+    TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 
+    parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getBspCprmsPresentFlag( i ), pcVPS->getMaxSubLayersMinus1() );     
+  }  
+  for( Int h = 1; h <= pcVPS->getVpsNumLayerSetsMinus1(); h++ )
+  {  
+    READ_UVLC( uiCode, "num_bitstream_partitions" ); vpsVuiBspHrdP->setNumBitstreamPartitions( h, uiCode );
+    for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
+    {
+      for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
+      {
+        if( pcVPS->getLayerIdIncludedFlag( h ,j ) )
+        {
+          READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 );
+        }
+        else
+        {
+          vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
+        }
+      }
+    }
+    vpsVuiBspHrdP->checkLayerInBspFlag( pcVPS, h ); 
+    
+    if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) )
+    {  
+      READ_UVLC( uiCode, "num_bsp_sched_combinations" ); vpsVuiBspHrdP->setNumBspSchedCombinations( h, uiCode );
+      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinations( h ); i++ )
+      {
+        for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
+        {  
+          READ_UVLC( uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode );
+          READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode );
+        }  
+      }
+    }  
+  }  
+}  
+#endif
+
+#if H_MV_6_PS_O0118_33
+Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) 
+{
+  UInt uiCode; 
+  READ_CODE( 3, uiCode, "video_vps_format" );             pcVideoSignalInfo->setVideoVpsFormat( uiCode );
+  READ_FLAG( uiCode, "video_full_range_vps_flag" );       pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 );
+  READ_CODE( 8, uiCode, "colour_primaries_vps" );         pcVideoSignalInfo->setColourPrimariesVps( uiCode );
+  READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode );
+  READ_CODE( 8, uiCode, "matrix_coeffs_vps" );            pcVideoSignalInfo->setMatrixCoeffsVps( uiCode );
+}
+#endif
+
+#if H_MV_6_HRD_O0217_13
+Void TDecCavlc::parseDpbSize( TComVPS* vps )
+{
+  UInt uiCode; 
+  TComDpbSize* dpbSize = vps->getDpbSize(); 
+  assert ( dpbSize != 0 ); 
+
+  for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
+  {  
+    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 );
+
+    for( Int j = 0; j  <=  vps->getMaxTLayers() - 1 ; j++ )
+    {  
+      if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
+      {
+        READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 );
+      }
+      if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
+      {  
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+        {
+          READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
+        }
+        READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode );
+        READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode );
+      }
+      else
+      {
+        if ( j > 0 )
+        {
+          for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+          {
+            dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
+          }
+          dpbSize->setMaxVpsNumReorderPics      ( i, j, dpbSize->getMaxVpsNumReorderPics      ( i, j - 1 ) );
+          dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );
+        }
+      }
+    }  
+  }  
+}
+#endif
 #endif
 
@@ -1280,5 +1729,5 @@
         if (i!=1)
         {
-          READ_UVLC (uiCode, "log2_sub_PU_size_minus2");     pcVPS->setSubPULog2Size(i, uiCode+2); 
+          READ_UVLC (uiCode, "log2_sub_PU_size_minus2[i]");     pcVPS->setSubPULog2Size(i, uiCode+2); 
         }
 #endif
@@ -1357,5 +1806,10 @@
   sps->inferRepFormat  ( vps , rpcSlice->getLayerId() ); 
   sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) );   
-
+#if H_MV_6_PS_O0118_33
+  if ( sps->getVuiParametersPresentFlag() )
+  {
+    sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); 
+  }
+#endif
   rpcSlice->setVPS(vps);      
   rpcSlice->setViewId   ( vps->getViewId   ( rpcSlice->getLayerId() )      );
@@ -1411,4 +1865,5 @@
 #if H_MV    
     Int esb = 0; //Don't use i, otherwise will shadow something below
+#if !H_MV_6_RALS_O0149_11
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1416,4 +1871,5 @@
       READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
     }
+#endif
 
     if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
@@ -1422,4 +1878,19 @@
       READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 );
     }
+
+#if H_MV_6_RALS_O0149_11
+    if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 );
+    }
+    rpcSlice->checkCrossLayerBlaFlag( ); 
+
+    if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 );
+    }
+#endif
 
     for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
@@ -1445,7 +1916,59 @@
     //   colour_plane_id                                      u(2)
 
+
+#if H_MV_6_POC_31_35_38
+    UInt slicePicOrderCntLsb = 0;
+    Int iPOClsb = slicePicOrderCntLsb;  // Needed later
+    if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() )
+    {
+      READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb");        
+    }    
+
+    Bool picOrderCntMSBZeroFlag = false;     
+
+    // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered??
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP   ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP   ); 
+    picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag ||   rpcSlice->getIdrPicFlag(); 
+
+    // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 &&   !rpcSlice->getFirstPicInLayerDecodedFlag() ); 
+
+    Int picOrderCntMSB = 0; 
+
+    if ( !picOrderCntMSBZeroFlag )
+    {
+      Int prevPicOrderCnt    = rpcSlice->getPrevTid0POC();
+      Int maxPicOrderCntLsb  = 1 << sps->getBitsForPOC();
+      Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1);
+      Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb;
+            
+      if( ( slicePicOrderCntLsb  <  prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb )  >=  ( maxPicOrderCntLsb / 2 ) ) )
+      {
+        picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb;
+      }
+      else if( (slicePicOrderCntLsb  >  prevPicOrderCntLsb )  && ( (slicePicOrderCntLsb - prevPicOrderCntLsb )  >  ( maxPicOrderCntLsb / 2 ) ) ) 
+      {
+        picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb;
+      }
+      else
+      {
+        picOrderCntMSB = prevPicOrderCntMsb;
+      }   
+    }
+      
+    rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb );
+    if ( rpcSlice->getPocResetFlag() )  
+    {
+      rpcSlice->setPocBeforeReset   ( rpcSlice->getPOC() ); 
+      rpcSlice->setPOC              ( 0 );
+    }      
+#endif
+
     if( rpcSlice->getIdrPicFlag() )
     {
+#if !H_MV_6_POC_31_35_38
       rpcSlice->setPOC(0);
+#endif
       TComReferencePictureSet* rps = rpcSlice->getLocalRPS();
       rps->setNumberOfNegativePictures(0);
@@ -1460,4 +1983,5 @@
     else
     {
+#if !H_MV_6_POC_31_35_38
       READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb");  
       Int iPOClsb = uiCode;
@@ -1494,4 +2018,5 @@
 
       }      
+#endif
 #endif
       TComReferencePictureSet* rps;
@@ -1628,6 +2153,10 @@
     }
 #if H_MV
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    Bool interLayerPredLayerIdcPresentFlag = false; 
+#endif
     Int layerId       = rpcSlice->getLayerId(); 
-    if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )    {   
+    if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
+    {   
       READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 );
       if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 )
@@ -1639,4 +2168,7 @@
         if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
         {
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+          interLayerPredLayerIdcPresentFlag = true; 
+#endif
           for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ )   
           {
@@ -1646,4 +2178,13 @@
       }  
     }
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    if ( !interLayerPredLayerIdcPresentFlag )
+    {
+      for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ )   
+      {
+        rpcSlice->setInterLayerPredLayerIdc( i, rpcSlice->getRefLayerPicIdc( i ) );
+      }
+    }
+#endif
 #endif
     if(sps->getUseSAO())
Index: branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecCAVLC.h	(revision 730)
@@ -78,6 +78,19 @@
 #if H_MV
   Void  parseVPSExtension   ( TComVPS* pcVPS ); 
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Void  parseRepFormat      ( Int i, TComRepFormat* curRepFormat, TComRepFormat* prevRepFormat );
+#else
   Void  parseRepFormat      ( TComRepFormat* pcRepFormat );
+#endif
   Void  parseVPSVUI         ( TComVPS* pcVPS );
+#if H_MV_6_PS_O0118_33
+  Void parseVideoSignalInfo ( TComVideoSignalInfo* pcVideoSignalInfo ); 
+#endif
+#if H_MV_6_HRD_O0217_13
+  Void  parseDpbSize        ( TComVPS* pcVPS ); 
+#endif
+#if H_MV_6_HRD_O0164_15
+  Void parseVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
+#endif
 #endif
 
Index: branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.cpp	(revision 730)
@@ -635,4 +635,10 @@
 #if H_MV
   m_apcSlicePilot->setVPS(vps);  
+#if H_MV_6_PS_0092_17
+  // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
+  assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, pps->getLayerId() ) );   
+  // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA.
+  assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getInDirectDependencyFlag( m_layerId, sps->getLayerId() ) );
+#endif
   sps->inferRepFormat  ( vps , m_layerId ); 
   sps->inferScalingList( m_parameterSetManagerDecoder.getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); 
@@ -665,8 +671,11 @@
 
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag  )
+#else
 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag )
+#endif
 {
   assert( nalu.m_layerId == m_layerId ); 
-
 #else
 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
@@ -722,9 +731,16 @@
 #endif
 #endif
+
+#if H_MV_LAYER_WISE_STARTUP
+    xCeckNoClrasOutput();
+#endif
     // Skip pictures due to random access
     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     {
-    m_prevSliceSkipped = true;
-    m_skippedPOC = m_apcSlicePilot->getPOC();
+      m_prevSliceSkipped = true;
+      m_skippedPOC = m_apcSlicePilot->getPOC();
+#if H_MV_FIX_SKIP_PICTURES
+      sliceSkippedFlag = true; 
+#endif
       return false;
     }
@@ -732,6 +748,9 @@
     if (isSkipPictureForBLA(iPOCLastDisplay))
     {
-    m_prevSliceSkipped = true;
-    m_skippedPOC = m_apcSlicePilot->getPOC();
+      m_prevSliceSkipped = true;
+      m_skippedPOC = m_apcSlicePilot->getPOC();
+#if H_MV_FIX_SKIP_PICTURES
+      sliceSkippedFlag = true; 
+#endif
       return false;
     }
@@ -788,4 +807,5 @@
     xCreateLostPicture(lostPoc-1);
   }
+  
   if (m_bFirstSliceInPicture)
   {
@@ -1171,5 +1191,9 @@
 
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag )
+#else
 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayerFlag)
+#endif
 #else
 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay)
@@ -1216,5 +1240,9 @@
     case NAL_UNIT_CODED_SLICE_RASL_R:
 #if H_MV
+#if H_MV_FIX_SKIP_PICTURES
+      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag, sliceSkippedFlag );
+#else
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, newLayerFlag);
+#endif
 #else
       return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
@@ -1242,4 +1270,5 @@
     return true;
   }
+
   return false;
 }
@@ -1265,5 +1294,9 @@
     return true;
   }
+#if H_MV_LAYER_WISE_STARTUP
+  else if ( !m_layerInitilizedFlag[ m_layerId ] ) // start of random access point, m_pocRandomAccess has not been set yet.
+#else
   else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
+#endif
   {
     if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
@@ -1272,13 +1305,57 @@
         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL )
     {
+
+#if H_MV_LAYER_WISE_STARTUP
+      if ( xAllRefLayersInitilized() )
+      {
+        m_layerInitilizedFlag[ m_layerId ] = true; 
+        m_pocRandomAccess = m_apcSlicePilot->getPOC();
+      }
+      else
+      {
+        return true; 
+      }
+#else
       // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT.
       m_pocRandomAccess = m_apcSlicePilot->getPOC();
+#endif
     }
     else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
     {
+#if H_MV_LAYER_WISE_STARTUP
+      if ( xAllRefLayersInitilized() )
+      {
+        m_layerInitilizedFlag[ m_layerId ] = true; 
+        m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
+      }
+      else
+      {
+        return true; 
+      }
+#else
       m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
+#endif
     }
     else 
     {
+#if H_MV_FIX_SKIP_PICTURES
+      static Bool warningMessage[MAX_NUM_LAYERS];
+      static Bool warningInitFlag = false;
+      
+      if (!warningInitFlag)
+      {
+        for ( Int i = 0; i < MAX_NUM_LAYERS; i++)
+        {
+          warningMessage[i] = true; 
+        }
+        warningInitFlag = true; 
+      }
+
+      if ( warningMessage[getLayerId()] )
+      {
+        printf("\nLayer%3d   No valid random access point. VCL NAL units of this layer are discarded until next layer initialization picture. ", getLayerId() ); 
+        warningMessage[m_layerId] = false; 
+      }
+#else
       static Bool warningMessage = false;
       if(!warningMessage)
@@ -1287,4 +1364,5 @@
         warningMessage = true;
       }
+#endif
       return true;
     }
@@ -1296,6 +1374,10 @@
     return true;
   }
+#if H_MV_LAYER_WISE_STARTUP
+  return !m_layerInitilizedFlag[ getLayerId() ]; 
+#else
   // if we reach here, then the picture is not skipped.
   return false; 
+#endif
 }
 
@@ -1338,4 +1420,40 @@
   }
 }
+
+#if H_MV_LAYER_WISE_STARTUP
+Void TDecTop::xCeckNoClrasOutput()
+{
+  // This part needs further testing! 
+  if ( getLayerId() == 0 )
+  {    
+    NalUnitType nut = m_apcSlicePilot->getNalUnitType(); 
+
+    Bool isBLA =  ( nut == NAL_UNIT_CODED_SLICE_BLA_W_LP  )  || ( nut == NAL_UNIT_CODED_SLICE_BLA_N_LP ) || ( nut == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); 
+    Bool isIDR  = ( nut == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) || ( nut == NAL_UNIT_CODED_SLICE_IDR_N_LP ); 
+    Bool noClrasOutputFlag  = isBLA || ( isIDR  &&  m_apcSlicePilot->getCrossLayerBlaFlag() ); 
+
+    if ( noClrasOutputFlag ) 
+    {
+      for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++)
+      {
+        m_layerInitilizedFlag[i] = false; 
+      } 
+    }
+  }
+}
+
+Bool TDecTop::xAllRefLayersInitilized()
+{
+  Bool allRefLayersInitilizedFlag = true; 
+  TComVPS* vps = m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); 
+  for (Int i = 0; i < vps->getNumDirectRefLayers( getLayerId()  ); i++ )
+  {
+    Int refLayerId = vps->getRefLayerId( m_layerId, i ); 
+    allRefLayersInitilizedFlag = allRefLayersInitilizedFlag && m_layerInitilizedFlag[ refLayerId ]; 
+  }
+
+  return allRefLayersInitilizedFlag;
+}
+#endif
 #endif
 //! \}
Index: branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibDecoder/TDecTop.h	(revision 730)
@@ -186,4 +186,7 @@
   TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
 #if H_MV
+#if H_MV_LAYER_WISE_STARTUP
+  Bool*                    m_layerInitilizedFlag; // initialization Layers
+#endif
   static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets 
 #else
@@ -243,4 +246,9 @@
   Void  init();
 #if H_MV  
+#if H_MV_FIX_SKIP_PICTURES
+  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer, Bool& sliceSkippedFlag );
+#else
+  Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
+#endif
   Bool  decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool newLayer );
 #else  
@@ -260,5 +268,10 @@
   TComList<TComPic*>*     getListPic            ()               { return &m_cListPic;  }  
   Void                    setIvPicLists         ( TComPicLists* picLists) { m_ivPicLists = picLists; }
-  
+#if H_MV_LAYER_WISE_STARTUP
+  Void                    setLayerInitilizedFlags( Bool* val )    { m_layerInitilizedFlag = val; }
+#endif
+#if H_MV_6_HRD_O0217_13
+  TComVPS*                getPrefetchedVPS      ()               { return m_parameterSetManagerDecoder.getPrefetchedVPS( 0 ); }; //Assuming that currently only one VPS is present. 
+#endif
   Int                     getCurrPoc            ()               { return m_apcSlicePilot->getPOC(); }
   Void                    setLayerId            ( Int layer)     { m_layerId = layer;   }
@@ -281,6 +294,15 @@
 #if H_MV  
   TComPic*  xGetPic( Int layerId, Int poc ); 
+#if H_MV_FIX_SKIP_PICTURES
+  Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag, Bool& sliceSkippedFlag );  
+#else
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool newLayerFlag );  
+#endif
   Void      xResetPocInPicBuffer();
+#if H_MV_LAYER_WISE_STARTUP
+  Void      xCeckNoClrasOutput();
+
+  Bool      xAllRefLayersInitilized();
+#endif
 #else
   Bool      xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay);
@@ -291,4 +313,5 @@
   Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
 
+
 };// END CLASS DEFINITION TDecTop
 
Index: branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 730)
@@ -280,4 +280,7 @@
   }
   WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(),            "video_signal_type_present_flag");
+#if H_MV_6_PS_O0118_33
+  assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 
+#endif
   if (pcVUI->getVideoSignalTypePresentFlag())
   {
@@ -443,8 +446,18 @@
   {
     WRITE_FLAG( pcSPS->getUpdateRepFormatFlag( ) ? 1 : 0 , "update_rep_format_flag" );
+#if H_MV_6_PS_REP_FORM_18_19_20    
+    if ( pcSPS->getUpdateRepFormatFlag() )
+    { 
+      WRITE_CODE( pcSPS->getSpsRepFormatIdx( ), 8, "sps_rep_format_idx" );
+    }
+  }
+  else
+  {
+#else
   }
 
   if ( pcSPS->getUpdateRepFormatFlag() )
   { 
+#endif
 #endif
   WRITE_UVLC( pcSPS->getChromaFormatIdc (),         "chroma_format_idc" );
@@ -472,5 +485,9 @@
   }
 #if H_MV
+#if H_MV_6_PS_REP_FORM_18_19_20
+  if ( pcSPS->getLayerId() == 0 )
+#else
   if ( pcSPS->getUpdateRepFormatFlag() )
+#endif
   { 
 #endif
@@ -577,4 +594,32 @@
   WRITE_FLAG( 0, "sps_extension_flag" );
 #else
+#if H_MV_6_PSEM_O0142_3
+  WRITE_FLAG( pcSPS->getSpsExtensionFlag(), "sps_extension_flag" );
+
+  if ( pcSPS->getSpsExtensionFlag() )
+  {
+    for (Int i = 0; i < PS_EX_T_MAX_NUM; i++)
+    {
+      WRITE_FLAG( pcSPS->getSpsExtensionTypeFlag( i ) ? 1 : 0 , "sps_extension_type_flag" );
+#if H_3D
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D ); 
+#else
+      assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV ); 
+#endif
+    }  
+
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV ))
+    {
+      codeSPSExtension( pcSPS ); 
+    }
+
+#if H_3D
+    if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D ))
+    {
+      codeSPSExtension2( pcSPS, viewIndex, depthFlag ); 
+    }
+#endif
+  }
+#else
   WRITE_FLAG( 1, "sps_extension_flag" );
   codeSPSExtension( pcSPS ); 
@@ -587,4 +632,5 @@
 #endif  
 #endif
+#endif
 }
 
@@ -593,5 +639,22 @@
 {
   WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" );
+
+#if !H_MV_6_SHVC_O0098_36
   WRITE_UVLC( 0, "sps_shvc_reserved_zero_idc" ); 
+#else
+  WRITE_UVLC( pcSPS->getNumScaledRefLayerOffsets( ), "num_scaled_ref_layer_offsets" );
+
+  for( Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets( ); i++)
+  {    
+    WRITE_CODE( pcSPS->getScaledRefLayerId( i ), 6, "scaled_ref_layer_id" );
+
+    Int j = pcSPS->getScaledRefLayerId( i ); 
+    
+    WRITE_SVLC( pcSPS->getScaledRefLayerLeftOffset( j ), "scaled_ref_layer_left_offset" );
+    WRITE_SVLC( pcSPS->getScaledRefLayerTopOffset( j ), "scaled_ref_layer_top_offset" );
+    WRITE_SVLC( pcSPS->getScaledRefLayerRightOffset( j ), "scaled_ref_layer_right_offset" );
+    WRITE_SVLC( pcSPS->getScaledRefLayerBottomOffset( j ), "scaled_ref_layer_bottom_offset" );
+  }
+#endif  
 }
 #endif
@@ -740,5 +803,13 @@
 {
   WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0,          "avc_base_layer_flag" );
+#if H_MV_6_PS_O0109_24
+  WRITE_FLAG( pcVPS->getVpsVuiPresentFlag() ? 1 : 0 , "vps_vui_present_flag" );
+  if ( pcVPS->getVpsVuiPresentFlag() )
+  {  
+#endif
   WRITE_CODE( pcVPS->getVpsVuiOffset( ), 16,                 "vps_vui_offset" );  // TBD
+#if H_MV_6_PS_O0109_24
+  }
+#endif
   WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0,             "splitting_flag" );
   
@@ -786,4 +857,23 @@
   }
 
+
+#if H_MV_6_PS_O0109_22
+    WRITE_CODE( pcVPS->getViewIdLen( ), 4, "view_id_len" );
+    
+    if ( pcVPS->getViewIdLen( ) > 0 )
+    {    
+      for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+      {
+        WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLen( ), "view_id_val[i]" );
+      }
+    }
+    else
+    {
+      for( Int i = 0; i < pcVPS->getNumViews(); i++ )
+      {
+        assert( pcVPS->getViewIdVal( i ) == 0 ); 
+      }
+    }
+#else
   // GT spec says: trac #39
   // if ( pcVPS->getNumViews() > 1 )  
@@ -792,9 +882,10 @@
     WRITE_CODE( pcVPS->getViewIdLenMinus1( ), 4, "view_id_len_minus1" );
   }
-
   for( Int i = 0; i < pcVPS->getNumViews(); i++ )
   {
     WRITE_CODE( pcVPS->getViewIdVal( i ), pcVPS->getViewIdLenMinus1( ) + 1, "view_id_val[i]" );
   }
+#endif
+
 
   for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
@@ -805,5 +896,22 @@
     }
   }
-
+#if H_MV_6_ILDSD_O0120_26
+  WRITE_FLAG( pcVPS->getVpsSubLayersMaxMinus1PresentFlag( ) ? 1 : 0 , "vps_sub_layers_max_minus1_present_flag" );
+  if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() )
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      WRITE_CODE( pcVPS->getSubLayersVpsMaxMinus1( i ), 3, "sub_layers_vps_max_minus1" );
+      pcVPS->checkSubLayersVpsMaxMinus1( i ); 
+    }
+  }  
+  else
+  {
+    for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      assert( pcVPS->getSubLayersVpsMaxMinus1( i ) + 1 == pcVPS->getMaxTLayers( ) );    
+    }
+  }
+#endif
   WRITE_FLAG( pcVPS->getMaxTidRefPresentFlag( ) ? 1 : 0 , "max_tid_ref_present_flag" );
 
@@ -812,5 +920,15 @@
     for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ )
     {
+#if H_MV_6_ILDDS_O0225_30
+      for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ )
+      {
+        if ( pcVPS->getDirectDependencyFlag(j,i) )
+        {
+          WRITE_CODE( pcVPS->getMaxTidIlRefPicsPlus1( i, j ), 3, "max_tid_il_ref_pics_plus1" );
+        }
+      }
+#else
       WRITE_CODE( pcVPS->getMaxTidIlRefPicPlus1( i ), 3,       "max_tid_il_ref_pics_plus1[i]" );
+#endif
     }
   }
@@ -826,4 +944,7 @@
     {    
       WRITE_CODE( pcVPS->getProfileRefMinus1( i ), 6, "profile_ref_minus1[i]" );
+#if H_MV_6_PS_O0109_23
+      pcVPS->checkProfileRefMinus1( i );      
+#endif
     }
     codePTL( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 );
@@ -842,7 +963,16 @@
   if( numOutputLayerSets > 1)
   {
+#if H_MV_6_PS_0109_25
+    WRITE_CODE( pcVPS->getDefaultOneTargetOutputLayerIdc( ), 2, "default_one_target_output_layer_idc" );
+    pcVPS->checkDefaultOneTargetOutputLayerIdc(); 
+#else
     WRITE_FLAG( pcVPS->getDefaultOneTargetOutputLayerFlag( ) ? 1 : 0, "default_one_target_output_layer_flag" );
+#endif        
   }  
 
+#if H_MV_6_HRD_O0217_13
+  assert( pcVPS->getOutputLayerFlag(0, 0) == pcVPS->inferOutputLayerFlag( 0, 0 )); 
+  assert( pcVPS->getOutputLayerSetIdxMinus1( 0 ) == -1 ); 
+#endif
   for( Int i = 1; i < numOutputLayerSets; i++ )
   {
@@ -855,4 +985,15 @@
       }      
     }
+#if H_MV_6_HRD_O0217_13
+    else
+    { // These inference rules would also be helpful in spec text
+      assert( pcVPS->getOutputLayerSetIdxMinus1(i ) ==  i - 1 ); 
+      for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ )
+      {              
+        assert( pcVPS->getOutputLayerFlag( i , j ) == pcVPS->inferOutputLayerFlag( i, j )); 
+      }
+    }
+#endif
+
     if ( pcVPS->getProfileLevelTierIdxLen()  > 0 )
     {      
@@ -861,4 +1002,11 @@
   }
 
+#if H_MV_6_GEN_0153_28
+  if( pcVPS->getMaxLayersMinus1() > 0 )
+  {
+    WRITE_FLAG( pcVPS->getAltOutputLayerFlag( ) ? 1 : 0 , "alt_output_layer_flag" );
+  }
+#endif
+
   WRITE_FLAG( pcVPS->getRepFormatIdxPresentFlag( ) ? 1 : 0 , "rep_format_idx_present_flag" );
   if ( pcVPS->getRepFormatIdxPresentFlag() )
@@ -869,6 +1017,12 @@
   for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ )
   {    
+#if H_MV_6_PS_REP_FORM_18_19_20
+    TComRepFormat* curRepFormat = pcVPS->getRepFormat(i);     
+    TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 
+    codeRepFormat( i, curRepFormat ,  prevRepFormat); 
+#else
     TComRepFormat* pcRepFormat = pcVPS->getRepFormat(i);     
     codeRepFormat( pcRepFormat ); 
+#endif
   }
 
@@ -879,5 +1033,9 @@
       if( pcVPS->getVpsNumRepFormatsMinus1() > 0 )
       {
+#if H_MV_6_PS_REP_FORM_18_19_20
+        WRITE_CODE( pcVPS->getVpsRepFormatIdx( i ), 8, "vps_rep_format_idx" );
+#else
         WRITE_CODE( pcVPS->getVpsRepFormatIdx( i ), 4, "vps_rep_format_idx" );
+#endif
       }
     }
@@ -885,7 +1043,49 @@
 
   WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );
+#if H_MV_6_MISC_O0062_31
+  for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) )  ==  0 )
+    {      
+      WRITE_FLAG( pcVPS->getPocLsbNotPresentFlag( i ) ? 1 : 0 , "poc_lsb_not_present_flag" );
+    }
+  }
+#endif
+#if H_MV_6_HRD_O0217_13
+  codeDpbSize( pcVPS ); 
+#endif
+
+#if !H_MV_6_PS_O0223_29
   WRITE_FLAG( pcVPS->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
+#endif
   WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ),         "direct_dep_type_len_minus2"); 
 
+#if H_MV_6_PS_O0096_21
+  WRITE_FLAG( pcVPS->getDefaultDirectDependencyFlag( ) ? 1 : 0 , "default_direct_dependency_flag" );
+
+  if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+  {  
+    WRITE_CODE( pcVPS->getDefaultDirectDependencyType( ), pcVPS->getDirectDepTypeLenMinus2( ) + 2 , "default_direct_dependency_type" );    
+  }
+
+  for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
+  {
+    for( Int j = 0; j < i; j++ )
+    {
+      if (pcVPS->getDirectDependencyFlag( i, j) )
+      {        
+        if ( pcVPS->getDefaultDirectDependencyFlag( ) )
+        {  
+          assert( pcVPS->getDirectDependencyType( i, j ) == pcVPS->getDefaultDirectDependencyType( ) );
+        }
+        else
+        {
+          assert ( pcVPS->getDirectDependencyType( i, j ) != -1 ); 
+          WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2,  "direct_dependency_type[i][j]" );
+        }
+      }
+    }
+  }  
+#else
     for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ )
     {
@@ -899,7 +1099,9 @@
       }
     }
-    
+#endif
     WRITE_FLAG ( 0,                                      "vps_shvc_reserved_zero_flag" ); 
+#if !H_MV_6_PS_O0109_24
     WRITE_FLAG( pcVPS->getVpsVuiPresentFlag( ) ? 1 : 0 , "vps_vui_present_flag" );
+#endif
 
     if( pcVPS->getVpsVuiPresentFlag() )
@@ -909,19 +1111,95 @@
     }     
 }
-
+#if H_MV_6_PS_O0118_33
+Void TEncCavlc::codeVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo )
+{
+  assert( pcVideoSignalInfo ); 
+  WRITE_CODE( pcVideoSignalInfo->getVideoVpsFormat( ), 3, "video_vps_format" );
+  WRITE_FLAG( pcVideoSignalInfo->getVideoFullRangeVpsFlag( ) ? 1 : 0 , "video_full_range_vps_flag" );
+  WRITE_CODE( pcVideoSignalInfo->getColourPrimariesVps( ), 8, "colour_primaries_vps" );
+  WRITE_CODE( pcVideoSignalInfo->getTransferCharacteristicsVps( ), 8, "transfer_characteristics_vps" );
+  WRITE_CODE( pcVideoSignalInfo->getMatrixCoeffsVps( ), 8, "matrix_coeffs_vps" );
+}
+#endif
+
+#if H_MV_6_HRD_O0217_13
+Void TEncCavlc::codeDpbSize( TComVPS* vps )
+{ 
+  TComDpbSize* dpbSize = vps->getDpbSize(); 
+  assert ( dpbSize != 0 ); 
+
+  for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ )
+  {  
+    WRITE_FLAG( dpbSize->getSubLayerFlagInfoPresentFlag( i ) ? 1 : 0 , "sub_layer_flag_info_present_flag" );
+
+    for( Int j = 0; j  <=  vps->getMaxTLayers() - 1 ; j++ )
+    {  
+      if( j > 0  &&  dpbSize->getSubLayerDpbInfoPresentFlag( i, j )  )  
+      {
+        WRITE_FLAG( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ? 1 : 0 , "sub_layer_dpb_info_present_flag" );
+      }
+      if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) )
+      {  
+        for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   // Preliminary fix does not match with spec
+        {
+          WRITE_UVLC( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ), "max_vps_dec_pic_buffering_minus1" );
+        }
+        WRITE_UVLC( dpbSize->getMaxVpsNumReorderPics( i, j ), "max_vps_num_reorder_pics" );
+        WRITE_UVLC( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ), "max_vps_latency_increase_plus1" );
+      }
+      else
+      {
+        if ( j > 0 )
+        {
+          for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ )   
+          {
+            assert( dpbSize->getMaxVpsDecPicBufferingMinus1( i, k, j ) == dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) );
+          }
+          assert( dpbSize->getMaxVpsNumReorderPics      ( i, j ) ==  dpbSize->getMaxVpsNumReorderPics      ( i, j - 1 ) );
+          assert( dpbSize->getMaxVpsLatencyIncreasePlus1( i, j ) ==  dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) );
+        }
+      }
+    }        
+  }  
+}
+#endif
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+Void TEncCavlc::codeRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat )
+#else
 Void TEncCavlc::codeRepFormat( TComRepFormat* pcRepFormat )
+#endif
 {
   assert( pcRepFormat ); 
 
-  WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" );
-
-  if ( pcRepFormat->getChromaFormatVpsIdc() == 3 )
-  {
-    WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" );
-  }
+#if H_MV_6_PS_REP_FORM_18_19_20
   WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ),  16, "pic_width_vps_in_luma_samples" );
   WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" );
+  WRITE_FLAG( pcRepFormat->getChromaAndBitDepthVpsPresentFlag( ) ? 1 : 0 , "chroma_and_bit_depth_vps_present_flag" );
+  
+  pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); 
+
+  if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() )
+  {  
+#endif
+  WRITE_CODE( pcRepFormat->getChromaFormatVpsIdc( ), 2, "chroma_format_vps_idc" );
+
+  if ( pcRepFormat->getChromaFormatVpsIdc() == 3 )
+  {
+    WRITE_FLAG( pcRepFormat->getSeparateColourPlaneVpsFlag( ) ? 1 : 0 , "separate_colour_plane_vps_flag" );
+  }
+#if !H_MV_6_PS_REP_FORM_18_19_20
+  WRITE_CODE( pcRepFormat->getPicWidthVpsInLumaSamples( ),  16, "pic_width_vps_in_luma_samples" );
+  WRITE_CODE( pcRepFormat->getPicHeightVpsInLumaSamples( ), 16, "pic_height_vps_in_luma_samples" );
+#endif
   WRITE_CODE( pcRepFormat->getBitDepthVpsLumaMinus8( ),      4, "bit_depth_vps_luma_minus8" );
   WRITE_CODE( pcRepFormat->getBitDepthVpsChromaMinus8( ),    4, "bit_depth_vps_chroma_minus8" );
+#if H_MV_6_PS_REP_FORM_18_19_20
+  }
+  else
+  {
+    pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, true ); 
+  }
+#endif
 }
 
@@ -933,4 +1211,12 @@
 
   assert( pcVPSVUI ); 
+
+#if H_MV_6_PS_O0223_29
+  WRITE_FLAG( pcVPSVUI->getCrossLayerPicTypeAlignedFlag( ) ? 1 : 0 , "cross_layer_pic_type_aligned_flag" );
+  if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() )
+  {  
+    WRITE_FLAG( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ? 1 : 0 , "cross_layer_irap_aligned_flag" );
+  }
+#endif
 
   WRITE_FLAG( pcVPSVUI->getBitRatePresentVpsFlag( ) ? 1 : 0 , "bit_rate_present_vps_flag" );
@@ -964,4 +1250,40 @@
   }
 
+#if H_MV_6_O0226_37
+  WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" );
+  if( !pcVPSVUI->getTilesNotInUseFlag() ) 
+  {      
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      WRITE_FLAG( pcVPSVUI->getTilesInUseFlag( i ) ? 1 : 0 , "tiles_in_use_flag[i]" );
+      if( pcVPSVUI->getTilesInUseFlag( i ) )  
+      {
+        WRITE_FLAG( pcVPSVUI->getLoopFilterNotAcrossTilesFlag( i ) ? 1 : 0, "loop_filter_not_across_tiles_flag[i]" );
+      }
+    }  
+
+    for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ )
+      {  
+        Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getRefLayerId(pcVPS->getLayerIdInNuh( i ) , j  ));  
+        if( pcVPSVUI->getTilesInUseFlag( i )  &&  pcVPSVUI->getTilesInUseFlag( layerIdx ) )  
+        {
+          WRITE_FLAG( pcVPSVUI->getTileBoundariesAlignedFlag( i, j ) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" );
+        }
+      }  
+    }
+  }  
+
+  WRITE_FLAG( pcVPSVUI->getWppNotInUseFlag( ) ? 1 : 0 , "wpp_not_in_use_flag" );
+
+  if( !pcVPSVUI->getWppNotInUseFlag( ) )
+  {
+    for( Int i = 0; i  <=  pcVPS->getMaxLayersMinus1(); i++ )  
+    {
+      WRITE_FLAG( pcVPSVUI->getWppInUseFlag( i ) ? 1 : 0 , "wpp_in_use_flag[i]" );
+    }
+  }
+#else
   for( Int i = 1; i  <=  pcVPS->getMaxLayersMinus1(); i++ )
   {
@@ -971,5 +1293,5 @@
     }
   }
-
+#endif
   WRITE_FLAG( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ? 1 : 0 , "ilp_restricted_ref_layers_flag" );
 
@@ -992,5 +1314,105 @@
     }
   }
-}
+#if H_MV_6_PS_O0118_33
+  WRITE_FLAG( pcVPSVUI->getVideoSignalInfoIdxPresentFlag( ) ? 1 : 0 , "video_signal_info_idx_present_flag" );
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    WRITE_CODE( pcVPSVUI->getVpsNumVideoSignalInfoMinus1( ), 4, "vps_num_video_signal_info_minus1" );
+  }
+  else
+  {
+    pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); 
+  }
+
+  for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ )
+  {
+    assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); 
+    TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); 
+    codeVideoSignalInfo( curVideoSignalInfo );     
+  }
+
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" );
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() );
+    }
+  }
+  else
+  {
+    for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i  ) == ( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ) ); 
+    }
+  }
+#endif
+#if H_MV_6_HRD_O0164_15
+  WRITE_FLAG( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ? 1 : 0 , "vps_vui_bsp_hrd_present_flag" );
+  if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
+  {
+    codeVpsVuiBspHrdParameters( pcVPS ); 
+  }
+#endif
+}
+#if H_MV_6_HRD_O0164_15
+Void TEncCavlc::codeVpsVuiBspHrdParameters( TComVPS* pcVPS )
+{
+  assert( pcVPS ); 
+
+  TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 
+
+  assert( pcVPSVUI ); 
+
+  TComVpsVuiBspHrdParameters*  vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 
+
+  assert ( vpsVuiBspHrdP );
+
+  
+  WRITE_UVLC( vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ), "vps_num_bsp_hrd_parameters_minus1" );
+  for( Int i = 0; i <= vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ); i++ )
+  {  
+    if( i > 0 )
+    {
+      WRITE_FLAG( vpsVuiBspHrdP->getBspCprmsPresentFlag( i ) ? 1 : 0 , "bsp_cprms_present_flag" );
+    }
+    TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 
+    codeHrdParameters( hrdParameters, vpsVuiBspHrdP->getBspCprmsPresentFlag( i ), pcVPS->getMaxSubLayersMinus1() );     
+  }  
+  for( Int h = 1; h <= pcVPS->getVpsNumLayerSetsMinus1(); h++ )
+  {  
+    WRITE_UVLC( vpsVuiBspHrdP->getNumBitstreamPartitions( h ), "num_bitstream_partitions" );
+    for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ )  
+    {
+      for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ )  
+      {
+        if( pcVPS->getLayerIdIncludedFlag( h ,j ) )
+        {
+          WRITE_FLAG( vpsVuiBspHrdP->getLayerInBspFlag( h, i, j ) ? 1 : 0 , "layer_in_bsp_flag" );
+        }
+        else
+        {
+          vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec 
+        }
+      }
+    }
+    vpsVuiBspHrdP->checkLayerInBspFlag( pcVPS, h ); 
+
+    if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) )
+    {  
+      WRITE_UVLC( vpsVuiBspHrdP->getNumBspSchedCombinations( h ), "num_bsp_sched_combinations" );
+      for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinations( h ); i++ )
+      {
+        for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ )
+        {  
+          WRITE_UVLC( vpsVuiBspHrdP->getBspCombHrdIdx( h, i, j ), "bsp_comb_hrd_idx" );
+          WRITE_UVLC( vpsVuiBspHrdP->getBspCombSchedIdx( h, i, j ), "bsp_comb_sched_idx" );
+        }  
+      }
+    }  
+  }  
+}  
+#endif
+
 #endif
 
@@ -1115,4 +1537,5 @@
 #if H_MV    
     Int esb = 0;  //Don't use i, otherwise will shadow something below
+#if !H_MV_6_RALS_O0149_11
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
     {
@@ -1120,4 +1543,5 @@
       WRITE_FLAG( pcSlice->getPocResetFlag( ) ? 1 : 0 , "poc_reset_flag" );
     }
+#endif
 
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
@@ -1126,4 +1550,21 @@
       WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );
     }
+
+#if H_MV_6_RALS_O0149_11
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      WRITE_FLAG( pcSlice->getCrossLayerBlaFlag( ) ? 1 : 0 , "cross_layer_bla_flag" );
+    }
+    pcSlice->checkCrossLayerBlaFlag( ); 
+
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb )
+    {
+      esb++; 
+      WRITE_FLAG( pcSlice->getPocResetFlag( ) ? 1 : 0 , "poc_reset_flag" );
+    }
+#endif
+
+
 
     for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++)    
@@ -1148,8 +1589,17 @@
     //   colour_plane_id                                      u(2)
 
+#if H_MV_6_POC_31_35_38
+    if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() )
+    {
+      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
+      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb");
+    }
+#endif
     if( !pcSlice->getIdrPicFlag() )
     {
+#if !H_MV_6_POC_31_35_38
       Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
       WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
+#endif
       TComReferencePictureSet* rps = pcSlice->getRPS();
       
@@ -1265,4 +1715,7 @@
     }
 #if H_MV
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    Bool interLayerPredLayerIdcPresentFlag = false; 
+#endif
     Int layerId = pcSlice->getLayerId(); 
     if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 )
@@ -1276,5 +1729,8 @@
         }
         if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) )
-        {        
+        {
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+          interLayerPredLayerIdcPresentFlag = true; 
+#endif
           for( Int idx = 0; idx < pcSlice->getNumActiveRefLayerPics(); idx++ )   
           {
@@ -1284,4 +1740,13 @@
       }  
     }
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    if ( !interLayerPredLayerIdcPresentFlag )
+    {
+      for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ )   
+      {
+        assert( pcSlice->getInterLayerPredLayerIdc( i ) == pcSlice->getRefLayerPicIdc( i ) );
+      }
+    }
+#endif
 #endif
     if(pcSlice->getSPS()->getUseSAO())
Index: branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.h
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.h	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncCavlc.h	(revision 730)
@@ -85,7 +85,22 @@
   Void  codeVPS                 ( TComVPS* pcVPS );
 #if H_MV
-  Void  codeVPSExtension       ( TComVPS *pcVPS );
-  Void  codeRepFormat          ( TComRepFormat* pcRepFormat );
-  Void  codeVPSVUI             ( TComVPS* pcVPS );
+  Void  codeVPSExtension        ( TComVPS *pcVPS );
+#if H_MV_6_PS_O0118_33
+  Void  codeVideoSignalInfo     ( TComVideoSignalInfo* pcVideoSignalInfo ); 
+#endif
+
+#if H_MV_6_HRD_O0217_13
+  Void  codeDpbSize   ( TComVPS* vps );
+#endif
+
+#if H_MV_6_PS_REP_FORM_18_19_20
+  Void  codeRepFormat           ( Int i, TComRepFormat* curRepFormat, TComRepFormat* prevRepFormat );
+#else
+  Void  codeRepFormat           ( TComRepFormat* pcRepFormat );
+#endif
+  Void  codeVPSVUI              ( TComVPS* pcVPS );
+#if H_MV_6_HRD_O0164_15
+  Void  codeVpsVuiBspHrdParameters( TComVPS* pcVPS ); 
+#endif
 #endif 
   Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
Index: branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncGOP.cpp	(revision 730)
@@ -664,5 +664,9 @@
     refPicListModification->setRefPicListModificationFlagL1(0);
 #if H_MV
+#if H_MV_6_RALS_O0149_11
+    if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )
+#else
     if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 1 )
+#endif
     {
       // Some more sophisticated algorithm to determine discardable_flag might be added here. 
@@ -673,5 +677,8 @@
     Int numDirectRefLayers = vps    ->getNumDirectRefLayers( getLayerId() ); 
     GOPEntry gopEntry      = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );     
-    
+
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    Bool interLayerPredLayerIdcPresentFlag = false; 
+#endif
     if ( getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && numDirectRefLayers > 0 )
     {         
@@ -685,4 +692,7 @@
         if ( gopEntry.m_numActiveRefLayerPics != vps->getNumDirectRefLayers( getLayerId() ) )
         {        
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+          interLayerPredLayerIdcPresentFlag = true; 
+#endif
           for (Int i = 0; i < gopEntry.m_numActiveRefLayerPics; i++ )
           {
@@ -692,4 +702,15 @@
       }
     }
+#if H_MV_6_ILDDS_ILREFPICS_27_34
+    if ( !interLayerPredLayerIdcPresentFlag )
+    {
+      for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ )   
+      {
+        pcSlice->setInterLayerPredLayerIdc(i, pcSlice->getRefLayerPicIdc( i ) );
+      }
+    }
+#endif
+
+
     assert( pcSlice->getNumActiveRefLayerPics() == gopEntry.m_numActiveRefLayerPics ); 
     
Index: branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp
===================================================================
--- branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 729)
+++ branches/HTM-9.0-dev0/source/Lib/TLibEncoder/TEncTop.cpp	(revision 730)
@@ -719,7 +719,18 @@
 
 #if H_MV  
+#if H_MV_6_PS_REP_FORM_18_19_20
+  m_cSPS.setUpdateRepFormatFlag           ( false );    
+#else
   m_cSPS.setUpdateRepFormatFlag           ( m_layerId == 0 );    
+#endif
   m_cSPS.setSpsInferScalingListFlag       ( m_layerId > 0 && m_cVPS->getInDirectDependencyFlag( getLayerIdInVps(), 0 ) ); 
   m_cSPS.setSpsScalingListRefLayerId      ( 0              ); 
+#if H_MV_6_PSEM_O0142_3
+  m_cSPS.setSpsExtensionFlag              ( true ); 
+  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_MV ,true ); 
+#if H_3D
+  m_cSPS.setSpsExtensionTypeFlag          ( PS_EX_T_3D ,true ); 
+#endif
+#endif
 #endif
   m_cSPS.setPicWidthInLumaSamples         ( m_iSourceWidth      );
@@ -808,5 +819,9 @@
     pcVUI->setOverscanInfoPresentFlag(getOverscanInfoPresentFlag());
     pcVUI->setOverscanAppropriateFlag(getOverscanAppropriateFlag());
+#if H_MV_6_PS_O0118_33
+    pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag() && getLayerId() == 0 );
+#else
     pcVUI->setVideoSignalTypePresentFlag(getVideoSignalTypePresentFlag());
+#endif
     pcVUI->setVideoFormat(getVideoFormat());
     pcVUI->setVideoFullRangeFlag(getVideoFullRangeFlag());
@@ -922,5 +937,9 @@
   m_cPPS.setOutputFlagPresentFlag( false );
 #if H_MV
+#if H_MV_6_RALS_O0149_11
+  m_cPPS.setNumExtraSliceHeaderBits( 3 ); 
+#else
   m_cPPS.setNumExtraSliceHeaderBits( 2 ); 
+#endif
 #endif
   m_cPPS.setSignHideFlag(getSignHideFlag());
