diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index 8ad8384dc07f343b20045c2ae1d150c488c0fbdc..fdeb68a1105372f7bae01b9c19bca4a7d4965716 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -1924,20 +1924,6 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom pRecSrc0 += iRecStride2; } } -#if JVET_L0338_MDLM && !JVET_L0191_LM_WO_LMS -void IntraPrediction::xPadMdlmTemplateSample(Pel*pSrc, Pel*pCur, int cWidth, int cHeight, int existSampNum, int targetSampNum) -{ - int sampNumToBeAdd = targetSampNum - existSampNum; - Pel*pTempSrc = pSrc + existSampNum; - Pel*pTempCur = pCur + existSampNum; - for (int i = 0; i < sampNumToBeAdd; i++) - { - pTempSrc[i] = pSrc[existSampNum - 1]; - pTempCur[i] = pCur[existSampNum - 1]; - } -} -#endif -#if JVET_L0191_LM_WO_LMS void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const ComponentID compID, const CompArea &chromaArea, int &a, int &b, int &iShift) @@ -2154,356 +2140,5 @@ void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const Component iShift = 0; } } -#else -static int GetFloorLog2( unsigned x ) -{ - int bits = -1; - while( x > 0 ) - { - bits++; - x >>= 1; - } - return bits; -} - - -void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const ComponentID compID, const CompArea& chromaArea, - int& a, int& b, int& iShift) -{ - CHECK( compID == COMPONENT_Y, "" ); - - const SizeType uiCWidth = chromaArea.width; - const SizeType uiCHeight = chromaArea.height; - - const Position posLT = chromaArea; - - CodingStructure& cs = *(pu.cs); - const CodingUnit& cu = *(pu.cu); - - const SPS &sps = *cs.sps; - const uint32_t uiTuWidth = chromaArea.width; - const uint32_t uiTuHeight = chromaArea.height; - const ChromaFormat nChromaFormat = sps.getChromaFormatIdc(); - - const int iBaseUnitSize = 1 << MIN_CU_LOG2; - const int iUnitWidth = iBaseUnitSize >> getComponentScaleX( chromaArea.compID, nChromaFormat ); - const int iUnitHeight = iBaseUnitSize >> getComponentScaleX( chromaArea.compID, nChromaFormat ); - - - const int iTUWidthInUnits = uiTuWidth / iUnitWidth; - const int iTUHeightInUnits = uiTuHeight / iUnitHeight; - const int iAboveUnits = iTUWidthInUnits; - const int iLeftUnits = iTUHeightInUnits; -#if JVET_L0338_MDLM - int topTemplateSampNum = 2 * uiCWidth; // for MDLM, the template sample number is 2W or 2H; - int leftTemplateSampNum = 2 * uiCHeight; - assert(m_topRefLength >= topTemplateSampNum); - assert(m_leftRefLength >= leftTemplateSampNum); - int totalAboveUnits = (topTemplateSampNum + (iUnitWidth - 1)) / iUnitWidth; - int totalLeftUnits = (leftTemplateSampNum + (iUnitHeight - 1)) / iUnitHeight; - int totalUnits = totalLeftUnits + totalAboveUnits + 1; - int aboveRightUnits = totalAboveUnits - iAboveUnits; - int leftBelowUnits = totalLeftUnits - iLeftUnits; - int avaiAboveRightUnits = 0; - int avaiLeftBelowUnits = 0; - int avaiAboveUnits = 0; - int avaiLeftUnits = 0; - - int curChromaMode = pu.intraDir[1]; -#endif - bool bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1]; -#if JVET_L0338_MDLM - memset(bNeighborFlags, 0, totalUnits); -#else - memset( bNeighborFlags, 0, 1 + iLeftUnits + iAboveUnits ); -#endif - - bool bAboveAvaillable, bLeftAvaillable; - - int availlableUnit = isAboveAvailable( cu, CHANNEL_TYPE_CHROMA, posLT, iAboveUnits, iUnitWidth, -#if JVET_L0338_MDLM - (bNeighborFlags + iLeftUnits + leftBelowUnits + 1 ) ); -#else - ( bNeighborFlags + iLeftUnits + 1 ) ); -#endif - bAboveAvaillable = availlableUnit == iTUWidthInUnits; - - availlableUnit = isLeftAvailable( cu, CHANNEL_TYPE_CHROMA, posLT, iLeftUnits, iUnitHeight, -#if JVET_L0338_MDLM - (bNeighborFlags + iLeftUnits + leftBelowUnits - 1 ) ); -#else - ( bNeighborFlags + iLeftUnits - 1 ) ); -#endif - bLeftAvaillable = availlableUnit == iTUHeightInUnits; -#if JVET_L0338_MDLM - if (bLeftAvaillable) // if left is not available, then the below left is not available - { - avaiLeftUnits = iTUHeightInUnits; - avaiLeftBelowUnits = isBelowLeftAvailable(cu, CHANNEL_TYPE_CHROMA, chromaArea.bottomLeftComp(chromaArea.compID), leftBelowUnits, iUnitHeight, (bNeighborFlags + leftBelowUnits - 1)); - } - if (bAboveAvaillable) // if above is not available, then the above right is not available. - { - avaiAboveUnits = iTUWidthInUnits; - avaiAboveRightUnits = isAboveRightAvailable(cu, CHANNEL_TYPE_CHROMA, chromaArea.topRightComp(chromaArea.compID), aboveRightUnits, iUnitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + iAboveUnits + 1)); - } -#endif - Pel *pSrcColor0, *pCurChroma0; - int iSrcStride, iCurStride; - - PelBuf Temp; -#if JVET_L0338_MDLM - if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX)) - { - iSrcStride = 2 * MAX_CU_SIZE + 1; - Temp = PelBuf(m_pMdlmTemp + iSrcStride + 1, iSrcStride, Size(chromaArea)); - } - else - { -#endif - iSrcStride = MAX_CU_SIZE + 1; - Temp = PelBuf(m_piTemp + iSrcStride + 1, iSrcStride, Size(chromaArea)); -#if JVET_L0338_MDLM - } -#endif - pSrcColor0 = Temp.bufAt(0, 0); - pCurChroma0 = getPredictorPtr(compID); - iCurStride = m_topRefLength + 1; - pCurChroma0 += iCurStride + 1; - int x = 0, y = 0, xx = 0, xy = 0; - int iCountShift = 0; - unsigned uiInternalBitDepth = sps.getBitDepth( CHANNEL_TYPE_CHROMA ); - - Pel *pSrc = pSrcColor0 - iSrcStride; - Pel *pCur = pCurChroma0 - iCurStride; -#if JVET_L0338_MDLM - //get the temp buffer to store the downsampled luma and chroma - Pel* pTempBufferSrc = new Pel[2 * MAX_CU_SIZE]; // for MDLM, use tempalte size 2W or 2H, - Pel* pTempBufferCur = new Pel[2 * MAX_CU_SIZE]; - - int actualTopTemplateSampNum = iUnitWidth*(avaiAboveUnits + avaiAboveRightUnits); - int actualLeftTemplateSampNum = iUnitHeight*(avaiLeftUnits + avaiLeftBelowUnits); - - if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX)) - { - if (curChromaMode == MDLM_T_IDX) - { - if (bAboveAvaillable) - { - for (int j = 0; j < actualTopTemplateSampNum; j++) - { - pTempBufferSrc[j] = pSrc[j]; - pTempBufferCur[j] = pCur[j]; - } - } - } - else - { - if (bLeftAvaillable) - { - pSrc = pSrcColor0 - 1; - pCur = pCurChroma0 - 1; - for (int i = 0; i < actualLeftTemplateSampNum; i++) - { - pTempBufferSrc[i] = pSrc[iSrcStride *i]; - pTempBufferCur[i] = pCur[iCurStride *i]; - } - } - } - //pad the temple sample to targetSampNum. - int orgNumSample = (curChromaMode == MDLM_T_IDX) ? (avaiAboveUnits*iUnitWidth) : (avaiLeftUnits*iUnitHeight); - int existSampNum = (curChromaMode == MDLM_T_IDX) ? actualTopTemplateSampNum : actualLeftTemplateSampNum; - int targetSampNum = 1 << (g_aucLog2[existSampNum - 1] + 1); - - if (orgNumSample == 0) - { - delete[] pTempBufferSrc; - delete[] pTempBufferCur; - pTempBufferSrc = nullptr; - pTempBufferCur = nullptr; - - a = 0; - b = 1 << (uiInternalBitDepth - 1); - iShift = 0; - return; - } - if (targetSampNum != existSampNum)//if existSampNum not a value of power of 2 - { - xPadMdlmTemplateSample(pTempBufferSrc, pTempBufferCur, uiCWidth, uiCHeight, existSampNum, targetSampNum); - } - for (int j = 0; j < targetSampNum; j++) - { - x += pTempBufferSrc[j]; - y += pTempBufferCur[j]; - xx += pTempBufferSrc[j] * pTempBufferSrc[j]; - xy += pTempBufferSrc[j] * pTempBufferCur[j]; - } - iCountShift = g_aucLog2[targetSampNum]; - } - else - { -#endif - int minDim = bLeftAvaillable && bAboveAvaillable ? 1 << g_aucPrevLog2[std::min( uiCHeight, uiCWidth )] : 1 << g_aucPrevLog2[bLeftAvaillable ? uiCHeight : uiCWidth]; - int minStep = 1; - int numSteps = minDim / minStep; - - if( bAboveAvaillable ) - { - for( int j = 0; j < numSteps; j++ ) - { - int idx = ( j * minStep * uiCWidth ) / minDim; - - x += pSrc[idx]; - y += pCur[idx]; - xx += pSrc[idx] * pSrc[idx]; - xy += pSrc[idx] * pCur[idx]; - } - - iCountShift = g_aucLog2[minDim / minStep]; - } - - if( bLeftAvaillable ) - { - pSrc = pSrcColor0 - 1; - pCur = pCurChroma0 - 1; - - for( int i = 0; i < numSteps; i++ ) - { - int idx = ( i * uiCHeight * minStep ) / minDim; - x += pSrc[iSrcStride * idx]; - y += pCur[iCurStride * idx]; - xx += pSrc[iSrcStride * idx] * pSrc[iSrcStride * idx]; - xy += pSrc[iSrcStride * idx] * pCur[iCurStride * idx]; - } - - iCountShift += bAboveAvaillable ? 1 : g_aucLog2[minDim / minStep]; - } -#if JVET_L0338_MDLM - } - - delete[] pTempBufferSrc; - delete[] pTempBufferCur; - pTempBufferSrc = nullptr; - pTempBufferCur = nullptr; -#endif -#if JVET_L0338_MDLM - if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX)) - { - if ((curChromaMode == MDLM_L_IDX) ? (!bLeftAvaillable) : (!bAboveAvaillable)) - { - a = 0; - b = 1 << (uiInternalBitDepth - 1); - iShift = 0; - return; - } - } - else - { -#endif - if( !bLeftAvaillable && !bAboveAvaillable ) - { - a = 0; - b = 1 << ( uiInternalBitDepth - 1 ); - iShift = 0; - return; - } -#if JVET_L0338_MDLM - } -#endif - int iTempShift = uiInternalBitDepth + iCountShift - 15; - - if( iTempShift > 0 ) - { - x = ( x + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; - y = ( y + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; - xx = ( xx + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; - xy = ( xy + ( 1 << ( iTempShift - 1 ) ) ) >> iTempShift; - iCountShift -= iTempShift; - } - - - /////// xCalcLMParameters - - int avgX = x >> iCountShift; - int avgY = y >> iCountShift; - - int RErrX = x & ( ( 1 << iCountShift ) - 1 ); - int RErrY = y & ( ( 1 << iCountShift ) - 1 ); - - int iB = 7; - iShift = 13 - iB; - - - if( iCountShift == 0 ) - { - a = 0; - b = 1 << ( uiInternalBitDepth - 1 ); - iShift = 0; - } - else - { - int a1 = xy - ( avgX * avgY << iCountShift ) - avgX * RErrY - avgY * RErrX; - int a2 = xx - ( avgX * avgX << iCountShift ) - 2 * avgX * RErrX; - const int iShiftA1 = uiInternalBitDepth - 2; - const int iShiftA2 = 5; - const int iAccuracyShift = uiInternalBitDepth + 4; - - int iScaleShiftA2 = 0; - int iScaleShiftA1 = 0; - int a1s = a1; - int a2s = a2; - - iScaleShiftA1 = a1 == 0 ? 0 : GetFloorLog2( abs( a1 ) ) - iShiftA1; - iScaleShiftA2 = a2 == 0 ? 0 : GetFloorLog2( abs( a2 ) ) - iShiftA2; - - if( iScaleShiftA1 < 0 ) - { - iScaleShiftA1 = 0; - } - - if( iScaleShiftA2 < 0 ) - { - iScaleShiftA2 = 0; - } - - int iScaleShiftA = iScaleShiftA2 + iAccuracyShift - iShift - iScaleShiftA1; - - a2s = a2 >> iScaleShiftA2; - - a1s = a1 >> iScaleShiftA1; - - if( a2s >= 32 ) - { - uint32_t a2t = m_auShiftLM[a2s - 32]; - a = a1s * a2t; - } - else - { - a = 0; - } - - if( iScaleShiftA < 0 ) - { - a = a << -iScaleShiftA; - } - else - { - a = a >> iScaleShiftA; - } - a = Clip3( -( 1 << ( 15 - iB ) ), ( 1 << ( 15 - iB ) ) - 1, a ); - a = a << iB; - - int16_t n = 0; - if( a != 0 ) - { - n = GetFloorLog2( abs( a ) + ( ( a < 0 ? -1 : 1 ) - 1 ) / 2 ) - 5; - } - - iShift = ( iShift + iB ) - n; - a = a >> n; - - b = avgY - ( ( a * avgX ) >> iShift ); - } -} -#endif //! \} diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h index 9b7b0387e863b3140bb680b5ec13b9e029ff9952..5bef96186e1537bb12fe4c1d60a6754eaf49159f 100644 --- a/source/Lib/CommonLib/IntraPrediction.h +++ b/source/Lib/CommonLib/IntraPrediction.h @@ -130,9 +130,6 @@ protected: void xFilterGroup ( Pel* pMulDst[], int i, Pel const* const piSrc, int iRecStride, bool bAboveAvaillable, bool bLeftAvaillable); void xGetLMParameters(const PredictionUnit &pu, const ComponentID compID, const CompArea& chromaArea, int& a, int& b, int& iShift); -#if JVET_L0338_MDLM && !JVET_L0191_LM_WO_LMS - void xPadMdlmTemplateSample (Pel*pSrc, Pel*pCur, int cWidth, int cHeight, int existSampNum, int targetSampNum); -#endif public: IntraPrediction(); virtual ~IntraPrediction(); diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 95e03c56348699ccc98be24921166b0b5b13ad04..f1b45ad0ba1fd17bc767649c4f81eaf3ae418e84 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -180,7 +180,6 @@ public: return rtn; } }; -#if JVET_L0191_LM_WO_LMS int g_aiLMDivTableLow[] = { 0, 0, 21845, 0, 13107, 43690, 18724, 0, 50972, 39321, 53620, 21845, 15123, 9362, 4369, 0, 3855, 58254, 17246, 52428, 49932, 59578, 25644, 43690, 28835, 40329, 16990, 37449, 56496, 34952, 4228, 0, 61564, 34695, @@ -245,7 +244,6 @@ int g_aiLMDivTableHigh[] = { 134, 134, 134, 133, 133, 133, 132, 132, 132, 132, 131, 131, 131, 131, 130, 130, 130, 130, 129, 129, 129, 129, 128, 128, 128, 128, }; -#endif #if !JVET_L0338_MDLM const int g_aiNonLMPosThrs[] = { 3, 1, 0 }; #endif diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index 8cb6e8b9945288c3a203d5a9345edd13b4b4e037..3f17d5319443b0f5eb85b6a8f6f8dce14ffb4525 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -214,10 +214,8 @@ extern const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM]; extern MsgLevel g_verbosity; -#if JVET_L0191_LM_WO_LMS extern int g_aiLMDivTableLow[]; extern int g_aiLMDivTableHigh[]; -#endif extern const int g_aiNonLMPosThrs[]; diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index aec1ae1bcf013b1361f7d24fca7853af0a9770c6..1f591c817c3796f7ceb6f0e84619abca097e5b6b 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -64,7 +64,6 @@ -#define JVET_L0191_LM_WO_LMS 1 // NO LMS regression. min/max are used instead #define JVET_L0338_MDLM 1 // multi-directional LM. L0338 test5.4.1,L0340 test5.6.1