Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp	(revision 1061)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.cpp	(revision 1062)
@@ -4439,4 +4439,5 @@
 
 #if H_MV
+#if !H_MV_HLS10_PTL_INFER_FIX
 Void TComPTL::copyLevelFrom( TComPTL* source )
 {
@@ -4448,4 +4449,5 @@
   }
 }
+#endif
 #endif
 //! \}
Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h	(revision 1061)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TComSlice.h	(revision 1062)
@@ -208,4 +208,5 @@
   
 #if H_MV_HLS10_PTL
+#if H_MV
   Bool m_max12bitConstraintFlag;
   Bool m_max10bitConstraintFlag;
@@ -219,4 +220,5 @@
   Bool m_inbldFlag;
 #endif
+#endif
 public:
   ProfileTierLevel();
@@ -249,4 +251,5 @@
   Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; }
 
+#if H_MV
 #if H_MV_HLS10_PTL
   Void setMax12bitConstraintFlag( Bool flag ) { m_max12bitConstraintFlag = flag; } 
@@ -278,4 +281,52 @@
   Void setInbldFlag( Bool flag ) { m_inbldFlag = flag; } 
   Bool getInbldFlag(  ) { return m_inbldFlag; } 
+#endif
+#if H_MV_HLS10_PTL_INFER_FIX
+
+  Bool getV2ConstraintsPresentFlag() 
+  {
+  return ( 
+    getProfileIdc( ) ==  4 || getProfileCompatibilityFlag( 4 ) || getProfileIdc( ) ==  5 || getProfileCompatibilityFlag( 5 )  ||
+    getProfileIdc( ) ==  6 || getProfileCompatibilityFlag( 6 ) || getProfileIdc( ) ==  7 || getProfileCompatibilityFlag( 7 ) 
+    ); 
+  }
+  
+  Bool getInbldPresentFlag() 
+  {
+    return ( 
+      ( getProfileIdc() >= 1 && getProfileIdc() <= 5 )  || getProfileCompatibilityFlag( 1 ) || getProfileCompatibilityFlag( 2 ) || 
+      getProfileCompatibilityFlag( 3 ) || getProfileCompatibilityFlag( 4 )  ||   getProfileCompatibilityFlag( 5 ) 
+      );
+  }
+
+  Void copyV2ConstraintFlags( ProfileTierLevel* ptlRef )
+  {
+    setMax12bitConstraintFlag         ( ptlRef->getMax12bitConstraintFlag       ( ) );
+    setMax10bitConstraintFlag         ( ptlRef->getMax10bitConstraintFlag       ( ) );
+    setMax8bitConstraintFlag          ( ptlRef->getMax8bitConstraintFlag        ( ) );
+    setMax422chromaConstraintFlag     ( ptlRef->getMax422chromaConstraintFlag   ( ) );
+    setMax420chromaConstraintFlag     ( ptlRef->getMax420chromaConstraintFlag   ( ) );
+    setMaxMonochromeConstraintFlag    ( ptlRef->getMaxMonochromeConstraintFlag  ( ) );
+    setIntraConstraintFlag            ( ptlRef->getIntraConstraintFlag          ( ) );
+    setOnePictureOnlyConstraintFlag   ( ptlRef->getOnePictureOnlyConstraintFlag ( ) );
+    setLowerBitRateConstraintFlag     ( ptlRef->getLowerBitRateConstraintFlag   ( ) );   
+  }
+
+  Void copyProfile( ProfileTierLevel* ptlRef )
+  {
+      setProfileSpace            ( ptlRef->getProfileSpace              ( ) );
+      setTierFlag                ( ptlRef->getTierFlag                  ( ) );
+      setProfileIdc              ( ptlRef->getProfileIdc                ( ) );
+      for (Int j = 0; j < 32; j++)
+      {      
+        setProfileCompatibilityFlag(j, ptlRef->getProfileCompatibilityFlag  ( j ) );            
+      }
+      setProgressiveSourceFlag   ( ptlRef->getProgressiveSourceFlag     ( ) );
+      setInterlacedSourceFlag    ( ptlRef->getInterlacedSourceFlag      ( ) );
+      setNonPackedConstraintFlag ( ptlRef->getNonPackedConstraintFlag   ( ) );
+      setFrameOnlyConstraintFlag ( ptlRef->getFrameOnlyConstraintFlag   ( ) );
+      copyV2ConstraintFlags      ( ptlRef );
+  }
+#endif
 #endif
 
@@ -301,5 +352,94 @@
   ProfileTierLevel* getSubLayerPTL(Int i)  { return &m_subLayerPTL[i]; }
 #if H_MV
+#if H_MV_HLS10_PTL_INFER_FIX
+  Void inferGeneralValues( Bool profilePresentFlag, Int k, TComPTL* refPTL )
+  {
+    ProfileTierLevel* refProfileTierLevel = NULL; 
+    if ( k > 0 )
+    {    
+      assert( refPTL != NULL);
+      refProfileTierLevel = refPTL->getGeneralPTL(); 
+    }
+
+    ProfileTierLevel* curProfileTierLevel = getGeneralPTL( ); 
+
+    if( !profilePresentFlag )
+    {
+      assert( k > 0 ); 
+      assert( refProfileTierLevel != NULL ); 
+      curProfileTierLevel->copyProfile( refProfileTierLevel);
+    }
+    else
+    {
+      if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() )
+      {
+        curProfileTierLevel->setMax12bitConstraintFlag         ( false );
+        curProfileTierLevel->setMax10bitConstraintFlag         ( false );
+        curProfileTierLevel->setMax8bitConstraintFlag          ( false );
+        curProfileTierLevel->setMax422chromaConstraintFlag     ( false );
+        curProfileTierLevel->setMax420chromaConstraintFlag     ( false );
+        curProfileTierLevel->setMaxMonochromeConstraintFlag    ( false );
+        curProfileTierLevel->setIntraConstraintFlag            ( false );
+        curProfileTierLevel->setOnePictureOnlyConstraintFlag   ( false );
+        curProfileTierLevel->setLowerBitRateConstraintFlag     ( false );   
+      }
+
+      if ( !curProfileTierLevel->getInbldPresentFlag() )
+      {
+        curProfileTierLevel->setInbldFlag( false ); 
+      }      
+    }         
+  }; 
+
+  Void inferSubLayerValues( Int maxNumSubLayersMinus1, Int k, TComPTL* refPTL )
+  {
+    assert( k == 0 || refPTL != NULL ); 
+
+    for (Int i = maxNumSubLayersMinus1; i >= 0; i--)
+    {
+      ProfileTierLevel* refProfileTierLevel;
+      if ( k != 0 )
+      {
+        refProfileTierLevel = refPTL->getSubLayerPTL( i );
+      }
+      else
+      {
+        if ( i == maxNumSubLayersMinus1)      
+        {
+          refProfileTierLevel = getGeneralPTL();
+        }
+        else
+        {
+          refProfileTierLevel = getSubLayerPTL( i + 1 );
+        }
+      }    
+
+      ProfileTierLevel* curProfileTierLevel = getSubLayerPTL( i ); 
+      if( !getSubLayerLevelPresentFlag( i ) )
+      {
+        curProfileTierLevel->setLevelIdc( refProfileTierLevel->getLevelIdc() ); 
+      }
+
+      if( !getSubLayerProfilePresentFlag( i ) )
+      {
+        curProfileTierLevel->copyProfile( refProfileTierLevel);
+      }
+      else
+      {
+        if ( !curProfileTierLevel->getV2ConstraintsPresentFlag() )
+        {
+          curProfileTierLevel->copyV2ConstraintFlags( refProfileTierLevel ); 
+        }
+
+        if ( !curProfileTierLevel->getInbldPresentFlag() )
+        {
+          curProfileTierLevel->setInbldFlag( refProfileTierLevel->getInbldFlag() ); 
+        }      
+      }     
+    }
+  }; 
+#else
   Void copyLevelFrom( TComPTL* source );
+#endif
 #endif
 };
Index: /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1061)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibCommon/TypeDef.h	(revision 1062)
@@ -414,5 +414,6 @@
 #define H_MV_HLS10_MAXNUMPICS                1  // constraint on number of pictures in rps  
 #define H_MV_HLS10_PTL                       1  // profile tier level
-#define H_MV_HLS10_PTL_FIX                   1  // profile tier level
+#define H_MV_HLS10_PTL_FIX                   1  // profile tier level fix
+#define H_MV_HLS10_PTL_INFER_FIX             1  // fix inference ptl
 #define H_MV_HLS10_MULTILAYERSPS             1  // multilayer SPS extension 
 #define H_MV_HLS10_VPS_VUI                   1  // vsp vui
Index: /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1061)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1062)
@@ -803,4 +803,8 @@
 
     parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
+#if H_MV_HLS10_PTL_INFER_FIX
+    pcSPS->getPTL()->inferGeneralValues ( true, 0, NULL ); 
+    pcSPS->getPTL()->inferSubLayerValues( pcSPS->getMaxTLayers() - 1, 0, NULL );
+#endif
 #if H_MV
   }
@@ -1146,4 +1150,10 @@
   READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
   parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1);
+#if H_MV_HLS10_PTL_INFER_FIX
+#if H_MV
+  pcVPS->getPTL()->inferGeneralValues ( true, 0, NULL );
+  pcVPS->getPTL()->inferSubLayerValues( pcVPS->getMaxTLayers() - 1, 0, NULL );
+#endif
+#endif
   UInt subLayerOrderingInfoPresentFlag;
   READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag");
@@ -1269,8 +1279,13 @@
     parsePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1()  );  
     
+#if !H_MV_HLS10_PTL_INFER_FIX
     // Copy Profile info
     TComPTL temp = *pcVPS->getPTL( 1 );
     *pcVPS->getPTL( 1 ) = *pcVPS->getPTL( 0 );
     pcVPS->getPTL( 1 )->copyLevelFrom( &temp );
+#else
+    pcVPS->getPTL( 1 )->inferGeneralValues ( false, 1, pcVPS->getPTL( 0 ) );
+    pcVPS->getPTL( 1 )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1(), 1, pcVPS->getPTL( 0 ) );    
+#endif
   }
 #endif 
@@ -1404,4 +1419,8 @@
     READ_FLAG(  uiCode, "vps_profile_present_flag[i]" );    pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 );
     parsePTL ( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1);
+#if H_MV_HLS10_PTL_INFER_FIX
+    pcVPS->getPTL( offsetVal )->inferGeneralValues ( pcVPS->getVpsProfilePresentFlag( i ), offsetVal, pcVPS->getPTL( offsetVal - 1 ) );    
+    pcVPS->getPTL( offsetVal )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1()      , offsetVal, pcVPS->getPTL( offsetVal - 1 ) );    
+#else
     if( !pcVPS->getVpsProfilePresentFlag( i ) )
     {
@@ -1410,4 +1429,5 @@
       pcVPS->getPTL( offsetVal )->copyLevelFrom( &temp );
     }
+#endif
     offsetVal++;
   }
@@ -3166,5 +3186,10 @@
       READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
 #if H_MV
-    rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) );
+#if !H_MV_HLS10_PTL_INFER_FIX
+      rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) );
+#else
+      // When profilePresentFlag is equal to 0, sub_layer_profile_present_flag[ i ] shall be equal to 0.
+      assert( profilePresentFlag || !rpcPTL->getSubLayerProfilePresentFlag(i) );
+#endif
 #else
     }
@@ -3184,5 +3209,13 @@
   for(Int i = 0; i < maxNumSubLayersMinus1; i++)
   {
-    if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) )
+#if H_MV_HLS10_PTL_INFER_FIX
+#if H_MV
+    if( rpcPTL->getSubLayerProfilePresentFlag(i) )         
+#else
+    if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) )          
+#endif
+#else
+    if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) )    
+#endif
     {
       parseProfileTier(rpcPTL->getSubLayerPTL(i));
@@ -3218,18 +3251,22 @@
   
 #if H_MV_HLS10_PTL
+#if H_MV_HLS10_PTL_INFER_FIX
+  if( ptl->getV2ConstraintsPresentFlag() )
+#else
   if( ptl->getProfileIdc( ) ==  4 || ptl->getProfileCompatibilityFlag( 4 )  ||
       ptl->getProfileIdc( ) ==  5 || ptl->getProfileCompatibilityFlag( 5 )  ||
       ptl->getProfileIdc( ) ==  6 || ptl->getProfileCompatibilityFlag( 6 )  ||
       ptl->getProfileIdc( ) ==  7 || ptl->getProfileCompatibilityFlag( 7 ) ) 
-  {
-    READ_FLAG( uiCode, "max_12bit_constraint_flag" ); ptl->setMax12bitConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "max_10bit_constraint_flag" ); ptl->setMax10bitConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "max_8bit_constraint_flag" ); ptl->setMax8bitConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "max_422chroma_constraint_flag" ); ptl->setMax422chromaConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "max_420chroma_constraint_flag" ); ptl->setMax420chromaConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "max_monochrome_constraint_flag" ); ptl->setMaxMonochromeConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "intra_constraint_flag" ); ptl->setIntraConstraintFlag( uiCode == 1 );
+#endif
+  {
+    READ_FLAG( uiCode, "max_12bit_constraint_flag" );        ptl->setMax12bitConstraintFlag      ( uiCode == 1 );
+    READ_FLAG( uiCode, "max_10bit_constraint_flag" );        ptl->setMax10bitConstraintFlag      ( uiCode == 1 );
+    READ_FLAG( uiCode, "max_8bit_constraint_flag" );         ptl->setMax8bitConstraintFlag       ( uiCode == 1 );
+    READ_FLAG( uiCode, "max_422chroma_constraint_flag" );    ptl->setMax422chromaConstraintFlag  ( uiCode == 1 );
+    READ_FLAG( uiCode, "max_420chroma_constraint_flag" );    ptl->setMax420chromaConstraintFlag  ( uiCode == 1 );
+    READ_FLAG( uiCode, "max_monochrome_constraint_flag" );   ptl->setMaxMonochromeConstraintFlag ( uiCode == 1 );
+    READ_FLAG( uiCode, "intra_constraint_flag" );            ptl->setIntraConstraintFlag         ( uiCode == 1 );
     READ_FLAG( uiCode, "one_picture_only_constraint_flag" ); ptl->setOnePictureOnlyConstraintFlag( uiCode == 1 );
-    READ_FLAG( uiCode, "lower_bit_rate_constraint_flag" ); ptl->setLowerBitRateConstraintFlag( uiCode == 1 );    
+    READ_FLAG( uiCode, "lower_bit_rate_constraint_flag" );   ptl->setLowerBitRateConstraintFlag  ( uiCode == 1 );    
     READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[0..15]");
     READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[16..31]");
@@ -3242,8 +3279,12 @@
     READ_CODE(11, uiCode, "XXX_reserved_zero_43bits[32..42]");
   }
+#if H_MV_HLS10_PTL_INFER_FIX
+  if( ptl->getInbldPresentFlag() )
+#else
   if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 )  ||
     ptl->getProfileCompatibilityFlag( 1 ) || ptl->getProfileCompatibilityFlag( 2 )  ||
     ptl->getProfileCompatibilityFlag( 3 ) || ptl->getProfileCompatibilityFlag( 4 )  ||
     ptl->getProfileCompatibilityFlag( 5 ) )
+#endif
   {
     READ_FLAG( uiCode, "inbld_flag" ); ptl->setInbldFlag( uiCode == 1 );
Index: /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1061)
+++ /branches/HTM-12.0-dev1/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1062)
@@ -2559,8 +2559,12 @@
   
 #if H_MV_HLS10_PTL
+#if H_MV_HLS10_PTL_INFER_FIX
+  if( ptl->getV2ConstraintsPresentFlag() ) 
+#else
   if( ptl->getProfileIdc( ) ==  4 || ptl->getProfileCompatibilityFlag( 4 )  ||
     ptl->getProfileIdc( ) ==  5 || ptl->getProfileCompatibilityFlag( 5 )  ||
     ptl->getProfileIdc( ) ==  6 || ptl->getProfileCompatibilityFlag( 6 )  ||
     ptl->getProfileIdc( ) ==  7 || ptl->getProfileCompatibilityFlag( 7 ) ) 
+#endif
   {
     WRITE_FLAG( ptl->getMax12bitConstraintFlag( ) ? 1 : 0 , "max_12bit_constraint_flag" );
@@ -2583,8 +2587,12 @@
     WRITE_CODE( 0, 11, "XXX_reserved_zero_43bits[32..42]");
   }
+#if H_MV_HLS10_PTL_INFER_FIX
+    if( ptl->getInbldPresentFlag() )
+#else
   if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 )  ||
     ptl->getProfileCompatibilityFlag( 1 ) || ptl->getProfileCompatibilityFlag( 2 )  ||
     ptl->getProfileCompatibilityFlag( 3 ) || ptl->getProfileCompatibilityFlag( 4 )  ||
     ptl->getProfileCompatibilityFlag( 5 ) )
+#endif
   {
     WRITE_FLAG( ptl->getInbldFlag( ) ? 1 : 0 , "inbld_flag" );
