diff --git a/cfg/lossless/lossless.cfg b/cfg/lossless/lossless.cfg index bca758fcf2403f0b3abdce66250aff0b8676be69..793b2bedbd16f9300826026cd8bb27cf2024e94a 100644 --- a/cfg/lossless/lossless.cfg +++ b/cfg/lossless/lossless.cfg @@ -20,3 +20,5 @@ BIO : 0 PROF : 0 Log2MaxTbSize : 5 InternalBitDepth : 0 +TSRCdisableLL : 1 + diff --git a/cfg/per-class/formatRGB.cfg b/cfg/per-class/formatRGB.cfg index fe065ff2f0920a6d63e87687c136e6dbe9ccfc82..a761a1d399d7f31d22a14c54e53b6aa38a0683e9 100644 --- a/cfg/per-class/formatRGB.cfg +++ b/cfg/per-class/formatRGB.cfg @@ -1,2 +1,3 @@ ColorTransform : 1 -Log2MaxTbSize : 5 \ No newline at end of file +Log2MaxTbSize : 5 +DualITree: 0 \ No newline at end of file diff --git a/doc/software-manual.tex b/doc/software-manual.tex index 166663323f16ed86755fbb8c5638e20d37b2d602..a155272dda781520cf940e56cd43947252d8abdb 100644 --- a/doc/software-manual.tex +++ b/doc/software-manual.tex @@ -2660,6 +2660,12 @@ Specifies location of a chroma sample relatively to the luma sample in vertical \end{tabular} \\ +\Option{TSRCdisableLL} & +%\ShortOption{\None} & +\Default{1} & +Enables or disables the use of Transform Skip Residual Coding for lossless compression. +\\ + \end{OptionTableNoShorthand} %% diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 98d5290c82a57007f500ab410c1fd9b85da3fb2d..f0a203bb9feeedb330a503fac98a0cd5e2083e7c 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -748,6 +748,9 @@ void EncApp::xInitLibCfg() m_cEncLib.setInitialCpbFullness ( m_RCInitialCpbFullness ); #endif m_cEncLib.setCostMode ( m_costMode ); +#if JVET_R0143_TSRCdisableLL + m_cEncLib.setTSRCdisableLL ( m_TSRCdisableLL ); +#endif m_cEncLib.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); m_cEncLib.setDCIEnabled ( m_DCIEnabled ); m_cEncLib.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag ); diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 727eb90c18b5f2d620ffbb54dec57e0af0b356b0..a5854c23bff1c6ab8d81e75c55da43b42b60d8ea 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1138,6 +1138,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ( "RCInitialCpbFullness", m_RCInitialCpbFullness, 0.9, "Rate control: initial CPB fullness" ) #endif ("CostMode", m_costMode, COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).") +#if JVET_R0143_TSRCdisableLL + ("TSRCdisableLL", m_TSRCdisableLL, true, "Disable TSRC for lossless coding" ) +#endif ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case") ("HrdParametersPresent,-hrd", m_hrdParametersPresentFlag, false, "Enable generation of hrd_parameters()") ("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()") diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 2dfb8315b59a0e73a8b552b968645d9f51e2a77e..ee76d6a84695523003fb8e8a2f8aaa4ec58b35c8 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -622,6 +622,9 @@ protected: std::string m_scalingListFileName; ///< quantization matrix file name bool m_disableScalingMatrixForLfnstBlks; CostMode m_costMode; ///< Cost mode to use +#if JVET_R0143_TSRCdisableLL + bool m_TSRCdisableLL; ///< disable TSRC for lossless +#endif bool m_recalculateQPAccordingToLambda; ///< recalculate QP value according to the lambda value diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp index ab7287b5d22b009d6cc78c66d71e5acdcdb1b288..c82551538f0030392a409acbf836ab11adbc3c5d 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp @@ -1262,7 +1262,11 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf } else { +#if JVET_R0208_ALF_VB_ROUNDING_FIX + sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3); +#else sum = (sum + offset) >> (shift + 3); +#endif } sum += curr; pRec1[jj] = ClipPel( sum, clpRng ); @@ -1341,6 +1345,12 @@ void AdaptiveLoopFilter::filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf const Pel *srcCross = lumaPtr + col + row * lumaStride; int pos = ((startHeight + i + ii) << scaleY) & (vbCTUHeight - 1); +#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION + if (scaleY == 0 && (pos == vbPos || pos == vbPos + 1)) + { + continue; + } +#endif if (pos == (vbPos - 2) || pos == (vbPos + 1)) { offset3 = offset1; diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 0cec835a1c69e90f74ffffc53d5143e813232b4b..2020b41a5c2f2c6d38ac0ea439cad61fa8c121b0 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -1573,7 +1573,11 @@ DepQuant::~DepQuant() void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeffBuf &pSrc, TCoeff &uiAbsSum, const QpParam &cQP, const Ctx& ctx ) { +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if ( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) ) +#else if ( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) ) +#endif { //===== scaling matrix ==== const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1; @@ -1599,7 +1603,11 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const ComponentID &compID, const QpParam &cQP ) { +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) ) +#else if( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP)) +#endif { const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1; const int qpPer = qpDQ / 6; diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index c73ad6c79de801331fadffe5952a249460349ccc..9ccb411b147c839010e1e33a8106361de76a2843 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -967,8 +967,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); { +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); - +#endif const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1; diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index 378c30ed7ad7102ee20da82936c457618a8fe75a..881f0178c4f42f4d62e5d4534b1230cc9582ee9f 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -639,8 +639,12 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1; - + +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); +#endif const int iCGSizeM1 = (1 << cctx.log2CGSize()) - 1; int iCGLastScanPos = -1; @@ -1225,7 +1229,11 @@ void QuantRDOQ::xRateDistOptQuantTS( TransformUnit &tu, const ComponentID &compI uint32_t coeffLevels[3]; double coeffLevelError[4]; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx( tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag() ); +#else CoeffCodingContext cctx( tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag() ); +#endif const int sbSizeM1 = ( 1 << cctx.log2CGSize() ) - 1; double baseCost = 0; uint32_t goRiceParam = 0; @@ -1450,7 +1458,11 @@ void QuantRDOQ::forwardRDPCM( TransformUnit &tu, const ComponentID &compID, cons uint32_t coeffLevels[3]; double coeffLevelError[4]; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); +#endif const int sbSizeM1 = (1 << cctx.log2CGSize()) - 1; double baseCost = 0; uint32_t goRiceParam = 0; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 7e02c2fcc9c994e8a5a97181d173ec469e3f01e7..5bb9ef378353fdc777f2a5011288729d50760019 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -69,6 +69,10 @@ Slice::Slice() , m_deblockingFilterCbTcOffsetDiv2 ( 0 ) , m_deblockingFilterCrBetaOffsetDiv2( 0 ) , m_deblockingFilterCrTcOffsetDiv2 ( 0 ) +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC +, m_depQuantEnabledFlag ( false ) +, m_signDataHidingEnabledFlag ( false ) +#endif , m_tsResidualCodingDisabledFlag ( false ) , m_pendingRasInit ( false ) , m_bCheckLDC ( false ) @@ -907,6 +911,10 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_deblockingFilterCbTcOffsetDiv2 = pSrc->m_deblockingFilterCbTcOffsetDiv2; m_deblockingFilterCrBetaOffsetDiv2 = pSrc->m_deblockingFilterCrBetaOffsetDiv2; m_deblockingFilterCrTcOffsetDiv2 = pSrc->m_deblockingFilterCrTcOffsetDiv2; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + m_depQuantEnabledFlag = pSrc->m_depQuantEnabledFlag; + m_signDataHidingEnabledFlag = pSrc->m_signDataHidingEnabledFlag; +#endif m_tsResidualCodingDisabledFlag = pSrc->m_tsResidualCodingDisabledFlag; for (i = 0; i < NUM_REF_PIC_LIST_01; i++) @@ -2170,8 +2178,10 @@ PicHeader::PicHeader() , m_numAlfAps ( 0 ) , m_alfApsId ( 0 ) , m_alfChromaApsId ( 0 ) +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC , m_depQuantEnabledFlag ( 0 ) , m_signDataHidingEnabledFlag ( 0 ) +#endif , m_deblockingFilterOverrideFlag ( 0 ) , m_deblockingFilterDisable ( 0 ) , m_deblockingFilterBetaOffsetDiv2 ( 0 ) @@ -2261,8 +2271,10 @@ void PicHeader::initPicHeader() m_qpDelta = 0; m_numAlfAps = 0; m_alfChromaApsId = 0; +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC m_depQuantEnabledFlag = 0; m_signDataHidingEnabledFlag = 0; +#endif m_deblockingFilterOverrideFlag = 0; m_deblockingFilterDisable = 0; m_deblockingFilterBetaOffsetDiv2 = 0; diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index d4362df191fbc1e9178e08e20e104202eab178fb..f10cf2f9745dfb80b861ef73a2bd0d42dd381eac 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -2177,8 +2177,10 @@ private: bool m_ccalfEnabledFlag[MAX_NUM_COMPONENT]; int m_ccalfCbApsId; int m_ccalfCrApsId; +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag +#endif bool m_deblockingFilterOverrideFlag; //!< deblocking filter override controls enabled bool m_deblockingFilterDisable; //!< deblocking filter disabled flag int m_deblockingFilterBetaOffsetDiv2; //!< beta offset for deblocking filter @@ -2312,10 +2314,12 @@ public: int getCcAlfCbApsId() const { return m_ccalfCbApsId; } void setCcAlfCrApsId(int i) { m_ccalfCrApsId = i; } int getCcAlfCrApsId() const { return m_ccalfCrApsId; } +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; } - bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } + bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; } - bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } + bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } +#endif void setDeblockingFilterOverrideFlag( bool b ) { m_deblockingFilterOverrideFlag = b; } bool getDeblockingFilterOverrideFlag() const { return m_deblockingFilterOverrideFlag; } void setDeblockingFilterDisable( bool b ) { m_deblockingFilterDisable= b; } @@ -2442,6 +2446,10 @@ private: int m_deblockingFilterCbTcOffsetDiv2; //< tc offset for deblocking filter int m_deblockingFilterCrBetaOffsetDiv2; //< beta offset for deblocking filter int m_deblockingFilterCrTcOffsetDiv2; //< tc offset for deblocking filter +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag + bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag +#endif bool m_tsResidualCodingDisabledFlag; int m_list1IdxToList0Idx[MAX_NUM_REF]; int m_aiNumRefIdx [NUM_REF_PIC_LIST_01]; // for multiple reference of current slice @@ -2626,6 +2634,12 @@ public: void setDeblockingFilterCbTcOffsetDiv2( int i ) { m_deblockingFilterCbTcOffsetDiv2 = i; } void setDeblockingFilterCrBetaOffsetDiv2( int i ) { m_deblockingFilterCrBetaOffsetDiv2 = i; } void setDeblockingFilterCrTcOffsetDiv2( int i ) { m_deblockingFilterCrTcOffsetDiv2 = i; } +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; } + bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } + void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; } + bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } +#endif void setTSResidualCodingDisabledFlag(bool b) { m_tsResidualCodingDisabledFlag = b; } bool getTSResidualCodingDisabledFlag() const { return m_tsResidualCodingDisabledFlag; } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 91029a7e3b059c8f81aa866229ba9fb1e4a38c46..4c6848cce69b4fd3180a88eebc43d7c5190121b9 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -52,9 +52,18 @@ //########### place macros to be removed in next cycle below this line ############### +#define JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC 1 // JVET-R0271/R0155: Slice level DQ and SDH granularity for mixed lossy/lossless. + +#define JVET_R0143_TSRCdisableLL 1 // JVET-R0143: disable TSRC for lossless coding + +#define JVET_R0233_CCALF_LINE_BUFFER_REDUCTION 1 // JVET-R0233 method 2: Line buffer reduction for CCALF + #define JVET_Q0471_CHROMA_QT_SPLIT 1 // JVET-Q0471: Chroma QT split +#define JVET_R0208_ALF_VB_ROUNDING_FIX 1 // JVET-R0208: Rounding offset fix for ALF virtual boundary processing +#define JVET_R0232_CCALF_APS_CONSTRAINT 1 // JVET-R0232 section 3.2: APS contraint for CCALF #define JVET_R0156_ASPECT3_SPS_CLEANUP 1 // Condition sps_sublayer_dpb_params_flag on sps_ptl_dpb_hrd_params_present_flag, in addition to sps_max_sublayer_minus1, JVET-R0156 proposal 3, JVET-R0170, JVET-R0222 proposal 2 + //########### place macros to be be kept below this line ############### #define JVET_M0497_MATRIX_MULT 0 // 0: Fast method; 1: Matrix multiplication diff --git a/source/Lib/CommonLib/version.h b/source/Lib/CommonLib/version.h index c25c904c98faecd636a83262a3f3356071b3ddbd..908c57ea0e948777d395bed7ebb2fb9d258df0fc 100644 --- a/source/Lib/CommonLib/version.h +++ b/source/Lib/CommonLib/version.h @@ -1,3 +1,3 @@ #if ! defined( VTM_VERSION ) -#define VTM_VERSION "8.1" +#define VTM_VERSION "8.2" #endif diff --git a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h index 295465d592d39ce3132853dc0484f94b85e26c70..12c44a2f87d0d8046c0e10fa31ff4dbbf4ef7467 100644 --- a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h +++ b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h @@ -313,6 +313,9 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs constexpr int SHIFT = AdaptiveLoopFilter::m_NUM_BITS - 1; constexpr int ROUND = 1 << (SHIFT - 1); +#if JVET_R0208_ALF_VB_ROUNDING_FIX + const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND); +#endif const size_t width = blk.width; const size_t height = blk.height; @@ -425,8 +428,13 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs } else { +#if JVET_R0208_ALF_VB_ROUNDING_FIX + accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3); + accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3); +#else accumA = _mm_srai_epi32(accumA, SHIFT + 3); accumB = _mm_srai_epi32(accumB, SHIFT + 3); +#endif } accumA = _mm_packs_epi32(accumA, accumB); accumA = _mm_add_epi16(accumA, cur); @@ -507,6 +515,9 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs Pel * dst = dstBuffer.buf + blkDst.y * dstStride + blkDst.x; const __m128i mmOffset = _mm_set1_epi32(ROUND); +#if JVET_R0208_ALF_VB_ROUNDING_FIX + const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND); +#endif const __m128i mmMin = _mm_set1_epi16( clpRng.min ); const __m128i mmMax = _mm_set1_epi16( clpRng.max ); @@ -655,8 +666,13 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs } else { +#if JVET_R0208_ALF_VB_ROUNDING_FIX + accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3); + accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3); +#else accumA = _mm_srai_epi32(accumA, SHIFT + 3); accumB = _mm_srai_epi32(accumB, SHIFT + 3); +#endif } accumA = _mm_packs_epi32(accumA, accumB); accumA = _mm_add_epi16(accumA, cur); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index f5f9e3d255c57f0423ba9fc5791cb0141b28fe0c..b6d8c50bd7e5b6777d6b6a428ed18f2e8f79a8b2 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -2891,7 +2891,11 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& } // determine sign hiding +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#else bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#endif if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP ) { const ChannelType chType = toChannelType( compID ); @@ -2924,7 +2928,11 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& } // parse subblocks +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + const int stateTransTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 ); +#else const int stateTransTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 ); +#endif int state = 0; int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA; diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 567b1e07633d53dcb5ffe1df7c89f5ca1cf3dff3..fa08a88288778b494c75ceceb5df38db773cf09f 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -980,6 +980,9 @@ bool DecLib::isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu ) void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& parameterSetManager, APS** apss, APS* lmcsAPS, APS* scalingListAPS) { +#if JVET_R0232_CCALF_APS_CONSTRAINT + const SPS *sps = parameterSetManager.getSPS(picHeader->getSPSId()); +#endif //luma APSs if (pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { @@ -998,6 +1001,10 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + +#if JVET_R0232_CCALF_APS_CONSTRAINT + CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0"); +#endif } } } @@ -1016,6 +1023,10 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + +#if JVET_R0232_CCALF_APS_CONSTRAINT + CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0"); +#endif } } @@ -1381,7 +1392,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) CHECK( sps->getSubPicInfoPresentFlag() != 0, "When res_change_in_clvs_allowed_flag is equal to 1, the value of subpic_info_present_flag shall be equal to 0." ); } - CHECK( sps->getRprEnabledFlag() && sps->getVirtualBoundariesEnabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0" ); + CHECK( sps->getRprEnabledFlag() && sps->getVirtualBoundariesPresentFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0" ); if( sps->getCTUSize() + 2 * ( 1 << sps->getLog2MinCodingBlockSize() ) > pps->getPicWidthInLumaSamples() ) { diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 26da9e93fa27814b642647114333ace58ac6652b..5280dcd1d06c05e10bfe3e01754be2ac2fc0a9d2 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -2822,6 +2822,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag } +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // dependent quantization if (sps->getDepQuantEnabledFlag()) { @@ -2843,6 +2844,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { picHeader->setSignDataHidingEnabledFlag(false); } +#endif // deblocking filter controls if (pps->getDeblockingFilterControlPresentFlag()) @@ -3719,8 +3721,43 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 ); } +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + // dependent quantization + if( sps->getDepQuantEnabledFlag() ) + { + READ_FLAG(uiCode, "slice_dep_quant_enabled_flag"); + pcSlice->setDepQuantEnabledFlag(uiCode != 0); + } + else + { + pcSlice->setDepQuantEnabledFlag(false); + } + + // sign data hiding + if( sps->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() ) + { + READ_FLAG( uiCode, "slice_sign_data_hiding_enabled_flag" ); + pcSlice->setSignDataHidingEnabledFlag( uiCode != 0 ); + } + else + { + pcSlice->setSignDataHidingEnabledFlag(false); + } + + // signal TS residual coding disabled flag + if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() ) + { + READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag"); + pcSlice->setTSResidualCodingDisabledFlag( uiCode != 0 ); + } + else + { + pcSlice->setTSResidualCodingDisabledFlag( false ); + } +#else READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag"); pcSlice->setTSResidualCodingDisabledFlag(uiCode != 0); +#endif if (picHeader->getLmcsEnabledFlag()) { diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index d68dc008dcb18104b36f680ef4ddbd46d18dce51..ba55122653500ae34f9abcef1c7036582503204c 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -2641,7 +2641,11 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID, } // determine sign hiding +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#else bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#endif if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP) { const ChannelType chType = toChannelType( compID ); @@ -2691,7 +2695,11 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID, last_sig_coeff( cctx, tu, compID ); // code subblocks +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + const int stateTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 ); +#else const int stateTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 ); +#endif int state = 0; int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA; diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp index 82b2d9027aa76c235779b2a7be6f03506f6e557e..e7d06837ff7f6ce3d069d14efa0453328e8e88f1 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp @@ -4014,6 +4014,12 @@ void EncAdaptiveLoopFilter::getBlkStatsCcAlf(AlfCovariance &alfCovariance, const for (int i = 0; i < compArea.height; i++) { int vbDistance = ((i << getComponentScaleY(compID, m_chromaFormat)) % vbCTUHeight) - vbPos; +#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION + if ((getComponentScaleY(compID, m_chromaFormat) == 0) && (vbDistance == 0 || vbDistance == 1)) + { + continue; + } +#endif for (int j = 0; j < compArea.width; j++) { std::memset(ELocal, 0, sizeof(ELocal)); diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 19ed66be49afe81ccf7a718bad9f7539531d29f1..146887dbdc3816ae7fb9265ab76edd178b9cf606 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -651,7 +651,9 @@ protected: double m_RCInitialCpbFullness; #endif CostMode m_costMode; ///< The cost function to use, primarily when considering lossless coding. - +#if JVET_R0143_TSRCdisableLL + bool m_TSRCdisableLL; ///< Disable TSRC for lossless +#endif DCI m_dci; bool m_DCIEnabled; ///< enable Decoding Capability Information (DCI) @@ -1687,8 +1689,10 @@ public: #endif CostMode getCostMode( ) const { return m_costMode; } void setCostMode(CostMode m ) { m_costMode = m; } - - +#if JVET_R0143_TSRCdisableLL + bool getTSRCdisableLL () { return m_TSRCdisableLL; } + void setTSRCdisableLL ( bool b ) { m_TSRCdisableLL = b; } +#endif void setDCI(DCI *p) { m_dci = *p; } DCI* getDCI() { return &m_dci; } diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 6aaee4261f49d95a0980cb2c004cf2396da2fc6a..87a06b1451d4c4277a1d30fde46584a6ba7b0132 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1685,10 +1685,11 @@ void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps picHeader.setMaxBTSizes( sps.getMaxBTSizes() ); picHeader.setMaxTTSizes( sps.getMaxTTSizes() ); +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // quantization picHeader.setDepQuantEnabledFlag( sps.getDepQuantEnabledFlag() ); picHeader.setSignDataHidingEnabledFlag( sps.getSignDataHidingEnabledFlag() ); - +#endif bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false; if( (getMaxDeltaQP() != 0 )|| getUseAdaptiveQP() ) diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index f10fee633a40b88011552edc101793fc3a901758..434fecfc32922602302109ca999704e978d81c49 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -339,7 +339,36 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr picHeader->setPicOutputFlag(true); } rpcSlice->setPOC( pocCurr ); + +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if( m_pcCfg->getCostMode() != COST_LOSSLESS_CODING ) + { + rpcSlice->setDepQuantEnabledFlag( m_pcCfg->getDepQuantEnabledFlag() ); + rpcSlice->setSignDataHidingEnabledFlag( m_pcCfg->getSignDataHidingEnabledFlag() ); + rpcSlice->setTSResidualCodingDisabledFlag( false ); + + CHECK( (m_pcCfg->getDepQuantEnabledFlag() || m_pcCfg->getSignDataHidingEnabledFlag() ) + && rpcSlice->getTSResidualCodingDisabledFlag() , "TSRC cannot be bypassed if either DQ or SDH are enabled at slice level."); + } + else + { + rpcSlice->setDepQuantEnabledFlag( false ); //should be disabled for lossless + rpcSlice->setSignDataHidingEnabledFlag( false ); //should be disabled for lossless +#if JVET_R0143_TSRCdisableLL + if( m_pcCfg->getTSRCdisableLL() ) + { + rpcSlice->setTSResidualCodingDisabledFlag( true ); + } +#else + rpcSlice->setTSResidualCodingDisabledFlag( true ); +#endif + } +#else +#if JVET_R0143_TSRCdisableLL + if( ( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING ) && m_pcCfg->getTSRCdisableLL() ) +#else if( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING ) +#endif { rpcSlice->setTSResidualCodingDisabledFlag(true); } @@ -347,6 +376,7 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr { rpcSlice->setTSResidualCodingDisabledFlag(false); } +#endif #if SHARP_LUMA_DELTA_QP pcPic->fieldPic = isField; diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 1415bbd57b9517687a5dd4b548205ffe95e5fa71..c57cb471b444aa0b48fddaae3f29842156e985de 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -1870,6 +1870,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB } +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // dependent quantization if (sps->getDepQuantEnabledFlag()) { @@ -1888,6 +1889,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingB { picHeader->setSignDataHidingEnabledFlag(false); } +#endif // deblocking filter controls if (pps->getDeblockingFilterControlPresentFlag()) @@ -2338,7 +2340,35 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 ); } +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + // dependent quantization + if( pcSlice->getSPS()->getDepQuantEnabledFlag() ) + { + WRITE_FLAG(pcSlice->getDepQuantEnabledFlag(), "slice_dep_quant_enabled_flag"); + } + else + { + pcSlice->setDepQuantEnabledFlag(false); + } + + // sign data hiding + if( pcSlice->getSPS()->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() ) + { + WRITE_FLAG(pcSlice->getSignDataHidingEnabledFlag(), "slice_sign_data_hiding_enabled_flag" ); + } + else + { + pcSlice->setSignDataHidingEnabledFlag(false); + } + + // signal TS residual coding disabled flag + if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() ) + { + WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag"); + } +#else WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag"); +#endif if (picHeader->getLmcsEnabledFlag()) {