diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index c42ec4f9b2c843444b231f544c499dd2131ec1e7..bb88024b6fcc439a3f0c79f7999a20d68168c5e4 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -538,6 +538,9 @@ static const int EPBIN_WEIGHT_FACTOR = 4; #endif #if JVET_O1164_RPR static const int ENC_PPS_ID_RPR = 3; +static const int SCALE_RATIO_BITS = 14; +static const int MAX_SCALING_RATIO = 8; // max scaling ratio allowed in the software, it is used to allocated an internla buffer in the rescaling +static const std::pair<int, int> SCALE_1X = std::pair<int, int>( 1 << SCALE_RATIO_BITS, 1 << SCALE_RATIO_BITS ); // scale ratio 1x #endif // ==================================================================================================================== diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index 538373017c97932f074e0bf809e6d1fae202302c..a1645c62555b6910d22164fcc3c3565640a30bca 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -487,7 +487,7 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& m_iRefListIdx = eRefPicList; #endif #if JVET_O1164_RPR - xPredAffineBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx )->unscaledPic, mv, pcYuvPred, bi, pu.cu->slice->clpRng( compID ) ); + xPredAffineBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx )->unscaledPic, mv, pcYuvPred, bi, pu.cu->slice->clpRng( compID ), pu.cu->slice->getScalingRatio( eRefPicList, iRefIdx )); #else xPredAffineBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx ), mv, pcYuvPred, bi, pu.cu->slice->clpRng( compID ) ); #endif @@ -504,7 +504,7 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& else { #if JVET_O1164_RPR - xPredInterBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx )->unscaledPic, mv[0], pcYuvPred, bi, pu.cu->slice->clpRng( compID ), bioApplied, isIBC ); + xPredInterBlk( compID, pu, pu.cu->slice->getRefPic( eRefPicList, iRefIdx )->unscaledPic, mv[0], pcYuvPred, bi, pu.cu->slice->clpRng( compID ), bioApplied, isIBC, pu.cu->slice->getScalingRatio( eRefPicList, iRefIdx ) ); #else xPredInterBlk(compID, pu, pu.cu->slice->getRefPic(eRefPicList, iRefIdx), mv[0], pcYuvPred, bi, pu.cu->slice->clpRng(compID) , bioApplied @@ -691,6 +691,9 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred) void InterPrediction::xPredInterBlk ( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng , const bool& bioApplied , bool isIBC +#if JVET_O1164_RPR + , const std::pair<int, int> scalingRatio +#endif , SizeType dmvrWidth , SizeType dmvrHeight , bool bilinearMC @@ -717,7 +720,7 @@ void InterPrediction::xPredInterBlk ( const ComponentID& compID, const Predictio } #if JVET_O1164_RPR - if( xPredInterBlkRPR( compID, pu, refPic, mv, dstPic, bi, wrapRef, clpRng ) ) + if( !isIBC && xPredInterBlkRPR( scalingRatio, compID, pu, refPic, mv, dstPic, bi, wrapRef, clpRng ) ) { CHECK( bilinearMC, "DMVR should be disabled with RPR" ); CHECK( bioApplied, "BDOF should be disabled with RPR" ); @@ -915,7 +918,12 @@ bool InterPrediction::isSubblockVectorSpreadOverLimit( int a, int b, int c, int } return false; } + +#if JVET_O1164_RPR +void InterPrediction::xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng, const std::pair<int, int> scalingRatio ) +#else void InterPrediction::xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng ) +#endif { JVET_J0090_SET_REF_PICTURE( refPic, compID ); @@ -1142,7 +1150,7 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio } #if JVET_O1164_RPR - if( xPredInterBlkRPR( compID, pu, refPic, Mv( iMvScaleTmpHor, iMvScaleTmpVer ), dstPic, bi, wrapRef, clpRng ) ) + if( xPredInterBlkRPR( scalingRatio, compID, pu, refPic, Mv( iMvScaleTmpHor, iMvScaleTmpVer ), dstPic, bi, wrapRef, clpRng ) ) { CHECK( enablePROF, "PROF should be disabled with RPR" ); } @@ -2425,8 +2433,14 @@ void InterPrediction::xFinalPaddedMCForDMVR(PredictionUnit& pu, PelUnitBuf &pcYu offset += (deltaIntMvX); srcBufPelPtr = (srcBuf.buf + offset); } + +#if JVET_O1164_RPR + xPredInterBlk( (ComponentID)compID, pu, refPic, cMvClipped, pcYUVTemp, true, pu.cs->slice->getClpRngs().comp[compID], + bioApplied, false, pu.cu->slice->getScalingRatio( refId, pu.refIdx[refId] ), 0, 0, 0, srcBufPelPtr, pcPadstride ); +#else xPredInterBlk((ComponentID)compID, pu, refPic, cMvClipped, pcYUVTemp, true, pu.cs->slice->getClpRngs().comp[compID], bioApplied, false, 0, 0, 0, srcBufPelPtr, pcPadstride); +#endif #else int mvshiftTemp = mvShift + getComponentScaleX((ComponentID)compID, pu.chromaFormat); int leftPixelExtra; @@ -2524,7 +2538,7 @@ void InterPrediction::xinitMC(PredictionUnit& pu, const ClpRngs &clpRngs) #if JVET_O1164_RPR xPredInterBlk( COMPONENT_Y, pu, pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->unscaledPic, mergeMVL0, yuvPredTempL0, true, clpRngs.comp[COMPONENT_Y], - false, false, pu.lwidth() + ( 2 * DMVR_NUM_ITERATION ), pu.lheight() + ( 2 * DMVR_NUM_ITERATION ), true, ( (Pel *)srcBuf.buf ) + offset, srcBuf.stride ); + false, false, pu.cu->slice->getScalingRatio( REF_PIC_LIST_0, refIdx0 ), pu.lwidth() + ( 2 * DMVR_NUM_ITERATION ), pu.lheight() + ( 2 * DMVR_NUM_ITERATION ), true, ( (Pel *)srcBuf.buf ) + offset, srcBuf.stride ); #else xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_0, refIdx0), mergeMVL0, yuvPredTempL0, true, clpRngs.comp[COMPONENT_Y], false, false, pu.lwidth() + (2 * DMVR_NUM_ITERATION), pu.lheight() + (2 * DMVR_NUM_ITERATION), true, ((Pel *)srcBuf.buf) + offset, srcBuf.stride @@ -2550,7 +2564,7 @@ void InterPrediction::xinitMC(PredictionUnit& pu, const ClpRngs &clpRngs) #if JVET_O1164_RPR xPredInterBlk( COMPONENT_Y, pu, pu.cu->slice->getRefPic( REF_PIC_LIST_1, refIdx1 )->unscaledPic, mergeMVL1, yuvPredTempL1, true, clpRngs.comp[COMPONENT_Y], - false, false, pu.lwidth() + ( 2 * DMVR_NUM_ITERATION ), pu.lheight() + ( 2 * DMVR_NUM_ITERATION ), true, ( (Pel *)srcBuf.buf ) + offset, srcBuf.stride ); + false, false, pu.cu->slice->getScalingRatio( REF_PIC_LIST_1, refIdx1 ), pu.lwidth() + ( 2 * DMVR_NUM_ITERATION ), pu.lheight() + ( 2 * DMVR_NUM_ITERATION ), true, ( (Pel *)srcBuf.buf ) + offset, srcBuf.stride ); #else xPredInterBlk(COMPONENT_Y, pu, pu.cu->slice->getRefPic(REF_PIC_LIST_1, refIdx1), mergeMVL1, yuvPredTempL1, true, clpRngs.comp[COMPONENT_Y], false, false, pu.lwidth() + (2 * DMVR_NUM_ITERATION), pu.lheight() + (2 * DMVR_NUM_ITERATION), true, ((Pel *)srcBuf.buf) + offset, srcBuf.stride @@ -2986,7 +3000,7 @@ bool InterPrediction::isLumaBvValid(const int ctuSize, const int xCb, const int #endif #if JVET_O1164_RPR -bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& mv, PelUnitBuf& dstPic, const bool bi, const bool wrapRef, const ClpRng& clpRng ) +bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& mv, PelUnitBuf& dstPic, const bool bi, const bool wrapRef, const ClpRng& clpRng ) { const ChromaFormat chFmt = pu.chromaFormat; const bool rndRes = !bi; @@ -2999,42 +3013,42 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict unsigned height = dstBuf.height; CPelBuf refBuf; + const bool scaled = scalingRatio != SCALE_1X; + + if( scaled ) + { + int row, col; + #if RPR_CONF_WINDOW - const Window& inputConfWindow = refPic->cs->pps->getConformanceWindow(); - int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples() - ( inputConfWindow.getWindowLeftOffset() + inputConfWindow.getWindowRightOffset() ) * SPS::getWinUnitX( pu.cs->sps->getChromaFormatIdc() ); - int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples() - ( inputConfWindow.getWindowTopOffset() + inputConfWindow.getWindowBottomOffset() ) * SPS::getWinUnitY( pu.cs->sps->getChromaFormatIdc() ); + const Window& inputConfWindow = refPic->cs->pps->getConformanceWindow(); + int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples() - ( inputConfWindow.getWindowLeftOffset() + inputConfWindow.getWindowRightOffset() ) * SPS::getWinUnitX( pu.cs->sps->getChromaFormatIdc() ); + int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples() - ( inputConfWindow.getWindowTopOffset() + inputConfWindow.getWindowBottomOffset() ) * SPS::getWinUnitY( pu.cs->sps->getChromaFormatIdc() ); #else - int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples(); + int refPicWidth = refPic->cs->pps->getPicWidthInLumaSamples(); + int refPicHeight = refPic->cs->pps->getPicHeightInLumaSamples(); #endif #if RPR_BUFFER #if RPR_CONF_WINDOW - const Window& curConfWindow = pu.cs->pps->getConformanceWindow(); - int curPicHeight = pu.cs->pps->getPicHeightInLumaSamples() - ( curConfWindow.getWindowTopOffset() + curConfWindow.getWindowBottomOffset() ) * SPS::getWinUnitY( pu.cs->sps->getChromaFormatIdc() ); + const Window& curConfWindow = pu.cs->pps->getConformanceWindow(); + int curPicHeight = pu.cs->pps->getPicHeightInLumaSamples() - ( curConfWindow.getWindowTopOffset() + curConfWindow.getWindowBottomOffset() ) * SPS::getWinUnitY( pu.cs->sps->getChromaFormatIdc() ); #else - int curPicHeight = pu.cs->pps->getPicHeightInLumaSamples(); + int curPicHeight = pu.cs->pps->getPicHeightInLumaSamples(); #endif #endif - int xScale, yScale; - bool scaled = CU::getRprScaling( pu.cs->sps, pu.cs->pps, refPic->cs->pps, xScale, yScale ); - - if( scaled ) - { - int row, col; - + const int posShift = SCALE_RATIO_BITS - 4; const ChromaFormat chFmt = pu.chromaFormat; - int stepX = ( xScale + 8 ) >> 4; - int stepY = ( yScale + 8 ) >> 4; + int stepX = ( scalingRatio.first + 8 ) >> 4; + int stepY = ( scalingRatio.second + 8 ) >> 4; int64_t x0Int; int64_t y0Int; - int offX = 1 << ( 10 - shiftHor - 1 ); - int offY = 1 << ( 10 - shiftVer - 1 ); + int offX = 1 << ( posShift - shiftHor - 1 ); + int offY = 1 << ( posShift - shiftVer - 1 ); - x0Int = ( ( pu.blocks[compID].pos().x << ( 4 + ::getComponentScaleX( compID, chFmt ) ) ) + mv.getHor() )* xScale; + x0Int = ( ( pu.blocks[compID].pos().x << ( 4 + ::getComponentScaleX( compID, chFmt ) ) ) + mv.getHor() )* scalingRatio.first; x0Int = SIGN( x0Int ) * ( ( llabs( x0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleX( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleX( compID, chFmt ) ) ); - y0Int = ( ( pu.blocks[compID].pos().y << ( 4 + ::getComponentScaleY( compID, chFmt ) ) ) + mv.getVer() )* yScale; + y0Int = ( ( pu.blocks[compID].pos().y << ( 4 + ::getComponentScaleY( compID, chFmt ) ) ) + mv.getVer() )* scalingRatio.second; y0Int = SIGN( y0Int ) * ( ( llabs( y0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleY( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleY( compID, chFmt ) ) ); #if RPR_BUFFER @@ -3045,14 +3059,16 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict int refHeight = ( height * refPicHeight ) / curPicHeight; refHeight = std::max<int>( 1, refHeight ); - Pel* buffer = new Pel[( MAX_CU_SIZE + 16 )*( std::max<int>( MAX_CU_SIZE, refHeight + vFilterSize - 1 + extSize ) + 16 )]; + CHECK( MAX_CU_SIZE * MAX_SCALING_RATIO < refHeight + vFilterSize - 1 + extSize, "Buffer size is not enough, increase MAX_SCALING_RATIO" ); + + Pel buffer[( MAX_CU_SIZE + 16 ) * ( MAX_CU_SIZE * MAX_SCALING_RATIO + 16 )]; int tmpStride = width; - int yInt0 = ( (int32_t)y0Int + offY ) >> 10; + int yInt0 = ( (int32_t)y0Int + offY ) >> posShift; yInt0 = std::min( std::max( 0, yInt0 ), ( refPicHeight >> ::getComponentScaleY( compID, chFmt ) ) ); - int xInt0 = ( (int32_t)x0Int + offX ) >> 10; + int xInt0 = ( (int32_t)x0Int + offX ) >> posShift; xInt0 = std::min( std::max( 0, xInt0 ), ( refPicWidth >> ::getComponentScaleX( compID, chFmt ) ) ); int xInt = 0, yInt = 0; @@ -3060,9 +3076,9 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict for( col = 0; col < width; col++ ) { int posX = (int32_t)x0Int + col * stepX; - xInt = ( posX + offX ) >> 10; + xInt = ( posX + offX ) >> posShift; xInt = std::min( std::max( 0, xInt ), ( refPicWidth >> ::getComponentScaleX( compID, chFmt ) ) ); - int xFrac = ( ( posX + offX ) >> ( 10 - shiftHor ) ) & ( ( 1 << shiftHor ) - 1 ); + int xFrac = ( ( posX + offX ) >> ( posShift - shiftHor ) ) & ( ( 1 << shiftHor ) - 1 ); CHECK( xInt0 > xInt, "Wrong horizontal starting point" ); @@ -3076,9 +3092,9 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict for( row = 0; row < height; row++ ) { int posY = (int32_t)y0Int + row * stepY; - yInt = ( posY + offY ) >> 10; + yInt = ( posY + offY ) >> posShift; yInt = std::min( std::max( 0, yInt ), ( refPicHeight >> ::getComponentScaleY( compID, chFmt ) ) ); - int yFrac = ( ( posY + offY ) >> ( 10 - shiftVer ) ) & ( ( 1 << shiftVer ) - 1 ); + int yFrac = ( ( posY + offY ) >> ( posShift - shiftVer ) ) & ( ( 1 << shiftVer ) - 1 ); CHECK( yInt0 > yInt, "Wrong vertical starting point" ); @@ -3091,8 +3107,6 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict Position offset = Position( xInt, yInt ); refBuf = refPic->getRecoBuf( CompArea( compID, chFmt, offset, Size( 1, 1 ) ), wrapRef ); - - delete[] buffer; #else for( row = 0; row < height; row++ ) { @@ -3103,15 +3117,15 @@ bool InterPrediction::xPredInterBlkRPR( const ComponentID& compID, const Predict int posY = (int32_t)y0Int + row * stepY; // integer reference position in the reference frame - int xInt = ( posX + offX ) >> 10; - int yInt = ( posY + offY ) >> 10; + int xInt = ( posX + offX ) >> posShift; + int yInt = ( posY + offY ) >> posShift; xInt = std::min( std::max( 0, xInt ), ( refPicWidth >> ::getComponentScaleX( compID, chFmt ) ) ); yInt = std::min( std::max( 0, yInt ), ( refPicHeight >> ::getComponentScaleY( compID, chFmt ) ) ); // fractional position in the reference frame - int xFrac = ( ( posX + offX ) >> ( 10 - shiftHor ) ) & ( ( 1 << shiftHor ) - 1 ); - int yFrac = ( ( posY + offY ) >> ( 10 - shiftVer ) ) & ( ( 1 << shiftVer ) - 1 ); + int xFrac = ( ( posX + offX ) >> ( posShift - shiftHor ) ) & ( ( 1 << shiftHor ) - 1 ); + int yFrac = ( ( posY + offY ) >> ( posShift - shiftVer ) ) & ( ( 1 << shiftVer ) - 1 ); Position offset = Position( xInt, yInt ); diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index 30b9334731b28506ff4052a88794bc2b713bf0a1..21cb2cab98f89ca93cd693503c44d96d22a9fb71 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -145,6 +145,9 @@ protected: void xPredInterBlk ( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng , const bool& bioApplied , bool isIBC +#if JVET_O1164_RPR + , const std::pair<int, int> scalingRatio = SCALE_1X +#endif , SizeType dmvrWidth = 0 , SizeType dmvrHeight = 0 , bool bilinearMC = false @@ -164,7 +167,11 @@ protected: #if JVET_O0070_PROF void xApplyBiPROF (const PredictionUnit& pu, const CPelBuf& pcYuvSrc0, const CPelBuf& pcYuvSrc1, PelBuf& pcYuvDst, const ClpRng& clpRng); #endif +#if JVET_O1164_RPR + void xPredAffineBlk ( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng, const std::pair<int, int> scalingRatio = SCALE_1X ); +#else void xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng ); +#endif 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 ); @@ -247,7 +254,7 @@ public: #endif #if JVET_O1164_RPR - bool xPredInterBlkRPR( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& mv, PelUnitBuf& dstPic, const bool bi, const bool wrapRef, const ClpRng& clpRng ); + bool xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv& mv, PelUnitBuf& dstPic, const bool bi, const bool wrapRef, const ClpRng& clpRng ); #endif }; diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 00b24e23fa26e5bb27ae25861448409dcd4d0294..d068d5c875f8c135404af58a6b44063e816ca890 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -2325,7 +2325,12 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[], APS** apss, APS& lmcsAps, { // if rescaling is needed, otherwise just reuse the original picture pointer; it is needed for motion field, otherwise motion field requires a copy as well // reference resampling for the whole picture is not applied at decoder - if( ( m_apcRefPicList[refList][rIdx]->lwidth() == pps->getPicWidthInLumaSamples() && m_apcRefPicList[refList][rIdx]->lheight() == pps->getPicHeightInLumaSamples() ) || isDecoder ) + + int xScale, yScale; + CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx]->slices[0]->getPPS(), xScale, yScale ); + m_scalingRatio[refList][rIdx] = std::pair<int, int>( xScale, yScale ); + + if( m_scalingRatio[refList][rIdx] == SCALE_1X || isDecoder ) { m_scaledRefPicList[refList][rIdx] = m_apcRefPicList[refList][rIdx]; } diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 934bd9613e051221adf7648806dc4dc1e1d55662..ab8699180a5f7064b003b4605d5b9a45b02f8228 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -1612,6 +1612,7 @@ private: #if JVET_O1164_RPR Picture* m_scaledRefPicList[NUM_REF_PIC_LIST_01][MAX_NUM_REF + 1]; Picture* m_savedRefPicList[NUM_REF_PIC_LIST_01][MAX_NUM_REF + 1]; + std::pair<int, int> m_scalingRatio[NUM_REF_PIC_LIST_01][MAX_NUM_REF_PICS]; #endif @@ -2005,6 +2006,7 @@ public: void scaleRefPicList( Picture *scaledRefPic[], APS** apss, APS& lmcsAps, const bool isDecoder ); void freeScaledRefPicList( Picture *scaledRefPic[] ); bool checkRPR(); + const std::pair<int, int>& getScalingRatio( const RefPicList refPicList, const int refIdx ) const { return m_scalingRatio[refPicList][refIdx]; } #endif protected: Picture* xGetRefPic (PicList& rcListPic, int poc); diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 5c59c68dd71c359a2759f39343c2287966afe1e4..8978e6191347769ee70c15f71a049f53065d4ee9 100755 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -107,7 +107,6 @@ void CS::setRefinedMotionField(CodingStructure &cs) #if JVET_O1164_RPR bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, const PPS* refPPS, int& xScale, int& yScale ) { - #if RPR_CONF_WINDOW const Window& curConfWindow = curPPS->getConformanceWindow(); int curPicWidth = curPPS->getPicWidthInLumaSamples() - (curConfWindow.getWindowLeftOffset() + curConfWindow.getWindowRightOffset()) * SPS::getWinUnitY(sps->getChromaFormatIdc()); @@ -122,8 +121,8 @@ bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, const PPS* refPPS, in int refPicHeight = refPPS->getPicHeightInLumaSamples(); #endif - xScale = ( ( refPicWidth << 14 ) + ( curPicWidth >> 1 ) ) / curPicWidth; - yScale = ( ( refPicHeight << 14 ) + ( curPicHeight >> 1 ) ) / curPicHeight; + xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; + yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; return refPicWidth != curPicWidth || refPicHeight != curPicHeight; } diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 61bd81ff1143220157771c17caf68f6ddf73e987..e820fbfcf369bb82f6296fee76fc370ea0c0f250 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -643,16 +643,15 @@ void DecLib::finishPicture(int& poc, PicList*& rpcListPic, MsgLevel msgl ) for (int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++) { #if RPR_CTC_PRINT - int xScale, yScale; - CU::getRprScaling( pcSlice->getSPS(), pcSlice->getPPS(), pcSlice->getRefPic( RefPicList( iRefList ), iRefIndex )->unscaledPic->cs->pps, xScale, yScale ); + const std::pair<int, int>& scaleRatio = pcSlice->getScalingRatio( RefPicList( iRefList ), iRefIndex ); if( pcSlice->getEnableTMVPFlag() && pcSlice->getColFromL0Flag() == bool(1 - iRefList) && pcSlice->getColRefIdx() == iRefIndex ) { - msg( msgl, "%dc(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( xScale ) / ( 1 << 14 ), double( yScale ) / ( 1 << 14 ) ); + msg( msgl, "%dc(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( scaleRatio.first ) / ( 1 << SCALE_RATIO_BITS ), double( scaleRatio.second ) / ( 1 << SCALE_RATIO_BITS ) ); } else { - msg( msgl, "%d(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( xScale ) / ( 1 << 14 ), double( yScale ) / ( 1 << 14 ) ); + msg( msgl, "%d(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( scaleRatio.first ) / ( 1 << SCALE_RATIO_BITS ), double( scaleRatio.second ) / ( 1 << SCALE_RATIO_BITS ) ); } #else msg( msgl, "%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)); diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index fe1ab579211044436c5fa141faea09b88bc53292..5835f3c64913ae74f91f2fc6ca0e180f688b0ef8 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -3894,18 +3894,15 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni #if RPR_CTC_PRINT if( m_pcEncLib->isRPREnabled() ) { - const Picture* refPic = pcSlice->getRefPic( RefPicList( iRefList ), iRefIndex ); - - int xScale, yScale; - CU::getRprScaling( pcSlice->getSPS(), pcSlice->getPPS(), refPic->unscaledPic->cs->pps, xScale, yScale ); + const std::pair<int, int>& scaleRatio = pcSlice->getScalingRatio( RefPicList( iRefList ), iRefIndex ); if( pcSlice->getEnableTMVPFlag() && pcSlice->getColFromL0Flag() == bool( 1 - iRefList ) && pcSlice->getColRefIdx() == iRefIndex ) { - msg( NOTICE, "%dc(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( xScale ) / ( 1 << 14 ), double( yScale ) / ( 1 << 14 ) ); + msg( NOTICE, "%dc(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( scaleRatio.first ) / ( 1 << SCALE_RATIO_BITS ), double( scaleRatio.second ) / ( 1 << SCALE_RATIO_BITS ) ); } else { - msg( NOTICE, "%d(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( xScale ) / ( 1 << 14 ), double( yScale ) / ( 1 << 14 ) ); + msg( NOTICE, "%d(%1.2lfx, %1.2lfx) ", pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ), double( scaleRatio.first ) / ( 1 << SCALE_RATIO_BITS ), double( scaleRatio.second ) / ( 1 << SCALE_RATIO_BITS ) ); } } else