diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 983ae59f90d84bbc7b75a5f5eb542156248da0c4..4502c3d655f7ac5e2ee11f7fd618c7bdb7249a0b 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -50,8 +50,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp , m_chType (toChannelType(m_compID)) , m_width (tu.block(m_compID).width) , m_height (tu.block(m_compID).height) +#if JVET_N0103_CGSIZE_HARMONIZATION + , m_log2CGWidth ( g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0] ) + , m_log2CGHeight ( g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1] ) +#else , m_log2CGWidth ( g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0] ) , m_log2CGHeight ( g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1] ) +#endif , m_log2CGSize (m_log2CGWidth + m_log2CGHeight) , m_widthInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) >> m_log2CGWidth) , m_heightInGroups(std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_height) >> m_log2CGHeight) @@ -68,8 +73,13 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp #else , m_scanType (SCAN_DIAG) #endif +#if JVET_N0103_CGSIZE_HARMONIZATION + , m_scan (g_scanOrder [SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )]) + , m_scanCG (g_scanOrder [SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)]) +#else , m_scan (g_scanOrder [m_chType][SCAN_GROUPED_4x4][m_scanType][gp_sizeIdxInfo->idxFrom(m_width )][gp_sizeIdxInfo->idxFrom(m_height )]) , m_scanCG (g_scanOrder [m_chType][SCAN_UNGROUPED ][m_scanType][gp_sizeIdxInfo->idxFrom(m_widthInGroups)][gp_sizeIdxInfo->idxFrom(m_heightInGroups)]) +#endif , m_CtxSetLastX (Ctx::LastX[m_chType]) , m_CtxSetLastY (Ctx::LastY[m_chType]) , m_maxLastPosX(g_uiGroupIdx[std::min<unsigned>(JVET_C0024_ZERO_OUT_TH, m_width) - 1]) diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 86ecec0010fc112f4bf0dbbbabe945375a9b0888..2fc1ab08566713fc491748cdafc1f20135d058fa 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -128,8 +128,13 @@ namespace DQIntern Rom() : m_scansInitialized(false) {} ~Rom() { xUninitScanArrays(); } void init () { xInitScanArrays(); } +#if JVET_N0103_CGSIZE_HARMONIZATION + const NbInfoSbb* getNbInfoSbb( int hd, int vd ) const { return m_scanId2NbInfoSbbArray[hd][vd]; } + const NbInfoOut* getNbInfoOut( int hd, int vd ) const { return m_scanId2NbInfoOutArray[hd][vd]; } +#else const NbInfoSbb* getNbInfoSbb( int hd, int vd, int ch ) const { return m_scanId2NbInfoSbbArray[hd][vd][ch]; } const NbInfoOut* getNbInfoOut( int hd, int vd, int ch ) const { return m_scanId2NbInfoOutArray[hd][vd][ch]; } +#endif const TUParameters* getTUPars ( const CompArea& area, const ComponentID compID ) const { return m_tuParameters[g_aucLog2[area.width]][g_aucLog2[area.height]][toChannelType(compID)]; @@ -139,8 +144,13 @@ namespace DQIntern void xUninitScanArrays (); private: bool m_scansInitialized; +#if JVET_N0103_CGSIZE_HARMONIZATION + NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ]; + NbInfoOut* m_scanId2NbInfoOutArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ]; +#else NbInfoSbb* m_scanId2NbInfoSbbArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ]; NbInfoOut* m_scanId2NbInfoOutArray[ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ]; +#endif TUParameters* m_tuParameters [ MAX_CU_DEPTH+1 ][ MAX_CU_DEPTH+1 ][ MAX_NUM_CHANNEL_TYPE ]; }; @@ -157,8 +167,10 @@ namespace DQIntern uint32_t raster2id[ MAX_CU_SIZE * MAX_CU_SIZE ]; ::memset(raster2id, 0, sizeof(raster2id)); +#if !JVET_N0103_CGSIZE_HARMONIZATION for( int ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ ) { +#endif for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ ) { for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ ) @@ -169,17 +181,28 @@ namespace DQIntern } const uint32_t blockWidth = (1 << hd); const uint32_t blockHeight = (1 << vd); +#if JVET_N0103_CGSIZE_HARMONIZATION + const uint32_t log2CGWidth = g_log2SbbSize[hd][vd][0]; + const uint32_t log2CGHeight = g_log2SbbSize[hd][vd][1]; +#else const uint32_t log2CGWidth = g_log2SbbSize[ch][hd][vd][0]; const uint32_t log2CGHeight = g_log2SbbSize[ch][hd][vd][1]; +#endif const uint32_t groupWidth = 1 << log2CGWidth; const uint32_t groupHeight = 1 << log2CGHeight; const uint32_t groupSize = groupWidth * groupHeight; const CoeffScanType scanType = SCAN_DIAG; const SizeType blkWidthIdx = gp_sizeIdxInfo->idxFrom( blockWidth ); const SizeType blkHeightIdx = gp_sizeIdxInfo->idxFrom( blockHeight ); +#if JVET_N0103_CGSIZE_HARMONIZATION + const ScanElement * scanId2RP = g_scanOrder[SCAN_GROUPED_4x4][scanType][blkWidthIdx][blkHeightIdx]; + NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd]; + NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd]; +#else const ScanElement * scanId2RP = g_scanOrder[ch][SCAN_GROUPED_4x4][scanType][blkWidthIdx][blkHeightIdx]; NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd][ch]; NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd][ch]; +#endif // consider only non-zero-out region const uint32_t blkWidthNZOut = std::min<unsigned>( JVET_C0024_ZERO_OUT_TH, blockWidth ); const uint32_t blkHeightNZOut= std::min<unsigned>( JVET_C0024_ZERO_OUT_TH, blockHeight ); @@ -289,10 +312,19 @@ namespace DQIntern nbOut.maxDist -= scanId; } +#if JVET_N0103_CGSIZE_HARMONIZATION + for( int chId = 0; chId < MAX_NUM_CHANNEL_TYPE; chId++ ) + { + m_tuParameters[hd][vd][chId] = new TUParameters( *this, blockWidth, blockHeight, ChannelType(chId) ); + } +#else m_tuParameters[hd][vd][ch] = new TUParameters( *this, blockWidth, blockHeight, ChannelType(ch) ); +#endif } } +#if !JVET_N0103_CGSIZE_HARMONIZATION } +#endif m_scansInitialized = true; } @@ -302,6 +334,32 @@ namespace DQIntern { return; } +#if JVET_N0103_CGSIZE_HARMONIZATION + for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ ) + { + for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ ) + { + NbInfoSbb*& sId2NbSbb = m_scanId2NbInfoSbbArray[hd][vd]; + NbInfoOut*& sId2NbOut = m_scanId2NbInfoOutArray[hd][vd]; + if( sId2NbSbb ) + { + delete [] sId2NbSbb; + } + if( sId2NbOut ) + { + delete [] sId2NbOut; + } + for( int chId = 0; chId < MAX_NUM_CHANNEL_TYPE; chId++ ) + { + TUParameters*& tuPars = m_tuParameters[hd][vd][chId]; + if( tuPars ) + { + delete tuPars; + } + } + } + } +#else for( int hd = 0; hd <= MAX_CU_DEPTH; hd++ ) { for( int vd = 0; vd <= MAX_CU_DEPTH; vd++ ) @@ -326,6 +384,7 @@ namespace DQIntern } } } +#endif m_scansInitialized = false; } @@ -341,8 +400,13 @@ namespace DQIntern const uint32_t nonzeroWidth = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_width); const uint32_t nonzeroHeight = std::min<uint32_t>(JVET_C0024_ZERO_OUT_TH, m_height); m_numCoeff = nonzeroWidth * nonzeroHeight; +#if JVET_N0103_CGSIZE_HARMONIZATION + m_log2SbbWidth = g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0]; + m_log2SbbHeight = g_log2SbbSize[ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1]; +#else m_log2SbbWidth = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][0]; m_log2SbbHeight = g_log2SbbSize[m_chType][ g_aucLog2[m_width] ][ g_aucLog2[m_height] ][1]; +#endif m_log2SbbSize = m_log2SbbWidth + m_log2SbbHeight; m_sbbSize = ( 1 << m_log2SbbSize ); m_sbbMask = m_sbbSize - 1; @@ -359,12 +423,21 @@ namespace DQIntern SizeType vsbb = gp_sizeIdxInfo->idxFrom( m_heightInSbb ); SizeType hsId = gp_sizeIdxInfo->idxFrom( m_width ); SizeType vsId = gp_sizeIdxInfo->idxFrom( m_height ); +#if JVET_N0103_CGSIZE_HARMONIZATION + m_scanSbbId2SbbPos = g_scanOrder [ SCAN_UNGROUPED ][ m_scanType ][ hsbb ][ vsbb ]; + m_scanId2BlkPos = g_scanOrder [ SCAN_GROUPED_4x4 ][ m_scanType ][ hsId ][ vsId ]; + int log2W = g_aucLog2[ m_width ]; + int log2H = g_aucLog2[ m_height ]; + m_scanId2NbInfoSbb = rom.getNbInfoSbb( log2W, log2H ); + m_scanId2NbInfoOut = rom.getNbInfoOut( log2W, log2H ); +#else m_scanSbbId2SbbPos = g_scanOrder [ chType ][ SCAN_UNGROUPED ][ m_scanType ][ hsbb ][ vsbb ]; m_scanId2BlkPos = g_scanOrder [ chType ][ SCAN_GROUPED_4x4 ][ m_scanType ][ hsId ][ vsId ]; int log2W = g_aucLog2[ m_width ]; int log2H = g_aucLog2[ m_height ]; m_scanId2NbInfoSbb = rom.getNbInfoSbb( log2W, log2H, chType ); m_scanId2NbInfoOut = rom.getNbInfoOut( log2W, log2H, chType ); +#endif m_scanInfo = new ScanInfo[ m_numCoeff ]; for( int scanIdx = 0; scanIdx < m_numCoeff; scanIdx++ ) { @@ -736,7 +809,11 @@ namespace DQIntern #else const CoeffScanType scanType = SCAN_DIAG; #endif +#if JVET_N0103_CGSIZE_HARMONIZATION + const ScanElement *scan = g_scanOrder[SCAN_GROUPED_4x4][scanType][hsId][vsId]; +#else const ScanElement *scan = g_scanOrder[toChannelType(compID)][SCAN_GROUPED_4x4][scanType][hsId][vsId]; +#endif const TCoeff* qCoeff = tu.getCoeffs( compID ).buf; TCoeff* tCoeff = recCoeff.buf; diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index d4b8a98f8ef5fda5a48c61a609b2dae992864f14..b1ec86acd15804ead4c729857cda341890d1180b 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -288,48 +288,38 @@ Pel IntraPrediction::xGetPredValDc( const CPelBuf &pSrc, const Size &dstSize ) } -void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu, const bool useFilteredPredSamples ) +void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu) { const ComponentID compID = MAP_CHROMA( compId ); const ChannelType channelType = toChannelType( compID ); const int iWidth = piPred.width; const int iHeight = piPred.height; - const Size cuSize = Size( pu.cu->blocks[compId].width, pu.cu->blocks[compId].height ); - const uint32_t uiDirMode = PU::getFinalIntraMode( pu, channelType ); + + const uint32_t uiDirMode = PU::getFinalIntraMode( pu, channelType ); CHECK( g_aucLog2[iWidth] < 2 && pu.cs->pcv->noChroma2x2, "Size not allowed" ); CHECK( g_aucLog2[iWidth] > 7, "Size not allowed" ); - const int multiRefIdx = (compID == COMPONENT_Y) ? pu.multiRefIdx : 0; - const bool useISP = pu.cu->ispMode && isLuma( compID ); - const int whRatio = useISP ? std::max( unsigned( 1 ), cuSize.width / cuSize.height ) : std::max( 1, iWidth / iHeight ); - const int hwRatio = useISP ? std::max( unsigned( 1 ), cuSize.height / cuSize.width ) : std::max( 1, iHeight / iWidth ); + const int multiRefIdx = m_ipaParam.multiRefIndex; + const int whRatio = m_ipaParam.whRatio; + const int hwRatio = m_ipaParam.hwRatio; + const int srcStride = m_topRefLength + 1 + (whRatio + 1) * multiRefIdx; const int srcHStride = m_leftRefLength + 1 + (hwRatio + 1) * multiRefIdx; - Pel *ptrSrc = getPredictorPtr(compID, useFilteredPredSamples); + const CPelBuf & srcBuf = CPelBuf(getPredictorPtr(compID), srcStride, srcHStride); const ClpRng& clpRng(pu.cu->cs->slice->clpRng(compID)); switch (uiDirMode) { - case(PLANAR_IDX): xPredIntraPlanar(CPelBuf(ptrSrc, srcStride, srcHStride), piPred, *pu.cs->sps); break; - case(DC_IDX): xPredIntraDc(CPelBuf(ptrSrc, srcStride, srcHStride), piPred, channelType, false); break; - case(2): - case(DIA_IDX): - case(VDIA_IDX): - if (getWideAngle(useISP ? cuSize.width : iWidth, useISP ? cuSize.height : iHeight, uiDirMode) == static_cast<int>(uiDirMode)) // check if uiDirMode is not wide-angle - { - xPredIntraAng(CPelBuf(ptrSrc, srcStride, srcHStride), piPred, channelType, uiDirMode, clpRng, *pu.cs->sps, multiRefIdx, useFilteredPredSamples, useISP, cuSize ); - break; - } - default: xPredIntraAng(CPelBuf(getPredictorPtr(compID, false), srcStride, srcHStride), piPred, channelType, uiDirMode, clpRng, *pu.cs->sps, multiRefIdx, useFilteredPredSamples, useISP, cuSize); break; + case(PLANAR_IDX): xPredIntraPlanar(srcBuf, piPred); break; + case(DC_IDX): xPredIntraDc(srcBuf, piPred, channelType, false); break; + default: xPredIntraAng(srcBuf, piPred, channelType, clpRng); break; } - bool pdpcCondition = (uiDirMode == PLANAR_IDX || uiDirMode == DC_IDX || uiDirMode == HOR_IDX || uiDirMode == VER_IDX); - if( pdpcCondition && multiRefIdx == 0 && !useISP ) + if (m_ipaParam.applyPDPC) { - const CPelBuf srcBuf = CPelBuf(ptrSrc, srcStride, srcStride); PelBuf dstBuf = piPred; const int scale = ((g_aucLog2[iWidth] - 2 + g_aucLog2[iHeight] - 2 + 2) >> 2); CHECK(scale < 0 || scale > 31, "PDPC: scale < 0 || scale > 31"); @@ -434,7 +424,7 @@ void IntraPrediction::xFilterGroup(Pel* pMulDst[], int i, Pel const * const piSr */ //NOTE: Bit-Limit - 24-bit source -void IntraPrediction::xPredIntraPlanar( const CPelBuf &pSrc, PelBuf &pDst, const SPS& sps ) +void IntraPrediction::xPredIntraPlanar( const CPelBuf &pSrc, PelBuf &pDst ) { const uint32_t width = pDst.width; const uint32_t height = pDst.height; @@ -536,7 +526,93 @@ void IntraPrediction::xDCPredFiltering(const CPelBuf &pSrc, PelBuf &pDst, const } #endif -// Function for deriving the angular Intra predictions +// Function for initialization of intra prediction parameters +void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompArea area, const SPS& sps) +{ + const ComponentID compId = area.compID; + const ChannelType chType = toChannelType(compId); + + const bool useISP = NOT_INTRA_SUBPARTITIONS != pu.cu->ispMode && isLuma( chType ); + + const Size cuSize = Size( pu.cu->blocks[compId].width, pu.cu->blocks[compId].height ); + const Size puSize = Size( area.width, area.height ); + const Size& blockSize = useISP ? cuSize : puSize; + const int dirMode = PU::getFinalIntraMode(pu, chType); + const int predMode = getWideAngle( blockSize.width, blockSize.height, dirMode ); + + m_ipaParam.whRatio = std::max( unsigned( 1 ), blockSize.width / blockSize.height ) ; + m_ipaParam.hwRatio = std::max( unsigned( 1 ), blockSize.height / blockSize.width ) ; + m_ipaParam.isModeVer = predMode >= DIA_IDX; + m_ipaParam.multiRefIndex = isLuma (chType) ? pu.multiRefIdx : 0 ; + m_ipaParam.refFilterFlag = false; + m_ipaParam.interpolationFlag = false; + m_ipaParam.applyPDPC = !useISP && m_ipaParam.multiRefIndex == 0; + + const int intraPredAngleMode = (m_ipaParam.isModeVer) ? predMode - VER_IDX : -(predMode - HOR_IDX); + + + int absAng = 0; + if (dirMode > DC_IDX && dirMode < NUM_LUMA_MODE) // intraPredAngle for directional modes + { + static const int angTable[32] = { 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 23, 26, 29, 32, 35, 39, 45, 51, 57, 64, 73, 86, 102, 128, 171, 256, 341, 512, 1024 }; + static const int invAngTable[32] = { 0, 8192, 4096, 2731, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 356, 315, 282, 256, 234, 210, 182, 160, 144, 128, 112, 95, 80, 64, 48, 32, 24, 16, 8 }; // (256 * 32) / Angle + + const int absAngMode = abs(intraPredAngleMode); + const int signAng = intraPredAngleMode < 0 ? -1 : 1; + absAng = angTable [absAngMode]; + + m_ipaParam.invAngle = invAngTable[absAngMode]; + m_ipaParam.intraPredAngle = signAng * absAng; + m_ipaParam.applyPDPC &= m_ipaParam.intraPredAngle == 0 || m_ipaParam.intraPredAngle >= 12; // intra prediction modes: HOR, VER, x, where x>=VDIA-8 or x<=2+8 + } + + // high level conditions and DC intra prediction + if( sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag() +#if JVET_N0671_INTRA_TPM_ALIGNWITH420 + || !isLuma( chType ) +#else + || ( !isLuma( chType ) && pu.chromaFormat != CHROMA_444 ) +#endif + || useISP + || m_ipaParam.multiRefIndex + || DC_IDX == dirMode + ) + { + if (useISP) + { + m_ipaParam.interpolationFlag = (m_ipaParam.isModeVer ? puSize.width : puSize.height) > 8 ? true : false ; + } + } + else if (dirMode == PLANAR_IDX) // Planar intra prediction + { + m_ipaParam.refFilterFlag = puSize.width * puSize.height > 32 ? true : false; + } + else if (!useISP)// HOR, VER and angular modes (MDIS) + { + bool filterFlag = false; + + if (predMode != dirMode ) // wide-anlge mode + { + filterFlag = true; + } + else + { + const int diff = std::min<int>( abs( dirMode - HOR_IDX ), abs( dirMode - VER_IDX ) ); + 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]); + } + + // Selelection of either ([1 2 1] / 4 ) refrence filter OR Gaussian 4-tap interpolation filter + if (filterFlag) + { + const bool isRefFilter = isIntegerSlope(absAng); + m_ipaParam.refFilterFlag = isRefFilter; + m_ipaParam.interpolationFlag = !isRefFilter; + } + } +} + /** Function for deriving the simplified angular intra predictions. * @@ -549,39 +625,18 @@ void IntraPrediction::xDCPredFiltering(const CPelBuf &pSrc, PelBuf &pDst, const * from the extended main reference. */ //NOTE: Bit-Limit - 25-bit source -#if HEVC_USE_HOR_VER_PREDFILTERING -void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const bool bEnableEdgeFilters, const SPS& sps - , int multiRefIdx - , const bool enableBoundaryFilter ) -#else -void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps, - int multiRefIdx, - const bool useFilteredPredSamples , - const bool useISP, - const Size cuSize ) -#endif + +void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const ClpRng& clpRng) { int width =int(pDst.width); int height=int(pDst.height); - CHECK( !( dirMode > DC_IDX && dirMode < NUM_LUMA_MODE ), "Invalid intra dir" ); - int predMode = useISP ? getWideAngle( cuSize.width, cuSize.height, dirMode ) : getWideAngle( width, height, dirMode ); - const bool bIsModeVer = predMode >= DIA_IDX; - const int intraPredAngleMode = (bIsModeVer) ? predMode - VER_IDX : -(predMode - HOR_IDX); - const int absAngMode = abs(intraPredAngleMode); - const int signAng = intraPredAngleMode < 0 ? -1 : 1; -#if HEVC_USE_HOR_VER_PREDFILTERING - const bool edgeFilter = bEnableEdgeFilters && isLuma(channelType) && (width <= MAXIMUM_INTRA_FILTERED_WIDTH) && (height <= MAXIMUM_INTRA_FILTERED_HEIGHT); -#endif - - // Set bitshifts and scale the angle parameter to block size - - static const int angTable[32] = { 0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16, 18, 20, 23, 26, 29, 32, 35, 39, 45, 51, 57, 64, 73, 86, 102, 128, 171, 256, 341, 512, 1024 }; - static const int invAngTable[32] = { 0, 8192, 4096, 2731, 2048, 1365, 1024, 819, 683, 585, 512, 455, 410, 356, 315, 282, 256, 234, 210, 182, 160, 144, 128, 112, 95, 80, 64, 48, 32, 24, 16, 8 }; // (256 * 32) / Angle - - int invAngle = invAngTable[absAngMode]; - int absAng = angTable [absAngMode]; - int intraPredAngle = signAng * absAng; + const bool bIsModeVer = m_ipaParam.isModeVer; + const int whRatio = m_ipaParam.whRatio; + const int hwRatio = m_ipaParam.hwRatio; + const int multiRefIdx = m_ipaParam.multiRefIndex; + const int intraPredAngle = m_ipaParam.intraPredAngle; + const int invAngle = m_ipaParam.invAngle; Pel* refMain; Pel* refSide; @@ -589,16 +644,14 @@ void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const Ch Pel refAbove[2 * MAX_CU_SIZE + 3 + 33 * MAX_REF_LINE_IDX]; Pel refLeft [2 * MAX_CU_SIZE + 3 + 33 * MAX_REF_LINE_IDX]; - const int whRatio = useISP ? std::max( unsigned( 1 ), cuSize.width / cuSize.height ) : std::max( 1, width / height ); - const int hwRatio = useISP ? std::max( unsigned( 1 ), cuSize.height / cuSize.width ) : std::max( 1, height / width ); - // Initialize the Main and Left reference array. if (intraPredAngle < 0) { - auto width = int(pDst.width) +1; - auto height = int(pDst.height)+1; - auto lastIdx = (bIsModeVer ? width : height) + multiRefIdx; - auto firstIdx = ( ((bIsModeVer ? height : width) -1) * intraPredAngle ) >> 5; + const int width = pDst.width + 1; + const int height = pDst.height + 1; + const int lastIdx = (bIsModeVer ? width : height) + multiRefIdx; + const int firstIdx = (((bIsModeVer ? height : width) - 1) * intraPredAngle) >> 5; + for (int x = 0; x < width + 1 + multiRefIdx; x++) { refAbove[x + height - 1] = pSrc.at( x, 0 ); @@ -680,12 +733,12 @@ void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const Ch const int deltaInt = deltaPos >> 5; const int deltaFract = deltaPos & (32 - 1); - if (absAng != 0 && absAng != 32) + if ( !isIntegerSlope( abs(intraPredAngle) ) ) { if( isLuma(channelType) ) { Pel p[4]; - const bool useCubicFilter = useISP ? ( width <= 8 ) : ( !useFilteredPredSamples || multiRefIdx > 0 ); + const bool useCubicFilter = !m_ipaParam.interpolationFlag; TFilterCoeff const * const f = (useCubicFilter) ? InterpolationFilter::getChromaFilterTable(deltaFract) : g_intraGaussFilter[deltaFract]; int refMainIndex = deltaInt + 1; @@ -726,51 +779,50 @@ void IntraPrediction::xPredIntraAng( const CPelBuf &pSrc, PelBuf &pDst, const Ch pDsty[x] = refMain[x + deltaInt + 1]; } } - const int numModes = 8; const int scale = ((g_aucLog2[width] - 2 + g_aucLog2[height] - 2 + 2) >> 2); CHECK(scale < 0 || scale > 31, "PDPC: scale < 0 || scale > 31"); - if( !useISP ) - { - if ((predMode == 2 || predMode == VDIA_IDX) && multiRefIdx == 0) + if (m_ipaParam.applyPDPC) { - int wT = 16 >> std::min(31, ((y << 1) >> scale)); - - for (int x = 0; x < width; x++) + if (m_ipaParam.intraPredAngle == 32) // intra prediction modes: 2 and VDIA { - int wL = 16 >> std::min(31, ((x << 1) >> scale)); - if (wT + wL == 0) break; + int wT = 16 >> std::min(31, ((y << 1) >> scale)); + + for (int x = 0; x < width; x++) + { + int wL = 16 >> std::min(31, ((x << 1) >> scale)); + if (wT + wL == 0) break; - int c = x + y + 1; - if (c >= 2 * height) { wL = 0; } - if (c >= 2 * width) { wT = 0; } - const Pel left = (wL != 0) ? refSide[c + 1] : 0; - const Pel top = (wT != 0) ? refMain[c + 1] : 0; + int c = x + y + 1; + if (c >= 2 * height) { wL = 0; } + if (c >= 2 * width) { wT = 0; } + const Pel left = (wL != 0) ? refSide[c + 1] : 0; + const Pel top = (wT != 0) ? refMain[c + 1] : 0; - pDsty[x] = ClipPel((wL * left + wT * top + (64 - wL - wT) * pDsty[x] + 32) >> 6, clpRng); + pDsty[x] = ClipPel((wL * left + wT * top + (64 - wL - wT) * pDsty[x] + 32) >> 6, clpRng); + } } - } - else if (((predMode >= VDIA_IDX - numModes && predMode != VDIA_IDX) || (predMode != 2 && predMode <= (2 + numModes))) && multiRefIdx == 0) - { - int invAngleSum0 = 2; - for (int x = 0; x < width; x++) + else { - invAngleSum0 += invAngle; - int deltaPos0 = invAngleSum0 >> 2; - int deltaFrac0 = deltaPos0 & 63; - int deltaInt0 = deltaPos0 >> 6; + int invAngleSum0 = 2; + for (int x = 0; x < width; x++) + { + invAngleSum0 += invAngle; + int deltaPos0 = invAngleSum0 >> 2; + int deltaFrac0 = deltaPos0 & 63; + int deltaInt0 = deltaPos0 >> 6; - int deltay = y + deltaInt0 + 1; - if (deltay >(bIsModeVer ? m_leftRefLength : m_topRefLength) - 1) break; + int deltay = y + deltaInt0 + 1; + if (deltay >(bIsModeVer ? m_leftRefLength : m_topRefLength) - 1) break; - int wL = 32 >> std::min(31, ((x << 1) >> scale)); - if (wL == 0) break; - Pel *p = refSide + deltay; + int wL = 32 >> std::min(31, ((x << 1) >> scale)); + if (wL == 0) break; + Pel *p = refSide + deltay; - Pel left = p[deltaFrac0 >> 5]; - pDsty[x] = ClipPel((wL * left + (64 - wL) * pDsty[x] + 32) >> 6, clpRng); + Pel left = p[deltaFrac0 >> 5]; + pDsty[x] = ClipPel((wL * left + (64 - wL) * pDsty[x] + 32) >> 6, clpRng); + } } } - } } #if HEVC_USE_HOR_VER_PREDFILTERING if( edgeFilter && absAng <= 1 ) @@ -907,15 +959,14 @@ void IntraPrediction::geneIntrainterPred(const CodingUnit &cu) const PredictionUnit* pu = cu.firstPU; - bool isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, *pu, true, *pu); - initIntraPatternChType(cu, pu->Y(), isUseFilter); - predIntraAng(COMPONENT_Y, cu.cs->getPredBuf(*pu).Y(), *pu, isUseFilter); - isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Cb, *pu, true, *pu); - initIntraPatternChType(cu, pu->Cb(), isUseFilter); - predIntraAng(COMPONENT_Cb, cu.cs->getPredBuf(*pu).Cb(), *pu, isUseFilter); - isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Cr, *pu, true, *pu); - initIntraPatternChType(cu, pu->Cr(), isUseFilter); - predIntraAng(COMPONENT_Cr, cu.cs->getPredBuf(*pu).Cr(), *pu, isUseFilter); + initIntraPatternChType(cu, pu->Y()); + predIntraAng(COMPONENT_Y, cu.cs->getPredBuf(*pu).Y(), *pu); + + initIntraPatternChType(cu, pu->Cb()); + predIntraAng(COMPONENT_Cb, cu.cs->getPredBuf(*pu).Cb(), *pu); + + initIntraPatternChType(cu, pu->Cr()); + predIntraAng(COMPONENT_Cr, cu.cs->getPredBuf(*pu).Cr(), *pu); for (int currCompID = 0; currCompID < 3; currCompID++) { @@ -931,10 +982,15 @@ inline int isLeftAvailable ( const CodingUnit &cu, const ChannelType &chT inline int isAboveRightAvailable ( const CodingUnit &cu, const ChannelType &chType, const Position &posRT, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *validFlags ); inline int isBelowLeftAvailable ( const CodingUnit &cu, const ChannelType &chType, const Position &posLB, const uint32_t uiNumUnitsInPU, const uint32_t unitHeight, bool *validFlags ); -void IntraPrediction::initIntraPatternChType(const CodingUnit &cu, const CompArea &area, const bool bFilterRefSamples) +void IntraPrediction::initIntraPatternChType(const CodingUnit &cu, const CompArea &area, const bool forceRefFilterFlag) { const CodingStructure& cs = *cu.cs; + if (!forceRefFilterFlag) + { + initPredIntraParams(*cu.firstPU, area, *cs.sps); + } + Pel *refBufUnfiltered = m_piYuvExt[area.compID][PRED_BUF_UNFILTERED]; Pel *refBufFiltered = m_piYuvExt[area.compID][PRED_BUF_FILTERED]; @@ -943,11 +999,9 @@ void IntraPrediction::initIntraPatternChType(const CodingUnit &cu, const CompAre // ----- Step 1: unfiltered reference samples ----- xFillReferenceSamples( cs.picture->getRecoBuf( area ), refBufUnfiltered, area, cu ); // ----- Step 2: filtered reference samples ----- - if( bFilterRefSamples ) + if( m_ipaParam.refFilterFlag || forceRefFilterFlag ) { - xFilterReferenceSamples( refBufUnfiltered, refBufFiltered, area, *cs.sps - , cu.firstPU->multiRefIdx - ); + xFilterReferenceSamples( refBufUnfiltered, refBufFiltered, area, *cs.sps, cu.firstPU->multiRefIdx ); } } diff --git a/source/Lib/CommonLib/IntraPrediction.h b/source/Lib/CommonLib/IntraPrediction.h index 22a2af108d4bcd2c6549a2758e2d4b08322a3c69..f8d1e5fe9dce8d710f571750ef28835c20e3a6dd 100644 --- a/source/Lib/CommonLib/IntraPrediction.h +++ b/source/Lib/CommonLib/IntraPrediction.h @@ -74,6 +74,32 @@ private: static const uint8_t m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS]; + struct IntraPredParam //parameters of Intra Prediction + { + bool refFilterFlag; + bool applyPDPC; + bool isModeVer; + int multiRefIndex; + int whRatio; + int hwRatio; + int intraPredAngle; + int invAngle; + bool interpolationFlag; + + IntraPredParam() : + refFilterFlag ( false ), + applyPDPC ( false ), + isModeVer ( false ), + multiRefIndex ( -1 ), + whRatio ( 0 ), + hwRatio ( 0 ), + intraPredAngle ( std::numeric_limits<int>::max() ), + invAngle ( std::numeric_limits<int>::max() ), + interpolationFlag ( false ) {} + }; + + IntraPredParam m_ipaParam; + Pel* m_piTemp; Pel* m_pMdlmTemp; // for MDLM mode protected: @@ -83,19 +109,14 @@ protected: int m_topRefLength; int m_leftRefLength; // prediction - void xPredIntraPlanar ( const CPelBuf &pSrc, PelBuf &pDst, const SPS& sps ); - void xPredIntraDc ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const bool enableBoundaryFilter = true ); -#if HEVC_USE_HOR_VER_PREDFILTERING - void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const bool bEnableEdgeFilters, const SPS& sps - , int multiRefIdx - , const bool enableBoundaryFilter = true ); -#else - void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const uint32_t dirMode, const ClpRng& clpRng, const SPS& sps, - int multiRefIdx, - const bool useFilteredPredSamples, - const bool useISP = false, - const Size cuSize = Size( 0, 0 ) ); -#endif + void xPredIntraPlanar ( const CPelBuf &pSrc, PelBuf &pDst ); + void xPredIntraDc ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const bool enableBoundaryFilter = true ); + void xPredIntraAng ( const CPelBuf &pSrc, PelBuf &pDst, const ChannelType channelType, const ClpRng& clpRng); + + void initPredIntraParams ( const PredictionUnit & pu, const CompArea compArea, const SPS& sps ); + + static bool isIntegerSlope ( const int absAng ) { return (0 == (absAng & 0x1F)) && absAng <=32; } // integer-slope modes 2, DIA_IDX and VDIA_IDX. "absAng <=32" restricts wide-angle integer modes + Pel xGetPredValDc ( const CPelBuf &pSrc, const Size &dstSize ); void xFillReferenceSamples ( const CPelBuf &recoBuf, Pel* refBufUnfiltered, const CompArea &area, const CodingUnit &cu ); @@ -121,13 +142,14 @@ public: void init (ChromaFormat chromaFormatIDC, const unsigned bitDepthY); // Angular Intra - void predIntraAng ( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu, const bool useFilteredPredSamples ); - Pel* getPredictorPtr (const ComponentID compID, const bool bUseFilteredPredictions = false) { return m_piYuvExt[compID][bUseFilteredPredictions?PRED_BUF_FILTERED:PRED_BUF_UNFILTERED]; } + void predIntraAng ( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu); + Pel* getPredictorPtr ( const ComponentID compId ) { return m_piYuvExt[compId][m_ipaParam.refFilterFlag ? PRED_BUF_FILTERED : PRED_BUF_UNFILTERED]; } + // Cross-component Chroma void predIntraChromaLM(const ComponentID compID, PelBuf &piPred, const PredictionUnit &pu, const CompArea& chromaArea, int intraDir); void xGetLumaRecPixels(const PredictionUnit &pu, CompArea chromaArea); /// set parameters from CU data for accessing intra data - void initIntraPatternChType (const CodingUnit &cu, const CompArea &area, const bool bFilterRefSamples = false ); + void initIntraPatternChType (const CodingUnit &cu, const CompArea &area, const bool forceRefFilterFlag = false); // use forceRefFilterFlag to get both filtered and unfiltered buffers static bool useFilteredIntraRefSamples( const ComponentID &compID, const PredictionUnit &pu, bool modeSpecific, const UnitArea &tuArea ); static bool useDPCMForFirstPassIntraEstimation(const PredictionUnit &pu, const uint32_t &uiDirMode); diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 4e2a4f03376b5894b135f7ae816f5695597635e4..cdc5fa930fb9418b144694b2a70e39fe12fdcc58 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -269,6 +269,20 @@ uint32_t deriveWeightIdxBits(uint8_t gbiIdx) // Note: align this with TEncSbac:: return numBits; } +#if JVET_N0103_CGSIZE_HARMONIZATION +uint32_t g_log2SbbSize[MAX_CU_DEPTH + 1][MAX_CU_DEPTH + 1][2] = +//===== luma/chroma ===== +{ + { { 0,0 },{ 0,1 },{ 0,2 },{ 0,3 },{ 0,4 },{ 0,4 },{ 0,4 },{ 0,4 } }, + { { 1,0 },{ 1,1 },{ 1,1 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 },{ 1,3 } }, + { { 2,0 },{ 1,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 3,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } }, + { { 4,0 },{ 3,1 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 },{ 2,2 } } +}; +#else uint32_t g_log2SbbSize[2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2] = { //===== luma ===== @@ -294,6 +308,7 @@ uint32_t g_log2SbbSize[2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2] = { {0,0}, {1,1}, {2,2}, {2,2}, {2,2}, {2,2}, {2,2}, {2,2} } }, }; +#endif // initialize ROM variables void initROM() { @@ -325,8 +340,10 @@ void initROM() SizeIndexInfoLog2 sizeInfo; sizeInfo.init(MAX_CU_SIZE); +#if !JVET_N0103_CGSIZE_HARMONIZATION for( int ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ ) { +#endif // initialize scan orders for (uint32_t blockHeightIdx = 0; blockHeightIdx < sizeInfo.numAllHeights(); blockHeightIdx++) { @@ -350,7 +367,11 @@ void initROM() scan = new ScanElement[totalValues]; } +#if JVET_N0103_CGSIZE_HARMONIZATION + g_scanOrder[SCAN_UNGROUPED][scanType][blockWidthIdx][blockHeightIdx] = scan; +#else g_scanOrder[ch][SCAN_UNGROUPED][scanType][blockWidthIdx][blockHeightIdx] = scan; +#endif if (scan == nullptr) { @@ -374,7 +395,11 @@ void initROM() //-------------------------------------------------------------------------------------------------- //grouped scan orders +#if JVET_N0103_CGSIZE_HARMONIZATION + const uint32_t* log2Sbb = g_log2SbbSize[g_aucLog2[blockWidth]][g_aucLog2[blockHeight]]; +#else const uint32_t* log2Sbb = g_log2SbbSize[ch][ g_aucLog2[blockWidth] ][ g_aucLog2[blockHeight] ]; +#endif const uint32_t log2CGWidth = log2Sbb[0]; const uint32_t log2CGHeight = log2Sbb[1]; @@ -392,7 +417,11 @@ void initROM() ScanElement *scan = new ScanElement[totalValues]; +#if JVET_N0103_CGSIZE_HARMONIZATION + g_scanOrder[SCAN_GROUPED_4x4][scanType][blockWidthIdx][blockHeightIdx] = scan; +#else g_scanOrder[ch][SCAN_GROUPED_4x4][scanType][blockWidthIdx][blockHeightIdx] = scan; +#endif if ( blockWidth > JVET_C0024_ZERO_OUT_TH || blockHeight > JVET_C0024_ZERO_OUT_TH ) { @@ -434,7 +463,9 @@ void initROM() //-------------------------------------------------------------------------------------------------- } } +#if !JVET_N0103_CGSIZE_HARMONIZATION } +#endif for( int idxH = MAX_CU_DEPTH - MIN_CU_LOG2; idxH >= 0; --idxH ) { @@ -464,6 +495,22 @@ void destroyROM() unsigned numWidths = gp_sizeIdxInfo->numAllWidths(); unsigned numHeights = gp_sizeIdxInfo->numAllHeights(); +#if JVET_N0103_CGSIZE_HARMONIZATION + for (uint32_t groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++) + { + for (uint32_t scanOrderIndex = 0; scanOrderIndex < SCAN_NUMBER_OF_TYPES; scanOrderIndex++) + { + for (uint32_t blockWidthIdx = 0; blockWidthIdx <= numWidths; blockWidthIdx++) + { + for (uint32_t blockHeightIdx = 0; blockHeightIdx <= numHeights; blockHeightIdx++) + { + delete[] g_scanOrder[groupTypeIndex][scanOrderIndex][blockWidthIdx][blockHeightIdx]; + g_scanOrder[groupTypeIndex][scanOrderIndex][blockWidthIdx][blockHeightIdx] = nullptr; + } + } + } + } +#else for( uint32_t ch = 0; ch < MAX_NUM_CHANNEL_TYPE; ch++ ) { for( uint32_t groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++ ) @@ -481,6 +528,7 @@ void destroyROM() } } } +#endif delete gp_sizeIdxInfo; gp_sizeIdxInfo = nullptr; @@ -574,7 +622,11 @@ UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 ); // ==================================================================================================================== // scanning order table +#if JVET_N0103_CGSIZE_HARMONIZATION +ScanElement *g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1]; +#else ScanElement *g_scanOrder[2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1]; +#endif const uint32_t g_uiMinInGroup[LAST_SIGNIFICANT_GROUPS] = { 0,1,2,3,4,6,8,12,16,24,32,48,64,96 }; const uint32_t g_uiGroupIdx[MAX_TB_SIZEY] = { 0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9, 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11 }; diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index d896d304dda40320bfb3a39b13f4fa3991d5c397..d23aca95df3bf80404c4f292f986c79b3937049d 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -67,9 +67,15 @@ struct ScanElement uint16_t y; }; +#if JVET_N0103_CGSIZE_HARMONIZATION +extern uint32_t g_log2SbbSize[MAX_CU_DEPTH + 1][MAX_CU_DEPTH + 1][2]; +extern ScanElement + *g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1]; +#else extern uint32_t g_log2SbbSize [2][MAX_CU_DEPTH+1][MAX_CU_DEPTH+1][2]; extern ScanElement *g_scanOrder[2][SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][MAX_CU_SIZE / 2 + 1][MAX_CU_SIZE / 2 + 1]; +#endif extern const int g_quantScales [SCALING_LIST_REM_NUM]; // Q(QP%6) extern const int g_invQuantScales[SCALING_LIST_REM_NUM]; // IQ(QP%6) diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index a9e66f83670b022a66890cb810073ebdf93cec12..a3e4377f30b8c74151575244766399d76e9f4e43 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,6 +50,8 @@ #include <assert.h> #include <cassert> +#define JVET_N0103_CGSIZE_HARMONIZATION 1 // Chroma CG sizes aligned to luma CG sizes + #define JVET_N0146_DMVR_BDOF_CONDITION 1 // JVET-N146/N0162/N0442/N0153/N0262/N0440/N0086 applicable condition of DMVR and BDOF #define JVET_N0470_SMVD_FIX 1 // remove mvd_l1_zero_flag condition, align to spec text. diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index a32adca2e5a03e3de50281074b9b47f32cba77ba..9165a9be148be034d34fa4b21de9f8b6307d8618 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -188,9 +188,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) const uint32_t uiChFinalMode = PU::getFinalIntraMode( pu, chType ); //===== init availability pattern ===== - - const bool bUseFilteredPredictions = IntraPrediction::useFilteredIntraRefSamples( compID, pu, true, tu ); - m_pcIntraPred->initIntraPatternChType( *tu.cu, area, bUseFilteredPredictions ); + m_pcIntraPred->initIntraPatternChType( *tu.cu, area); //===== get prediction signal ===== if( compID != COMPONENT_Y && PU::isLMCMode( uiChFinalMode ) ) @@ -201,7 +199,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) } else { - m_pcIntraPred->predIntraAng( compID, piPred, pu, bUseFilteredPredictions ); + m_pcIntraPred->predIntraAng( compID, piPred, pu ); } const Slice &slice = *cs.slice; bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 3d0f61a4d6f3d8f00d75f1983f66648a32cfb14d..fa55a4a19c3d52471529624af24640382fcf8220 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1933,9 +1933,8 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& // generate intrainter Y prediction if (mergeCnt == 0) { - bool isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, pu, true, pu); - m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Y(), isUseFilter); - m_pcIntraSearch->predIntraAng(COMPONENT_Y, pu.cs->getPredBuf(pu).Y(), pu, isUseFilter); + m_pcIntraSearch->initIntraPatternChType( *pu.cu, pu.Y()); + m_pcIntraSearch->predIntraAng(COMPONENT_Y, pu.cs->getPredBuf(pu).Y(), pu); m_pcIntraSearch->switchBuffer(pu, COMPONENT_Y, pu.cs->getPredBuf(pu).Y(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Y, intraCnt)); } pu.cs->getPredBuf(pu).copyFrom(acMergeBuffer[mergeCand]); @@ -2067,14 +2066,14 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& pu.intraDir[0] = RdModeList2[mergeCnt]; pu.intraDir[1] = DM_CHROMA_IDX; uint32_t bufIdx = (pu.intraDir[0] > 1) ? (pu.intraDir[0] == HOR_IDX ? 2 : 3) : pu.intraDir[0]; - bool isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Cb, pu, true, pu); - m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Cb(), isUseFilter); - m_pcIntraSearch->predIntraAng(COMPONENT_Cb, pu.cs->getPredBuf(pu).Cb(), pu, isUseFilter); + + m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Cb()); + m_pcIntraSearch->predIntraAng(COMPONENT_Cb, pu.cs->getPredBuf(pu).Cb(), pu); m_pcIntraSearch->switchBuffer(pu, COMPONENT_Cb, pu.cs->getPredBuf(pu).Cb(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Cb, bufIdx)); - isUseFilter = IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Cr, pu, true, pu); - m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Cr(), isUseFilter); - m_pcIntraSearch->predIntraAng(COMPONENT_Cr, pu.cs->getPredBuf(pu).Cr(), pu, isUseFilter); - m_pcIntraSearch->switchBuffer(pu, COMPONENT_Cr, pu.cs->getPredBuf(pu).Cr(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Cr, bufIdx)); + + m_pcIntraSearch->initIntraPatternChType(*pu.cu, pu.Cr()); + m_pcIntraSearch->predIntraAng(COMPONENT_Cr, pu.cs->getPredBuf(pu).Cr(), pu); + m_pcIntraSearch->switchBuffer(pu, COMPONENT_Cr, pu.cs->getPredBuf(pu).Cr(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Cr, bufIdx)); } } pu.mhIntraFlag = false; diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index 258b886a858bc79400b10719a12c54bf76f34c9f..a1817bf964c2af31427d7bfa5b0c3c9bbb62d805 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -383,7 +383,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, pu.multiRefIdx = 0; //===== init pattern for luma prediction ===== - initIntraPatternChType( cu, pu.Y(), IntraPrediction::useFilteredIntraRefSamples( COMPONENT_Y, pu, false, pu ) ); + initIntraPatternChType( cu, pu.Y(), true); if( numModesForFullRD != numModesAvailable ) { CHECK( numModesForFullRD >= numModesAvailable, "Too many modes for full RD search" ); @@ -451,13 +451,14 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, pu.intraDir[0] = modeIdx; + initPredIntraParams(pu, pu.Y(), sps); if( useDPCMForFirstPassIntraEstimation( pu, uiMode ) ) { encPredIntraDPCM( COMPONENT_Y, piOrg, piPred, uiMode ); } else { - predIntraAng( COMPONENT_Y, piPred, pu, IntraPrediction::useFilteredIntraRefSamples( COMPONENT_Y, pu, true, pu ) ); + predIntraAng( COMPONENT_Y, piPred, pu); } #if JVET_N0363_INTRA_COST_MOD // Use the min between SAD and HAD as the cost criterion @@ -510,14 +511,14 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, { pu.intraDir[0] = mode; + initPredIntraParams(pu, pu.Y(), sps); if (useDPCMForFirstPassIntraEstimation(pu, mode)) { encPredIntraDPCM(COMPONENT_Y, piOrg, piPred, mode); } else { - predIntraAng(COMPONENT_Y, piPred, pu, - IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, pu, true, pu)); + predIntraAng(COMPONENT_Y, piPred, pu ); } #if JVET_N0363_INTRA_COST_MOD @@ -567,7 +568,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, pu.multiRefIdx = multiRefIdx; { - initIntraPatternChType(cu, pu.Y(), IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, pu, false, pu)); + initIntraPatternChType(cu, pu.Y(), true); } #if JVET_N0185_UNIFIED_MPM for (int x = 1; x < numMPMs; x++) @@ -578,6 +579,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, uint32_t mode = multiRefMPM[x]; { pu.intraDir[0] = mode; + initPredIntraParams(pu, pu.Y(), sps); if (useDPCMForFirstPassIntraEstimation(pu, mode)) { @@ -585,7 +587,7 @@ void IntraSearch::estIntraPredLumaQT( CodingUnit &cu, Partitioner &partitioner, } else { - predIntraAng(COMPONENT_Y, piPred, pu, IntraPrediction::useFilteredIntraRefSamples(COMPONENT_Y, pu, true, pu)); + predIntraAng(COMPONENT_Y, piPred, pu); } #if JVET_N0363_INTRA_COST_MOD @@ -1062,7 +1064,8 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner } else { - predIntraAng(COMPONENT_Cb, predCb, pu, false); + initPredIntraParams(pu, pu.Cb(), *pu.cs->sps); + predIntraAng(COMPONENT_Cb, predCb, pu); } sad += distParam.distFunc(distParam); @@ -1080,7 +1083,8 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner } else { - predIntraAng(COMPONENT_Cr, predCr, pu, false); + initPredIntraParams(pu, pu.Cr(), *pu.cs->sps); + predIntraAng(COMPONENT_Cr, predCr, pu); } sad += distParam.distFunc(distParam); satdSortedCost[idx] = sad; @@ -1616,8 +1620,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp PelBuf sharedPredTS( m_pSharedPredTransformSkip[compID], area ); if( default0Save1Load2 != 2 ) { - const bool bUseFilteredPredictions = IntraPrediction::useFilteredIntraRefSamples( compID, pu, true, tu ); - initIntraPatternChType( *tu.cu, area, bUseFilteredPredictions ); + initIntraPatternChType( *tu.cu, area ); //===== get prediction signal ===== if( compID != COMPONENT_Y && PU::isLMCMode( uiChFinalMode ) ) @@ -1629,7 +1632,7 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp } else { - predIntraAng( compID, piPred, pu, bUseFilteredPredictions ); + predIntraAng( compID, piPred, pu ); } @@ -2251,14 +2254,12 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio // Do predictions here to avoid repeating the "default0Save1Load2" stuff int predMode = PU::getFinalIntraMode( pu, CHANNEL_TYPE_CHROMA ); - bool refFiltCb = IntraPrediction::useFilteredIntraRefSamples( COMPONENT_Cb, pu, true, currTU ); - bool refFiltCr = IntraPrediction::useFilteredIntraRefSamples( COMPONENT_Cr, pu, true, currTU ); PelBuf piPredCb = cs.getPredBuf(cbArea); PelBuf piPredCr = cs.getPredBuf(crArea); - initIntraPatternChType( *currTU.cu, cbArea, refFiltCb ); - initIntraPatternChType( *currTU.cu, crArea, refFiltCr ); + initIntraPatternChType( *currTU.cu, cbArea); + initIntraPatternChType( *currTU.cu, crArea); if( PU::isLMCMode( predMode ) ) { @@ -2268,8 +2269,8 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio } else { - predIntraAng( COMPONENT_Cb, piPredCb, pu, refFiltCb ); - predIntraAng( COMPONENT_Cr, piPredCr, pu, refFiltCr ); + predIntraAng( COMPONENT_Cb, piPredCb, pu); + predIntraAng( COMPONENT_Cr, piPredCr, pu); } #endif