diff --git a/source/Lib/CommonLib/LoopFilter.cpp b/source/Lib/CommonLib/LoopFilter.cpp index 4823520fda84a37aadacfd07c23391571855a33a..66817bcb11e998151450660902355c0ca3592c24 100644 --- a/source/Lib/CommonLib/LoopFilter.cpp +++ b/source/Lib/CommonLib/LoopFilter.cpp @@ -1232,11 +1232,31 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed if ((bS[chromaIdx] == 2) || (largeBoundary && (bS[chromaIdx] == 1))) { const ClpRng& clpRng( cu.cs->slice->clpRng( ComponentID( chromaIdx + 1 )) ); +#if !JVET_P1001_DEBLOCKING_CHROMAQP_FIX const int chromaQPOffset = pps.getQpOffset( ComponentID( chromaIdx + 1 ) ); +#endif Pel* piTmpSrcChroma = (chromaIdx == 0) ? piTmpSrcCb : piTmpSrcCr; +#if JVET_P1001_DEBLOCKING_CHROMAQP_FIX + int shiftHor = cu.Y().valid() ? 0 : ::getComponentScaleX(COMPONENT_Cb, cu.firstPU->chromaFormat); + int shiftVer = cu.Y().valid() ? 0 : ::getComponentScaleY(COMPONENT_Cb, cu.firstPU->chromaFormat); + const Position& posQ = Position{ pos.x >> shiftHor, pos.y >> shiftVer }; + const Position posP = (edgeDir == EDGE_VER) ? posQ.offset(-1, 0) : posQ.offset(0, -1); + + const TransformUnit& tuQ = *cuQ.cs->getTU(posQ, cuQ.chType); + const TransformUnit& tuP = *cuP.cs->getTU(posP, cuQ.chType); //based on chType of the current cu, because cuQ.chType and cuP.chType are not the same when local dual-tree is applied + + const QpParam cQP(tuP, ComponentID(chromaIdx + 1)); + const QpParam cQQ(tuQ, ComponentID(chromaIdx + 1)); + const int qpBdOffset = tuP.cs->sps->getQpBDOffset(toChannelType(ComponentID(chromaIdx + 1))); + int baseQp_P = cQP.Qp(0) - qpBdOffset; + int baseQp_Q = cQQ.Qp(0) - qpBdOffset; + int iQP = ((baseQp_Q + baseQp_P + 1) >> 1); +#else int iQP = sps.getMappedChromaQpValue(ComponentID(chromaIdx + 1), ((cuP.qp + cuQ.qp + 1) >> 1)); iQP = Clip3(0, MAX_QP, iQP + chromaQPOffset); +#endif + const int iIndexTC = Clip3<int>(0, MAX_QP + DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET * (bS[chromaIdx] - 1) + (tcOffsetDiv2 << 1)); const int iTc = sps.getBitDepth(CHANNEL_TYPE_CHROMA) < 10 ? ((sm_tcTable[iIndexTC] + 2) >> (10 - sps.getBitDepth(CHANNEL_TYPE_CHROMA))) : ((sm_tcTable[iIndexTC]) << (sps.getBitDepth(CHANNEL_TYPE_CHROMA) - 10)); diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index b6b4c25ba495a327c42b0cb968ac8f608b65d931..0172fb6104e48c74f3b0bb0e8e1948a8ce6e2b48 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_P1001_DEBLOCKING_CHROMAQP_FIX 1 //JVET-P1001/P1002: Align Chroma QP used in deblocking with the one used in Transform/invTransform + #define JVET_P0043_DEBLOCKING_CLEANUP 1 // JVET-P0043: Fix deblocking design inconsistency in the affine and TPM mode #define JVET_P0273_MTSIntraMaxCand 1 // JVET-P0273: Use MTSIntraMaxCand if LFNST is used