From cf882a0a2224f575114d0f9cdd50e750c86bedd0 Mon Sep 17 00:00:00 2001 From: Franck Galpin <franck.galpin@interdigital.com> Date: Tue, 23 Aug 2022 17:04:58 +0200 Subject: [PATCH 1/2] cosmetic review of the code: minor cleanings --- source/App/DecoderApp/DecApp.cpp | 2 -- source/Lib/CommonLib/NNFilterSet1.h | 2 +- source/Lib/CommonLib/NNInference.h | 4 ++-- source/Lib/DecoderLib/DecLib.cpp | 16 ++++------------ source/Lib/DecoderLib/DecLib.h | 2 +- source/Lib/EncoderLib/EncGOP.cpp | 18 +++++------------- source/Lib/EncoderLib/EncGOP.h | 2 +- source/Lib/EncoderLib/EncNNFilterSet1.cpp | 2 +- 8 files changed, 15 insertions(+), 33 deletions(-) diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 96de4a463b..0fc7d179c8 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -337,7 +337,6 @@ uint32_t DecApp::decode() m_outputBitDepth[channelType] = bitDepths.recon[channelType]; } } -#if NNVC_DUMP_DATA m_jsonFile.open(m_dumpBasename + ".json"); m_jsonFile << "{\n"; #if NNVC_USE_REC_BEFORE_DBF @@ -388,7 +387,6 @@ uint32_t DecApp::decode() << " \"width\": " << activeSPS->getMaxPicWidthInLumaSamples() << ",\n" << " \"height\": " << activeSPS->getMaxPicHeightInLumaSamples() << ",\n"; m_dumpDataCnt = 0; -#endif } } #endif diff --git a/source/Lib/CommonLib/NNFilterSet1.h b/source/Lib/CommonLib/NNFilterSet1.h index 4e84967fc4..b97214a683 100644 --- a/source/Lib/CommonLib/NNFilterSet1.h +++ b/source/Lib/CommonLib/NNFilterSet1.h @@ -50,7 +50,7 @@ class NNFilterSet1 { public: NNFilterSet1(); - + std::vector<PelStorage> m_tempBuf; std::string m_interLuma, m_interChroma, m_intraLuma, m_intraChroma; #if SCALE_NN_RESIDUE diff --git a/source/Lib/CommonLib/NNInference.h b/source/Lib/CommonLib/NNInference.h index 3109b420b8..3c32c40dd6 100644 --- a/source/Lib/CommonLib/NNInference.h +++ b/source/Lib/CommonLib/NNInference.h @@ -166,9 +166,9 @@ public: #endif } template<typename T> - static void prepareInputs (Picture* pic, UnitArea inferArea, vector<sadl::Tensor<T>> &inputs, int globalQp, int localQp, int sliceType, std::vector<InputData> listInputData) + static void prepareInputs (Picture* pic, UnitArea inferArea, vector<sadl::Tensor<T>> &inputs, int globalQp, int localQp, int sliceType, const std::vector<InputData> &listInputData) { - for (auto &inputData : listInputData) + for (auto inputData : listInputData) { switch (inputData.nnInputType) { diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 04923354e2..bb62889561 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -503,9 +503,6 @@ void DecLib::create() { m_apcSlicePilot = new Slice; m_uiSliceSegmentIdx = 0; -#if NN_FILTERING_SET_1 - m_pcNNFilterSet1 = new NNFilterSet1; -#endif } void DecLib::destroy() @@ -519,12 +516,7 @@ void DecLib::destroy() m_dci = NULL; } #if NN_FILTERING_SET_1 - if (m_pcNNFilterSet1) - { - m_pcNNFilterSet1->destroy(); - delete m_pcNNFilterSet1; - m_pcNNFilterSet1 = NULL; - } + m_pcNNFilterSet1.destroy(); #endif m_cSliceDecoder.destroy(); } @@ -648,8 +640,8 @@ void DecLib::executeLoopFilters() #if NN_FILTERING_SET_1 if (cs.sps->getNnlfSet1EnabledFlag()) { - m_pcNNFilterSet1->create(cs.pcv->lumaWidth, cs.pcv->lumaHeight, cs.pcv->chrFormat, cs.sps->getNnlfSet1MaxNumParams()); - m_pcNNFilterSet1->init(getNnlfSet1InterLumaModelName(), getNnlfSet1InterChromaModelName(), getNnlfSet1IntraLumaModelName(), getNnlfSet1IntraChromaModelName()); + m_pcNNFilterSet1.create(cs.pcv->lumaWidth, cs.pcv->lumaHeight, cs.pcv->chrFormat, cs.sps->getNnlfSet1MaxNumParams()); + m_pcNNFilterSet1.init(getNnlfSet1InterLumaModelName(), getNnlfSet1InterChromaModelName(), getNnlfSet1IntraLumaModelName(), getNnlfSet1IntraChromaModelName()); } #endif @@ -724,7 +716,7 @@ void DecLib::executeLoopFilters() #if NN_FILTERING_SET_1 if (cs.sps->getNnlfSet1EnabledFlag()) { - m_pcNNFilterSet1->cnnFilter(m_pcPic); + m_pcNNFilterSet1.cnnFilter(m_pcPic); } #endif diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 64a897a863..bd7a03f171 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -135,7 +135,7 @@ private: Reshape m_cReshaper; ///< reshaper class HRD m_HRD; #if NN_FILTERING_SET_1 - NNFilterSet1* m_pcNNFilterSet1; + NNFilterSet1 m_pcNNFilterSet1; #endif // decoder side RD cost computation RdCost m_cRdCost; ///< RD cost computation class diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 9013e928b2..8f159ad58d 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -178,9 +178,6 @@ void EncGOP::create() { m_bLongtermTestPictureHasBeenCoded = 0; m_bLongtermTestPictureHasBeenCoded2 = 0; -#if NN_FILTERING_SET_1 - m_pcNNFilterSet1 = new EncNNFilterSet1; -#endif } void EncGOP::destroy() @@ -206,12 +203,7 @@ void EncGOP::destroy() m_picOrig = NULL; } #if NN_FILTERING_SET_1 - if (m_pcNNFilterSet1) - { - m_pcNNFilterSet1->destroy(); - delete m_pcNNFilterSet1; - m_pcNNFilterSet1 = NULL; - } + m_pcNNFilterSet1.destroy(); #endif } @@ -239,7 +231,7 @@ void EncGOP::init ( EncLib* pcEncLib ) m_AUWriterIf = pcEncLib->getAUWriterIf(); #if NN_FILTERING_SET_1 - m_pcNNFilterSet1->create(m_pcCfg->getSourceWidth(), m_pcCfg->getSourceHeight(), m_pcCfg->getChromaFormatIdc(), m_pcCfg->getNnlfSet1MaxNumParams()); + m_pcNNFilterSet1.create(m_pcCfg->getSourceWidth(), m_pcCfg->getSourceHeight(), m_pcCfg->getChromaFormatIdc(), m_pcCfg->getNnlfSet1MaxNumParams()); #endif #if WCG_EXT @@ -3072,9 +3064,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, #if NN_FILTERING_SET_1 if ( cs.sps->getNnlfSet1EnabledFlag() ) { - m_pcNNFilterSet1->init(m_pcEncLib->getNnlfSet1InterLumaModelName(), m_pcEncLib->getNnlfSet1InterChromaModelName(), m_pcEncLib->getNnlfSet1IntraLumaModelName(), m_pcEncLib->getNnlfSet1IntraChromaModelName()); - m_pcNNFilterSet1->initCABACEstimator( m_pcEncLib->getCABACEncoder(), m_pcEncLib->getCtxCache(), pcSlice ); - m_pcNNFilterSet1->cnnFilterEncoder(pcPic, pcSlice->getLambdas()); + m_pcNNFilterSet1.init(m_pcEncLib->getNnlfSet1InterLumaModelName(), m_pcEncLib->getNnlfSet1InterChromaModelName(), m_pcEncLib->getNnlfSet1IntraLumaModelName(), m_pcEncLib->getNnlfSet1IntraChromaModelName()); + m_pcNNFilterSet1.initCABACEstimator( m_pcEncLib->getCABACEncoder(), m_pcEncLib->getCtxCache(), pcSlice ); + m_pcNNFilterSet1.cnnFilterEncoder(pcPic, pcSlice->getLambdas()); } #endif diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h index 73ba9fef49..ce428c792e 100644 --- a/source/Lib/EncoderLib/EncGOP.h +++ b/source/Lib/EncoderLib/EncGOP.h @@ -144,7 +144,7 @@ private: PicList* m_pcListPic; #if NN_FILTERING_SET_1 - EncNNFilterSet1* m_pcNNFilterSet1; + EncNNFilterSet1 m_pcNNFilterSet1; #endif HLSWriter* m_HLSWriter; diff --git a/source/Lib/EncoderLib/EncNNFilterSet1.cpp b/source/Lib/EncoderLib/EncNNFilterSet1.cpp index 002858b761..2918e502b2 100644 --- a/source/Lib/EncoderLib/EncNNFilterSet1.cpp +++ b/source/Lib/EncoderLib/EncNNFilterSet1.cpp @@ -57,7 +57,7 @@ EncNNFilterSet1::EncNNFilterSet1() { - m_CABACEstimator = NULL; + m_CABACEstimator = nullptr; m_singleModelISlice = false; } -- GitLab From d5aaebd8a4a3ad2e00ed6184614f8f3775aba9f7 Mon Sep 17 00:00:00 2001 From: Franck Galpin <franck.galpin@interdigital.com> Date: Wed, 24 Aug 2022 10:52:35 +0200 Subject: [PATCH 2/2] default both set to 1 --- source/Lib/CommonLib/TypeDef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 661d8f2246..4b52df120c 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -85,7 +85,7 @@ using TypeSadl = float; // nn filter set 1 -#define NN_FILTERING_SET_1 0 +#define NN_FILTERING_SET_1 1 // options set 1 #if NN_FILTERING_SET_1 #define SCALE_NN_RESIDUE 1 -- GitLab