diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 7da6763a4a11c29fa2fa7305ecdc26c9a1c4ca70..ce6484410b4b14e5f97b64e00fcdffa3aa1b1769 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -998,7 +998,9 @@ namespace DQIntern const int8_t m_stateId; const BinFracBits*const m_sigFracBitsArray; const CoeffFracBits*const m_gtxFracBitsArray; +#if !JVET_P0170_ZERO_POS_SIMPLIFICATION const uint32_t*const m_goRiceZeroArray; +#endif CommonCtx& m_commonCtx; public: unsigned effWidth; @@ -1011,7 +1013,9 @@ namespace DQIntern , m_stateId ( stateId ) , m_sigFracBitsArray( rateEst.sigFlagBits(stateId) ) , m_gtxFracBitsArray( rateEst.gtxFracBits(stateId) ) +#if !JVET_P0170_ZERO_POS_SIMPLIFICATION , m_goRiceZeroArray ( g_auiGoRicePosCoeff0[std::max(0,stateId-1)] ) +#endif , m_commonCtx ( commonCtx ) { } @@ -1162,7 +1166,11 @@ namespace DQIntern #undef UPDATE sumAbs = std::min<TCoeff>(31, sumAbs); m_goRicePar = g_auiGoRiceParsCoeff[sumAbs]; +#if JVET_P0170_ZERO_POS_SIMPLIFICATION + m_goRiceZero = g_auiGoRicePosCoeff0(m_stateId, m_goRicePar); +#else m_goRiceZero = m_goRiceZeroArray[sumAbs]; +#endif } } } diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index 378758f5071ab66441af77478536d107f53fa2b2..d6c97d34a6adfaec2de75d8d11259df3ca6bfa5a 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -732,7 +732,11 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, { unsigned sumAbs = cctx.templateAbsSum( iScanPos, piDstCoeff, 0 ); goRiceParam = g_auiGoRiceParsCoeff [ sumAbs ]; +#if JVET_P0170_ZERO_POS_SIMPLIFICATION + goRiceZero = g_auiGoRicePosCoeff0(0, goRiceParam); +#else goRiceZero = g_auiGoRicePosCoeff0[0][ sumAbs ]; +#endif } const BinFracBits fracBitsPar = fracBits.getFracBitsArray( uiParCtx ); diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 2822b75b3a7159c83f7514770c59d1ad8d9663f1..3250e138c7601afaf12c9d6c386de18e17e44bec 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -583,13 +583,14 @@ const uint32_t g_auiGoRiceParsCoeff[32] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3 }; +#if !JVET_P0170_ZERO_POS_SIMPLIFICATION const uint32_t g_auiGoRicePosCoeff0[3][32] = { {0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8}, {1, 1, 1, 1, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16}, {1, 1, 2, 2, 2, 3, 4, 4, 4, 6, 6, 6, 8, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 16, 16, 16} }; - +#endif const char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = { { diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index 6ba79c0c7270d6f762081a90b2449b063da02900..ac70317eb1f943cbaf6b4b33035e79f830a5d237 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -87,7 +87,14 @@ static const int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 6, extern const uint32_t g_uiGroupIdx[ MAX_TB_SIZEY ]; extern const uint32_t g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ]; extern const uint32_t g_auiGoRiceParsCoeff [ 32 ]; +#if JVET_P0170_ZERO_POS_SIMPLIFICATION +inline uint32_t g_auiGoRicePosCoeff0(int st, uint32_t ricePar) +{ + return (st < 2 ? 1 : 2) << ricePar; +} +#else extern const uint32_t g_auiGoRicePosCoeff0[ 3 ][ 32 ]; +#endif // ==================================================================================================================== // Intra prediction table diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 574475fa11298352f10029ab2f77b8aab6b1f668..302852907f374259f327b71f8275d0984e336c89 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -56,6 +56,8 @@ #define JVET_P0400_REMOVE_SHARED_MERGE_LIST 1 // JVET-P0400: removeal of shared merge list +#define JVET_P0170_ZERO_POS_SIMPLIFICATION 1 // JVET-P0170: Simplification of deriving ZeroPos + #define JVET_P0436_CQP_OFFSET_SIGNALLING 1 // JVET_P0436: CU chroma QP offset signalling consistent with VPDU and bugfix #define JVET_P0154_PROF_SAMPLE_OFFSET_CLIPPING 1 // JVET-P0154/P0094/P0172/P0413/P0518/P0281: Clip the PROF sample offset to 14-bit diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index f5987d816c179b65725e1805689f4f762524208a..0eb552c24269fea2506243305ceb4f26cf99f1c7 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3290,7 +3290,11 @@ void CABACReader::residual_coding_subblock( CoeffCodingContext& cctx, TCoeff* co { int sumAll = cctx.templateAbsSum(scanPos, coeff, 0); int rice = g_auiGoRiceParsCoeff [sumAll]; +#if JVET_P0170_ZERO_POS_SIMPLIFICATION + int pos0 = g_auiGoRicePosCoeff0(state, rice); +#else int pos0 = g_auiGoRicePosCoeff0[std::max(0, state - 1)][sumAll]; +#endif RExt__DECODER_DEBUG_BIT_STATISTICS_SET(ctype_escs); int rem = m_BinDecoder.decodeRemAbsEP( rice, cctx.extPrec(), cctx.maxLog2TrDRange() ); DTRACE( g_trace_ctx, D_SYNTAX_RESI, "rem_val() bin=%d ctx=%d\n", rem, rice ); diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index ad2d633f62dc11eba3185e7ed980eaeb7c4e5314..c60e70d147d59b64a410b1eb42a286401283b803 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -3052,7 +3052,11 @@ void CABACWriter::residual_coding_subblock( CoeffCodingContext& cctx, const TCoe unsigned absLevel = abs( Coeff ); int sumAll = cctx.templateAbsSum(scanPos, coeff, 0); int rice = g_auiGoRiceParsCoeff [sumAll]; +#if JVET_P0170_ZERO_POS_SIMPLIFICATION + int pos0 = g_auiGoRicePosCoeff0(state, rice); +#else int pos0 = g_auiGoRicePosCoeff0[std::max(0, state - 1)][sumAll]; +#endif unsigned rem = ( absLevel == 0 ? pos0 : absLevel <= pos0 ? absLevel-1 : absLevel ); m_BinEncoder.encodeRemAbsEP( rem, rice, cctx.extPrec(), cctx.maxLog2TrDRange() ); DTRACE( g_trace_ctx, D_SYNTAX_RESI, "rem_val() bin=%d ctx=%d\n", rem, rice );