Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp	(revision 1055)
@@ -103,4 +103,7 @@
 , m_temporalLayerNonReferenceFlag ( false )
 , m_enableTMVPFlag                ( true )
+#if I0044_SLICE_TMVP
+, m_availableForTMVPRefFlag       ( true )
+#endif
 #if H_MV
 , m_refPicSetInterLayer0           ( NULL )
@@ -725,4 +728,7 @@
 
         assert( rpsCurrList[li][ orgIdx ] != NULL ); 
+#if DISCARDABLE_PIC_RPS
+        assert( rpsCurrList[li][ orgIdx ]->getSlice(0)->getDiscardableFlag() == 0 );    // Inter-layer RPS shall not contain picture with discardable_flag = 1.
+#endif
         m_apcRefPicList    [li][rIdx] = rpsCurrList    [li][ orgIdx ];
         m_bIsUsedAsLongTerm[li][rIdx] = usedAsLongTerm [li][ orgIdx ] ; 
Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h	(revision 1055)
@@ -589,5 +589,5 @@
   Void setHrdParametermeters( Int k, TComHRD* val  ) {  m_hrdParameters[k] = val; }; 
   TComHRD* getHrdParametermeters( Int k ) {  return m_hrdParameters[k]; }; 
-#endif;
+#endif
 };
 
@@ -1204,4 +1204,7 @@
   Void    setLayerSetIdxForOlsMinus1( Int outLayerSetIdx, Int val )        { m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]  = val; } 
   Int     getLayerSetIdxForOlsMinus1( Int outLayerSetIdx )                 { return m_layerSetIdxForOlsMinus1[ outLayerSetIdx ]; } 
+#if VPS_MISC_UPDATES
+  Int     getLayerSetIdxForOlsMinus1Len( Int outLayerSetIdx )              { return gCeilLog2( getNumLayerSets() ); } 
+#endif
 
   Void    setOutputLayerFlag( Int outLayerSetIdx, Int i, Bool flag )       { m_outputLayerFlag[ outLayerSetIdx ][ i ] = flag; } 
@@ -1421,5 +1424,5 @@
     std::vector<Int> idx; 
     std::vector<Int> num; 
-    std::vector<std::vector<Int>> ptlInfo; 
+    std::vector< std::vector<Int> > ptlInfo; 
 
     std::cout << std::right << std::setw(60) << std::setfill('-') << " " << std::setfill(' ') << std::endl << "PTLI" << std::endl; 
@@ -2688,4 +2691,8 @@
 
   Bool       m_enableTMVPFlag;
+#if I0044_SLICE_TMVP
+  Bool       m_availableForTMVPRefFlag;
+#endif
+
 #if H_MV
   std::vector<TComPic*>* m_refPicSetInterLayer0; 
@@ -3024,4 +3031,8 @@
   Void      setEnableTMVPFlag     ( Bool   b )    { m_enableTMVPFlag = b; }
   Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
+#if I0044_SLICE_TMVP
+  Void      setAvailableForTMVPRefFlag     ( Bool   b )    { m_availableForTMVPRefFlag = b; }
+  Bool      getAvailableForTMVPRefFlag     ()              { return m_availableForTMVPRefFlag;}
+#endif
 
 #if H_MV
Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1055)
@@ -388,4 +388,15 @@
 // TBD: Check if integration is necessary. 
 
+
+
+//Added by Qualcomm for HLS
+#define DISCARDABLE_PIC_RPS              1      ///< JCT3V-G0131: Inter-layer RPS and temporal RPS should not contain picture with discardable_flag equal to 1
+#define VPS_MISC_UPDATES                 1      ///< Misc updates:JCT3V-0240, 
+#define NON_REF_NAL_TYPE_DISCARDABLE     1      ///< JCT3V-G0031: If discardable picture is a non-IRAP, it must be a non-referenced sub-layer picture
+#define INFERENCE_POC_MSB_VAL_PRESENT    1      ///< JCT3V-H0042: poc_msb_val_present_flag shall be equal to 0 when slice_header_extension_length is (inferred to be ) equal to 0
+#define INFERENCE_POC_RESET_INFO_PRESENT 1      ///< JCT3V-H0042: Infer the value of poc_reset_info_present_flag to be equal to 0 when no pps extension / pps extension for multilayer.
+#define I0044_SLICE_TMVP                 1      ///< JCT3V-I0044: Regarding slice_temporal_mvp_enabled_flag
+#define I0045_BR_PR_ADD_LAYER_SET        1      ///< JCT3V-I0045: Signalling of bit-rate and picture rate for additional layer set
+#define I0045_VPS_VUI_VST_PARAMS         1      ///< JCT3V-I0045: Related to signalling of VST parameters of the base layer.
 
 
Index: /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1055)
@@ -1438,5 +1438,5 @@
     }
   }
-#endif // H_MV_HLS10_GEN
+#endif
 
   if (pcVPS->getNumLayerSets() > 1)
@@ -1461,5 +1461,9 @@
     if( i >= pcVPS->getNumLayerSets( ) )    
     {        
+#if !VPS_MISC_UPDATES
       READ_UVLC( uiCode,      "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); 
+#else
+      READ_CODE( pcVPS->getLayerSetIdxForOlsMinus1Len( i ), uiCode, "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); 
+#endif
     }
 
@@ -1709,11 +1713,30 @@
   }
 
+#if I0045_VPS_VUI_VST_PARAMS
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
   {
-#if H_MV_HLS10_VPS_VUI
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#else
+    {
+      READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );
+    }
+  }
+  else if ( !pcVPSVUI->getVideoSignalInfoIdxPresentFlag() )
+  {
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, i );
+    }
+  }
+  else
+  {
+    for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 );
+    }
+  }
+#else
+  if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
+  {
     for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode );
@@ -1728,4 +1751,5 @@
     }
   }
+#endif
   READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 );
   if( !pcVPSVUI->getTilesNotInUseFlag() ) 
@@ -1802,4 +1826,7 @@
   if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) )
   {
+#if VPS_MISC_UPDATES
+    assert(pcVPS->getTimingInfo()->getTimingInfoPresentFlag() == 1);
+#endif
     parseVpsVuiBspHrdParameters( pcVPS ); 
   }
@@ -2287,4 +2314,14 @@
       esb++; 
       READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 );
+#if NON_REF_NAL_TYPE_DISCARDABLE
+      if ( uiCode == 1 )
+      {
+        assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&
+          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&
+          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&
+          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&
+          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);
+      }
+#endif
     }
 
@@ -2574,5 +2611,9 @@
       if (rpcSlice->getSPS()->getTMVPFlagsPresent())
       {
+#if I0044_SLICE_TMVP
+        READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
+#else
         READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" );
+#endif
         rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 
       }
@@ -3014,4 +3055,11 @@
 #endif
   }
+#if INFERENCE_POC_MSB_VAL_PRESENT
+  else
+  {
+    rpcSlice->setSliceSegmentHeaderExtensionLength( 0 );
+    rpcSlice->setPocMsbValPresentFlag( false );
+  }
+#endif
 
 
Index: /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecTop.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecTop.cpp	(revision 1055)
@@ -938,4 +938,28 @@
    }
 #endif
+   
+#if I0044_SLICE_TMVP
+  if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 )
+  {
+    //update all pics in the DPB such that they cannot be used for TMPV ref
+    TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin();  
+    while( iterRefPic != m_cListPic.end() )
+    {
+      TComPic *refPic = *iterRefPic;
+      if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() )
+      {
+        for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
+        {
+
+          TComSlice *refSlice = refPic->getSlice(i);
+          refSlice->setAvailableForTMVPRefFlag( false );
+        }
+      }
+      iterRefPic++;
+    }
+  }
+  m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
+#endif
+
   xActivateParameterSets();
 
@@ -1161,4 +1185,15 @@
 #endif    
 #endif
+    // For generalized B
+#if I0044_SLICE_TMVP
+    if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
+    {
+      TComPic* refPic = pcSlice->getRefPic(RefPicList(1 - pcSlice->getColFromL0Flag()), pcSlice->getColRefIdx());
+
+      assert ( refPic );
+      assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true );
+    }
+#endif
+
     // For generalized B
     // note: maybe not existed case (always L0 is copied to L1 if L1 is empty)
Index: /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1054)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1055)
@@ -1229,5 +1229,5 @@
     }
   }
-#endif // H_MV_HLS10_GEN
+#endif
 
   if (pcVPS->getNumLayerSets() > 1)
@@ -1247,5 +1247,9 @@
     if( i >= pcVPS->getNumLayerSets( ) )    
     {      
+#if !VPS_MISC_UPDATES
       WRITE_UVLC( pcVPS->getLayerSetIdxForOlsMinus1( i ),      "layer_set_idx_for_ols_minus1[i]" );
+#else
+      WRITE_CODE( pcVPS->getLayerSetIdxForOlsMinus1( i ), pcVPS->getLayerSetIdxForOlsMinus1Len( i ) ,      "layer_set_idx_for_ols_minus1[i]" );
+#endif
     }
 
@@ -1562,9 +1566,11 @@
   if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 )
   {
-#if H_MV_HLS10_VPS_VUI
+#if I0045_VPS_VUI_VST_PARAMS
     for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
+    {
+      WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" );
+    }
 #else
     for( Int i = 1; i <=  pcVPS->getMaxLayersMinus1(); i++ )
-#endif
     {
       WRITE_CODE( pcVPSVUI->getVpsVideoSignalInfoIdx( i ), 4, "vps_video_signal_info_idx" );
@@ -1578,4 +1584,5 @@
       assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i  ) == ( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ) ); 
     }
+#endif
   }
   WRITE_FLAG( pcVPSVUI->getTilesNotInUseFlag( ) ? 1 : 0 , "tiles_not_in_use_flag" );
@@ -1941,4 +1948,14 @@
       esb++; 
       WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );
+#if NON_REF_NAL_TYPE_DISCARDABLE
+      if (pcSlice->getDiscardableFlag( ))
+      {
+        assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&
+          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&
+          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&
+          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&
+          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);
+      }
+#endif
     }
 
@@ -2101,5 +2118,9 @@
       if (pcSlice->getSPS()->getTMVPFlagsPresent())
       {
+#if I0044_SLICE_TMVP
+        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
+#else
         WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" );
+#endif
       }
     }
