From 3dbc6cbc0f1ff085795bdffc42f73c169cc4530c Mon Sep 17 00:00:00 2001 From: Antti Hallapuro <antti.hallapuro@nokia.com> Date: Tue, 23 May 2023 14:43:38 +0300 Subject: [PATCH] Implementation of JVET-AD0054 nnpfc_absent_input_pic_zero_flag --- source/App/EncoderApp/EncApp.cpp | 3 +++ source/App/EncoderApp/EncAppCfg.cpp | 5 +++++ source/App/EncoderApp/EncAppCfg.h | 3 +++ source/Lib/CommonLib/SEI.h | 3 +++ source/Lib/CommonLib/TypeDef.h | 2 ++ source/Lib/DecoderLib/SEIread.cpp | 4 ++++ source/Lib/EncoderLib/EncCfg.h | 7 +++++++ source/Lib/EncoderLib/SEIEncoder.cpp | 4 ++++ source/Lib/EncoderLib/SEIwrite.cpp | 3 +++ 9 files changed, 34 insertions(+) diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 67e603553..dfcf10f56 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -1237,6 +1237,9 @@ void EncApp::xInitLibCfg( int layerIdx ) m_cEncLib.setNNPostFilterSEICharacteristicsInputPicOutputFlag( m_nnPostFilterSEICharacteristicsInputPicOutputFlag[i], i); #endif } +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + m_cEncLib.setNNPostFilterSEICharacteristicsAbsentInputPicZeroFlag (m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[i], i); +#endif m_cEncLib.setNNPostFilterSEICharacteristicsComponentLastFlag (m_nnPostFilterSEICharacteristicsComponentLastFlag[i], i); m_cEncLib.setNNPostFilterSEICharacteristicsInpFormatIdc (m_nnPostFilterSEICharacteristicsInpFormatIdc[i], i); if (m_cEncLib.getNNPostFilterSEICharacteristicsInpFormatIdc(i) == 1) diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index a33062a74..fb0382f9f 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1931,6 +1931,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) std::ostringstream InputPicOutputFlag; InputPicOutputFlag << "SEINNPFCInputPicOutputFlag" << i; opts.addOptions()(InputPicOutputFlag.str(), cfg_nnPostFilterSEICharacteristicsInputPicOutputFlagList[i], cfg_nnPostFilterSEICharacteristicsInputPicOutputFlagList[i], "Indicates whether NNPF will generate a corresponding output picture for the input picture"); +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + std::ostringstream absentInputPicZeroFlag; + absentInputPicZeroFlag << "SEINNPFCAbsentInputPicZeroFlag" << i; + opts.addOptions()(absentInputPicZeroFlag.str(), m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[i], false, "Specifies the value of nnpfc_absent_input_pic_zero_flag in the Neural Network Post Filter Characteristics SEI message"); +#endif opts.addOptions()("SEINNPostFilterActivationEnabled", m_nnPostFilterSEIActivationEnabled, false, "Control use of the Neural Network Post Filter SEI on current picture"); opts.addOptions()("SEINNPostFilterActivationTargetId", m_nnPostFilterSEIActivationTargetId, 0u, "Target id of the Neural Network Post Filter on current picture"); diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index d39b81d35..7c8a2f85a 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -778,6 +778,9 @@ protected: uint32_t m_nnPostFilterSEICharacteristicsNumberInputDecodedPicturesMinus1[MAX_NUM_NN_POST_FILTERS]; std::vector<uint32_t> m_nnPostFilterSEICharacteristicsNumberInterpolatedPictures[MAX_NUM_NN_POST_FILTERS]; std::vector<bool> m_nnPostFilterSEICharacteristicsInputPicOutputFlag[MAX_NUM_NN_POST_FILTERS]; +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + bool m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[MAX_NUM_NN_POST_FILTERS]; +#endif bool m_nnPostFilterSEIActivationCancelFlag; bool m_nnPostFilterSEIActivationPersistenceFlag; diff --git a/source/Lib/CommonLib/SEI.h b/source/Lib/CommonLib/SEI.h index 1e8059791..27a56a76f 100644 --- a/source/Lib/CommonLib/SEI.h +++ b/source/Lib/CommonLib/SEI.h @@ -1310,6 +1310,9 @@ public: uint32_t m_numberInputDecodedPicturesMinus1; std::vector<uint32_t> m_numberInterpolatedPictures; std::vector<bool> m_inputPicOutputFlag; +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + bool m_absentInputPicZeroFlag; +#endif }; class SEINeuralNetworkPostFilterActivation : public SEI diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 1a0cbdb5f..7ced86074 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -65,6 +65,8 @@ #define JVET_AD0067_SWAP_SYNTAX 1 // Swap the two syntax elements: nnpfc_auxiliary_inp_idc and nnpfc_inp_order_idc +#define JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG 1 + //########### place macros to be be kept below this line ############### #define GDR_ENABLED 1 diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index 4dd8125bb..e858283ab 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -2853,6 +2853,10 @@ void SEIReader::xParseSEINNPostFilterCharacteristics(SEINeuralNetworkPostFilterC { CHECK(!atLeastOne, "When picRateUpsamplingFlag is equal to 0 and nnpfc_num_input_pics_minus1 is greater than 0, at least one value of nnpfc_input_pic_output_flag[i] shall be greater than 0"); } +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + sei_read_flag(pDecodedMessageOutputStream, val, "nnpfc_absent_input_pic_zero_flag"); + sei.m_absentInputPicZeroFlag = val; +#endif } else { diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index dfd54adf4..3cb30494e 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -740,6 +740,9 @@ protected: uint32_t m_nnPostFilterSEICharacteristicsNumberInputDecodedPicturesMinus1[MAX_NUM_NN_POST_FILTERS]; std::vector<uint32_t> m_nnPostFilterSEICharacteristicsNumberInterpolatedPictures[MAX_NUM_NN_POST_FILTERS]; std::vector<bool> m_nnPostFilterSEICharacteristicsInputPicOutputFlag[MAX_NUM_NN_POST_FILTERS]; +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + bool m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[MAX_NUM_NN_POST_FILTERS]; +#endif bool m_nnPostFilterSEIActivationEnabled; uint32_t m_nnPostFilterSEIActivationTargetId; @@ -2020,6 +2023,10 @@ public: const std::vector<uint32_t>& getNNPostFilterSEICharacteristicsNumberInterpolatedPictures(int filterIdx) { return m_nnPostFilterSEICharacteristicsNumberInterpolatedPictures[filterIdx]; } void setNNPostFilterSEICharacteristicsInputPicOutputFlag(std::vector<bool> value, int filterIdx) { m_nnPostFilterSEICharacteristicsInputPicOutputFlag[filterIdx] = value; } const std::vector<bool>& getNNPostFilterSEICharacteristicsInputPicOutputFlag(int filterIdx) { return m_nnPostFilterSEICharacteristicsInputPicOutputFlag[filterIdx]; } +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + void setNNPostFilterSEICharacteristicsAbsentInputPicZeroFlag(bool absentInputPicZeroFlag, int filterIdx) { m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[filterIdx] = absentInputPicZeroFlag; } + bool getNNPostFilterSEICharacteristicsAbsentInputPicZeroFlag(int filterIdx) const { return m_nnPostFilterSEICharacteristicsAbsentInputPicZeroFlag[filterIdx]; } +#endif void setNnPostFilterSEIActivationEnabled(bool enabledFlag) { m_nnPostFilterSEIActivationEnabled = enabledFlag; } bool getNnPostFilterSEIActivationEnabled() const { return m_nnPostFilterSEIActivationEnabled; } void setNnPostFilterSEIActivationTargetId(uint32_t targetId) { m_nnPostFilterSEIActivationTargetId = targetId; } diff --git a/source/Lib/EncoderLib/SEIEncoder.cpp b/source/Lib/EncoderLib/SEIEncoder.cpp index 68d9ce524..fa0b01e7c 100644 --- a/source/Lib/EncoderLib/SEIEncoder.cpp +++ b/source/Lib/EncoderLib/SEIEncoder.cpp @@ -1325,6 +1325,10 @@ void SEIEncoder::initSEINeuralNetworkPostFilterCharacteristics(SEINeuralNetworkP sei->m_inputPicOutputFlag = m_pcCfg->getNNPostFilterSEICharacteristicsInputPicOutputFlag(filterIdx); #endif +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + sei->m_absentInputPicZeroFlag = m_pcCfg->getNNPostFilterSEICharacteristicsAbsentInputPicZeroFlag(filterIdx); +#endif + if((sei->m_purpose & NNPC_PurposeType::CHROMA_UPSAMPLING) != 0) { sei->m_outSubCFlag = m_pcCfg->getNNPostFilterSEICharacteristicsOutSubCFlag(filterIdx); diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp index 79f8d7172..ecb686416 100644 --- a/source/Lib/EncoderLib/SEIwrite.cpp +++ b/source/Lib/EncoderLib/SEIwrite.cpp @@ -1706,6 +1706,9 @@ void SEIWriter::xWriteSEINeuralNetworkPostFilterCharacteristics(const SEINeuralN { xWriteFlag(sei.m_inputPicOutputFlag[i], "nnpfc_input_pic_output_flag"); } +#if JVET_AD0054_NNPFC_ABSENT_INPUT_PIC_ZERO_FLAG + xWriteFlag(sei.m_absentInputPicZeroFlag, "nnpfc_absent_input_pic_zero_flag"); +#endif } #endif -- GitLab