diff --git a/cfg/per-class/classF.cfg b/cfg/per-class/classF.cfg index 0edc6f8c15bcee5cdd03a22df2d25406613a7c33..7646377dcd6ff9113b2c92107da4624ee90b5fb3 100644 --- a/cfg/per-class/classF.cfg +++ b/cfg/per-class/classF.cfg @@ -1,3 +1,3 @@ IBC : 1 HashME : 1 -BDPCM: 1 +BDPCM: 2 diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 840e718022d7fe96554c26ba30c06e479855d9e6..139c24d1ac953c98bf76facddaef65bf5d27d722 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -419,10 +419,17 @@ const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet const CtxSet ContextSetCfg::BDPCMMode = ContextSetCfg::addCtxSet ({ +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + { 19, 28, 25, 51, }, + { 40, 36, 17, 28, }, + { 19, 35, 9, 44, }, + { 4, 4, 1, 1, }, +#else { 19, 28, }, { 40, 36, }, { 19, 35, }, { 4, 4, }, +#endif }); const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index a68b90ae01fe6e578c082dd809363fac7449ad6e..756850b86b059df6a67a94fd810dd00696bd4a68 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_Q0110_Q0785_CHROMA_BDPCM_420 1 // JVET-Q0110/Q0785: Enable chroma BDPCM for 420, separate contexts for chroma BDPCM and bug-fixes. + #define JVET_Q0512_ENC_CHROMA_TS_ACT 1 // JVET-Q0512: encoder-side improvement on enabling chroma transform-skip for ACT #define JVET_Q0446_MIP_CONST_SHIFT_OFFSET 1 // JVET-Q0446: MIP with constant shift and offset diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 08e21e18342c54ed0421f1443206e1c9bafec7d1..5f9043eab5b5bb3cb5d4325073ac1a79dd4f35ce 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -859,9 +859,11 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& end_of_ctu(cu, cuCtx); return; } +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 bdpcm_mode( cu, ComponentID( partitioner.chType ) ); if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType)) bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); +#endif // --> create PUs @@ -1145,10 +1147,19 @@ void CABACReader::bdpcm_mode( CodingUnit& cu, const ComponentID compID ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__BDPCM_MODE, cu.block(compID).lumaSize(), compID ); int bdpcmMode; +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + unsigned ctxId = isLuma( compID ) ? 0 : 2; + bdpcmMode = m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId) ); +#else bdpcmMode = m_BinDecoder.decodeBin(Ctx::BDPCMMode(0)); +#endif if (bdpcmMode) { +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + bdpcmMode += m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId+1) ); +#else bdpcmMode += m_BinDecoder.decodeBin(Ctx::BDPCMMode(1)); +#endif } if (isLuma(compID)) { @@ -1172,7 +1183,19 @@ void CABACReader::cu_pred_data( CodingUnit &cu ) { if( CU::isIntra( cu ) ) { +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( cu.Y().valid() ) + { + bdpcm_mode(cu, COMPONENT_Y ); + } +#endif intra_luma_pred_modes( cu ); +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( !cu.Y().valid() || ( !cu.isSepTree() && cu.Y().valid() ) ) + { + bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); + } +#endif intra_chroma_pred_modes( cu ); return; } @@ -1413,6 +1436,13 @@ void CABACReader::intra_chroma_pred_modes( CodingUnit& cu ) return; } +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( cu.bdpcmModeChroma ) + { + cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; + return; + } +#endif PredictionUnit *pu = cu.firstPU; { @@ -1450,7 +1480,7 @@ void CABACReader::intra_chroma_pred_mode(PredictionUnit& pu) } // LM chroma mode - +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 if (pu.cu->bdpcmModeChroma) { unsigned chromaCandModes[NUM_CHROMA_MODE]; @@ -1458,6 +1488,7 @@ void CABACReader::intra_chroma_pred_mode(PredictionUnit& pu) pu.intraDir[1] = chromaCandModes[0]; return; } +#endif if (pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed()) { diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 7d65fe720255dd0806d39cd327a234df164cf094..48752f8ccaed7c61e518ece5b1cf13462f9a9d63 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1505,7 +1505,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) if (pcSPS->getTransformSkipEnabledFlag()) { READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( uiCode ) +#else if (uiCode && pcSPS->getChromaFormatIdc() == CHROMA_444 ) +#endif { READ_FLAG(uiCode, "sps_bdpcm_enabled_chroma_flag"); uiCode++; diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 441fe0465d068ff195c43326be4498f5a99fe5fb..5b851d934848790bc53284b1060affd058613456 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -691,9 +691,11 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C end_of_ctu(cu, cuCtx); return; } +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 bdpcm_mode( cu, ComponentID( partitioner.chType ) ); if (!CS::isDualITree(cs) && isLuma(partitioner.chType)) bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); +#endif // prediction data ( intra prediction modes / reference indexes + motion vectors ) cu_pred_data( cu ); @@ -818,11 +820,20 @@ void CABACWriter::bdpcm_mode( const CodingUnit& cu, const ComponentID compID ) int bdpcmMode = isLuma(compID) ? cu.bdpcmMode : cu.bdpcmModeChroma; +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + unsigned ctxId = isLuma(compID) ? 0 : 2; + m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(ctxId)); +#else m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(0)); +#endif if (bdpcmMode) { +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(ctxId+1)); +#else m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(1)); +#endif } if (isLuma(compID)) { @@ -839,7 +850,20 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu ) { if( CU::isIntra( cu ) ) { +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( cu.Y().valid() ) + { + bdpcm_mode( cu, COMPONENT_Y ); + } +#endif + intra_luma_pred_modes ( cu ); +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( !cu.Y().valid() || ( !cu.isSepTree() && cu.Y().valid() ) ) + { + bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) ); + } +#endif intra_chroma_pred_modes( cu ); return; } @@ -1204,6 +1228,13 @@ void CABACWriter::intra_chroma_pred_modes( const CodingUnit& cu ) return; } +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( cu.bdpcmModeChroma ) + { + cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; + return; + } +#endif const PredictionUnit* pu = cu.firstPU; intra_chroma_pred_mode( *pu ); @@ -1237,10 +1268,12 @@ void CABACWriter::intra_chroma_lmc_mode(const PredictionUnit& pu) void CABACWriter::intra_chroma_pred_mode(const PredictionUnit& pu) { +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 if (pu.cu->bdpcmModeChroma) { return; } +#endif const unsigned intraDir = pu.intraDir[1]; if (pu.cu->colorTransform) diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 011ce09d3ac128435543ec07d31b289d850b3e90..452e7cec6ccee5bf79c0e3bc78fe05b03f3e43d8 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1835,9 +1835,11 @@ bool EncCu::xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS m_CABACEstimator->pred_mode ( cu ); m_CABACEstimator->adaptive_color_transform(cu); m_CABACEstimator->cu_pred_data ( cu ); +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 m_CABACEstimator->bdpcm_mode ( cu, ComponentID(partitioner.chType) ); if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType)) m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); +#endif // Encode Coefficients CUCtx cuCtx; diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 02a43bae9d08b8e275bb3fcad5418c2354273120..ecacd5094dba4314d59e64e6713fbfb2108f82f6 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1426,7 +1426,11 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner if (uiMode < 0) { cu.bdpcmModeChroma = -uiMode; +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + chromaIntraMode = cu.bdpcmModeChroma == 2 ? chromaCandModes[1] : chromaCandModes[2]; +#else chromaIntraMode = chromaCandModes[0]; +#endif } else { @@ -2590,9 +2594,11 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner { return; } +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 m_CABACEstimator->bdpcm_mode ( cu, ComponentID(partitioner.chType) ); if (!CS::isDualITree(cs) && isLuma(partitioner.chType)) m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); +#endif } PredictionUnit &pu = *cs.getPU(partitioner.currArea().lumaPos(), partitioner.chType); @@ -2602,6 +2608,9 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner { if ( !cu.Y().valid()) m_CABACEstimator->pred_mode( cu ); +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + m_CABACEstimator->bdpcm_mode( cu, COMPONENT_Y ); +#endif m_CABACEstimator->intra_luma_pred_mode( pu ); } } @@ -2614,6 +2623,9 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner if( isFirst ) { +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + m_CABACEstimator->bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) ); +#endif m_CABACEstimator->intra_chroma_pred_mode( pu ); } } diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 056819f01ce1d6f7022da56a63b942d20df033f5..a4e36d7738868a58084e241b564dc055aa793162 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -962,14 +962,20 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) if (pcSPS->getTransformSkipEnabledFlag()) { WRITE_FLAG(pcSPS->getBDPCMEnabled() ? 1 : 0, "sps_bdpcm_enabled_flag"); +#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 + if( pcSPS->getBDPCMEnabled() ) +#else if (pcSPS->getBDPCMEnabled() && pcSPS->getChromaFormatIdc() == CHROMA_444) +#endif { WRITE_FLAG(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA ? 1 : 0, "sps_bdpcm_enabled_chroma_flag"); } +#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 else { CHECK(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA, "BDPCM for chroma can be used for 444 only.") } +#endif } else {