From 981b587c2ce24e3044dba94184667880285916c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E8=B6=85=E9=80=B8?= <linchaoyi.cy@bytedance.com> Date: Wed, 4 Jan 2023 17:35:04 +0800 Subject: [PATCH] define global constants for maximum nnpfc_id and nnpfa_id --- source/App/EncoderApp/EncAppCfg.cpp | 6 +++++- source/Lib/CommonLib/CommonDef.h | 6 ++++++ source/Lib/DecoderLib/SEIread.cpp | 6 ++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 92ff74f3f..bc6c670e4 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -4818,7 +4818,11 @@ bool EncAppCfg::xCheckParameter() { for (int i = 0; i < m_nnPostFilterSEICharacteristicsNumFilters; i++) { +#if JVET_AB0049 + xConfirmPara(m_nnPostFilterSEICharacteristicsId[i] > MAX_NNPFC_ID, "SEINNPostFilterCharacteristicsId must be in the range of 0 to 2^32-2"); +#else xConfirmPara(m_nnPostFilterSEICharacteristicsId[i] > (uint32_t)(((uint64_t)1 << 32) - 2), "SEINNPostFilterCharacteristicsId must be in the range of 0 to 2^32-2"); +#endif xConfirmPara(m_nnPostFilterSEICharacteristicsModeIdc[i] > 255, "SEINNPostFilterCharacteristicsModeIdc must be in the range of 0 to 255"); #if JVET_AB0049 xConfirmPara(m_nnPostFilterSEICharacteristicsPurpose[i] > 1023, "SEINNPostFilterCharacteristicsPurpose must be in the range of 0 to 1023"); @@ -4860,7 +4864,7 @@ bool EncAppCfg::xCheckParameter() if (m_nnPostFilterSEIActivationEnabled) { #if JVET_AB0049 - xConfirmPara(m_nnPostFilterSEIActivationId > (uint32_t)(((uint64_t)1 << 32) - 2), "SEINNPostFilterActivationId must be in the range of 0 to 2^32-2"); + xConfirmPara(m_nnPostFilterSEIActivationId > MAX_NNPFA_ID, "SEINNPostFilterActivationId must be in the range of 0 to 2^32-2"); #else xConfirmPara(m_nnPostFilterSEIActivationId > (1 << 20) - 1, "SEINNPostFilterActivationId must be in the range of 0 to 2^20-1"); #endif diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 20ec7350c..1118a19c8 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -130,6 +130,7 @@ static constexpr int AFFINE_MAX_NUM_CP = 3; // maximum number of contr // ==================================================================================================================== // Common constants // ==================================================================================================================== + static constexpr uint64_t MAX_UINT64 = 0xFFFFFFFFFFFFFFFFU; static constexpr uint32_t MAX_UINT = 0xFFFFFFFFU; ///< max. value of unsigned 32-bit integer static constexpr int MAX_INT = 2147483647; ///< max. value of signed 32-bit integer @@ -563,6 +564,11 @@ static constexpr int CBF_MASK_CBCR = CBF_MASK_CB | CBF_MASK_CR; // ==================================================================================================================== // SEI and related constants // ==================================================================================================================== + +#if JVET_AB0049 +static const uint32_t MAX_NNPFA_ID = 0xfffffffe; // Maximum supported nnpfa_id +static const uint32_t MAX_NNPFC_ID = 0xfffffffe; // Maximum supported nnpfc_id +#endif #if JVET_Z0120_SII_SEI_PROCESSING static constexpr double SII_PF_W2 = 0.6; // weight for current picture static constexpr double SII_PF_W1 = 0.4; // weight for previous picture , it must be equal to 1.0 - SII_PF_W2 diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index fc3f78c5c..ad61f8ab6 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -2648,8 +2648,7 @@ void SEIReader::xParseSEINNPostFilterCharacteristics(SEINeuralNetworkPostFilterC sei_read_uvlc( pDecodedMessageOutputStream, val, "nnpfc_id" ); sei.m_id = val; #if JVET_AB0049 - const uint32_t maxNnpfcId = 0xfffffffe; - CHECK((sei.m_id >= 256 && sei.m_id <= 511) || (sei.m_id >= (1<<31) && sei.m_id <= maxNnpfcId), "Reserved nnpfc_id value, shall ignore the SEI message"); + CHECK((sei.m_id >= 256 && sei.m_id <= 511) || (sei.m_id >= (1<<31) && sei.m_id <= MAX_NNPFC_ID), "Reserved nnpfc_id value, shall ignore the SEI message"); #endif sei_read_uvlc( pDecodedMessageOutputStream, val, "nnpfc_mode_idc" ); @@ -2926,8 +2925,7 @@ void SEIReader::xParseSEINNPostFilterActivation(SEINeuralNetworkPostFilterActiva sei_read_uvlc( pDecodedMessageOutputStream, val, "nnpfa_id" ); sei.m_id =val; #if JVET_AB0049 - const uint32_t maxNnpfaId = 0xfffffffe; - CHECK((sei.m_id >= 256 && sei.m_id <= 511) || (sei.m_id >= (1<<31) && sei.m_id <= maxNnpfaId), "Reserved nnpfa_id value, shall ignore the SEI message"); + CHECK((sei.m_id >= 256 && sei.m_id <= 511) || (sei.m_id >= (1<<31) && sei.m_id <= MAX_NNPFA_ID), "Reserved nnpfa_id value, shall ignore the SEI message"); #endif } -- GitLab