From 05fe5ac70168834138b9d48d3659b3beaada0248 Mon Sep 17 00:00:00 2001 From: Vadim Seregin <vseregin@qti.qualcomm.com> Date: Wed, 5 Feb 2020 15:51:59 -0800 Subject: [PATCH] restructure getMaxDpbSize function --- source/Lib/CommonLib/ProfileLevelTier.cpp | 23 +++++++++++ source/Lib/CommonLib/ProfileLevelTier.h | 3 ++ source/Lib/CommonLib/Slice.cpp | 46 ---------------------- source/Lib/CommonLib/Slice.h | 47 ----------------------- source/Lib/EncoderLib/EncLib.cpp | 8 +++- 5 files changed, 33 insertions(+), 94 deletions(-) diff --git a/source/Lib/CommonLib/ProfileLevelTier.cpp b/source/Lib/CommonLib/ProfileLevelTier.cpp index 44f8a7477..e6faf212b 100644 --- a/source/Lib/CommonLib/ProfileLevelTier.cpp +++ b/source/Lib/CommonLib/ProfileLevelTier.cpp @@ -125,3 +125,26 @@ uint64_t ProfileLevelTierFeatures::getCpbSizeInBits() const { return (m_pLevelTier!=0 && m_pProfile!=0) ? uint64_t(m_pProfile->cpbVclFactor) * m_pLevelTier->maxCpb[m_tier?1:0] : uint64_t(0); } + +#if JVET_Q0814_DPB +uint32_t ProfileLevelTierFeatures::getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const +{ + const uint32_t maxDpbPicBuf = 8; + uint32_t maxDpbSize = maxDpbPicBuf; + + if( picSizeMaxInSamplesY <= ( m_pLevelTier->maxLumaPs >> 2 ) ) + { + maxDpbSize = std::min<uint32_t>( 4 * maxDpbPicBuf, 16 ); + } + else if( picSizeMaxInSamplesY <= ( m_pLevelTier->maxLumaPs >> 1 ) ) + { + maxDpbSize = std::min<uint32_t>( 2 * maxDpbPicBuf, 16 ); + } + else if( picSizeMaxInSamplesY <= ( ( 3 * m_pLevelTier->maxLumaPs ) >> 2 ) ) + { + maxDpbSize = std::min<uint32_t>( ( 4 * maxDpbPicBuf ) / 3, 16 ); + } + + return maxDpbSize; +} +#endif \ No newline at end of file diff --git a/source/Lib/CommonLib/ProfileLevelTier.h b/source/Lib/CommonLib/ProfileLevelTier.h index 6cd54107e..dfb9d4596 100644 --- a/source/Lib/CommonLib/ProfileLevelTier.h +++ b/source/Lib/CommonLib/ProfileLevelTier.h @@ -95,6 +95,9 @@ class ProfileLevelTierFeatures Level::Tier getTier() const { return m_tier; } uint64_t getCpbSizeInBits() const; double getMinCr() const; +#if JVET_Q0814_DPB + uint32_t getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const; +#endif }; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 7e84b6419..74503476e 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -3457,28 +3457,6 @@ void ParameterSetMap<VPS>::setID(VPS* parameterSet, const int psId) parameterSet->setVPSId(psId); } -#if JVET_Q0814_DPB -#if defined( __GNUC__) && __GNUC__ < 6 -std::unordered_map<Level::Name, TierLevelLimits, EnumHash> ProfileTierLevel::m_tierLevelLimits = { -#else -std::unordered_map<Level::Name, TierLevelLimits> ProfileTierLevel::m_tierLevelLimits = { -#endif - { Level::Name::LEVEL1, TierLevelLimits( Level::Name::LEVEL1, 36864, std::pair<int, int>( 350, -1 ), 16, 1, 1 ) }, - { Level::Name::LEVEL2, TierLevelLimits( Level::Name::LEVEL2, 122880, std::pair<int, int>( 1500, -1 ), 16, 1, 1 ) }, - { Level::Name::LEVEL2_1, TierLevelLimits( Level::Name::LEVEL2_1, 245760, std::pair<int, int>( 3000, -1 ), 20, 1, 1 ) }, - { Level::Name::LEVEL3, TierLevelLimits( Level::Name::LEVEL3, 552960, std::pair<int, int>( 6000, -1 ), 30, 2, 2 ) }, - { Level::Name::LEVEL3_1, TierLevelLimits( Level::Name::LEVEL3_1, 983040, std::pair<int, int>( 10000, -1 ), 40, 3, 3 ) }, - { Level::Name::LEVEL4, TierLevelLimits( Level::Name::LEVEL4, 2228224, std::pair<int, int>( 12000, 30000 ), 75, 5, 5 ) }, - { Level::Name::LEVEL4_1, TierLevelLimits( Level::Name::LEVEL4_1, 2228224, std::pair<int, int>( 20000, 50000 ), 75, 5, 5 ) }, - { Level::Name::LEVEL5, TierLevelLimits( Level::Name::LEVEL5, 8912896, std::pair<int, int>( 25000, 100000 ), 200, 11, 10 ) }, - { Level::Name::LEVEL5_1, TierLevelLimits( Level::Name::LEVEL5_1, 8912896, std::pair<int, int>( 40000, 160000 ), 200, 11, 10 ) }, - { Level::Name::LEVEL5_2, TierLevelLimits( Level::Name::LEVEL5_2, 8912896, std::pair<int, int>( 60000, 240000 ), 200, 11, 10 ) }, - { Level::Name::LEVEL6, TierLevelLimits( Level::Name::LEVEL6, 35651584, std::pair<int, int>( 60000, 240000 ), 600, 22, 20 ) }, - { Level::Name::LEVEL6_1, TierLevelLimits( Level::Name::LEVEL6_1, 35651584, std::pair<int, int>( 120000, 480000 ), 600, 22, 20 ) }, - { Level::Name::LEVEL6_2, TierLevelLimits( Level::Name::LEVEL6_2, 35651584, std::pair<int, int>( 240000, 800000 ), 600, 22, 20 ) } -}; -#endif - ProfileTierLevel::ProfileTierLevel() : m_tierFlag (Level::MAIN) , m_profileIdc (Profile::NONE) @@ -3491,30 +3469,6 @@ ProfileTierLevel::ProfileTierLevel() } -#if JVET_Q0814_DPB -uint32_t ProfileTierLevel::getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const -{ - const uint32_t maxDpbPicBuf = 8; - const uint32_t maxLumaPs = m_tierLevelLimits[m_levelIdc].maxLumaPs; - uint32_t maxDpbSize = maxDpbPicBuf; - - if( picSizeMaxInSamplesY <= ( maxLumaPs >> 2 ) ) - { - maxDpbSize = std::min<uint32_t>( 4 * maxDpbPicBuf, 16 ); - } - else if( picSizeMaxInSamplesY <= ( maxLumaPs >> 1 ) ) - { - maxDpbSize = std::min<uint32_t>( 2 * maxDpbPicBuf, 16 ); - } - else if( picSizeMaxInSamplesY <= ( ( 3 * maxLumaPs ) >> 2 ) ) - { - maxDpbSize = std::min<uint32_t>( ( 4 * maxDpbPicBuf ) / 3, 16 ); - } - - return maxDpbSize; -} -#endif - void calculateParameterSetChangedFlag(bool &bChanged, const std::vector<uint8_t> *pOldData, const std::vector<uint8_t> *pNewData) { if (!bChanged) diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index fcec1c018..4e00c5cdd 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -446,50 +446,8 @@ public: void setNoApsConstraintFlag(bool bVal) { m_noApsConstraintFlag = bVal; } }; -#if JVET_Q0814_DPB -struct TierLevelLimits -{ - TierLevelLimits() {} - - TierLevelLimits( Level::Name _level, uint32_t _maxLumaPs, std::pair<int, int> _maxCPBsize, int _maxSlicesPerPictue, int _maxTileRows, int _maxTileColumns ) - : level( _level ) - , maxLumaPs( _maxLumaPs ) - , maxCPBsize( _maxCPBsize ) - , maxSlicesPerPictue( _maxSlicesPerPictue ) - , maxTileRows( _maxTileRows ) - , maxTileColumns( _maxTileColumns ) - { } - - Level::Name level; - uint32_t maxLumaPs; - std::pair<int, int> maxCPBsize; // main tiers, high tiers - int maxSlicesPerPictue; - int maxTileRows; - int maxTileColumns; -}; - -// drop gcc 5 support? -#if defined( __GNUC__) && __GNUC__ < 6 -struct EnumHash -{ - template <typename T> - std::size_t operator()( T value ) const - { - return static_cast<std::size_t>( value ); - } -}; -#endif -#endif - class ProfileTierLevel { -#if JVET_Q0814_DPB -#if defined( __GNUC__) && __GNUC__ < 6 - static std::unordered_map<Level::Name, TierLevelLimits, EnumHash> m_tierLevelLimits; -#else - static std::unordered_map<Level::Name, TierLevelLimits> m_tierLevelLimits; -#endif -#endif Level::Tier m_tierFlag; Profile::Name m_profileIdc; uint8_t m_numSubProfile; @@ -527,11 +485,6 @@ public: Level::Name getSubLayerLevelIdc(int i) const { return m_subLayerLevelIdc[i]; } void setSubLayerLevelIdc(int i, Level::Name x) { m_subLayerLevelIdc[i] = x; } - - -#if JVET_Q0814_DPB - uint32_t getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const; -#endif }; diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 0d55874e4..881b5554c 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -47,6 +47,9 @@ #include <omp.h> #endif #include "EncLibCommon.h" +#if JVET_Q0814_DPB +#include "CommonLib/ProfileLevelTier.h" +#endif //! \ingroup EncoderLib //! \{ @@ -1012,6 +1015,9 @@ void EncLib::xInitVPS( const SPS& sps ) // set the VPS profile information. m_vps->setMaxSubLayers( sps.getMaxTLayers() ); + ProfileLevelTierFeatures profileLevelTierFeatures; + profileLevelTierFeatures.extractPTLInformation( sps ); + m_vps->deriveOutputLayerSets(); m_vps->deriveTargetOutputLayerSet( m_vps->m_targetOlsIdx ); @@ -1066,7 +1072,7 @@ void EncLib::xInitVPS( const SPS& sps ) for( int j = ( m_vps->m_sublayerDpbParamsPresentFlag ? 0 : m_vps->m_dpbMaxTemporalId[i] ); j <= m_vps->m_dpbMaxTemporalId[i]; j++ ) { - m_vps->m_dpbParameters[i].m_maxDecPicBuffering[j] = sps.getProfileTierLevel()->getMaxDpbSize( m_vps->getOlsDpbPicSize( olsIdx ).width * m_vps->getOlsDpbPicSize( olsIdx ).height ); + m_vps->m_dpbParameters[i].m_maxDecPicBuffering[j] = profileLevelTierFeatures.getMaxDpbSize( m_vps->getOlsDpbPicSize( olsIdx ).width * m_vps->getOlsDpbPicSize( olsIdx ).height ); m_vps->m_dpbParameters[i].m_numReorderPics[j] = m_vps->m_dpbParameters[i].m_maxDecPicBuffering[j]; m_vps->m_dpbParameters[i].m_maxLatencyIncreasePlus1[j] = 0; } -- GitLab