From adf7a1b8d0a5b64e5b3f1fdac030b10db04338a9 Mon Sep 17 00:00:00 2001 From: Yue Li <yue.li@bytedance.com> Date: Wed, 31 May 2023 16:41:08 -0700 Subject: [PATCH] fix bug in hop debug option (see issue #47) --- source/App/DecoderApp/DecAppCfg.cpp | 2 +- source/App/EncoderApp/EncAppCfg.cpp | 2 +- source/Lib/DecoderLib/DecLib.cpp | 9 +-------- source/Lib/EncoderLib/EncGOP.cpp | 21 +++++++-------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/source/App/DecoderApp/DecAppCfg.cpp b/source/App/DecoderApp/DecAppCfg.cpp index 05989f0a71..7910efd581 100644 --- a/source/App/DecoderApp/DecAppCfg.cpp +++ b/source/App/DecoderApp/DecAppCfg.cpp @@ -83,7 +83,7 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] ) #if NN_HOP_UNIFIED ("NnlfHopModelName", m_nnlfHopModelName, string("models/nnlf_hop_model_int16.sadl"), "HOP loop filter model name\n") #if NN_HOP_UNIFIED_FORCE_USE - ( "NnlfHopDebugOption", m_nnlfHopOption, 0, "Option used to debug stage 1 model. 0: default, 1: apply only on I slice, 2: apply on all slices using I type as input (not decodable)" ) + ( "NnlfHopDebugOption", m_nnlfHopOption, 0, "Option used to debug stage 1 model. 0: default, 1: apply only on I slice, 2: apply on all slices using I type as input" ) #endif #endif diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 071ae44fa8..97d6c13c0a 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1168,7 +1168,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ( "NnlfHopMaxNumPrms", m_nnlfHopMaxNumPrms, 2u, "Number of conditional parameters of HOP loop filter" ) ( "NnlfHopModelName", m_nnlfHopModelName, string("models/nnlf_hop_model_int16.sadl"), "HOP loop filter model name" ) #if NN_HOP_UNIFIED_FORCE_USE - ( "NnlfHopDebugOption", m_nnlfHopOption, 0, "Option used to debug stage 1 model. 0: default, 1: apply only on I slice, 2: apply on all slices using I type as input (not decodable)" ) + ( "NnlfHopDebugOption", m_nnlfHopOption, 0, "Option used to debug stage 1 model. 0: default, 1: apply only on I slice, 2: apply on all slices using I type as input" ) #endif #endif ("SAO", m_bUseSAO, true, "Enable Sample Adaptive Offset") diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index e4f6140a6e..70c6b560d4 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -742,14 +742,7 @@ void DecLib::executeLoopFilters() m_nnfilterHOP.setPicprms(&m_pcPic->m_picprm); m_nnfilterHOP.setSliceprms(m_pcPic->cs->slice->getNnlfHopParameters()); #if NN_HOP_UNIFIED_FORCE_USE - //if (getNnlfHopOption()==1&&(!m_pcPic->cs->slice->isIntra())) { // not necessary because encoding choice? - // m_pcPic->m_picprm.sprm.mode = -1; - //} - if (getNnlfHopOption()==2) { // remove in the future? - m_nnfilterHOP.forceIntraType(true); - } else { - m_nnfilterHOP.forceIntraType(false); - } + m_nnfilterHOP.forceIntraType(getNnlfHopOption() == 2 ? true : false); #endif m_nnfilterHOP.filter(*m_pcPic); } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 19f9605a78..0156ed69c2 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -246,7 +246,10 @@ 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()); + if (m_pcCfg->getUseNnlfSet1()) + { + m_pcNNFilterSet1.create(m_pcCfg->getSourceWidth(), m_pcCfg->getSourceHeight(), m_pcCfg->getChromaFormatIdc(), m_pcCfg->getNnlfSet1MaxNumParams()); + } #endif #if NN_HOP_UNIFIED @@ -3186,23 +3189,13 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if (pcSlice->getSPS()->getNnlfHopEnabledFlag()) { m_nnfilterHOP.initCabac( m_pcEncLib->getCABACEncoder(), m_pcEncLib->getCtxCache(), *pcSlice); - int default_mode = pcPic->m_picprm.sprm.mode; + m_nnfilterHOP.setPicprms(&pcPic->m_picprm); #if NN_HOP_UNIFIED_FORCE_USE - if (m_pcCfg->getNnlfHopOption()==1&&(!pcSlice->isIntra())) { - pcPic->m_picprm.sprm.mode = -1; - } - if (m_pcCfg->getNnlfHopOption()==2) { // remove in the future? - m_nnfilterHOP.forceIntraType(true); - } else { - m_nnfilterHOP.forceIntraType(false); - } + m_nnfilterHOP.forceIntraType(m_pcCfg->getNnlfHopOption() == 2 ? true : false); + if (m_pcCfg->getNnlfHopOption() != 1 || pcSlice->isIntra()) // when m_nnlfHopOption == 1, skip NN filtering for inter slice (note m_picprm.sprm.mode = -1 by default) #endif - m_nnfilterHOP.setPicprms(&pcPic->m_picprm); m_nnfilterHOP.chooseParameters(*pcPic); pcSlice->setNnlfHopParameters(m_nnfilterHOP.getSliceprms()); -#if NN_HOP_UNIFIED_FORCE_USE - pcPic->m_picprm.sprm.mode = default_mode; -#endif } #endif -- GitLab