From d419dba65a69b8b5f3d2fdecbc9cf776cc3e2f5c Mon Sep 17 00:00:00 2001 From: zhangkai <zhangkai.video@bytedance.com> Date: Mon, 17 Feb 2020 19:32:52 -0800 Subject: [PATCH] Add the decoder checking for duplicated DCI --- source/App/EncoderApp/EncApp.cpp | 2 +- source/Lib/CommonLib/Slice.cpp | 87 ++++++++++++++++++++++++++++++++ source/Lib/CommonLib/Slice.h | 15 ++++++ source/Lib/DecoderLib/DecLib.cpp | 25 +++++++-- source/Lib/DecoderLib/DecLib.h | 4 ++ 5 files changed, 129 insertions(+), 4 deletions(-) diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 843e88597..b28fd797a 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -723,7 +723,7 @@ void EncApp::xInitLibCfg() m_cEncLib.setCostMode ( m_costMode ); m_cEncLib.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); #if JVET_Q0117_PARAMETER_SETS_CLEANUP - m_cEncLib.setDCIEnabled ( m_DCIEnabled ); + m_cEncLib.setDCIEnabled ( m_DCIEnabled ); #else m_cEncLib.setDecodingParameterSetEnabled ( m_decodingParameterSetEnabled ); #endif diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index ce9e57cff..d76bc2f0e 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -3415,6 +3415,93 @@ bool Slice::checkRPR() return false; } +#if JVET_Q0117_PARAMETER_SETS_CLEANUP +bool operator == (const ConstraintInfo& op1, const ConstraintInfo& op2) +{ + if( op1.m_progressiveSourceFlag != op2.m_progressiveSourceFlag ) return false; + if( op1.m_interlacedSourceFlag != op2.m_interlacedSourceFlag ) return false; + if( op1.m_nonPackedConstraintFlag != op2.m_nonPackedConstraintFlag ) return false; + if( op1.m_frameOnlyConstraintFlag != op2.m_frameOnlyConstraintFlag ) return false; + if( op1.m_intraOnlyConstraintFlag != op2.m_intraOnlyConstraintFlag ) return false; + if( op1.m_maxBitDepthConstraintIdc != op2.m_maxBitDepthConstraintIdc ) return false; + if( op1.m_maxChromaFormatConstraintIdc != op2.m_maxChromaFormatConstraintIdc ) return false; + if( op1.m_onePictureOnlyConstraintFlag != op2.m_onePictureOnlyConstraintFlag ) return false; + if( op1.m_lowerBitRateConstraintFlag != op2.m_lowerBitRateConstraintFlag ) return false; + if( op1.m_noQtbttDualTreeIntraConstraintFlag != op2.m_noQtbttDualTreeIntraConstraintFlag ) return false; + if( op1.m_noPartitionConstraintsOverrideConstraintFlag != op2.m_noPartitionConstraintsOverrideConstraintFlag ) return false; + if( op1.m_noSaoConstraintFlag != op2.m_noSaoConstraintFlag ) return false; + if( op1.m_noAlfConstraintFlag != op2.m_noAlfConstraintFlag ) return false; +#if JVET_Q0795_CCALF + if( op1.m_noCCAlfConstraintFlag != op2.m_noCCAlfConstraintFlag ) return false; +#endif + if( op1.m_noRefWraparoundConstraintFlag != op2.m_noRefWraparoundConstraintFlag ) return false; + if( op1.m_noTemporalMvpConstraintFlag != op2.m_noTemporalMvpConstraintFlag ) return false; + if( op1.m_noSbtmvpConstraintFlag != op2.m_noSbtmvpConstraintFlag ) return false; + if( op1.m_noAmvrConstraintFlag != op2.m_noAmvrConstraintFlag ) return false; + if( op1.m_noBdofConstraintFlag != op2.m_noBdofConstraintFlag ) return false; + if( op1.m_noDmvrConstraintFlag != op2.m_noDmvrConstraintFlag ) return false; + if( op1.m_noCclmConstraintFlag != op2.m_noCclmConstraintFlag ) return false; + if( op1.m_noMtsConstraintFlag != op2.m_noMtsConstraintFlag ) return false; + if( op1.m_noSbtConstraintFlag != op2.m_noSbtConstraintFlag ) return false; + if( op1.m_noAffineMotionConstraintFlag != op2.m_noAffineMotionConstraintFlag ) return false; + if( op1.m_noBcwConstraintFlag != op2.m_noBcwConstraintFlag ) return false; + if( op1.m_noIbcConstraintFlag != op2.m_noIbcConstraintFlag ) return false; + if( op1.m_noCiipConstraintFlag != op2.m_noCiipConstraintFlag ) return false; + if( op1.m_noFPelMmvdConstraintFlag != op2.m_noFPelMmvdConstraintFlag ) return false; + if( op1.m_noTriangleConstraintFlag != op2.m_noTriangleConstraintFlag ) return false; + if( op1.m_noLadfConstraintFlag != op2.m_noLadfConstraintFlag ) return false; + if( op1.m_noTransformSkipConstraintFlag != op2.m_noTransformSkipConstraintFlag ) return false; + if( op1.m_noBDPCMConstraintFlag != op2.m_noBDPCMConstraintFlag ) return false; + if( op1.m_noJointCbCrConstraintFlag != op2.m_noJointCbCrConstraintFlag ) return false; + if( op1.m_noQpDeltaConstraintFlag != op2.m_noQpDeltaConstraintFlag ) return false; + if( op1.m_noDepQuantConstraintFlag != op2.m_noDepQuantConstraintFlag ) return false; + if( op1.m_noSignDataHidingConstraintFlag != op2.m_noSignDataHidingConstraintFlag ) return false; + if( op1.m_noTrailConstraintFlag != op2.m_noTrailConstraintFlag ) return false; + if( op1.m_noStsaConstraintFlag != op2.m_noStsaConstraintFlag ) return false; + if( op1.m_noRaslConstraintFlag != op2.m_noRaslConstraintFlag ) return false; + if( op1.m_noRadlConstraintFlag != op2.m_noRadlConstraintFlag ) return false; + if( op1.m_noIdrConstraintFlag != op2.m_noIdrConstraintFlag ) return false; + if( op1.m_noCraConstraintFlag != op2.m_noCraConstraintFlag ) return false; + if( op1.m_noGdrConstraintFlag != op2.m_noGdrConstraintFlag ) return false; + if( op1.m_noApsConstraintFlag != op2.m_noApsConstraintFlag ) return false; + return true; +} +bool operator != (const ConstraintInfo& op1, const ConstraintInfo& op2) +{ + return !(op1 == op2); +} + +bool operator == (const ProfileTierLevel& op1, const ProfileTierLevel& op2) +{ + if (op1.m_tierFlag != op2.m_tierFlag) return false; + if (op1.m_profileIdc != op2.m_profileIdc) return false; + if (op1.m_numSubProfile != op2.m_numSubProfile) return false; + if (op1.m_levelIdc != op2.m_levelIdc) return false; + if (op1.m_constraintInfo != op2.m_constraintInfo) return false; + if (op1.m_subProfileIdc != op2.m_subProfileIdc) return false; + + for (int i = 0; i < MAX_TLAYER - 1; i++) + { + if (op1.m_subLayerLevelPresentFlag[i] != op2.m_subLayerLevelPresentFlag[i]) + { + return false; + } + } + for (int i = 0; i < MAX_TLAYER; i++) + { + if (op1.m_subLayerLevelIdc[i] != op2.m_subLayerLevelIdc[i]) + { + return false; + } + } + return true; +} +bool operator != (const ProfileTierLevel& op1, const ProfileTierLevel& op2) +{ + return !(op1 == op2); +} +#endif + #if ENABLE_TRACING void xTraceVPSHeader() { diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index ccc723a90..a757ab4b3 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -423,6 +423,11 @@ public: void setNoGdrConstraintFlag(bool bVal) { m_noGdrConstraintFlag = bVal; } bool getNoApsConstraintFlag() const { return m_noApsConstraintFlag; } void setNoApsConstraintFlag(bool bVal) { m_noApsConstraintFlag = bVal; } + +#if JVET_Q0117_PARAMETER_SETS_CLEANUP + friend bool operator == (const ConstraintInfo& op1, const ConstraintInfo& op2); + friend bool operator != (const ConstraintInfo& op1, const ConstraintInfo& op2); +#endif }; class ProfileTierLevel @@ -465,6 +470,10 @@ public: Level::Name getSubLayerLevelIdc(int i) const { return m_subLayerLevelIdc[i]; } void setSubLayerLevelIdc(int i, Level::Name x) { m_subLayerLevelIdc[i] = x; } +#if JVET_Q0117_PARAMETER_SETS_CLEANUP + friend bool operator == (const ProfileTierLevel& op1, const ProfileTierLevel& op2); + friend bool operator != (const ProfileTierLevel& op1, const ProfileTierLevel& op2); +#endif }; @@ -754,6 +763,12 @@ public: size_t getNumPTLs() const { return m_profileTierLevel.size(); } void setProfileTierLevel(const std::vector<ProfileTierLevel>& val) { m_profileTierLevel = val; } const ProfileTierLevel& getProfileTierLevel(int idx) const { return m_profileTierLevel[idx]; } + bool IsIndenticalDCI(const DCI& comparedDCI) const + { + if(m_maxSubLayersMinus1 != comparedDCI.m_maxSubLayersMinus1) return false; + if(m_profileTierLevel != comparedDCI.m_profileTierLevel) return false; + return true; + } }; #else class DPS diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 2d9e153b5..459bb2eaf 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -425,6 +425,9 @@ DecLib::DecLib() , m_vps( nullptr ) , m_scalingListUpdateFlag(true) , m_PreScalingListAPSId(-1) +#if JVET_Q0117_PARAMETER_SETS_CLEANUP + , m_dci(NULL) +#endif { #if ENABLE_SIMD_OPT_BUFFER g_pelBufOP.initPelBufOpsX86(); @@ -452,6 +455,14 @@ void DecLib::destroy() delete m_apcSlicePilot; m_apcSlicePilot = NULL; +#if JVET_Q0117_PARAMETER_SETS_CLEANUP + if( m_dci ) + { + delete m_dci; + m_dci = NULL; + } +#endif + m_cSliceDecoder.destroy(); } @@ -1767,12 +1778,20 @@ void DecLib::xDecodeVPS( InputNALUnit& nalu ) #if JVET_Q0117_PARAMETER_SETS_CLEANUP void DecLib::xDecodeDCI(InputNALUnit& nalu) { - DCI* dci = new DCI(); m_HLSReader.setBitstream(&nalu.getBitstream()); CHECK(nalu.m_temporalId, "The value of TemporalId of DCI NAL units shall be equal to 0"); - - m_HLSReader.parseDCI(dci); + if (!m_dci) + { + m_dci = new DCI; + m_HLSReader.parseDCI(m_dci); + } + else + { + DCI dupDCI; + m_HLSReader.parseDCI(&dupDCI); + CHECK( !m_dci->IsIndenticalDCI(dupDCI), "Two signaled DCIs are different"); + } } #else void DecLib::xDecodeDPS( InputNALUnit& nalu ) diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 3162b3ff5..8679334ae 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -141,6 +141,10 @@ private: public: int m_targetSubPicIdx; #endif + +#if JVET_Q0117_PARAMETER_SETS_CLEANUP + DCI* m_dci; +#endif public: DecLib(); virtual ~DecLib(); -- GitLab