diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index c4ad7c567b36e1247f505f6de8d141b3b1d4aa85..34a4886e8f80f07376d3fca04485dd4ac6a580f0 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -1875,6 +1875,9 @@ SPS::SPS() , m_bLongTermRefsPresent (false) // Tool list , m_transformSkipEnabledFlag (false) +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL +, m_log2MaxTransformSkipBlockSize (2) +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM , m_BDPCMEnabledFlag (false) #else @@ -2130,7 +2133,9 @@ PPS::PPS() , m_tileIdxDeltaPresentFlag (0) , m_loopFilterAcrossTilesEnabledFlag (1) , m_loopFilterAcrossSlicesEnabledFlag(0) -, m_log2MaxTransformSkipBlockSize (2) +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + , m_log2MaxTransformSkipBlockSize (2) +#endif , m_entropyCodingSyncEnabledFlag (false) , m_constantSliceHeaderParamsEnabledFlag (false) , m_PPSDepQuantEnabledIdc (0) diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 6418e04aa787c17babdc9b1cec58e6c7c3dd4953..bcaec33377334a20e9f354784ddb8754917ab41e 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1133,6 +1133,9 @@ private: // Tool list bool m_transformSkipEnabledFlag; +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + int m_log2MaxTransformSkipBlockSize; +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool m_BDPCMEnabledFlag; #else @@ -1348,6 +1351,10 @@ public: uint32_t getMaxCodingDepth() const { return m_uiMaxCodingDepth; } bool getTransformSkipEnabledFlag() const { return m_transformSkipEnabledFlag; } void setTransformSkipEnabledFlag( bool b ) { m_transformSkipEnabledFlag = b; } +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + uint32_t getLog2MaxTransformSkipBlockSize() const { return m_log2MaxTransformSkipBlockSize; } + void setLog2MaxTransformSkipBlockSize(uint32_t u) { m_log2MaxTransformSkipBlockSize = u; } +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool getBDPCMEnabledFlag() const { return m_BDPCMEnabledFlag; } void setBDPCMEnabledFlag( bool b ) { m_BDPCMEnabledFlag = b; } @@ -1660,7 +1667,9 @@ private: #endif bool m_loopFilterAcrossTilesEnabledFlag; //!< loop filtering applied across tiles flag bool m_loopFilterAcrossSlicesEnabledFlag; //!< loop filtering applied across slices flag +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL int m_log2MaxTransformSkipBlockSize; +#endif bool m_entropyCodingSyncEnabledFlag; //!< Indicates the presence of wavefronts bool m_constantSliceHeaderParamsEnabledFlag; @@ -1865,10 +1874,10 @@ public: void initRasterSliceMap( std::vector<uint32_t> sizes ); void checkSliceMap(); SliceMap getSliceMap( int idx ) const { CHECK( idx >= m_numSlicesInPic, "Slice index exceeds valid range" ); return m_sliceMap[idx]; } - +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL uint32_t getLog2MaxTransformSkipBlockSize() const { return m_log2MaxTransformSkipBlockSize; } void setLog2MaxTransformSkipBlockSize(uint32_t u) { m_log2MaxTransformSkipBlockSize = u; } - +#endif bool getEntropyCodingSyncEnabledFlag() const { return m_entropyCodingSyncEnabledFlag; } void setEntropyCodingSyncEnabledFlag(bool val) { m_entropyCodingSyncEnabledFlag = val; } diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 52745d048ae5e34fc2e07f2c85953b09b44eeedd..4499657bee965fcc838ae194c8eff5cfcc77a3ad 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -61,6 +61,8 @@ #define JVET_Q0504_PLT_NON444 1 // JVET-Q0504: enable palette mode for non 444 color format +#define JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL 1 // JVET-Q0183: Signal the max block size in SPS and conditionally signal min_qp_prime_ts_minus4 + #define JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM 1 // JVET-Q0089: RRC slice-level switch for lossless coding and one SPS flag for luma and chroma BDPCM. #define JVET_Q0816 1 // JVET_Q0816: Omit the signalling of subpic layout when there is only one subpicture diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 023d7796ff3031589b699c6a4c8802704d713b12..c4344e17ea2f7cd000d76cf198d62803b87c8724 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -3835,7 +3835,11 @@ uint8_t CU::deriveBcwIdx( uint8_t bcwLO, uint8_t bcwL1 ) bool CU::bdpcmAllowed( const CodingUnit& cu, const ComponentID compID ) { +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + SizeType transformSkipMaxSize = 1 << cu.cs->sps->getLog2MaxTransformSkipBlockSize(); +#else SizeType transformSkipMaxSize = 1 << cu.cs->pps->getLog2MaxTransformSkipBlockSize(); +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool bdpcmAllowed = cu.cs->sps->getBDPCMEnabledFlag(); @@ -3857,7 +3861,11 @@ bool CU::bdpcmAllowed( const CodingUnit& cu, const ComponentID compID ) bool CU::isMTSAllowed(const CodingUnit &cu, const ComponentID compID) { +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + SizeType tsMaxSize = 1 << cu.cs->sps->getLog2MaxTransformSkipBlockSize(); +#else SizeType tsMaxSize = 1 << cu.cs->pps->getLog2MaxTransformSkipBlockSize(); +#endif const int maxSize = CU::isIntra( cu ) ? MTS_INTRA_MAX_CU_SIZE : MTS_INTER_MAX_CU_SIZE; const int cuWidth = cu.blocks[0].lumaSize().width; const int cuHeight = cu.blocks[0].lumaSize().height; @@ -3900,7 +3908,11 @@ void TU::setCbfAtDepth(TransformUnit &tu, const ComponentID &compID, const unsig bool TU::isTSAllowed(const TransformUnit &tu, const ComponentID compID) { +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + const int maxSize = tu.cs->sps->getLog2MaxTransformSkipBlockSize(); +#else const int maxSize = tu.cs->pps->getLog2MaxTransformSkipBlockSize(); +#endif bool tsAllowed = tu.cs->sps->getTransformSkipEnabledFlag(); tsAllowed &= ( !tu.cu->ispMode || !isLuma(compID) ); diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 9d22d2d1e4d85a9a2502391b0a72102e05a9c5d9..ea537898c7aeb19f32d7c3ad246ba383ea325c25 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -607,9 +607,10 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetMana READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2"); pcPPS->setLog2MaxTransformSkipBlockSize(uiCode + 2); - +#endif READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); READ_SVLC( iCode, "pps_cb_qp_offset"); pcPPS->setQpOffset(COMPONENT_Cb, iCode); @@ -1391,10 +1392,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (int) (6*uiCode) ); pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (int) (6*uiCode) ); - +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL READ_UVLC( uiCode, "min_qp_prime_ts_minus4" ); pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode); CHECK(uiCode > 48, "Invalid min_qp_prime_ts_minus4 signalled"); +#endif pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_CHROMA, uiCode); READ_FLAG( uiCode, "sps_weighted_pred_flag" ); pcSPS->setUseWP( uiCode ? true : false ); READ_FLAG( uiCode, "sps_weighted_bipred_flag" ); pcSPS->setUseWPBiPred( uiCode ? true : false ); @@ -1605,6 +1607,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(uiCode, "sps_transform_skip_enabled_flag"); pcSPS->setTransformSkipEnabledFlag(uiCode ? true : false); if (pcSPS->getTransformSkipEnabledFlag()) { +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2"); + pcSPS->setLog2MaxTransformSkipBlockSize(uiCode + 2); +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); pcSPS->setBDPCMEnabledFlag(uiCode ? true : false); #else @@ -1731,6 +1737,14 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { pcSPS->setPLTMode(false); } +#endif +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + if (pcSPS->getTransformSkipEnabledFlag() || pcSPS->getPLTMode()) + { + READ_UVLC(uiCode, "min_qp_prime_ts_minus4"); + pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode); + CHECK(uiCode > 48, "Invalid min_qp_prime_ts_minus4 signalled"); + } #endif READ_FLAG( uiCode, "sps_bcw_enabled_flag" ); pcSPS->setUseBcw( uiCode != 0 ); READ_FLAG(uiCode, "sps_ibc_enabled_flag"); pcSPS->setIBCFlag(uiCode); diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 5b59d3243a724510b940f99c8f436146c350ba53..3e282241606d6500e4d11f594f43fb08ac8719c9 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -1157,6 +1157,9 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) CHECK(m_uiMaxMTTHierarchyDepthIChroma > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); sps.setTransformSkipEnabledFlag(m_useTransformSkip); +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + sps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize); +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM sps.setBDPCMEnabledFlag(m_useBDPCM); #else @@ -1627,7 +1630,9 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) CHECK(!(bestPos <= 15), "Unspecified error"); pps.setNumRefIdxL0DefaultActive(bestPos); pps.setNumRefIdxL1DefaultActive(bestPos); +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL pps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize); +#endif pps.setPictureHeaderExtensionPresentFlag(false); pps.pcv = new PreCalcValues( sps, pps, true ); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index f1b94db14c01b30ab3deaca05f1197235de4fc2d..086853b2d6ac758cb52a68ab1d88834b0a116b19 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -375,7 +375,9 @@ void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS ) WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL WRITE_UVLC( pcPPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2"); +#endif WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); @@ -909,9 +911,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_minus8" ); - +#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL WRITE_UVLC( pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4" ); - +#endif WRITE_FLAG( pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) WRITE_FLAG( pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) @@ -1039,6 +1041,9 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG(pcSPS->getTransformSkipEnabledFlag() ? 1 : 0, "sps_transform_skip_enabled_flag"); if (pcSPS->getTransformSkipEnabledFlag()) { +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + WRITE_UVLC(pcSPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2"); +#endif #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM WRITE_FLAG(pcSPS->getBDPCMEnabledFlag() ? 1 : 0, "sps_bdpcm_enabled_flag"); #else @@ -1151,6 +1156,12 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) { WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag" ); } +#endif +#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL + if (pcSPS->getTransformSkipEnabledFlag() || pcSPS->getPLTMode()) + { + WRITE_UVLC(pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4"); + } #endif WRITE_FLAG( pcSPS->getUseBcw() ? 1 : 0, "sps_bcw_enabled_flag" ); WRITE_FLAG(pcSPS->getIBCFlag() ? 1 : 0, "sps_ibc_enabled_flag");