diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp index 2bebe613c441ab579c1f8dfc0b9fa4e200f15fff..95004da3fa7aefed20d4016c0442a62ddd894eba 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp @@ -843,7 +843,7 @@ void AdaptiveLoopFilter::deriveClassificationBlk(AlfClassifier** classifier, int d0 = sumD0; dirTempD = 2; } - if( d1*hv0 > hv1*d0 ) + if( (uint32_t)d1 * (uint32_t)hv0 > (uint32_t)hv1 * (uint32_t)d0 ) { hvd1 = d1; hvd0 = d0; diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.h b/source/Lib/CommonLib/AdaptiveLoopFilter.h index 3ccb7ce9a6937fafac9e52ac2b5ef9baea841c55..16c0a9e0bcb7c9fc65005e79d430c60d2c335dc3 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.h +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.h @@ -92,10 +92,12 @@ public: void resetPCMBlkClassInfo(CodingStructure & cs, AlfClassifier** classifier, const CPelBuf& srcLuma, const Area& blk); template static void filterBlk(AlfClassifier** classifier, const PelUnitBuf &recDst, const CPelUnitBuf& recSrc, const Area& blkDst, const Area& blk, const ComponentID compId, short* filterSet, short* fClipSet, const ClpRng& clpRng, CodingStructure& cs, int vbCTUHeight, int vbPos); +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING inline static int getMaxGolombIdx( AlfFilterType filterType ) { return filterType == ALF_FILTER_5 ? 2 : 3; } +#endif void(*m_deriveClassificationBlk)(AlfClassifier** classifier, int** laplacian[NUM_DIRECTIONS], const CPelBuf& srcLuma, const Area& blkDst, const Area& blk, const int shift, int vbCTUHeight, int vbPos); diff --git a/source/Lib/CommonLib/Buffer.h b/source/Lib/CommonLib/Buffer.h index cfc14e7db99e166d073a34e092520972b7a70e91..5c287d84f7402454d793450f58b932a65c7a0d36 100644 --- a/source/Lib/CommonLib/Buffer.h +++ b/source/Lib/CommonLib/Buffer.h @@ -111,7 +111,7 @@ struct AreaBuf : public Size void copyClip ( const AreaBuf &src, const ClpRng& clpRng); void subtract ( const AreaBuf &other ); -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT void copyAndNegate ( const AreaBuf &other ); void subtractAndHalve ( const AreaBuf &other ); #endif @@ -359,7 +359,7 @@ void AreaBuf::subtract( const AreaBuf &other ) #undef SUBS_INC } -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT template void AreaBuf::copyAndNegate( const AreaBuf &other ) { @@ -928,11 +928,11 @@ private: Pel *m_origin[MAX_NUM_COMPONENT]; }; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT struct CompStorage : public PelBuf { CompStorage () { m_memory = nullptr; } - ~CompStorage() { delete [] m_memory; } + ~CompStorage() { if (valid()) delete [] m_memory; } void create( const Size& size ) { @@ -942,7 +942,7 @@ struct CompStorage : public PelBuf } void destroy() { - delete [] m_memory; + if (valid()) delete [] m_memory; m_memory = nullptr; } bool valid() { return m_memory != nullptr; } diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 2e75a0cf63286d1fb9feacaddfefa084a5b4dd5b..d18049b69e172fa3b590fb3997ef2fa66cb0ed3e 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -445,6 +445,9 @@ static constexpr int MV_MIN = -(1 << (MV_BITS - 1)); static const int PIC_ANALYZE_CW_BINS = 32; static const int PIC_CODE_CW_BINS = 16; +#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING +static const int LMCS_SEG_SIZE = (PIC_CODE_CW_BINS << 1); +#endif static const int FP_PREC = 11; static const int CSCALE_FP_PREC = 11; #if JVET_O1109_UNFIY_CRS diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index e4af3cec7516edb1fd173ccc6bcf2ea5d6a7f2fa..e3df7ce9ac2b525824aeda2bc51a7f9f3b38e544 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -784,7 +784,7 @@ const CtxSet ContextSetCfg::IBCFlag = ContextSetCfg::addCtxSet const CtxSet ContextSetCfg::JointCbCrFlag = ContextSetCfg::addCtxSet ({ -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT { 156, 156, 156, }, { 156, 156, 156, }, { 184, 184, 184, }, diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index a682bad02c55a0b79a01b4818a08e1211a8b7786..5ad65d3485b76b429c8e8b048aa256f960c13fa1 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -750,15 +750,13 @@ namespace DQIntern { if (enableScalingLists) invQScale = piDequantCoef[rasterPos];//scalingfactor*levelScale - if (shift < 0) + if (shift < 0 && (enableScalingLists || scanIdx == lastScanIdx)) { invQScale <<= -shift; - shift = 0; - //add = (1 << shift) >> 1; } Intermediate_Int qIdx = ( level << 1 ) + ( level > 0 ? -(state>>1) : (state>>1) ); - Intermediate_Int nomTCoeff = ( qIdx * invQScale + add ) >> shift; - tCoeff[ rasterPos ] = (TCoeff)Clip3( minTCoeff, maxTCoeff, nomTCoeff ); + int64_t nomTCoeff = ((int64_t)qIdx * (int64_t)invQScale + add) >> ((shift < 0) ? 0 : shift); + tCoeff[rasterPos] = (TCoeff)Clip3(minTCoeff, maxTCoeff, nomTCoeff); } state = ( 32040 >> ((state<<2)+((level&1)<<1)) ) & 3; // the 16-bit value "32040" represent the state transition table } @@ -1615,7 +1613,7 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = g_aucLog2[width]; const uint32_t log2TrHeight = g_aucLog2[height]; - const bool enableScalingLists = getUseScalingList(width, height, tu.mtsIdx == MTS_SKIP); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx == MTS_SKIP && isLuma(compID))); static_cast(p)->quant( tu, pSrc, compID, cQP, Quant::m_dLambda, ctx, uiAbsSum, enableScalingLists, Quant::getQuantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } else @@ -1639,7 +1637,7 @@ void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const Compo const uint32_t log2TrWidth = g_aucLog2[width]; const uint32_t log2TrHeight = g_aucLog2[height]; - const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx == MTS_SKIP)); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx == MTS_SKIP && isLuma(compID))); static_cast(p)->dequant( tu, dstCoeff, compID, cQP, enableScalingLists, Quant::getDequantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } else diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index 72d1b2ac3676aea6e18f9e0761faf59e206cf7d9..b911faf9410ac493aab564cb2981258c2130ad04 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -578,11 +578,7 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred) } else { -#if JVET_O0055_INT_DMVR_DIS_BDOF - xWeightedAverage( pu, srcPred0, srcPred1, pcYuvPred, slice.getSPS()->getBitDepths(), slice.clpRngs(), (bioApplied ? 1 : 0)); -#else xWeightedAverage( pu, srcPred0, srcPred1, pcYuvPred, slice.getSPS()->getBitDepths(), slice.clpRngs(), bioApplied ); -#endif } } } @@ -1121,11 +1117,7 @@ void InterPrediction::xCalcBlkGradient(int sx, int sy, int *arraysGx2, int g_pelBufOP.calcBlkGradient(sx, sy, arraysGx2, arraysGxGy, arraysGxdI, arraysGy2, arraysGydI, sGx2, sGy2, sGxGy, sGxdI, sGydI, width, height, unitSize); } -#if JVET_O0055_INT_DMVR_DIS_BDOF -void InterPrediction::xWeightedAverage(const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const int& bioApplied ) -#else void InterPrediction::xWeightedAverage(const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const bool& bioApplied ) -#endif { const int iRefIdx0 = pu.refIdx[0]; const int iRefIdx1 = pu.refIdx[1]; @@ -1138,11 +1130,7 @@ void InterPrediction::xWeightedAverage(const PredictionUnit& pu, const CPelUnitB pcYuvDst.addWeightedAvg(pcYuvSrc0, pcYuvSrc1, clpRngs, pu.cu->GBiIdx); return; } -#if JVET_O0055_INT_DMVR_DIS_BDOF - if (bioApplied > 0) -#else if (bioApplied) -#endif { const int src0Stride = pu.lwidth() + 2 * BIO_EXTEND_SIZE + 2; const int src1Stride = pu.lwidth() + 2 * BIO_EXTEND_SIZE + 2; @@ -1849,7 +1837,7 @@ void InterPrediction::xProcessDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvDst, con #if JVET_O0055_INT_DMVR_DIS_BDOF int bioEnabledThres = 8 * (dy >> 1) * dx; - int bioAppliedType[64]; + bool bioAppliedType[MAX_NUM_SUBCU_DMVR]; #endif { int num = 0; @@ -1909,7 +1897,7 @@ void InterPrediction::xProcessDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvDst, con } #if JVET_O0055_INT_DMVR_DIS_BDOF - bioAppliedType[num] = (minCost < bioEnabledThres) ? 0 : (bioApplied ? 2 : 0); + bioAppliedType[num] = (minCost < bioEnabledThres) ? false : bioApplied; #endif totalDeltaMV[0] = (totalDeltaMV[0] << mvShift); totalDeltaMV[1] = (totalDeltaMV[1] << mvShift); @@ -1956,7 +1944,7 @@ void InterPrediction::xProcessDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvDst, con m_cYuvRefBuffSubCuDMVRL0 = m_cYuvRefBuffDMVRL0.subBuf(UnitAreaRelative(pu, subPu)); m_cYuvRefBuffSubCuDMVRL1 = m_cYuvRefBuffDMVRL1.subBuf(UnitAreaRelative(pu, subPu)); #if JVET_O0055_INT_DMVR_DIS_BDOF - xFinalPaddedMCForDMVR(subPu, srcPred0, srcPred1, m_cYuvRefBuffSubCuDMVRL0, m_cYuvRefBuffSubCuDMVRL1, (bioAppliedType[num] > 0 ? true : false), mergeMv); + xFinalPaddedMCForDMVR(subPu, srcPred0, srcPred1, m_cYuvRefBuffSubCuDMVRL0, m_cYuvRefBuffSubCuDMVRL1, bioAppliedType[num], mergeMv); #else xFinalPaddedMCForDMVR(subPu, srcPred0, srcPred1, m_cYuvRefBuffSubCuDMVRL0, m_cYuvRefBuffSubCuDMVRL1, bioApplied, mergeMv); #endif diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 6e156008ba4fbdd5ea5b44e352ef468a6e5c91ad..bf30d6e3f7195c0007f93a33b638bd9723226815 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -136,11 +136,7 @@ protected: void xBioGradFilter (Pel* pSrc, int srcStride, int width, int height, int gradStride, Pel* gradX, Pel* gradY, int bitDepth); void xCalcBIOPar (const Pel* srcY0Temp, const Pel* srcY1Temp, const Pel* gradX0, const Pel* gradX1, const Pel* gradY0, const Pel* gradY1, int* dotProductTemp1, int* dotProductTemp2, int* dotProductTemp3, int* dotProductTemp5, int* dotProductTemp6, const int src0Stride, const int src1Stride, const int gradStride, const int widthG, const int heightG, int bitDepth); void xCalcBlkGradient (int sx, int sy, int *arraysGx2, int *arraysGxGy, int *arraysGxdI, int *arraysGy2, int *arraysGydI, int &sGx2, int &sGy2, int &sGxGy, int &sGxdI, int &sGydI, int width, int height, int unitSize); -#if JVET_O0055_INT_DMVR_DIS_BDOF - void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const int& bioApplied ); -#else - void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const bool& bioApplied ); -#endif + void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const bool& bioApplied ); void xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng ); void xWeightedTriangleBlk ( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 ); diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index b4563f2e4e27d2ac590f9dcecb6893999a7e904a..5a01b7121d353501322a7257ddcab872d28ad818 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -58,9 +58,15 @@ const uint8_t IntraPrediction::m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS] = { { // Luma +#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF + 24, // 1xn + 24, // 2xn + 24, // 4xn +#else 20, // 1xn 20, // 2xn 20, // 4xn +#endif 14, // 8xn 2, // 16xn 0, // 32xn @@ -556,14 +562,19 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA else if (!useISP)// HOR, VER and angular modes (MDIS) { bool filterFlag = false; - +#if !JVET_O0277_INTRA_SMALL_BLOCK_DCTIF if (predMode != dirMode ) // wide-anlge mode { filterFlag = true; } else +#endif { +#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF + const int diff = std::min( abs( predMode - HOR_IDX ), abs( predMode - VER_IDX ) ); +#else const int diff = std::min( abs( dirMode - HOR_IDX ), abs( dirMode - VER_IDX ) ); +#endif const int log2Size = ((g_aucLog2[puSize.width] + g_aucLog2[puSize.height]) >> 1); CHECK( log2Size >= MAX_INTRA_FILTER_DEPTHS, "Size not supported" ); filterFlag = (diff > m_aucIntraFilter[chType][log2Size]); @@ -573,7 +584,12 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA if (filterFlag) { const bool isRefFilter = isIntegerSlope(absAng); +#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF + CHECK( puSize.width * puSize.height <= 32, "DCT-IF interpolation filter is always used for 4x4, 4x8, and 8x4 luma CB" ); + m_ipaParam.refFilterFlag = isRefFilter; +#else m_ipaParam.refFilterFlag = isRefFilter && puSize.width * puSize.height > 32; +#endif m_ipaParam.interpolationFlag = !isRefFilter; } } diff --git a/source/Lib/CommonLib/LoopFilter.cpp b/source/Lib/CommonLib/LoopFilter.cpp index e7393d173805f46e4a6ba171c2403b663272956b..6d51b1c7134205def32cb6bf168a315c3bb869db 100644 --- a/source/Lib/CommonLib/LoopFilter.cpp +++ b/source/Lib/CommonLib/LoopFilter.cpp @@ -667,7 +667,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De tmpBs += BsSet(1, COMPONENT_Y); } // U -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cb) || TU::getCbf(tuP, COMPONENT_Cb) || tuQ.jointCbCr || tuP.jointCbCr)) #else if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cb) || TU::getCbf(tuP, COMPONENT_Cb))) @@ -676,7 +676,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De tmpBs += BsSet(1, COMPONENT_Cb); } // V -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cr) || TU::getCbf(tuP, COMPONENT_Cr) || tuQ.jointCbCr || tuP.jointCbCr)) #else if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cr) || TU::getCbf(tuP, COMPONENT_Cr))) @@ -1214,18 +1214,33 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed const int dp0 = xCalcDP(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 0), iOffset); const int dq0 = xCalcDQ(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 0), iOffset); +#if JVET_O0637_CHROMA_GRADIENT_LINE_SELECTION + const int subSamplingShift = ( edgeDir == EDGE_VER ) ? m_shiftVer : m_shiftHor; + const int dp3 = ( subSamplingShift == 1 ) ? xCalcDP(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 1), iOffset) : xCalcDP(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 3), iOffset); + const int dq3 = ( subSamplingShift == 1 ) ? xCalcDQ(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 1), iOffset) : xCalcDQ(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 3), iOffset); +#else const int dp1 = xCalcDP(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 1), iOffset); const int dq1 = xCalcDQ(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 1), iOffset); +#endif const int d0 = dp0 + dq0; +#if JVET_O0637_CHROMA_GRADIENT_LINE_SELECTION + const int d3 = dp3 + dq3; + const int d = d0 + d3; +#else const int d1 = dp1 + dq1; const int d = d0 + d1; +#endif if (d < beta) { useLongFilter = true; const bool sw = xUseStrongFiltering(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 0), iOffset, 2 * d0, beta, iTc) +#if JVET_O0637_CHROMA_GRADIENT_LINE_SELECTION + && xUseStrongFiltering(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + ( ( subSamplingShift == 1 ) ? 1 : 3 ) ), iOffset, 2 * d3, beta, iTc); +#else && xUseStrongFiltering(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 1), iOffset, 2 * d1, beta, iTc); +#endif for (unsigned step = 0; step < uiLoopLength; step++) { diff --git a/source/Lib/CommonLib/MotionInfo.h b/source/Lib/CommonLib/MotionInfo.h index 83bb07cffb317ddf0d457e52315ad3aed11b6389..4ebd998ddd81a81fee4957c596bb7c788fd98bb4 100644 --- a/source/Lib/CommonLib/MotionInfo.h +++ b/source/Lib/CommonLib/MotionInfo.h @@ -221,7 +221,9 @@ struct LutMotionCand { static_vector lut; static_vector lutIbc; +#if !JVET_O0078_SINGLE_HMVPLUT static_vector lutShareIbc; +#endif }; struct PatentBvCand { diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index db32eeae81c6e3d536f1cee10b9686d92239f12f..f994143f09b21bfadf52fd94bf05a48a47f9f413 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -103,9 +103,8 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int if (isChroma(compID)) { -#if JVET_O0105_ICT_HHI - const int absIct = abs( TU::getICTMode(tu) ); - const bool useJQP = ( absIct == 2 || absIct == 4 ); +#if JVET_O0105_ICT + const bool useJQP = ( abs(TU::getICTMode(tu)) == 2 ); chromaQpOffset += tu.cs->pps->getQpOffset ( useJQP ? JOINT_CbCr : compID ); chromaQpOffset += tu.cs->slice->getSliceChromaQpDelta( useJQP ? JOINT_CbCr : compID ); @@ -407,7 +406,7 @@ void Quant::dequant(const TransformUnit &tu, const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth]; const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight]; - int *piDequantCoef = getDequantCoeff(scalingListType, QP_rem, uiLog2TrWidth - 1, uiLog2TrHeight - 1); + int *piDequantCoef = getDequantCoeff(scalingListType, QP_rem, uiLog2TrWidth, uiLog2TrHeight); if(rightShift > 0) { @@ -921,7 +920,7 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const CCoeffBuf &piCoef = pSrc; CoeffBuf piQCoef = tu.getCoeffs(compID); - const bool useTransformSkip = tu.mtsIdx==MTS_SKIP; + const bool useTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID); const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); { @@ -935,7 +934,7 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth]; const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight]; - int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth-1, uiLog2TrHeight-1); + int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip); @@ -998,7 +997,7 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff const CCoeffBuf piCoef = pSrc; - const bool useTransformSkip = tu.mtsIdx==MTS_SKIP; + const bool useTransformSkip = tu.mtsIdx == MTS_SKIP && isLuma(compID); const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); int scalingListType = getScalingListType(tu.cu->predMode, compID); @@ -1006,7 +1005,7 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth]; const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight]; - int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth-1, uiLog2TrHeight-1); + int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0)); @@ -1064,7 +1063,7 @@ void Quant::transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &co const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth]; const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight]; - const int *const piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth-1, uiLog2TrHeight-1); + const int *const piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem, uiLog2TrWidth, uiLog2TrHeight); /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be * implemented as a bit-shift (the quantised result will be sqrt(2) * larger than required). Alternatively, adjust the @@ -1138,7 +1137,7 @@ void Quant::invTrSkipDeQuantOneSample(TransformUnit &tu, const ComponentID &comp const uint32_t uiLog2TrWidth = g_aucLog2[uiWidth]; const uint32_t uiLog2TrHeight = g_aucLog2[uiHeight]; - int *piDequantCoef = getDequantCoeff(scalingListType,QP_rem,uiLog2TrWidth-1, uiLog2TrHeight-1); + int *piDequantCoef = getDequantCoeff(scalingListType, QP_rem, uiLog2TrWidth, uiLog2TrHeight); if (rightShift > 0) { diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index 82039dd613dd2b4b49afd3eba8f60220f43919ea..79929415e03a9a69c06166ea8e5ffb473abfab1e 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -511,7 +511,7 @@ void QuantRDOQ::quant(TransformUnit &tu, const ComponentID &compID, const CCoeff const CCoeffBuf &piCoef = pSrc; CoeffBuf piQCoef = tu.getCoeffs(compID); - const bool useTransformSkip = tu.mtsIdx==MTS_SKIP; + const bool useTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID); bool useRDOQ = useTransformSkip ? m_useRDOQTS : m_useRDOQ; @@ -620,8 +620,8 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, const bool needSqrtAdjustment= TU::needsBlockSizeTrafoScale( tu, compID ); - const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, (uiLog2BlockWidth - 1), (uiLog2BlockHeight - 1), cQP.rem); - const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1)); + const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem); + const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem, uiLog2BlockWidth, uiLog2BlockHeight); const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID); const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip); const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem]; diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 2537607d5d3b13a415a4359120f2a0ae1118bf75..7cc906bc18e439e7a75e7acde71069af57c408c9 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -585,6 +585,10 @@ int8_t g_aucLog2 [MAX_CU_SIZE + 1]; int8_t g_aucNextLog2[MAX_CU_SIZE + 1]; int8_t g_aucPrevLog2[MAX_CU_SIZE + 1]; +#if JVET_O0105_ICT +const int g_ictModes[2][4] = { { 0, 3, 1, 2 }, { 0, -3, -1, -2 } }; +#endif + UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 ); diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index 7557243d3744a0c858db0216f05005c835d7fc77..ac26cd734f35915c85750631cec19343dde1c154 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -146,6 +146,10 @@ extern int8_t g_aucLog2 [MAX_CU_SIZE + 1]; extern int8_t g_aucNextLog2 [MAX_CU_SIZE + 1]; extern int8_t g_aucPrevLog2 [MAX_CU_SIZE + 1]; +#if JVET_O0105_ICT +extern const int g_ictModes[2][4]; +#endif + inline bool is34( const SizeType& size ) { return ( size & ( ( int64_t ) 1 << ( g_aucLog2[size] - 1 ) ) ); diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index f23ebe55af1396353533a5d6d0f2531c2c988c1f..b841f2b689091dae7c4f66bacf314e84e76b8f1f 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -97,7 +97,7 @@ Slice::Slice() , m_bTestWeightBiPred ( false ) , m_substreamSizes ( ) , m_cabacInitFlag ( false ) -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT , m_jointCbCrSignFlag ( false ) #endif , m_bLMvdL1Zero ( false ) @@ -195,7 +195,7 @@ void Slice::initSlice() m_disFracMMVD = false; m_substreamSizes.clear(); m_cabacInitFlag = false; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT m_jointCbCrSignFlag = false; #endif m_enableTMVPFlag = true; @@ -678,7 +678,7 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) } m_cabacInitFlag = pSrc->m_cabacInitFlag; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT m_jointCbCrSignFlag = pSrc->m_jointCbCrSignFlag; #endif memcpy(m_alfApss, pSrc->m_alfApss, sizeof(m_alfApss)); // this might be quite unsafe @@ -1705,7 +1705,7 @@ void ScalingList::checkPredMode(uint32_t sizeId, uint32_t listId) { for (int predListIdx = (int)listId; predListIdx >= 0; predListIdx--) { - if ((sizeId == SCALING_LIST_64x64 && (listId % 3) != 0) || (sizeId == SCALING_LIST_2x2 && (listId % 3) == 0)) + if ((sizeId == SCALING_LIST_64x64 && ((listId % 3) != 0 || (predListIdx % 3) != 0)) || (sizeId == SCALING_LIST_2x2 && ((listId % 3) == 0 || (predListIdx % 3) == 0))) continue; if( !::memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(int)*std::min(MAX_MATRIX_COEF_NUM,(int)g_scalingListSize[sizeId])) // check value of matrix diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 39235a518472efc3039035064c6ea17a6e1de9dc..690419edeae26a78986cc3dd2b269638f3287da8 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1467,7 +1467,7 @@ private: bool m_cabacInitFlag; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT bool m_jointCbCrSignFlag; #endif @@ -1744,7 +1744,7 @@ public: void setCabacInitFlag( bool val ) { m_cabacInitFlag = val; } //!< set CABAC initial flag bool getCabacInitFlag() const { return m_cabacInitFlag; } //!< get CABAC initial flag -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void setJointCbCrSignFlag( bool b ) { m_jointCbCrSignFlag = b; } bool getJointCbCrSignFlag() const { return m_jointCbCrSignFlag; } #endif diff --git a/source/Lib/CommonLib/TrQuant.cpp b/source/Lib/CommonLib/TrQuant.cpp index f18e45aea744ae6de6d5a76770f8e727d01f0b31..d633033d47e0142f0020896cdfae90a50455bb5e 100644 --- a/source/Lib/CommonLib/TrQuant.cpp +++ b/source/Lib/CommonLib/TrQuant.cpp @@ -83,8 +83,8 @@ InvTrans *fastInvTrans[NUM_TRANS_TYPE][g_numTransformMatrixSizes] = //! \ingroup CommonLib //! \{ -#if JVET_O0105_ICT_HHI -int64_t sqr( int d ) { return d*d; } +#if JVET_O0105_ICT +int64_t square( int d ) { return d*d; } template std::pair fwdTransformCbCr( const PelBuf &resCb, const PelBuf &resCr, PelBuf& resC1, PelBuf& resC2 ) { @@ -102,37 +102,37 @@ template std::pair fwdTransformCbCr( const PelB if ( signedMode == 1 ) { c1[x] = Pel( ( 4*cbx + 2*crx ) / 5 ); - d1 += sqr( cbx - c1[x] ) + sqr( crx - (c1[x]>>1) ); + d1 += square( cbx - c1[x] ) + square( crx - (c1[x]>>1) ); } else if ( signedMode == -1 ) { c1[x] = Pel( ( 4*cbx - 2*crx ) / 5 ); - d1 += sqr( cbx - c1[x] ) + sqr( crx - (-c1[x]>>1) ); + d1 += square( cbx - c1[x] ) + square( crx - (-c1[x]>>1) ); } else if ( signedMode == 2 ) { c1[x] = Pel( ( cbx + crx ) / 2 ); - d1 += sqr( cbx - c1[x] ) + sqr( crx - c1[x] ); + d1 += square( cbx - c1[x] ) + square( crx - c1[x] ); } else if ( signedMode == -2 ) { c1[x] = Pel( ( cbx - crx ) / 2 ); - d1 += sqr( cbx - c1[x] ) + sqr( crx + c1[x] ); + d1 += square( cbx - c1[x] ) + square( crx + c1[x] ); } else if ( signedMode == 3 ) { c2[x] = Pel( ( 4*crx + 2*cbx ) / 5 ); - d1 += sqr( cbx - (c2[x]>>1) ) + sqr( crx - c2[x] ); + d1 += square( cbx - (c2[x]>>1) ) + square( crx - c2[x] ); } else if ( signedMode == -3 ) { c2[x] = Pel( ( 4*crx - 2*cbx ) / 5 ); - d1 += sqr( cbx - (-c2[x]>>1) ) + sqr( crx - c2[x] ); + d1 += square( cbx - (-c2[x]>>1) ) + square( crx - c2[x] ); } else { - d1 += sqr( cbx ); - d2 += sqr( crx ); + d1 += square( cbx ); + d2 += square( crx ); } } } @@ -170,7 +170,7 @@ TrQuant::TrQuant() : m_quant( nullptr ) { m_mtsCoeffs[i] = (TCoeff*) xMalloc( TCoeff, MAX_CU_SIZE * MAX_CU_SIZE ); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT { m_invICT = m_invICTMem + maxAbsIctMode; m_invICT[ 0] = invTransformCbCr< 0>; @@ -650,7 +650,7 @@ void TrQuant::invRdpcmNxN(TransformUnit& tu, const ComponentID &compID, PelBuf & } } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT std::pair TrQuant::fwdTransformICT( const TransformUnit &tu, const PelBuf &resCb, const PelBuf &resCr, PelBuf &resC1, PelBuf &resC2, int jointCbCr ) { @@ -670,7 +670,7 @@ std::vector TrQuant::selectICTCandidates( const TransformUnit &tu, CompStor { CHECK( !resCb[0].valid() || !resCr[0].valid(), "standard components are not valid" ); -#if JVET_O0543_ICT_HHI_ICU_ONLY +#if JVET_O0543_ICT_ICU_ONLY if( !CU::isIntra( *tu.cu ) ) { int cbfMask = 3; diff --git a/source/Lib/CommonLib/TrQuant.h b/source/Lib/CommonLib/TrQuant.h index 4bc8b485b839f9f14f453026cee169750016ff00..f762386ac69e657895902d7540923876f41d29bd 100644 --- a/source/Lib/CommonLib/TrQuant.h +++ b/source/Lib/CommonLib/TrQuant.h @@ -103,7 +103,7 @@ public: void transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &compID, const TCoeff &resiDiff, TCoeff &coeff, const uint32_t &uiPos, const QpParam &cQP, const bool bUseHalfRoundingPoint); void invTrSkipDeQuantOneSample (TransformUnit &tu, const ComponentID &compID, const TCoeff &pcCoeff, Pel &reconSample, const uint32_t &uiPos, const QpParam &cQP); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void invTransformICT ( const TransformUnit &tu, PelBuf &resCb, PelBuf &resCr ); std::pair fwdTransformICT ( const TransformUnit &tu, const PelBuf &resCb, const PelBuf &resCr, PelBuf& resC1, PelBuf& resC2, int jointCbCr = -1 ); std::vector selectICTCandidates ( const TransformUnit &tu, CompStorage* resCb, CompStorage* resCr ); @@ -138,7 +138,7 @@ private: TCoeff** m_mtsCoeffs; TCoeff m_tempInMatrix [ 48 ]; TCoeff m_tempOutMatrix[ 48 ]; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT static const int maxAbsIctMode = 3; void (*m_invICTMem[1+2*maxAbsIctMode])(PelBuf&,PelBuf&); std::pair(*m_fwdICTMem[1+2*maxAbsIctMode])(const PelBuf&,const PelBuf&,PelBuf&,PelBuf&); diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 3f6cab81e2361a0ddc249c5f5be3ef7301135e27..01253661b6ba4b085f7a9c688aee0e177d22c98d 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,11 +50,17 @@ #include #include -#define JVET_O0105_ICT_HHI 1 // JVET-O0105: inter-chroma transform (ICT) as extension of joint chroma coding (JCC) -#define JVET_O0543_ICT_HHI_ICU_ONLY 1 // JVET-O0543: ICT only in Intra CUs (was Intra slices, modified during adoption) +#define JVET_O0105_ICT 1 // JVET-O0105: inter-chroma transform (ICT) as extension of joint chroma coding (JCC) +#define JVET_O0543_ICT_ICU_ONLY 1 // JVET-O0543: ICT only in Intra CUs (was Intra slices, modified during adoption) + +#define JVET_O0216_ALF_COEFF_EG3 1 // JVET-O0216/O0302/O0648: using EG3 for ALF coefficients 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 +#define JVET_O0637_CHROMA_GRADIENT_LINE_SELECTION 1 // Choose line0 and line3 for gradient computation when chroma is same size as luma + #define JVET_O0288_UNIFY_ALF_SLICE_TYPE_REMOVAL 1 // JVET-O0288: remove slice type dependency in ALF #define JVET_O0064_SIMP_ALF_CLIP_CODING 1 // JVET-O0047/O0058/O0064/O0067/O0290/O0301/O0430: use FLC for alf clipping indices, always signal alf clipping indices @@ -81,6 +87,8 @@ #define JVET_O0055_INT_DMVR_DIS_BDOF 1 // integer-distance DMVR cost to disable BDOF and disable BDOF early termination +#define JVET_O0277_INTRA_SMALL_BLOCK_DCTIF 1 // JVET-O0277: DCT-IF interpolation filter is always used for 4x4, 4x8, and 8x4 luma CB + #define JVET_O0267_IBC_SCALING_LIST 1 #define JVET_O0280_SIMD_TRIANGLE_WEIGHTING 1 // JVET-O0280: SIMD implementation for weighted sample prediction process of triangle prediction mode @@ -88,6 +96,12 @@ #define JVET_O0364_PDPC_DC 1 // JVET-O0364 Part 4: align PDPC process for DC with the one for Planar #define JVET_O0364_PDPC_ANGULAR 1 // JVET-O0364 Part 5: simplify PDPC process for angular modes +#define JVET_O0294_TRANSFORM_CLEANUP 1 // JVET-O0294: Context modelling for MTS index + +#define JVET_O1124_ALLOW_CCLM_COND 1 // JVET-O1124/JVET-O0196: CCLM restriction to reduce luma-chroma latency for chroma separate tree + +#define JVET_O0078_SINGLE_HMVPLUT 1 // JVET-O0078£ºSingle HMVP table for all CUs inside the shared merge list region for IBC + #define FIX_DB_MAX_TRANSFORM_SIZE 1 #define MRG_SHARELIST_SHARSIZE 32 @@ -1368,12 +1382,13 @@ struct AlfFilterShape 2, 2, 2, 2, 2, 1, 1 }; - +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING golombIdx = { 0, 0, 1, 0, 0, 1, 2, 2 }; +#endif filterType = ALF_FILTER_5; } @@ -1395,13 +1410,14 @@ struct AlfFilterShape 2, 2, 2, 2, 2, 2, 2, 2, 1, 1 }; - +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING golombIdx = { 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 1, 2, 3, 3 }; +#endif filterType = ALF_FILTER_7; } @@ -1418,7 +1434,9 @@ struct AlfFilterShape int filterSize; std::vector pattern; std::vector weights; +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING std::vector golombIdx; +#endif }; struct AlfSliceParam diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index b6f6ce9443fb7c000ef76925be6b19bbb1b99391..eff7d0bc5b1415266fac38047fe0d69d94aeabbe 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -327,6 +327,71 @@ void CodingUnit::initData() mipFlag = false; } +#if JVET_O1124_ALLOW_CCLM_COND +const bool CodingUnit::checkCCLMAllowed() const +{ + bool allowCCLM = false; + + if( chType != CHANNEL_TYPE_CHROMA ) //single tree + { + allowCCLM = true; + } + else if( slice->getSPS()->getCTUSize() <= 32 ) //dual tree, CTUsize < 64 + { + allowCCLM = true; + } + else //dual tree, CTU size 64 or 128 + { + int depthFor64x64Node = slice->getSPS()->getCTUSize() == 128 ? 1 : 0; + const PartSplit cuSplitTypeDepth1 = CU::getSplitAtDepth( *this, depthFor64x64Node ); + const PartSplit cuSplitTypeDepth2 = CU::getSplitAtDepth( *this, depthFor64x64Node + 1 ); + + //allow CCLM if 64x64 chroma tree node uses QT split or HBT+VBT split combination + if( cuSplitTypeDepth1 == CU_QUAD_SPLIT || (cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_VERT_SPLIT) ) + { + CHECK( !(blocks[COMPONENT_Cb].width <= 16 && blocks[COMPONENT_Cb].height <= 16), "chroma cu size shall be <= 16x16" ); + allowCCLM = true; + } + //allow CCLM if 64x64 chroma tree node uses NS (No Split) and becomes a chroma CU containing 32x32 chroma blocks + else if( cuSplitTypeDepth1 == CU_DONT_SPLIT ) + { + CHECK( !(blocks[COMPONENT_Cb].width == 32 && blocks[COMPONENT_Cb].height == 32), "chroma cu size shall be 32x32" ); + allowCCLM = true; + } + //allow CCLM if 64x32 chroma tree node uses NS and becomes a chroma CU containing 32x16 chroma blocks + else if( cuSplitTypeDepth1 == CU_HORZ_SPLIT && cuSplitTypeDepth2 == CU_DONT_SPLIT ) + { + CHECK( !(blocks[COMPONENT_Cb].width == 32 && blocks[COMPONENT_Cb].height == 16), "chroma cu size shall be 32x16" ); + allowCCLM = true; + } + + //further check luma conditions + if( allowCCLM ) + { + //disallow CCLM if luma 64x64 block uses BT or TT or NS with ISP + const Position lumaRefPos( chromaPos().x << getComponentScaleX( COMPONENT_Cb, chromaFormat ), chromaPos().y << getComponentScaleY( COMPONENT_Cb, chromaFormat ) ); + const CodingUnit* colLumaCu = cs->picture->cs->getCU( lumaRefPos, CHANNEL_TYPE_LUMA ); + + if( colLumaCu->lwidth() < 64 || colLumaCu->lheight() < 64 ) //further split at 64x64 luma node + { + const PartSplit cuSplitTypeDepth1Luma = CU::getSplitAtDepth( *colLumaCu, depthFor64x64Node ); + CHECK( !(cuSplitTypeDepth1Luma >= CU_QUAD_SPLIT && cuSplitTypeDepth1Luma <= CU_TRIV_SPLIT), "split mode shall be BT, TT or QT" ); + if( cuSplitTypeDepth1Luma != CU_QUAD_SPLIT ) + { + allowCCLM = false; + } + } + else if( colLumaCu->lwidth() == 64 && colLumaCu->lheight() == 64 && colLumaCu->ispMode ) //not split at 64x64 luma node and use ISP mode + { + allowCCLM = false; + } + } + } + + return allowCCLM; +} +#endif + const uint8_t CodingUnit::checkAllowedSbt() const { if( !slice->getSPS()->getUseSBT() ) diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index 5c2f9eb56775973b179559910cc1a3ac9e569175..99286a0a7c55a2fa5f81aa9d669394083e959f3e 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -350,6 +350,9 @@ struct CodingUnit : public UnitArea void setSbtPos( uint8_t pos ) { CHECK( pos >= 4, "sbt_pos wrong" ); sbtInfo = ( pos << 4 ) + ( sbtInfo & 0xcf ); } uint8_t getSbtTuSplit() const; const uint8_t checkAllowedSbt() const; +#if JVET_O1124_ALLOW_CCLM_COND + const bool checkCCLMAllowed() const; +#endif }; // --------------------------------------------------------------------------- diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 2422779d7c7d2cc9e7e36e2680dcd7f76baeb079..3f4dec71a98cd8519d332ebe8fd8ace6e9148286 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -787,7 +787,11 @@ bool PU::isLMCMode(unsigned mode) } bool PU::isLMCModeEnabled(const PredictionUnit &pu, unsigned mode) { +#if JVET_O1124_ALLOW_CCLM_COND + if ( pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed() ) +#else if ( pu.cs->sps->getUseLMChroma() ) +#endif { return true; } @@ -939,7 +943,11 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, bool isCa { hasPruned[subPuMvpPos] = true; } +#if JVET_O0078_SINGLE_HMVPLUT + auto &lut = ibcFlag ? cs.motionLut.lutIbc : cs.motionLut.lut; +#else auto &lut = ibcFlag ? ( isShared ? cs.motionLut.lutShareIbc : cs.motionLut.lutIbc ) : cs.motionLut.lut; +#endif int num_avai_candInLUT = (int) lut.size(); for (int mrgIdx = 1; mrgIdx <= num_avai_candInLUT; mrgIdx++) @@ -4489,14 +4497,13 @@ bool TU::isMTSAllowed(const TransformUnit &tu, const ComponentID compID) return mtsAllowed; } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT int TU::getICTMode( const TransformUnit& tu, int jointCbCr ) { if( jointCbCr < 0 ) { jointCbCr = tu.jointCbCr; } - static const int g_ictModes[2][4] = { { 0, 3, 1, 2 }, { 0, -3, -1, -2 } }; return g_ictModes[ tu.cs->slice->getJointCbCrSignFlag() ][ jointCbCr ]; } #endif diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index 00b232f0643d944c061c192494c50d0ad438f477..3dbe32cdb99bbd8c3e503df3a5b1004c4c977879 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -213,7 +213,7 @@ namespace TU bool needsBlockSizeTrafoScale ( const TransformUnit &tu, const ComponentID &compID ); TransformUnit* getPrevTU ( const TransformUnit &tu, const ComponentID compID ); bool getPrevTuCbfAtDepth( const TransformUnit &tu, const ComponentID compID, const int trDepth ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT int getICTMode ( const TransformUnit &tu, int jointCbCr = -1 ); #endif } diff --git a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h index dc75192ee5876eebffaf85a7b108b1bfa76672dd..618378c692c27e5f8d810fc6ce03f0df920961a6 100644 --- a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h +++ b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h @@ -276,7 +276,7 @@ static void simdDeriveClassificationBlk(AlfClassifier** classifier, int** laplac xmm6 = _mm_mullo_epi32( xmm8, xmm6 ); xmm9 = _mm_shuffle_epi32( xmm6, 0xB1 ); - xmm5 = _mm_cmpgt_epi32( xmm6, xmm9 ); + xmm5 = _mm_cmpgt_epi32(_mm_add_epi32(xmm6, _mm_set1_epi32(0x80000000)), _mm_add_epi32(xmm9, _mm_set1_epi32(0x80000000))); xmm5 = _mm_shuffle_epi32( xmm5, 0xF0 ); //second mask is for all upper part xmm8 = _mm_shuffle_epi32( xmm4, 0x0E ); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 848a87b8ccfa717efc037bc65bc3397fdf8c6c7b..930b7db640b4f929b04b1f1eb4606363c79806a7 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -1305,7 +1305,11 @@ void CABACReader::intra_chroma_pred_mode( PredictionUnit& pu ) } // LM chroma mode +#if JVET_O1124_ALLOW_CCLM_COND + if( pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed() ) +#else if( pu.cs->sps->getUseLMChroma() ) +#endif { if( intra_chroma_lmc_mode( pu ) ) { @@ -2318,7 +2322,7 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, ChromaCbfs& c bool cbfLuma = ( tu.cbf[ COMPONENT_Y ] != 0 ); bool cbfChroma = ( lumaOnly ? false : ( chromaCbfs.Cb || chromaCbfs.Cr ) ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( !lumaOnly ) { joint_cb_cr( tu, ( tu.cbf[COMPONENT_Cb] ? 2 : 0 ) + ( tu.cbf[COMPONENT_Cr] ? 1 : 0 ) ); @@ -2416,10 +2420,10 @@ void CABACReader::cu_chroma_qp_offset( CodingUnit& cu ) // void residual_coding_subblock( coeffCtx ) //================================================================================ -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void CABACReader::joint_cb_cr( TransformUnit& tu, const int cbfMask ) { -#if JVET_O0543_ICT_HHI_ICU_ONLY +#if JVET_O0543_ICT_ICU_ONLY if( ( CU::isIntra( *tu.cu ) && cbfMask ) || ( cbfMask == 3 ) ) #else if( cbfMask ) @@ -2442,7 +2446,7 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID ) const CodingUnit& cu = *tu.cu; DTRACE( g_trace_ctx, D_SYNTAX, "residual_coding() etype=%d pos=(%d,%d) size=%dx%d predMode=%d\n", tu.blocks[compID].compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.blocks[compID].width, tu.blocks[compID].height, cu.predMode ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr && tu.jointCbCr == 3 ) return; #else @@ -2508,7 +2512,9 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID ) void CABACReader::mts_coding( TransformUnit& tu, ComponentID compID ) { +#if !JVET_O0294_TRANSFORM_CLEANUP const CodingUnit &cu = *tu.cu; +#endif const bool tsAllowed = TU::isTSAllowed ( tu, compID ); const bool mtsAllowed = TU::isMTSAllowed( tu, compID ); @@ -2524,14 +2530,22 @@ void CABACReader::mts_coding( TransformUnit& tu, ComponentID compID ) { ctxIdx = 6; symbol = m_BinDecoder.decodeBin( Ctx::MTSIndex( ctxIdx ) ); +#if JVET_O0294_TRANSFORM_CLEANUP + tu.mtsIdx = symbol ? MTS_SKIP : MTS_DCT2_DCT2; +#else tu.mtsIdx = symbol ? MTS_DCT2_DCT2 : MTS_SKIP; +#endif } if( tu.mtsIdx != MTS_SKIP ) { if( mtsAllowed ) { +#if JVET_O0294_TRANSFORM_CLEANUP + ctxIdx = 0; +#else ctxIdx = std::min( (int)cu.qtDepth, 5 ); +#endif symbol = m_BinDecoder.decodeBin( Ctx::MTSIndex( ctxIdx ) ); if( symbol ) @@ -2551,7 +2565,11 @@ void CABACReader::mts_coding( TransformUnit& tu, ComponentID compID ) } } } +#if JVET_O0294_TRANSFORM_CLEANUP + DTRACE(g_trace_ctx, D_SYNTAX, "mts_coding() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, tu.cu->lx(), tu.cu->ly(), tu.mtsIdx); +#else DTRACE( g_trace_ctx, D_SYNTAX, "mts_coding() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, cu.lx(), cu.ly(), tu.mtsIdx ); +#endif } void CABACReader::isp_mode( CodingUnit& cu ) diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 8b2d9591ef49d7aa04d660dfde232016459b810a..670d2cc4dc8eafb972cd0cdfb21fa17d4cf4d90c 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -138,7 +138,7 @@ public: void residual_coding_subblock ( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state ); void residual_codingTS ( TransformUnit& tu, ComponentID compID ); void residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* coeff ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void joint_cb_cr ( TransformUnit& tu, const int cbfMask ); #else void joint_cb_cr ( TransformUnit& tu ); diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index afeee3d09bd722feb2719f74c1e75d6966465ebc..31e5ca4100be256b8280b081cbc0c41f8dff68ad 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -122,7 +122,9 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) if ((currCU.shareParentPos.x >= 0) && (!(currCU.shareParentPos.x == prevTmpPos.x && currCU.shareParentPos.y == prevTmpPos.y))) { m_shareStateDec = GEN_ON_SHARED_BOUND; +#if !JVET_O0078_SINGLE_HMVPLUT cs.motionLut.lutShareIbc = cs.motionLut.lutIbc; +#endif } if (currCU.shareParentPos.x < 0) @@ -226,7 +228,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) const QpParam cQP( tu, compID ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( tu.jointCbCr && isChroma(compID) ) { if( compID == COMPONENT_Cb ) @@ -261,7 +263,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) //===== reconstruction ===== flag = flag && (tu.blocks[compID].width*tu.blocks[compID].height > 4); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (flag && (TU::getCbf(tu, compID) || tu.jointCbCr) && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag()) { #else @@ -480,7 +482,12 @@ void DecCu::xReconInter(CodingUnit &cu) if (cu.Y().valid()) { const PredictionUnit &pu = *cu.firstPU; +#if JVET_O0078_SINGLE_HMVPLUT + bool isShare = ((CU::isIBC(cu) && (cu.shareParentSize.width != cu.Y().lumaSize().width || cu.shareParentSize.height != cu.Y().lumaSize().height)) ? true : false); + if (!cu.affine && !cu.triangle && !isShare) +#else if (!cu.affine && !cu.triangle) +#endif { MotionInfo mi = pu.getMotionInfo(); mi.GBiIdx = (mi.interDir == 3) ? cu.GBiIdx : GBI_DEFAULT; @@ -571,7 +578,7 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID ) const QpParam cQP(currTU, compID); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( currTU.jointCbCr && isChroma(compID) ) { if( compID == COMPONENT_Cb ) @@ -606,7 +613,7 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID ) //===== reconstruction ===== const Slice &slice = *cs.slice; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr) && slice.getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width * currTU.blocks[compID].height > 4) { diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 9ec856ab7100e16baa16c039052f8be6bd59d7a9..95e7efab246ba7969297de20adaa67512ab9b195 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -991,6 +991,10 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_apcSlicePilot->copySliceInfo( m_pcPic->slices[m_uiSliceSegmentIdx-1] ); } + m_apcSlicePilot->setSliceCurStartCtuTsAddr(0); + m_apcSlicePilot->setSliceCurEndCtuTsAddr(0); + m_apcSlicePilot->setSliceCurStartBrickIdx(0); + m_apcSlicePilot->setSliceCurEndBrickIdx(0); m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); m_apcSlicePilot->setTLayer(nalu.m_temporalId); diff --git a/source/Lib/DecoderLib/DecSlice.cpp b/source/Lib/DecoderLib/DecSlice.cpp index 7a2ade95b1148ce34a6200859e75b817691d72b7..b6a3688044678f476b4bdc68ad9e1124f6e5fed7 100644 --- a/source/Lib/DecoderLib/DecSlice.cpp +++ b/source/Lib/DecoderLib/DecSlice.cpp @@ -188,7 +188,9 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb { cs.motionLut.lut.resize(0); cs.motionLut.lutIbc.resize(0); +#if !JVET_O0078_SINGLE_HMVPLUT cs.motionLut.lutShareIbc.resize(0); +#endif } if( !cs.slice->isIntra() ) diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index 7da5c39f3dea87bc254e2ae15199321df54df7c5..71cc2d2f1149375e23dacf59410a00f64af2e2b8 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -1537,6 +1537,12 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para { READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); pcSlice->setPOC(uiCode); + ReferencePictureList* rpl0 = pcSlice->getLocalRPL0(); + (*rpl0) = ReferencePictureList(); + pcSlice->setRPL0(rpl0); + ReferencePictureList* rpl1 = pcSlice->getLocalRPL1(); + (*rpl1) = ReferencePictureList(); + pcSlice->setRPL1(rpl1); } else { @@ -1588,6 +1594,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para pcSlice->setRPL0idx(uiCode); pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(uiCode)); } + else + { + pcSlice->setRPL0idx(0); + pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(0)); + } } //Deal POC Msb cycle signalling for LTRP for (int i = 0; i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures(); i++) @@ -1621,7 +1632,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para } else { - if (sps->getNumRPL0() > 0) + if (sps->getNumRPL1() > 0) { READ_FLAG(uiCode, "ref_pic_list_sps_flag[1]"); } @@ -1878,6 +1889,21 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para parsePredWeightTable(pcSlice, sps); pcSlice->initWpScaling(sps); } + else + { + WPScalingParam *wp; + for ( int iNumRef=0 ; iNumRef<((pcSlice->getSliceType() == B_SLICE )?2:1); iNumRef++ ) + { + RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); + for ( int iRefIdx=0 ; iRefIdxgetNumRefIdx(eRefPicList) ; iRefIdx++ ) + { + pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); + wp[0].bPresentFlag = false; + wp[1].bPresentFlag = false; + wp[2].bPresentFlag = false; + } + } + } READ_FLAG( uiCode, "dep_quant_enabled_flag" ); pcSlice->setDepQuantEnabledFlag( uiCode != 0 ); if( !pcSlice->getDepQuantEnabledFlag() ) @@ -1967,7 +1993,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para pcSlice->setMaxNumTriangleCand(0); } } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (bChroma) { READ_FLAG( uiCode, "joint_cb_cr_sign_flag" ); pcSlice->setJointCbCrSignFlag( uiCode != 0 ); @@ -2594,15 +2620,20 @@ void HLSyntaxReader::alfFilter( AlfSliceParam& alfSliceParam, const bool isChrom // derive maxGolombIdx AlfFilterShape alfShape( isChroma ? 5 : 7 ); +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING const int maxGolombIdx = AdaptiveLoopFilter::getMaxGolombIdx( alfShape.filterType ); +#endif +#if !JVET_O0216_ALF_COEFF_EG3 READ_UVLC( code, isChroma ? "alf_chroma_min_eg_order_minus1" : "alf_luma_min_eg_order_minus1" ); - +#endif +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING int kMin = code + 1; static int kMinTab[MAX_NUM_ALF_COEFF]; +#endif const int numFilters = isChroma ? 1 : alfSliceParam.numLumaFilters; short* coeff = isChroma ? alfSliceParam.chromaCoeff : alfSliceParam.lumaCoeff; short* clipp = isChroma ? alfSliceParam.chromaClipp : alfSliceParam.lumaClipp; - +#if !JVET_O0216_ALF_COEFF_EG3 for( int idx = 0; idx < maxGolombIdx; idx++ ) { READ_FLAG( code, isChroma ? "alf_chroma_eg_order_increase_flag" : "alf_luma_eg_order_increase_flag" ); @@ -2610,7 +2641,7 @@ void HLSyntaxReader::alfFilter( AlfSliceParam& alfSliceParam, const bool isChrom kMinTab[idx] = kMin + code; kMin = kMinTab[idx]; } - +#endif if( !isChroma ) { if( alfSliceParam.alfLumaCoeffDeltaFlag ) @@ -2634,7 +2665,11 @@ void HLSyntaxReader::alfFilter( AlfSliceParam& alfSliceParam, const bool isChrom for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode( 3 ); +#else coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode( kMinTab[alfShape.golombIdx[i]] ); +#endif } } diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index 8cca811657189e8877568a0738c7ba8d4543b977..0e54c0e05aa6b1d0ffdbcfcc057ccb9a4ba6f7ca 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -1199,7 +1199,11 @@ void CABACWriter::intra_chroma_pred_mode( const PredictionUnit& pu ) } // LM chroma mode +#if JVET_O1124_ALLOW_CCLM_COND + if( pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed() ) +#else if( pu.cs->sps->getUseLMChroma() ) +#endif { intra_chroma_lmc_mode( pu ); if ( PU::isLMCMode( intraDir ) ) @@ -2198,7 +2202,7 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, ChromaC cbfChroma = ( cbf[ COMPONENT_Cb ] || cbf[ COMPONENT_Cr ] ); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( !lumaOnly ) { joint_cb_cr( tu, ( cbf[COMPONENT_Cb] ? 2 : 0 ) + ( cbf[COMPONENT_Cr] ? 1 : 0 ) ); @@ -2298,11 +2302,11 @@ void CABACWriter::cu_chroma_qp_offset( const CodingUnit& cu ) // void residual_coding_subblock( coeffCtx ) //================================================================================ -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void CABACWriter::joint_cb_cr( const TransformUnit& tu, const int cbfMask ) { CHECK( tu.jointCbCr && tu.jointCbCr != cbfMask, "wrong value of jointCbCr (" << (int)tu.jointCbCr << " vs " << (int)cbfMask << ")" ); -#if JVET_O0543_ICT_HHI_ICU_ONLY +#if JVET_O0543_ICT_ICU_ONLY if( ( CU::isIntra( *tu.cu ) && cbfMask ) || ( cbfMask == 3 ) ) #else if( cbfMask ) @@ -2323,7 +2327,7 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID ) const CodingUnit& cu = *tu.cu; DTRACE( g_trace_ctx, D_SYNTAX, "residual_coding() etype=%d pos=(%d,%d) size=%dx%d predMode=%d\n", tu.blocks[compID].compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.blocks[compID].width, tu.blocks[compID].height, cu.predMode ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr && tu.jointCbCr == 3 ) return; #else @@ -2406,7 +2410,9 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID ) void CABACWriter::mts_coding( const TransformUnit& tu, ComponentID compID ) { +#if !JVET_O0294_TRANSFORM_CLEANUP const CodingUnit &cu = *tu.cu; +#endif const bool tsAllowed = TU::isTSAllowed ( tu, compID ); const bool mtsAllowed = TU::isMTSAllowed( tu, compID ); @@ -2417,7 +2423,11 @@ void CABACWriter::mts_coding( const TransformUnit& tu, ComponentID compID ) if( tsAllowed ) { +#if JVET_O0294_TRANSFORM_CLEANUP + symbol = (tu.mtsIdx == MTS_SKIP) ? 1 : 0; +#else symbol = (tu.mtsIdx == MTS_SKIP) ? 0 : 1; +#endif ctxIdx = 6; m_BinEncoder.encodeBin( symbol, Ctx::MTSIndex( ctxIdx ) ); } @@ -2427,7 +2437,11 @@ void CABACWriter::mts_coding( const TransformUnit& tu, ComponentID compID ) if( mtsAllowed ) { symbol = tu.mtsIdx != MTS_DCT2_DCT2 ? 1 : 0; +#if JVET_O0294_TRANSFORM_CLEANUP + ctxIdx = 0; +#else ctxIdx = std::min( (int)cu.qtDepth, 5 ); +#endif m_BinEncoder.encodeBin( symbol, Ctx::MTSIndex( ctxIdx ) ); if( symbol ) @@ -2446,8 +2460,11 @@ void CABACWriter::mts_coding( const TransformUnit& tu, ComponentID compID ) } } } - +#if JVET_O0294_TRANSFORM_CLEANUP + DTRACE( g_trace_ctx, D_SYNTAX, "mts_coding() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, tu.cu->lx(), tu.cu->ly(), tu.mtsIdx); +#else DTRACE( g_trace_ctx, D_SYNTAX, "mts_coding() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, cu.lx(), cu.ly(), tu.mtsIdx ); +#endif } void CABACWriter::isp_mode( const CodingUnit& cu ) diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index d079c46917f3679d2624ea07b9f52c9318c04b16..90a75be39a604f740550ab1f09787fb69f36b784 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -150,7 +150,7 @@ public: void residual_coding_subblock ( CoeffCodingContext& cctx, const TCoeff* coeff, const int stateTransTable, int& state ); void residual_codingTS ( const TransformUnit& tu, ComponentID compID ); void residual_coding_subblockTS( CoeffCodingContext& cctx, const TCoeff* coeff ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void joint_cb_cr ( const TransformUnit& tu, const int cbfMask ); #else void joint_cb_cr ( const TransformUnit& tu ); diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp index 17d289090b099be02026b7d230eb48984d00754b..893b55eab536c7f9dd646af49792981089859904 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp @@ -985,12 +985,13 @@ int EncAdaptiveLoopFilter::getCoeffRate( AlfSliceParam& alfSliceParam, bool isCh { int iBits = 0; assert( isChroma ); - + AlfFilterShape alfShape(5); +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) ); - AlfFilterShape alfShape( 5 ); const int maxGolombIdx = AdaptiveLoopFilter::getMaxGolombIdx( alfShape.filterType ); const int numFilters = 1; - +#endif +#if !JVET_O0216_ALF_COEFF_EG3 // vlc for all for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { @@ -1015,11 +1016,15 @@ int EncAdaptiveLoopFilter::getCoeffRate( AlfSliceParam& alfSliceParam, bool isCh iBits += golombOrderIncreaseFlag; //golomb_order_increase_flag kMin = m_kMinTab[idx]; } - +#endif // Filter coefficients for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + iBits += lengthGolomb( alfSliceParam.chromaCoeff[i], 3 ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] +#else iBits += lengthGolomb( alfSliceParam.chromaCoeff[i], m_kMinTab[alfShape.golombIdx[i]] ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] +#endif } if( m_alfSliceParamTemp.nonLinearFlag[isChroma] ) @@ -1047,12 +1052,19 @@ int EncAdaptiveLoopFilter::getCoeffRate( AlfSliceParam& alfSliceParam, bool isCh m_bitsCoeffScan[alfShape.golombIdx[i]][k] += lengthGolomb( coeffVal, k, false ); } } - +#if JVET_O0216_ALF_COEFF_EG3 + int kMin = getGolombKMin(alfShape, numFilters, m_kMinTab, m_bitsCoeffScan); +#else kMin = getGolombKMin( alfShape, numFilters, m_kMinTab, m_bitsCoeffScan ); +#endif // Golomb parameters iBits += lengthUvlc( kMin - 1 ); // "min_golomb_order" +#if JVET_O0216_ALF_COEFF_EG3 + int golombOrderIncreaseFlag = 0; +#else golombOrderIncreaseFlag = 0; +#endif for( int idx = 0; idx < maxGolombIdx; idx++ ) { @@ -1322,9 +1334,13 @@ int EncAdaptiveLoopFilter::getTBlength( int uiSymbol, const int uiMaxSymbol ) int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters, bool* codedVarBins ) { +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING const int maxGolombIdx = getMaxGolombIdx( alfShape.filterType ); memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) ); - +#endif +#if JVET_O0216_ALF_COEFF_EG3 + int len = numFilters; //filter_coefficient_flag[i] +#else for( int ind = 0; ind < numFilters; ++ind ) { if( !codedVarBins[ind] ) @@ -1347,7 +1363,7 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i int len = kMin //min_golomb_order + maxGolombIdx //golomb_order_increase_flag + numFilters; //filter_coefficient_flag[i] - +#endif // Filter coefficients for( int ind = 0; ind < numFilters; ++ind ) { @@ -1355,7 +1371,11 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i { for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + len += lengthGolomb( abs( pDiffQFilterCoeffIntPP[ind][i] ), 3 ); // alf_coeff_luma_delta[i][j] +#else len += lengthGolomb( abs( pDiffQFilterCoeffIntPP[ind][i] ), m_kMinTab[alfShape.golombIdx[i]] ); // alf_coeff_luma_delta[i][j] +#endif } } } @@ -1394,8 +1414,11 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i } } } - +#if JVET_O0216_ALF_COEFF_EG3 + int kMin = getGolombKMin(alfShape, numFilters, m_kMinTab, m_bitsCoeffScan); +#else kMin = getGolombKMin( alfShape, numFilters, m_kMinTab, m_bitsCoeffScan ); +#endif // Coding parameters len += kMin //min_golomb_order @@ -1459,8 +1482,10 @@ int EncAdaptiveLoopFilter::deriveFilterCoefficientsPredictionMode( AlfFilterShap int EncAdaptiveLoopFilter::getCostFilterCoeff( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters ) { +#if JVET_O0216_ALF_COEFF_EG3 + return lengthFilterCoeffs( alfShape, numFilters, pDiffQFilterCoeffIntPP ); // alf_coeff_luma_delta[i][j]; +#else const int maxGolombIdx = getMaxGolombIdx( alfShape.filterType ); - memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) ); for( int ind = 0; ind < numFilters; ++ind ) @@ -1485,6 +1510,7 @@ int EncAdaptiveLoopFilter::getCostFilterCoeff( AlfFilterShape& alfShape, int **p len += lengthFilterCoeffs( alfShape, numFilters, pDiffQFilterCoeffIntPP, m_kMinTab ); // alf_coeff_luma_delta[i][j] return len; +#endif } int EncAdaptiveLoopFilter::getCostFilterClipp( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters ) @@ -1523,7 +1549,11 @@ int EncAdaptiveLoopFilter::getCostFilterClipp( AlfFilterShape& alfShape, int **p #endif } +#if JVET_O0216_ALF_COEFF_EG3 +int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff ) +#else int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab ) +#endif { int bitCnt = 0; @@ -1531,7 +1561,11 @@ int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const i { for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + bitCnt += lengthGolomb( abs( FilterCoeff[ind][i] ), 3 ); +#else bitCnt += lengthGolomb( abs( FilterCoeff[ind][i] ), kMinTab[alfShape.golombIdx[i]] ); +#endif } } return bitCnt; @@ -1558,8 +1592,10 @@ int EncAdaptiveLoopFilter::lengthFilterClipps( AlfFilterShape& alfShape, const i double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int numFilters, double errorTabForce0Coeff[MAX_NUM_ALF_CLASSES][2], bool* codedVarBins ) { static int bitsVarBin[MAX_NUM_ALF_CLASSES]; - +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING memset( m_bitsCoeffScan, 0, sizeof( m_bitsCoeffScan ) ); +#endif +#if !JVET_O0216_ALF_COEFF_EG3 for( int ind = 0; ind < numFilters; ++ind ) { for( int i = 0; i < alfShape.numCoeff - 1; i++ ) @@ -1573,13 +1609,18 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int } getGolombKMin( alfShape, numFilters, m_kMinTab, m_bitsCoeffScan ); +#endif for( int ind = 0; ind < numFilters; ++ind ) { bitsVarBin[ind] = 0; for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + bitsVarBin[ind] += lengthGolomb( abs( m_filterCoeffSet[ind][i] ), 3 ); +#else bitsVarBin[ind] += lengthGolomb( abs( m_filterCoeffSet[ind][i] ), m_kMinTab[alfShape.golombIdx[i]] ); +#endif } } @@ -1633,7 +1674,7 @@ double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int return distForce0; } - +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING int EncAdaptiveLoopFilter::getGolombKMin( AlfFilterShape& alfShape, const int numFilters, int kMinTab[MAX_NUM_ALF_LUMA_COEFF], int bitsCoeffScan[m_MAX_SCAN_VAL][m_MAX_EXP_GOLOMB] ) { int kStart; @@ -1683,7 +1724,7 @@ int EncAdaptiveLoopFilter::getGolombKMin( AlfFilterShape& alfShape, const int nu return minKStart; } - +#endif double EncAdaptiveLoopFilter::getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, const int numFilters ) { double distForce0 = 0; diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h index 9d718dfd9e6fe5f6651c82990767ab3bb679eca6..59b1bdb956502419945d75c10b706775e2a8a9f1 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h @@ -219,8 +219,10 @@ private: class EncAdaptiveLoopFilter : public AdaptiveLoopFilter { public: +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING static constexpr int m_MAX_SCAN_VAL = 11; static constexpr int m_MAX_EXP_GOLOMB = 16; +#endif int m_alfWSSD; inline void setAlfWSSD(int alfWSSD) { m_alfWSSD = alfWSSD; } static std::vector m_lumaLevelToWeightPLUT; @@ -245,8 +247,10 @@ private: int** m_filterCoeffSet; int** m_filterClippSet; int** m_diffFilterCoeff; +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING int m_kMinTab[MAX_NUM_ALF_LUMA_COEFF]; int m_bitsCoeffScan[m_MAX_SCAN_VAL][m_MAX_EXP_GOLOMB]; +#endif short m_filterIndices[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES]; unsigned m_bitsNewFilter[MAX_NUM_CHANNEL_TYPE]; int m_apsIdStart; @@ -278,7 +282,9 @@ public: void create( const EncCfg* encCfg, const int picWidth, const int picHeight, const ChromaFormat chromaFormatIDC, const int maxCUWidth, const int maxCUHeight, const int maxCUDepth, const int inputBitDepth[MAX_NUM_CHANNEL_TYPE], const int internalBitDepth[MAX_NUM_CHANNEL_TYPE] ); void destroy(); static int lengthGolomb( int coeffVal, int k, bool signed_coeff=true ); +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING static int getGolombKMin( AlfFilterShape& alfShape, const int numFilters, int kMinTab[MAX_NUM_ALF_LUMA_COEFF], int bitsCoeffScan[m_MAX_SCAN_VAL][m_MAX_EXP_GOLOMB] ); +#endif private: void alfEncoder( CodingStructure& cs, AlfSliceParam& alfSliceParam, const PelUnitBuf& orgUnitBuf, const PelUnitBuf& recExtBuf, const PelUnitBuf& recBuf, const ChannelType channel @@ -322,7 +328,11 @@ private: int getCostFilterCoeffForce0( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters, bool* codedVarBins ); int getCostFilterCoeff( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters ); int getCostFilterClipp( AlfFilterShape& alfShape, int **pDiffQFilterCoeffIntPP, const int numFilters ); +#if JVET_O0216_ALF_COEFF_EG3 + int lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff ); +#else int lengthFilterCoeffs( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab ); +#endif #if !JVET_O0064_SIMP_ALF_CLIP_CODING int lengthFilterClipps( AlfFilterShape& alfShape, const int numFilters, int **FilterCoeff, int* kMinTab ); #endif diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index d72f65eec47d6f229ba111ef19e98ee2f8e17f53..2ae45ae5a8a2e11899e467039387c5b2e7fc09a9 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -786,7 +786,12 @@ void EncCu::xCompressCU( CodingStructure *&tempCS, CodingStructure *&bestCS, Par const CodingUnit& cu = *bestCS->cus.front(); const PredictionUnit& pu = *cu.firstPU; +#if JVET_O0078_SINGLE_HMVPLUT + bool isShare = ((CU::isIBC(cu) && m_shareState == 2) ? true : false); + if (!cu.affine && !cu.triangle && !isShare) +#else if (!cu.affine && !cu.triangle) +#endif { MotionInfo mi = pu.getMotionInfo(); mi.GBiIdx = (mi.interDir == 3) ? cu.GBiIdx : GBI_DEFAULT; @@ -1158,7 +1163,9 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, } if ( m_shareState == GEN_ON_SHARED_BOUND && slice.getSPS()->getIBCFlag() ) { +#if !JVET_O0078_SINGLE_HMVPLUT tempCS->motionLut.lutShareIbc = tempCS->motionLut.lutIbc; +#endif m_shareBndPosX = uiLPelX; m_shareBndPosY = uiTPelY; m_shareBndSizeW = tempCS->area.lwidth(); diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp index 5abfc38ae4473d3251eedd4fb10abff155bf48e4..1217aea13849ae17d4a2ea4c4ae0068c6d506a98 100644 --- a/source/Lib/EncoderLib/EncReshape.cpp +++ b/source/Lib/EncoderLib/EncReshape.cpp @@ -1054,6 +1054,10 @@ void EncReshape::initLUTfromdQPModel() } #endif +#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING + adjustLmcsPivot(); +#endif + int maxAbsDeltaCW = 0, absDeltaCW = 0, deltaCW = 0; for (int i = m_sliceReshapeInfo.reshaperModelMinBinIdx; i <= m_sliceReshapeInfo.reshaperModelMaxBinIdx; i++) { @@ -1261,6 +1265,11 @@ void EncReshape::constructReshaperSDR() { m_binCW[i] = m_binCW[2 * i] + m_binCW[2 * i + 1]; } + +#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING + adjustLmcsPivot(); +#endif + m_sliceReshapeInfo.reshaperModelMinBinIdx = 0; m_sliceReshapeInfo.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1; for (int i = 0; i < PIC_CODE_CW_BINS; i++) @@ -1361,6 +1370,44 @@ void EncReshape::constructReshaperSDR() #endif } +#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING +void EncReshape::adjustLmcsPivot() +{ + int bdShift = m_lumaBD - 10; + int totCW = bdShift != 0 ? (bdShift > 0 ? m_reshapeLUTSize / (1 << bdShift) : m_reshapeLUTSize * (1 << (-bdShift))) : m_reshapeLUTSize; + int orgCW = totCW / PIC_CODE_CW_BINS; + int log2SegSize = g_aucLog2[LMCS_SEG_SIZE]; + m_reshapePivot[0] = 0; + for (int i = 0; i < PIC_CODE_CW_BINS; i++) + { + m_reshapePivot[i+1] = m_reshapePivot[i] + m_binCW[i]; + int segIdxCurr = (m_reshapePivot[i] >> log2SegSize); + int segIdxNext = (m_reshapePivot[i + 1] >> log2SegSize); + if ((segIdxCurr == segIdxNext) && (m_reshapePivot[i] != m_reshapePivot[i + 1]) && (m_reshapePivot[i] != (segIdxCurr << log2SegSize))) + { + int16_t adjustVal = ((segIdxCurr + 1) << log2SegSize) - m_reshapePivot[i + 1]; + m_reshapePivot[i + 1] += adjustVal; + m_binCW[i] += adjustVal; + for (int j = i + 1; j < PIC_CODE_CW_BINS; j++) + { + if (m_binCW[j] < (adjustVal + (orgCW >> 3))) + { + adjustVal -= (m_binCW[j] - (orgCW >> 3)); + m_binCW[j] = (orgCW >> 3); + } + else + { + m_binCW[j] -= adjustVal; + adjustVal = 0; + } + if (adjustVal == 0) + break; + } + } + } +} +#endif + #if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM void EncReshape::copyState(const EncReshape &other) { diff --git a/source/Lib/EncoderLib/EncReshape.h b/source/Lib/EncoderLib/EncReshape.h index 6e4871866a05ae33047cd22d06befe504902211c..53bb44d423ca0dd839067aee7025ad68a3ab8a46 100644 --- a/source/Lib/EncoderLib/EncReshape.h +++ b/source/Lib/EncoderLib/EncReshape.h @@ -93,6 +93,9 @@ public: ReshapeCW * getReshapeCW() { return &m_reshapeCW; } Pel * getWeightTable() { return m_cwLumaWeight; } double getCWeight() { return m_chromaWeight; } +#if JVET_O0272_LMCS_SIMP_INVERSE_MAPPING + void adjustLmcsPivot(); +#endif #if ENABLE_SPLIT_PARALLELISM || ENABLE_WPP_PARALLELISM void copyState(const EncReshape& other); diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index 089f7170e65da6ae3c53424b6e15893673adb484..a9c4120eda55ed0c2783a75d75845939c0126c3c 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -1460,7 +1460,7 @@ void EncSlice::checkDisFracMmvd( Picture* pcPic, uint32_t startCtuTsAddr, uint32 } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT void setJointCbCrModes( CodingStructure& cs, const Position topLeftLuma, const Size sizeLuma ) { bool sgnFlag = true; @@ -1480,6 +1480,8 @@ void setJointCbCrModes( CodingStructure& cs, const Position topLeftLuma, const S const Pel* pCb = orgCb.buf + y0 * cbs; const Pel* pCr = orgCr.buf + y0 * crs; int64_t sumCbCr = 0; + + // determine inter-chroma transform sign from correlation between high-pass filtered (i.e., zero-mean) Cb and Cr planes for( int y = y0; y < y1; y++, pCb += cbs, pCr += crs ) { for( int x = x0; x < x1; x++ ) @@ -1490,7 +1492,7 @@ void setJointCbCrModes( CodingStructure& cs, const Position topLeftLuma, const S } } - sgnFlag = ( sumCbCr < 0 ); + sgnFlag = ( sumCbCr < 0 ); } cs.slice->setJointCbCrSignFlag( sgnFlag ); @@ -1548,7 +1550,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons } checkDisFracMmvd( pcPic, startCtuTsAddr, boundingCtuTsAddr ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT setJointCbCrModes( cs, Position(0, 0), cs.area.lumaSize() ); #endif @@ -1580,7 +1582,9 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons { cs.motionLut.lut.resize(0); cs.motionLut.lutIbc.resize(0); +#if !JVET_O0078_SINGLE_HMVPLUT cs.motionLut.lutShareIbc.resize(0); +#endif } #if ENABLE_WPP_PARALLELISM diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index 9b92e3d188aba813049c4a03a4ed0695f525433e..9827166bd168ab8975cd9f77ef2dd381a6d7b06a 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -5946,7 +5946,7 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti { if( currArea.blocks[compID].valid() ) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr ) { const int cbfMask = ( TU::getCbf( currTU, COMPONENT_Cb ) ? 2 : 0) + ( TU::getCbf( currTU, COMPONENT_Cr ) ? 1 : 0 ); @@ -6425,7 +6425,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par #endif m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cRescale*cRescale)); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( isChroma( compID ) && tu.cu->cs->slice->getSliceQp() > 18 ) { m_pcTrQuant->setLambda( 1.05 * m_pcTrQuant->getLambda() ); @@ -6516,7 +6516,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par const bool prevCbf = ( compID == COMPONENT_Cr ? tu.cbf[COMPONENT_Cb] : false ); m_CABACEstimator->cbf_comp( *csFull, true, compArea, currDepth, prevCbf ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr ) { const int cbfMask = ( tu.cbf[COMPONENT_Cb] ? 2 : 0 ) + 1; @@ -6633,7 +6633,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par bool checkJointCbCr = !tu.noResidual && (TU::getCbf(tu, COMPONENT_Cb) || TU::getCbf(tu, COMPONENT_Cr)); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT const int channelBitDepth = sps.getBitDepth(toChannelType(COMPONENT_Cb)); bool reshape = slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && slice.getLmcsChromaResidualScaleFlag() && tu.blocks[COMPONENT_Cb].width * tu.blocks[COMPONENT_Cb].height > 4; @@ -6661,7 +6661,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par if ( checkJointCbCr ) #endif { -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT const int channelBitDepth = sps.getBitDepth(toChannelType(COMPONENT_Cb)); double minCostCbCr = minCost[COMPONENT_Cb] + minCost[COMPONENT_Cr]; bool isLastBest = false; @@ -6672,7 +6672,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par Distortion currCompDistCr = 0; double currCompCost = 0; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT tu.jointCbCr = (uint8_t) cbfMask; tu.compAlpha[COMPONENT_Cb] = tu.compAlpha[COMPONENT_Cr] = 0; #else @@ -6686,7 +6686,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_pcTrQuant->selectLambda(COMPONENT_Cb); #endif // Lambda is loosened for the joint mode with respect to single modes as the same residual is used for both chroma blocks -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT const int absIct = abs( TU::getICTMode(tu) ); const double lfact = ( absIct == 1 || absIct == 3 ? 0.8 : 0.5 ); m_pcTrQuant->setLambda( lfact * m_pcTrQuant->getLambda() ); @@ -6701,7 +6701,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_CABACEstimator->getCtx() = ctxStart; m_CABACEstimator->resetBits(); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT PelBuf cbResi = csFull->getResiBuf(cbArea); PelBuf crResi = csFull->getResiBuf(crArea); cbResi.copyFrom(orgResiCb[cbfMask]); @@ -6727,13 +6727,13 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par double cRescale = round((double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj())); #endif m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cRescale*cRescale)); -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT cbResi.scaleSignal(tu.getChromaAdj(), 1, tu.cu->cs->slice->clpRng(COMPONENT_Cb)); #endif } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT int codedCbfMask = 0; ComponentID codeCompId = (tu.jointCbCr >> 1 ? COMPONENT_Cb : COMPONENT_Cr); ComponentID otherCompId = (codeCompId == COMPONENT_Cr ? COMPONENT_Cb : COMPONENT_Cr); @@ -6769,7 +6769,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par if (currAbsSum > 0) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT m_CABACEstimator->cbf_comp(cs, codedCbfMask >> 1, cbArea, currDepth, false); m_CABACEstimator->cbf_comp(cs, codedCbfMask & 1, crArea, currDepth, codedCbfMask >> 1); m_CABACEstimator->joint_cb_cr(tu, codedCbfMask); @@ -6824,7 +6824,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par uiSingleDistComp[COMPONENT_Cb] = currCompDistCb; uiSingleDistComp[COMPONENT_Cr] = currCompDistCr; minCostCbCr = currCompCost; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT isLastBest = (cbfMask == jointCbfMasksToTest.back()); if (!isLastBest) { @@ -6878,7 +6878,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par continue; if (tu.blocks[compID].valid()) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr ) { const int cbfMask = ( TU::getCbf( tu, COMPONENT_Cb ) ? 2 : 0 ) + ( TU::getCbf( tu, COMPONENT_Cr ) ? 1 : 0 ); diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index c8418492838870b5bf561e88e4bb38fa63e73729..250a2d0b3f168f52d11ac7bf265aaffc081744c7 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1645,7 +1645,7 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co if( currArea.blocks[compID].valid() ) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( compID == COMPONENT_Cr ) { const int cbfMask = ( TU::getCbf( currTU, COMPONENT_Cb ) ? 2 : 0 ) + ( TU::getCbf( currTU, COMPONENT_Cr ) ? 1 : 0 ); @@ -1702,7 +1702,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQTSingleChromaComponent( CodingStructure TransformUnit &currTU = *cs.getTU( currArea.blocks[partitioner.chType], partitioner.chType ); //cbf coding -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT const bool prevCbf = ( compID == COMPONENT_Cr ? TU::getCbfAtDepth( currTU, COMPONENT_Cb, partitioner.currTrDepth ) : false ); m_CABACEstimator->cbf_comp( cs, TU::getCbfAtDepth( currTU, compID, partitioner.currTrDepth ), currArea.blocks[compID], partitioner.currTrDepth - 1, prevCbf ); #else @@ -1736,7 +1736,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQTChroma(TransformUnit& currTU, const Com if ( currTU.jointCbCr ) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT const int cbfMask = ( TU::getCbf( currTU, COMPONENT_Cb ) ? 2 : 0 ) + ( TU::getCbf( currTU, COMPONENT_Cr ) ? 1 : 0 ); m_CABACEstimator->cbf_comp( cs, cbfMask>>1, currTU.blocks[ COMPONENT_Cb ], currTU.depth, false ); m_CABACEstimator->cbf_comp( cs, cbfMask &1, currTU.blocks[ COMPONENT_Cr ], currTU.depth, cbfMask>>1 ); @@ -1765,7 +1765,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQTChroma(TransformUnit& currTU, const Com if ( compID == COMPONENT_Cb ) m_CABACEstimator->cbf_comp( cs, TU::getCbf( currTU, compID ), currTU.blocks[ compID ], currTU.depth, false ); else -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT { const bool cbCbf = TU::getCbf( currTU, COMPONENT_Cb ); const bool crCbf = TU::getCbf( currTU, compID ); @@ -1778,7 +1778,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQTChroma(TransformUnit& currTU, const Com #endif } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( !currTU.jointCbCr && TU::getCbf( currTU, compID ) ) #else if( TU::getCbf( currTU, compID ) ) @@ -1827,7 +1827,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp //===== init availability pattern ===== -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT CHECK( tu.jointCbCr && compID == COMPONENT_Cr, "wrong combination of compID and jointCbCr" ); #endif bool jointCbCr = tu.jointCbCr && compID == COMPONENT_Cb; @@ -1879,7 +1879,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp const Slice &slice = *cs.slice; bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (isLuma(compID)) { #endif @@ -1923,7 +1923,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp } CrossComponentPrediction::crossComponentPrediction(tu, compID, cs.getResiBuf(tu.Y()), piResi, piResi, false); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT } #endif @@ -1948,7 +1948,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp double cResScale = round((double)(1 << CSCALE_FP_PREC) / (double)cResScaleInv); #endif m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cResScale*cResScale)); -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT if ( !jointCbCr ) // Joint CbCr signal is to be scaled in the case of joint chroma piResi.scaleSignal(cResScaleInv, 1, tu.cu->cs->slice->clpRng(compID)); #endif @@ -1962,7 +1962,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp if ( jointCbCr ) { -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT // Get Cr prediction and residual crResi.copyFrom( crOrg ); crResi.subtract( crPred ); @@ -1975,7 +1975,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp piResi.scaleSignal(tu.getChromaAdj(), 1, tu.cu->cs->slice->clpRng(compID)); #endif // Lambda is loosened for the joint mode with respect to single modes as the same residual is used for both chroma blocks -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT const int absIct = abs( TU::getICTMode(tu) ); const double lfact = ( absIct == 1 || absIct == 3 ? 0.8 : 0.5 ); m_pcTrQuant->setLambda( lfact * m_pcTrQuant->getLambda() ); @@ -1983,7 +1983,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp m_pcTrQuant->setLambda( 0.60 * m_pcTrQuant->getLambda() ); #endif } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( isChroma(compID) && tu.cu->cs->slice->getSliceQp() > 18 ) { m_pcTrQuant->setLambda( 1.3 * m_pcTrQuant->getLambda() ); @@ -1993,7 +1993,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp m_pcTrQuant->setLambda( 1.10 * m_pcTrQuant->getLambda() ); #endif -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( isLuma(compID) ) { #endif @@ -2029,7 +2029,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp { piResi.fill(0); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT } else // chroma { @@ -2077,7 +2077,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp if ( flag && uiAbsSum > 0 && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag() ) { piResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID)); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( jointCbCr ) { crResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(COMPONENT_Cr)); @@ -2087,7 +2087,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp if (bUseCrossCPrediction) { CrossComponentPrediction::crossComponentPrediction(tu, compID, cs.getResiBuf(tu.Y()), piResi, piResi, true); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( jointCbCr ) { CrossComponentPrediction::crossComponentPrediction(tu, COMPONENT_Cr, cs.getResiBuf(tu.Y()), crResi, crResi, true); @@ -2103,7 +2103,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp piReco.reconstruct(tmpPred, piResi, cs.slice->clpRng(compID)); } else -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT { piReco.reconstruct(piPred, piResi, cs.slice->clpRng( compID )); if( jointCbCr ) @@ -2115,7 +2115,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp piReco.reconstruct(piPred, piResi, cs.slice->clpRng( compID )); #endif -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT if ( jointCbCr ) { // Cr uses negative of the signalled Cb residual @@ -2164,7 +2164,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp ruiDist += m_pcRdCost->getDistPart(piOrg, tmpRecLuma, sps.getBitDepth(toChannelType(compID)), compID, DF_SSE_WTD, &orgLuma); } else -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT { ruiDist += m_pcRdCost->getDistPart(piOrg, piReco, bitDepth, compID, DF_SSE_WTD, &orgLuma); if( jointCbCr ) @@ -2180,7 +2180,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp #endif { ruiDist += m_pcRdCost->getDistPart( piOrg, piReco, bitDepth, compID, DF_SSE ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if( jointCbCr ) { ruiDist += m_pcRdCost->getDistPart( crOrg, crReco, bitDepth, COMPONENT_Cr, DF_SSE ); @@ -2688,7 +2688,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio TransformUnit &currTU = *cs.getTU( currArea.chromaPos(), CHANNEL_TYPE_CHROMA ); const PredictionUnit &pu = *cs.getPU( currArea.chromaPos(), CHANNEL_TYPE_CHROMA ); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT bool lumaUsesISP = false; #else bool lumaUsesISP = !CS::isDualITree( cs ) && currTU.cu->ispMode; @@ -2765,7 +2765,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio predIntraAng( COMPONENT_Cr, piPredCr, pu); } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT // determination of chroma residuals including reshaping and cross-component prediction //----- get chroma residuals ----- PelBuf resiCb = cs.getResiBuf(cbArea); @@ -2834,7 +2834,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio Distortion singleDistCTmp = 0; double singleCostTmp = 0; -#if !JVET_O0105_ICT_HHI +#if !JVET_O0105_ICT const bool checkCrossComponentPrediction = PU::isChromaIntraModeCrossCheckMode( pu ) && pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && TU::getCbf( currTU, COMPONENT_Y ); #endif const int crossCPredictionModesToTest = checkCrossComponentPrediction ? 2 : 1; @@ -2854,7 +2854,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio { for (int crossCPredictionModeId = 0; crossCPredictionModeId < crossCPredictionModesToTest; crossCPredictionModeId++) { -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT resiCb.copyFrom( orgResiCb[4*crossCPredictionModeId] ); resiCr.copyFrom( orgResiCr[4*crossCPredictionModeId] ); @@ -2958,7 +2958,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio double bestCostCbCr = bestCostCb + bestCostCr; Distortion bestDistCbCr = bestDistCb + bestDistCr; int bestJointCbCr = 0; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT bool lastIsBest = false; std::vector jointCbfMasksToTest; if( TU::getCbf(tmpTU, COMPONENT_Cb) || TU::getCbf(tmpTU, COMPONENT_Cr) ) @@ -2975,7 +2975,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio { Distortion distTmp = 0; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT currTU.jointCbCr = (uint8_t)cbfMask; #else currTU.jointCbCr = 1; @@ -2985,7 +2985,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio m_CABACEstimator->getCtx() = ctxStartTU; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT resiCb.copyFrom( orgResiCb[cbfMask] ); resiCr.copyFrom( orgResiCr[cbfMask] ); xIntraCodingTUBlock( currTU, COMPONENT_Cb, false, distTmp, 0 ); @@ -3007,7 +3007,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio { bestCostCbCr = costTmp; bestDistCbCr = distTmp; -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT bestJointCbCr = currTU.jointCbCr; // store data @@ -3043,7 +3043,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio } // Retrieve the best CU data (unless it was the very last one tested) -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if ( !( maxModesTested == 1 && jointCbfMasksToTest.empty() ) && !lastIsBest ) #else if ( !(maxModesTested == 1 && !checkJointCbCr) && bestJointCbCr == 0 ) @@ -3081,7 +3081,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio cbfs.cbf(COMPONENT_Cb) = TU::getCbf(currTU, COMPONENT_Cb); cbfs.cbf(COMPONENT_Cr) = TU::getCbf(currTU, COMPONENT_Cr); -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT currTU.jointCbCr = ( (cbfs.cbf(COMPONENT_Cb) + cbfs.cbf(COMPONENT_Cr)) ? bestJointCbCr : 0 ); #else currTU.jointCbCr = cbfs.cbf(COMPONENT_Cb) ? bestJointCbCr : 0; diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 404c90276b5f28220b8cd80af73a6dd99dc85508..7d6f17a6bbd293616dd3f9df5239640de94da74a 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -1375,7 +1375,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) pcSlice->setMaxNumTriangleCand(0); } } -#if JVET_O0105_ICT_HHI +#if JVET_O0105_ICT if (chromaEnabled) { WRITE_FLAG( pcSlice->getJointCbCrSignFlag() ? 1 : 0, "joint_cb_cr_sign_flag" ); @@ -1777,16 +1777,18 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro } #endif } - + AlfFilterShape alfShape(isChroma ? 5 : 7); +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING static int bitsCoeffScan[EncAdaptiveLoopFilter::m_MAX_SCAN_VAL][EncAdaptiveLoopFilter::m_MAX_EXP_GOLOMB]; memset( bitsCoeffScan, 0, sizeof( bitsCoeffScan ) ); - AlfFilterShape alfShape( isChroma ? 5 : 7 ); const int maxGolombIdx = AdaptiveLoopFilter::getMaxGolombIdx( alfShape.filterType ); +#endif const short* coeff = isChroma ? alfSliceParam.chromaCoeff : alfSliceParam.lumaCoeff; const short* clipp = isChroma ? alfSliceParam.chromaClipp : alfSliceParam.lumaClipp; const int numFilters = isChroma ? 1 : alfSliceParam.numLumaFilters; // vlc for all +#if !JVET_O0216_ALF_COEFF_EG3 for( int ind = 0; ind < numFilters; ++ind ) { if( isChroma || !alfSliceParam.alfLumaCoeffDeltaFlag || alfSliceParam.alfLumaCoeffFlag[ind] ) @@ -1802,10 +1804,12 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro } } } - +#endif +#if !JVET_O0216_ALF_COEFF_EG3 || !JVET_O0064_SIMP_ALF_CLIP_CODING static int kMinTab[MAX_NUM_ALF_COEFF]; +#endif +#if !JVET_O0216_ALF_COEFF_EG3 int kMin = EncAdaptiveLoopFilter::getGolombKMin( alfShape, numFilters, kMinTab, bitsCoeffScan ); - // Golomb parameters WRITE_UVLC( kMin - 1, isChroma ? "alf_chroma_min_eg_order_minus1" : "alf_luma_min_eg_order_minus1" ); @@ -1816,7 +1820,7 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro WRITE_FLAG( golombOrderIncreaseFlag, isChroma ? "alf_chroma_eg_order_increase_flag" : "alf_luma_eg_order_increase_flag" ); kMin = kMinTab[idx]; } - +#endif if( !isChroma ) { if( alfSliceParam.alfLumaCoeffDeltaFlag ) @@ -1838,7 +1842,11 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { +#if JVET_O0216_ALF_COEFF_EG3 + alfGolombEncode( coeff[ind* MAX_NUM_ALF_LUMA_COEFF + i], 3 ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] +#else alfGolombEncode( coeff[ind* MAX_NUM_ALF_LUMA_COEFF + i], kMinTab[alfShape.golombIdx[i]] ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] +#endif } } @@ -1895,8 +1903,11 @@ void HLSWriter::alfFilter( const AlfSliceParam& alfSliceParam, const bool isChro } } } - +#if JVET_O0216_ALF_COEFF_EG3 + int kMin = EncAdaptiveLoopFilter::getGolombKMin(alfShape, numFilters, kMinTab, bitsCoeffScan); +#else kMin = EncAdaptiveLoopFilter::getGolombKMin( alfShape, numFilters, kMinTab, bitsCoeffScan ); +#endif // Golomb parameters WRITE_UVLC( kMin - 1, "clip_min_golomb_order" );