diff --git a/cfg/per-class/classH1.cfg b/cfg/per-class/classH1.cfg index a6b09ffa1f9acffa0b742fe305e391b30c4a5283..5a2c188cd9388a3a9384742cd2bd209d76e29186 100644 --- a/cfg/per-class/classH1.cfg +++ b/cfg/per-class/classH1.cfg @@ -25,3 +25,5 @@ VerCollocatedChroma : 1 #======== HDR Metrics ============ CalculateHdrMetrics : 1 # Calculate HDR metrics for Class H1 (PQ) content + +PrintWPSNR : 1 \ No newline at end of file diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 887b04be70a14f6f65f8ebbcf3eb35bc68191e06..11679cf63499062a81a353614a01d57018b74293 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -250,6 +250,9 @@ void EncApp::xInitLibCfg() m_cEncLib.setPrintHexPsnr(m_printHexPsnr); m_cEncLib.setPrintSequenceMSE ( m_printSequenceMSE); m_cEncLib.setPrintMSSSIM ( m_printMSSSIM ); +#if PRINT_WPSNR + m_cEncLib.setPrintWPSNR ( m_printWPSNR ); +#endif m_cEncLib.setCabacZeroWordPaddingEnabled ( m_cabacZeroWordPaddingEnabled ); m_cEncLib.setFrameRate ( m_iFrameRate ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 5f77fca0cfd5e223e714940110e1874a9a61dbc8..6305b22588a64610d6824aa6bd16f1e300d3e7ae 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -728,6 +728,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("PrintFrameMSE", m_printFrameMSE, false, "0 (default) emit only bit count and PSNRs for each frame, 1 = also emit MSE values") ("PrintSequenceMSE", m_printSequenceMSE, false, "0 (default) emit only bit rate and PSNRs for the whole sequence, 1 = also emit MSE values") ("PrintMSSSIM", m_printMSSSIM, false, "0 (default) do not print MS-SSIM scores, 1 = print MS-SSIM scores for each frame and for the whole sequence") +#if PRINT_WPSNR + ("PrintWPSNR", m_printWPSNR, false, "0 (default) do not print HDR-PQ based wPSNR, 1 = print HDR-PQ based wPSNR") +#endif ("CabacZeroWordPaddingEnabled", m_cabacZeroWordPaddingEnabled, true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required") ("ChromaFormatIDC,-cf", tmpChromaFormat, 0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)") ("ConformanceMode", m_conformanceWindowMode, 0, "Deprecated alias of ConformanceWindowMode") diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index c5196940838c0fc27e563394de7849b2c3d058ff..8058fd38daa464e3ba1aa740bea3d663e6a6239e 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -127,6 +127,9 @@ protected: bool m_printFrameMSE; bool m_printSequenceMSE; bool m_printMSSSIM; +#if PRINT_WPSNR + bool m_printWPSNR; +#endif bool m_cabacZeroWordPaddingEnabled; bool m_bClipInputVideoToRec709Range; bool m_bClipOutputVideoToRec709Range; diff --git a/source/Lib/CommonLib/RdCost.cpp b/source/Lib/CommonLib/RdCost.cpp index 8e6c7cfd7828bcc6cc1f7efbc3df1985e5af1a8d..4392eae24f312380ca25b28a58719c83529bf3e2 100644 --- a/source/Lib/CommonLib/RdCost.cpp +++ b/source/Lib/CommonLib/RdCost.cpp @@ -2950,11 +2950,28 @@ void RdCost::saveUnadjustedLambda() m_DistScaleUnadjusted = m_DistScale; } +#if PRINT_WPSNR +void RdCost::initLumaLevelToWeightTable(int bitDepth) +#else void RdCost::initLumaLevelToWeightTable() +#endif { +#if PRINT_WPSNR + int lutSize = 1 << bitDepth; + if (m_lumaLevelToWeightPLUT.empty()) + { + m_lumaLevelToWeightPLUT.resize(lutSize, 1.0); + } + for (int i = 0; i < lutSize; i++) +#else for (int i = 0; i < LUMA_LEVEL_TO_DQP_LUT_MAXSIZE; i++) +#endif { +#if PRINT_WPSNR + double x = bitDepth < 10 ? i << (10 - bitDepth) : bitDepth > 10 ? i >> (bitDepth - 10) : i; +#else double x = i; +#endif double y; y = 0.015 * x - 1.5 diff --git a/source/Lib/CommonLib/RdCost.h b/source/Lib/CommonLib/RdCost.h index 68911b80721a84c4f537fa319a81815dfd288d2e..3f82dc0ee2be19c87f823033764a947b6520ef98 100644 --- a/source/Lib/CommonLib/RdCost.h +++ b/source/Lib/CommonLib/RdCost.h @@ -315,7 +315,11 @@ public: uint32_t getBitsOfVectorWithPredictor( const int x, const int y, const unsigned imvShift ) { return xGetExpGolombNumberOfBits(((x << m_iCostScale) - m_mvPredictor.getHor())>>imvShift) + xGetExpGolombNumberOfBits(((y << m_iCostScale) - m_mvPredictor.getVer())>>imvShift); } #if WCG_EXT void saveUnadjustedLambda (); +#if PRINT_WPSNR + void initLumaLevelToWeightTable (int bitDepth); +#else void initLumaLevelToWeightTable (); +#endif inline double getWPSNRLumaLevelWeight (int val) { return m_lumaLevelToWeightPLUT[val]; } void initLumaLevelToWeightTableReshape(); void updateReshapeLumaLevelToWeightTableChromaMD (std::vector<Pel>& ILUT); diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 8fc25214f73649022c4398987ffbe8ee21666972..019a18f6e1d1dca7ff3a1ce66a4f4528f53127b4 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,10 @@ #include <assert.h> #include <cassert> + +#define PRINT_WPSNR 1 + + // clang-format off #define JVET_U0081 1 // ALF filter strength target diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 05af5a017c64eb3af8fb8f9dbed275797dc7b7c2..55ee0ac72a27dd1c8ff2b471502f8325d79f5c1b 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -174,6 +174,9 @@ protected: bool m_printFrameMSE; bool m_printSequenceMSE; bool m_printMSSSIM; +#if PRINT_WPSNR + bool m_printWPSNR; +#endif bool m_cabacZeroWordPaddingEnabled; bool m_gciPresentFlag; @@ -935,6 +938,11 @@ public: bool getPrintMSSSIM () const { return m_printMSSSIM; } void setPrintMSSSIM (bool value) { m_printMSSSIM = value; } +#if PRINT_WPSNR + bool getPrintWPSNR () const { return m_printWPSNR; } + void setPrintWPSNR (bool value) { m_printWPSNR = value; } +#endif + bool getCabacZeroWordPaddingEnabled() const { return m_cabacZeroWordPaddingEnabled; } void setCabacZeroWordPaddingEnabled(bool value) { m_cabacZeroWordPaddingEnabled = value; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 75e23bdbb98db29a880f724a601d50b83a51b1e8..e6dda73b2df206bad0db2ba29602ab42ea7f855e 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -231,6 +231,12 @@ void EncGOP::init ( EncLib* pcEncLib ) pcEncLib->getRdCost()->setReshapeInfo(RESHAPE_SIGNAL_PQ, m_pcCfg->getBitDepth(CHANNEL_TYPE_LUMA)); pcEncLib->getRdCost()->initLumaLevelToWeightTableReshape(); } +#if PRINT_WPSNR + else if (m_pcCfg->getPrintWPSNR()) + { + pcEncLib->getRdCost()->initLumaLevelToWeightTable(m_pcCfg->getBitDepth(CHANNEL_TYPE_LUMA)); + } +#endif pcEncLib->getALF()->getLumaLevelWeightTable() = pcEncLib->getRdCost()->getLumaLevelWeightTable(); int alfWSSD = 0; if (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ ) @@ -3679,7 +3685,11 @@ void EncGOP::printOutSummary( uint32_t uiNumAllPicCoded, bool isField, const boo const bool useWPSNR = m_pcEncLib->getUseWPSNR(); #endif #if WCG_WPSNR +#if PRINT_WPSNR + const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ) || m_pcEncLib->getPrintWPSNR(); +#else const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ); +#endif #endif if( m_pcCfg->getDecodeBitstream(0).empty() && m_pcCfg->getDecodeBitstream(1).empty() && !m_pcCfg->useFastForwardToPOC() ) @@ -4039,7 +4049,11 @@ uint64_t EncGOP::xFindDistortionPlane(const CPelBuf& pic0, const CPelBuf& pic1, double EncGOP::xFindDistortionPlaneWPSNR(const CPelBuf& pic0, const CPelBuf& pic1, const uint32_t rshift, const CPelBuf& picLuma0, ComponentID compID, const ChromaFormat chfmt ) { +#if PRINT_WPSNR + const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ) || m_pcEncLib->getPrintWPSNR(); +#else const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ); +#endif if (!useLumaWPSNR) { return 0; @@ -4178,7 +4192,11 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni double dPSNR[MAX_NUM_COMPONENT]; double msssim[MAX_NUM_COMPONENT] = {0.0}; #if WCG_WPSNR +#if PRINT_WPSNR + const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ) || m_pcEncLib->getPrintWPSNR(); +#else const bool useLumaWPSNR = m_pcEncLib->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcCfg->getLmcs() && m_pcCfg->getReshapeSignalType() == RESHAPE_SIGNAL_PQ); +#endif double dPSNRWeighted[MAX_NUM_COMPONENT]; double MSEyuvframeWeighted[MAX_NUM_COMPONENT]; #endif