diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 8adc6a119feba92ac363f0a35241cc53df60d6cd..3c476b7766dfc4d4029e37b2a0e3b503932289c3 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -88,6 +88,8 @@ #define JVET_O0256_ADJUST_THD_DEPQUANT 1 // JVET-O0256: Fast encoder with adjusted threshold in dependent quantization +#define JVET_O0619_GTX_SINGLE_PASS_TS_RESIDUAL_CODING 1 // JVET-O0619/O0623 : Single pass coding of abs_level_gtx_flag[x] for TS residual coding + #define JVET_O0272_LMCS_SIMP_INVERSE_MAPPING 1 // JVET-O0272: LMCS simplified inverse mapping #define JVET_O0247_ALF_CTB_CODING_REDUNDANCY_REMOVAL 1 // JVET-O0247: not signal APS index when number APS is 2 diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 6b9aff8ced1d76db30d1917a0ffd4a5c9322e2b6..245c8b5a7755e14cf9e26bc581c31bd2e61507a3 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -3271,6 +3271,34 @@ void CABACReader::residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* int numGtBins = 4; //===== 2nd PASS: gt2 ===== +#if JVET_O0619_GTX_SINGLE_PASS_TS_RESIDUAL_CODING + for (int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++) + { + TCoeff& tcoeff = coeff[cctx.blockPos(scanPos)]; + cutoffVal = 2; + for (int i = 0; i < numGtBins; i++) + { + if (tcoeff >= cutoffVal) + { + RExt__DECODER_DEBUG_BIT_STATISTICS_SET(ctype_gt2); + unsigned gt2Flag; + if (cctx.isContextCoded()) + { + gt2Flag = m_BinDecoder.decodeBin(cctx.greaterXCtxIdAbsTS(cutoffVal >> 1)); + tcoeff += (gt2Flag << 1); + DTRACE(g_trace_ctx, D_SYNTAX_RESI, "ts_gt%d_flag() bin=%d ctx=%d sp=%d coeff=%d\n", i, gt2Flag, cctx.greaterXCtxIdAbsTS(cutoffVal >> 1), scanPos, tcoeff); + } + else + { + gt2Flag = m_BinDecoder.decodeBinEP(); + tcoeff += (gt2Flag << 1); + DTRACE(g_trace_ctx, D_SYNTAX_RESI, "ts_gt%d_flag() EPbin=%d sp=%d coeff=%d\n", i, gt2Flag, scanPos, tcoeff); + } + } + cutoffVal += 2; + } + } +#else for( int i = 0; i < numGtBins; i++ ) { for( int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++ ) @@ -3296,7 +3324,7 @@ void CABACReader::residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* } cutoffVal += 2; } - +#endif //===== 3rd PASS: Go-rice codes ===== for( int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++ ) { diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 0771d006d0e86069dfcd52172113400b0cd102f8..aaa75beca75b77e99516a7bb4fdaa275213f8aa5 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -3108,6 +3108,31 @@ void CABACWriter::residual_coding_subblockTS( CoeffCodingContext& cctx, const TC int cutoffVal = 2; int numGtBins = 4; +#if JVET_O0619_GTX_SINGLE_PASS_TS_RESIDUAL_CODING + for (int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++) + { + unsigned absLevel = abs(coeff[cctx.blockPos(scanPos)]); + cutoffVal = 2; + for (int i = 0; i < numGtBins; i++) + { + if (absLevel >= cutoffVal) + { + unsigned gt2 = (absLevel >= (cutoffVal + 2)); + if (cctx.isContextCoded()) + { + m_BinEncoder.encodeBin(gt2, cctx.greaterXCtxIdAbsTS(cutoffVal >> 1)); + DTRACE(g_trace_ctx, D_SYNTAX_RESI, "ts_gt%d_flag() bin=%d ctx=%d sp=%d coeff=%d\n", i, gt2, cctx.greaterXCtxIdAbsTS(cutoffVal >> 1), scanPos, min<int>(absLevel, cutoffVal + 2)); + } + else + { + m_BinEncoder.encodeBinEP(gt2); + DTRACE(g_trace_ctx, D_SYNTAX_RESI, "ts_gt%d_flag() EPbin=%d sp=%d coeff=%d\n", i, gt2, scanPos, min<int>(absLevel, cutoffVal + 2)); + } + } + cutoffVal += 2; + } + } +#else for( int i = 0; i < numGtBins; i++ ) { for( int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++ ) @@ -3130,6 +3155,7 @@ void CABACWriter::residual_coding_subblockTS( CoeffCodingContext& cctx, const TC } cutoffVal += 2; } +#endif //===== coeff bypass ==== for( int scanPos = firstSigPos; scanPos <= minSubPos; scanPos++ )