diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 45ec89bc63cfd47bd8effba28d76d44ae94023d3..2bb92ba14c27f83de49ac313b40ba95a95066462 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -1591,7 +1591,12 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = floorLog2(width); const uint32_t log2TrHeight = floorLog2(height); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); @@ -1626,7 +1631,12 @@ void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const Compo CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = floorLog2(width); const uint32_t log2TrHeight = floorLog2(height); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index 0bc59f1e2f95c98bbd1c038a79cbdeb021fc0dca..b95d60fb332f175377cefb9b49a23744af794b4c 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -381,7 +381,12 @@ void Quant::dequant(const TransformUnit &tu, const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff transformMaximum = (1 << maxLog2TrDynamicRange) - 1; const bool isTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); @@ -1028,7 +1033,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const uint32_t uiLog2TrWidth = floorLog2(uiWidth); const uint32_t uiLog2TrHeight = floorLog2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); @@ -1112,7 +1121,11 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff const uint32_t uiLog2TrHeight = floorLog2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); @@ -1168,7 +1181,12 @@ void Quant::transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &co const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange); const int scalingListType = getScalingListType(tu.cu->predMode, compID); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); @@ -1233,7 +1251,12 @@ void Quant::invTrSkipDeQuantOneSample(TransformUnit &tu, const ComponentID &comp const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange); const int scalingListType = getScalingListType(tu.cu->predMode, compID); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index 9b4d0543a9c0ec6f595345f10f2e010b924d98cc..23f3951d3109ee8012c15dc50f1440f7893e5012 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -634,7 +634,12 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, const bool isTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP); const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip)); const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem(isTransformSkip), uiLog2BlockWidth, uiLog2BlockHeight); + +#if JVET_R0064 + const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->slice->getSPS()->getDisableScalingMatrixForLfnstBlks() : false; +#else const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; +#endif const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 4db41ba7bdffcfe6ff43865256d38bf9291d4c20..c2c9c865ed2aeafc0a8427c3c7b27e54058bcb4f 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -2539,6 +2539,9 @@ SPS::SPS() , m_scalingMatrixAlternativeColourSpaceDisabledFlag( false ) , m_scalingMatrixDesignatedColourSpaceFlag( true ) #endif +#if JVET_R0064 +, m_disableScalingMatrixForLfnstBlks( true) +#endif { for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) { @@ -3383,7 +3386,9 @@ void ReferencePictureList::printRefPicInfo() const ScalingList::ScalingList() { +#if !JVET_R0064 m_disableScalingMatrixForLfnstBlks = true; +#endif m_chromaScalingListPresentFlag = true; for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++) { diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index c7f471ae7c6da7e71a557f193592908700e6d577..3c6b66fb7aad65c166d741955702c1a95c4f03a2 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -163,8 +163,11 @@ class ScalingList public: ScalingList(); virtual ~ScalingList() { } + +#if !JVET_R0064 bool getDisableScalingMatrixForLfnstBlks() const { return m_disableScalingMatrixForLfnstBlks;} void setDisableScalingMatrixForLfnstBlks(bool flag) { m_disableScalingMatrixForLfnstBlks = flag;} +#endif int* getScalingListAddress(uint32_t scalingListId) { return &(m_scalingListCoef[scalingListId][0]); } //!< get matrix coefficient const int* getScalingListAddress(uint32_t scalingListId) const { return &(m_scalingListCoef[scalingListId][0]); } //!< get matrix coefficient void checkPredMode(uint32_t scalingListId); @@ -226,7 +229,9 @@ public: private: void outputScalingLists(std::ostream &os) const; +#if !JVET_R0064 bool m_disableScalingMatrixForLfnstBlks; +#endif bool m_scalingListPredModeFlagIsCopy [30]; //!< reference list index int m_scalingListDC [30]; //!< the DC value of the matrix coefficient for 16x16 uint32_t m_refMatrixId [30]; //!< RefMatrixID @@ -1485,6 +1490,11 @@ private: bool m_scalingMatrixAlternativeColourSpaceDisabledFlag; bool m_scalingMatrixDesignatedColourSpaceFlag; #endif + +#if JVET_R0064 + bool m_disableScalingMatrixForLfnstBlks; +#endif + public: SPS(); @@ -1553,6 +1563,10 @@ public: void setSubPicTreatedAsPicFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicTreatedAsPicFlag = v; } void setLoopFilterAcrossSubpicEnabledFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_loopFilterAcrossSubpicEnabledFlag = v; } +#if JVET_R0064 + bool getDisableScalingMatrixForLfnstBlks() const { return m_disableScalingMatrixForLfnstBlks; } + void setDisableScalingMatrixForLfnstBlks(bool flag) { m_disableScalingMatrixForLfnstBlks = flag; } +#endif void setSubPicIdMappingExplicitlySignalledFlag( bool b ) { m_subPicIdMappingExplicitlySignalledFlag = b; } bool getSubPicIdMappingExplicitlySignalledFlag() const { return m_subPicIdMappingExplicitlySignalledFlag; } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 90a74ca84477fe826c835cb60e27ece4a1fea8e2..1e61cb22d9aecabdddbefb9218d1bc8dd5f18351 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -51,12 +51,14 @@ #include <cassert> //########### place macros to be removed in next cycle below this line ############### +#define JVET_R0064 1 // JVET-R0064, aspect 2: Move the flag scaling_matrix_for_lfnst_disabled_flag from the scaling_list_data( ) syntax to the SPS. + #define RETRAIN_CABAC 1 // CABAC initial values retrained on VTM-9.0rc1 #define JVET_R0058 1 // JVET-R0058: the combination of RPR, subpictures, and scalability #define JVET_R0185_OLS_DPB_CLEANUP 1 // JVET-R0185: Replace if( !vps_all_independent_layers_flag ) condition on vps_num_dpb_params syntax element with if(!each_layer_is_an_ols_flag) - // Change vps_num_dpb_params to vps_num_dpb_params_minus1 and change the semantics to a “two-way” constraint + // Change vps_num_dpb_params to vps_num_dpb_params_minus1 and change the semantics to a “two-way?constraint // Signal DPB parameters for OLS in this case only if(!each_layer_is_an_ols_flag) #define JVET_R0078_DISABLE_CHROMA_DBF_OFFSET_SINGALLING 1 // JVET-R0078: disable chroma DBF offset signalling diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 8d6dc924164f941172cb84213d8d3b98c78de09e..ddbdca7d0b7380f9d0614034dd67407b355c6012 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -2171,6 +2171,14 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setLog2ParallelMergeLevelMinus2(uiCode); #endif READ_FLAG(uiCode, "sps_explicit_scaling_list_enabled_flag"); pcSPS->setScalingListFlag(uiCode); + +#if JVET_R0064 + if (pcSPS->getUseLFNST() && pcSPS->getScalingListFlag()) + { + READ_FLAG(uiCode, "scaling_matrix_for_lfnst_disabled_flag"); pcSPS->setDisableScalingMatrixForLfnstBlks(uiCode ? true : false); + } +#endif + #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB if (pcSPS->getUseColorTrans() && pcSPS->getScalingListFlag()) { @@ -5441,7 +5449,10 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList) { uint32_t code; bool scalingListCopyModeFlag; + +#if !JVET_R0064 READ_FLAG(code, "scaling_matrix_for_lfnst_disabled_flag"); scalingList->setDisableScalingMatrixForLfnstBlks(code ? true : false); +#endif READ_FLAG(code, "scaling_list_chroma_present_flag"); scalingList->setChromaScalingListPresentFlag(code ? true : false); for (int scalingListId = 0; scalingListId < 28; scalingListId++) diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index a1fa226246168d961b70e09e070fb99d555cf246..0abebdbae3fbd55e38b2881c19e43414cebc609f 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -536,7 +536,12 @@ void EncLib::xInitScalingLists( SPS &sps, APS &aps ) getTrQuant( jId )->getQuant()->setUseScalingList( true ); } #endif + +#if JVET_R0064 + sps.setDisableScalingMatrixForLfnstBlks(getDisableScalingMatrixForLfnstBlks()); +#else aps.getScalingList().setDisableScalingMatrixForLfnstBlks(getDisableScalingMatrixForLfnstBlks()); +#endif } else { diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 6140112e3a601e5dcaa1169f315e2224d1c7c40d..31cdb0e40b11c77dd3d3bedf702488925ce60243 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -1350,6 +1350,14 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) // KJS: remove scaling lists? WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "sps_scaling_list_enabled_flag" ); + +#if JVET_R0064 + if (pcSPS->getUseLFNST() && pcSPS->getScalingListFlag()) + { + WRITE_FLAG(pcSPS->getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag"); + } +#endif + #if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB if (pcSPS->getUseColorTrans() && pcSPS->getScalingListFlag()) { @@ -3184,7 +3192,9 @@ void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) void HLSWriter::codeScalingList( const ScalingList &scalingList ) { //for each size +#if !JVET_R0064 WRITE_FLAG(scalingList.getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag"); +#endif WRITE_FLAG(scalingList.getChromaScalingListPresentFlag(), "scaling_list_chroma_present_flag"); for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++) {