diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 1e35ab2fa557689283adec96e6724e730d556044..629b23511b892ff9d5601b501b3d368b55daa73b 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -457,7 +457,7 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) if (!m_reconFileName.empty()) { - const Window &conf = pcPic->cs->pps->getConformanceWindow(); + const Window &conf = pcPic->getConformanceWindow(); const SPS* sps = pcPic->cs->sps; ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc(); if( m_upscaledOutput ) @@ -581,7 +581,7 @@ void DecApp::xFlushOutput( PicList* pcListPic ) if (!m_reconFileName.empty()) { - const Window &conf = pcPic->cs->pps->getConformanceWindow(); + const Window &conf = pcPic->getConformanceWindow(); const SPS* sps = pcPic->cs->sps; ChromaFormat chromaFormatIDC = sps->getChromaFormatIdc(); if( m_upscaledOutput ) diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index 5ed8333002d80b4ae4e400646f4d59b200351e67..0590804d633d3fcfee397aed3384f735738b8b81 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -860,7 +860,7 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio enablePROF &= !subblkMVSpreadOverLimit; const int profThres = 1 << (iBit + (m_isBi ? 1 : 0)); enablePROF &= !m_encOnly || pu.cu->slice->getCheckLDC() || iDMvHorX > profThres || iDMvHorY > profThres || iDMvVerX > profThres || iDMvVerY > profThres || iDMvHorX < -profThres || iDMvHorY < -profThres || iDMvVerX < -profThres || iDMvVerY < -profThres; - enablePROF &= pu.cs->pps->getPicWidthInLumaSamples() == refPic->cs->pps->getPicWidthInLumaSamples() && pu.cs->pps->getPicHeightInLumaSamples() == refPic->cs->pps->getPicHeightInLumaSamples(); + enablePROF &= pu.cs->pps->getPicWidthInLumaSamples() == refPic->getPicWidthInLumaSamples() && pu.cs->pps->getPicHeightInLumaSamples() == refPic->getPicHeightInLumaSamples(); if (compID == COMPONENT_Y) { @@ -2358,8 +2358,8 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, if( scaled ) { int row, col; - int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = refPic->getPicWidthInLumaSamples(); + int refPicHeight = refPic->getPicHeightInLumaSamples(); #if JVET_P0088_P0353_RPR_FILTERS int xFilter = filterIndex; diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 9c8c5d24624356224e1b22dcd6d952ba84bdf4cc..e352118b9c7860092a3234e37a47457840544ff5 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -296,6 +296,19 @@ public: std::deque<Slice*> slices; SEIMessages SEIs; + uint32_t m_picWidthInLumaSamples; + uint32_t m_picHeightInLumaSamples; + Window m_conformanceWindow; + + void setPicWidthInLumaSamples( uint32_t u ) { m_picWidthInLumaSamples = u; } + uint32_t getPicWidthInLumaSamples() const { return m_picWidthInLumaSamples; } + void setPicHeightInLumaSamples( uint32_t u ) { m_picHeightInLumaSamples = u; } + uint32_t getPicHeightInLumaSamples() const { return m_picHeightInLumaSamples; } + + Window& getConformanceWindow() { return m_conformanceWindow; } + const Window& getConformanceWindow() const { return m_conformanceWindow; } + void setConformanceWindow( Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; } + void allocateNewSlice(); Slice *swapSliceObject(Slice * p, uint32_t i); void clearSliceBuffer(); diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 3b1548a506952bc866086713434fad873140e3b4..2890f78484c663b46ce661b2a791b09beb020ad3 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -2527,7 +2527,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], APS** apss, APS* lmcsAps, // reference resampling for the whole picture is not applied at decoder int xScale, yScale; - CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx]->slices[0]->getPPS(), xScale, yScale ); + CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx], xScale, yScale ); m_scalingRatio[refList][rIdx] = std::pair<int, int>( xScale, yScale ); if( m_scalingRatio[refList][rIdx] == SCALE_1X || isDecoder ) diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 467d56ecbe11baabb1f5ca2b7a8317be905b69dc..2ca98de92fde125f01a050cdd88d5fc8b6488a95 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -100,14 +100,14 @@ void CS::setRefinedMotionField(CodingStructure &cs) } // CU tools -bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, const PPS* refPPS, int& xScale, int& yScale ) +bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ) { const Window& curConfWindow = curPPS->getConformanceWindow(); int curPicWidth = curPPS->getPicWidthInLumaSamples() - (curConfWindow.getWindowLeftOffset() + curConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); int curPicHeight = curPPS->getPicHeightInLumaSamples() - (curConfWindow.getWindowTopOffset() + curConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); - const Window& refConfWindow = refPPS->getConformanceWindow(); - int refPicWidth = refPPS->getPicWidthInLumaSamples() - (refConfWindow.getWindowLeftOffset() + refConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); - int refPicHeight = refPPS->getPicHeightInLumaSamples() - (refConfWindow.getWindowTopOffset() + refConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); + const Window& refConfWindow = refPic->getConformanceWindow(); + int refPicWidth = refPic->getPicWidthInLumaSamples() - (refConfWindow.getWindowLeftOffset() + refConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); + int refPicHeight = refPic->getPicHeightInLumaSamples() - (refConfWindow.getWindowTopOffset() + refConfWindow.getWindowBottomOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; @@ -3920,16 +3920,16 @@ bool PU::isRefPicSameSize( const PredictionUnit& pu ) if( pu.refIdx[0] >= 0 ) { - int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->getPicWidthInLumaSamples(); + int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_0, pu.refIdx[0] )->getPicHeightInLumaSamples(); samePicSize = refPicWidth == curPicWidth && refPicHeight == curPicHeight; } if( pu.refIdx[1] >= 0 ) { - int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->getPicWidthInLumaSamples(); + int refPicHeight = pu.cu->slice->getRefPic( REF_PIC_LIST_1, pu.refIdx[1] )->getPicHeightInLumaSamples(); samePicSize = samePicSize && ( refPicWidth == curPicWidth && refPicHeight == curPicHeight ); } diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index d9445e937802f71f9d4276a673d7d4d17376dff3..a1c766ff382a35bb7b2a6ef16892523d363d5a5d 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -119,7 +119,7 @@ namespace CU uint8_t numSbtModeRdo (uint8_t sbtAllowed); bool isSbtMode (const uint8_t sbtInfo); bool isSameSbtSize (const uint8_t sbtInfo1, const uint8_t sbtInfo2); - bool getRprScaling ( const SPS* sps, const PPS* curPPS, const PPS* refPPS, int& xScale, int& yScale ); + bool getRprScaling ( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ); } // PU tools namespace PU diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index e8f2871708dea749dee60c835f271db78ce6c602..58b680f472034e721f325330d8228222af96004f 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -922,6 +922,12 @@ void DecLib::xActivateParameterSets() m_pcPic->cs->slice = pSlice; m_pcPic->cs->sps = sps; m_pcPic->cs->pps = pps; + + Window confWin = pps->getConformanceWindow( ); + m_pcPic->setPicWidthInLumaSamples( pps->getPicWidthInLumaSamples() ); + m_pcPic->setPicHeightInLumaSamples( pps->getPicHeightInLumaSamples() ); + m_pcPic->setConformanceWindow( confWin ); + memcpy(m_pcPic->cs->alfApss, apss, sizeof(m_pcPic->cs->alfApss)); m_pcPic->cs->lmcsAps = lmcsAPS; m_pcPic->cs->scalinglistAps = scalinglistAPS; diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index cfd0e5e35a1ecd6ce2d4a70da830dd78329e5280..4a29681e41dfc5feea13c07f29a1b7c17154a726 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -558,6 +558,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru const PPS *pps = m_ppsMap.getPS(2); const SPS *sps = m_spsMap.getPS(pps->getSPSId()); + Window confWin = pps->getConformanceWindow( ); + picCurr->setPicWidthInLumaSamples( pps->getPicWidthInLumaSamples() ); + picCurr->setPicHeightInLumaSamples( pps->getPicHeightInLumaSamples() ); + picCurr->setConformanceWindow( confWin ); + picCurr->M_BUFS(0, PIC_ORIGINAL).copyFrom(m_cGOPEncoder.getPicBg()->getRecoBuf()); picCurr->finalInit( *sps, *pps, m_apss, m_lmcsAPS, m_scalinglistAPS ); picCurr->poc = m_iPOCLast - 1; @@ -619,6 +624,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru const PPS *pPPS=(ppsID<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsID); const SPS *pSPS=m_spsMap.getPS(pPPS->getSPSId()); + Window confWin = pPPS->getConformanceWindow( ); + pcPicCurr->setPicWidthInLumaSamples( pPPS->getPicWidthInLumaSamples() ); + pcPicCurr->setPicHeightInLumaSamples( pPPS->getPicHeightInLumaSamples() ); + pcPicCurr->setConformanceWindow( confWin ); + if( m_rprEnabled ) { pcPicCurr->M_BUFS( 0, PIC_ORIGINAL_INPUT ).getBuf( COMPONENT_Y ).copyFrom( pcPicYuvOrg->getBuf( COMPONENT_Y ) ); @@ -740,6 +750,11 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* pcPicYuvTr int ppsID=-1; // Use default PPS ID const PPS *pPPS=(ppsID<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsID); const SPS *pSPS=m_spsMap.getPS(pPPS->getSPSId()); + Window confWin = pPPS->getConformanceWindow( ); + pcField->setPicWidthInLumaSamples( pPPS->getPicWidthInLumaSamples() ); + pcField->setPicHeightInLumaSamples( pPPS->getPicHeightInLumaSamples() ); + pcField->setConformanceWindow( confWin ); + pcField->finalInit( *pSPS, *pPPS, m_apss, m_lmcsAPS, m_scalinglistAPS ); }