diff --git a/source/Lib/CommonLib/InterpolationFilter.h b/source/Lib/CommonLib/InterpolationFilter.h index 25ad67cd810f5ae044ec3680d99e8713d64aa8fd..777a53affd56576431c0eea7ed4c8a6c5c172b0b 100644 --- a/source/Lib/CommonLib/InterpolationFilter.h +++ b/source/Lib/CommonLib/InterpolationFilter.h @@ -55,12 +55,18 @@ */ class InterpolationFilter { - static const TFilterCoeff m_lumaFilter4x4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; + static const TFilterCoeff m_lumaFilter4x4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; +#if JVET_O1164_RPR +public: +#endif static const TFilterCoeff m_lumaFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; ///< Luma filter taps + static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps +#if JVET_O1164_RPR +private: +#endif #if JVET_O0057_ALTHPELIF static const TFilterCoeff m_lumaAltHpelIFilter[NTAPS_LUMA]; ///< Luma filter taps #endif - static const TFilterCoeff m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps static const TFilterCoeff m_bilinearFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_BILINEAR]; ///< bilinear filter taps static const TFilterCoeff m_bilinearFilterPrec4[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_BILINEAR]; ///< bilinear filter taps public: diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index 41a977735efe5225b02f6b49a8b6e34c3f9d0666..aefee96c0b849cdf9ef031a7af587ac916e6b778 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -1023,26 +1023,6 @@ void Picture::finishCtuPart( const UnitArea& ctuArea ) #endif #if JVET_O1164_RPR -const TFilterCoeff InterpolationFilterSRC[16][8] = -{ - { 0, 0, 0, 64, 0, 0, 0, 0 }, - { 0, 1, -3, 63, 4, -2, 1, 0 }, - { -1, 2, -5, 62, 8, -3, 1, 0 }, - { -1, 3, -8, 60, 13, -4, 1, 0 }, - { -1, 4, -10, 58, 17, -5, 1, 0 }, - { -1, 4, -11, 52, 26, -8, 3, -1 }, - { -1, 3, -9, 47, 31, -10, 4, -1 }, - { -1, 4, -11, 45, 34, -10, 4, -1 }, - { -1, 4, -11, 40, 40, -11, 4, -1 }, - { -1, 4, -10, 34, 45, -11, 4, -1 }, - { -1, 4, -10, 31, 47, -9, 3, -1 }, - { -1, 3, -8, 26, 52, -11, 4, -1 }, - { 0, 1, -5, 17, 58, -10, 4, -1 }, - { 0, 1, -4, 13, 60, -8, 3, -1 }, - { 0, 1, -3, 8, 62, -5, 2, -1 }, - { 0, 1, -2, 4, 63, -3, 1, 0 } -}; - const TFilterCoeff DownsamplingFilterSRC[8][16][12] = { { // D = 1 @@ -1195,7 +1175,7 @@ const TFilterCoeff DownsamplingFilterSRC[8][16][12] = } }; -void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType orgHeight, SizeType orgStride, Pel* scaledSrc, SizeType scaledWidth, SizeType scaledHeight, SizeType scaledStride, int bitDepth, const bool downsampling ) +void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType orgHeight, SizeType orgStride, Pel* scaledSrc, SizeType scaledWidth, SizeType scaledHeight, SizeType scaledStride, const int bitDepth, const bool useLumaFilter, const bool downsampling ) { if( orgWidth == scaledWidth && orgHeight == scaledHeight ) { @@ -1207,8 +1187,9 @@ void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType org return; } - const TFilterCoeff* filterHor = &InterpolationFilterSRC[0][0]; - const TFilterCoeff* filterVer = &InterpolationFilterSRC[0][0]; + const TFilterCoeff* filterHor = useLumaFilter ? &InterpolationFilter::m_lumaFilter[0][0] : &InterpolationFilter::m_chromaFilter[0][0]; + const TFilterCoeff* filterVer = useLumaFilter ? &InterpolationFilter::m_lumaFilter[0][0] : &InterpolationFilter::m_chromaFilter[0][0]; + const int numFracPositions = useLumaFilter ? 15 : 31; if( downsampling ) { @@ -1234,7 +1215,7 @@ void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType org filterVer = &DownsamplingFilterSRC[verFilter][0][0]; } - const int filerLength = downsampling ? 12 : 8; + const int filerLength = downsampling ? 12 : ( useLumaFilter ? NTAPS_LUMA : NTAPS_CHROMA ); const int log2Norm = downsampling ? 14 : 12; int *buf = new int[orgHeight * scaledWidth]; @@ -1246,7 +1227,7 @@ void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType org { const Pel* org = orgSrc; int integer = ( i * orgWidth ) / scaledWidth; - int frac = ( ( i * orgWidth << 4 ) / scaledWidth ) & 15; + int frac = ( ( i * orgWidth << 4 ) / scaledWidth ) & numFracPositions; int* tmp = buf + i; @@ -1273,7 +1254,7 @@ void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType org for( int j = 0; j < scaledHeight; j++ ) { int integer = ( j * orgHeight ) / scaledHeight; - int frac = ( ( j * orgHeight << 4 ) / scaledHeight ) & 15; + int frac = ( ( j * orgHeight << 4 ) / scaledHeight ) & numFracPositions; for( int i = 0; i < scaledWidth; i++ ) { @@ -1296,14 +1277,15 @@ void Picture::sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType org delete[] buf; } -void Picture::rescalePicture( const CPelUnitBuf& beforeScaling, const PelUnitBuf& afterScaling, const ChromaFormat chromaFormatIDC, const BitDepths& bitDepths, const bool downsampling ) +void Picture::rescalePicture( const CPelUnitBuf& beforeScaling, const PelUnitBuf& afterScaling, const ChromaFormat chromaFormatIDC, const BitDepths& bitDepths, const bool useLumaFilter, const bool downsampling ) { for( int comp = 0; comp < ::getNumberValidComponents( chromaFormatIDC ); comp++ ) { - const CPelBuf& beforeScale = beforeScaling.get( ComponentID( comp ) ); - const PelBuf& afterScale = afterScaling.get( ComponentID( comp ) ); + ComponentID compID = ComponentID( comp ); + const CPelBuf& beforeScale = beforeScaling.get( compID ); + const PelBuf& afterScale = afterScaling.get( compID ); - Picture::sampleRateConv( beforeScale.buf, beforeScale.width, beforeScale.height, beforeScale.stride, afterScale.buf, afterScale.width, afterScale.height, afterScale.stride, bitDepths.recon[comp], downsampling ); + Picture::sampleRateConv( beforeScale.buf, beforeScale.width, beforeScale.height, beforeScale.stride, afterScale.buf, afterScale.width, afterScale.height, afterScale.stride, bitDepths.recon[comp], downsampling || useLumaFilter ? true : isLuma(compID), downsampling ); } } #endif diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 34680f30587e3ba5d45604b8d668a2b4969fbd41..ca051557d821b83339e071b31d6d9185d45445fa 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -50,6 +50,10 @@ #include "MCTS.h" #include <deque> +#if JVET_O1164_RPR +#include "CommonLib/InterpolationFilter.h" +#endif + #if ENABLE_WPP_PARALLELISM || ENABLE_SPLIT_PARALLELISM #if ENABLE_WPP_PARALLELISM #include <mutex> @@ -244,9 +248,9 @@ struct Picture : public UnitArea void createSpliceIdx(int nums); bool getSpliceFull(); #if JVET_O1164_RPR - static void sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType orgHeight, SizeType orgStride, Pel* scaledSrc, SizeType scaledWidth, SizeType scaledHeight, SizeType scaledStride, int bitDepth, const bool downsampling = false ); + static void sampleRateConv( const Pel* orgSrc, SizeType orgWidth, SizeType orgHeight, SizeType orgStride, Pel* scaledSrc, SizeType scaledWidth, SizeType scaledHeight, SizeType scaledStride, const int bitDepth, const bool useLumaFilter, const bool downsampling = false ); - static void rescalePicture( const CPelUnitBuf& beforeScaling, const PelUnitBuf& afterScaling, const ChromaFormat chromaFormatIDC, const BitDepths& bitDepths, const bool downsampling = false ); + static void rescalePicture( const CPelUnitBuf& beforeScaling, const PelUnitBuf& afterScaling, const ChromaFormat chromaFormatIDC, const BitDepths& bitDepths, const bool useLumaFilter, const bool downsampling = false ); #endif public: diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index 559b630f96868d65c2622a152508efc8a9c81c22..872027100c6b9ccf1460c48215c295be5c625ea8 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -2364,7 +2364,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[], APS** apss, APS& lmcsAps, scaledRefPic[j]->poc = poc; // rescale the reference picture - Picture::rescalePicture( m_apcRefPicList[refList][rIdx]->getRecoBuf(), scaledRefPic[j]->getRecoBuf(), sps->getChromaFormatIdc(), sps->getBitDepths() ); + Picture::rescalePicture( m_apcRefPicList[refList][rIdx]->getRecoBuf(), scaledRefPic[j]->getRecoBuf(), sps->getChromaFormatIdc(), sps->getBitDepths(), true ); scaledRefPic[j]->extendPicBorder(); m_scaledRefPicList[refList][rIdx] = scaledRefPic[j]; diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 62f4f725c0e96b94eae67a283203f2c4e79f9c91..231161abcef7965269ba8f380dc998b979ef49af 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -3598,7 +3598,7 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni { const CPelBuf& upscaledOrg = sps.getUseReshaper() ? pcPic->m_bufs[PIC_TRUE_ORIGINAL_INPUT].get( COMPONENT_Y ) : pcPic->m_bufs[PIC_ORIGINAL_INPUT].get( COMPONENT_Y ); upscaledRec.create( pic.chromaFormat, Area( Position(), upscaledOrg ) ); - Picture::rescalePicture( picC, upscaledRec, format, sps.getBitDepths() ); + Picture::rescalePicture( picC, upscaledRec, format, sps.getBitDepths(), false ); } #endif diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 95eba732eef3b2191175cafd3b0e86ff84a56e87..88528b12deb6319cbd5bf94db22b92986707fa8a 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -698,8 +698,8 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru const ChromaFormat chromaFormatIDC = pSPS->getChromaFormatIdc(); - Picture::rescalePicture( *pcPicYuvOrg, pcPicCurr->getOrigBuf(), chromaFormatIDC, pSPS->getBitDepths(), true ); - Picture::rescalePicture( *cPicYuvTrueOrg, pcPicCurr->getTrueOrigBuf(), chromaFormatIDC, pSPS->getBitDepths(), true ); + Picture::rescalePicture( *pcPicYuvOrg, pcPicCurr->getOrigBuf(), chromaFormatIDC, pSPS->getBitDepths(), true, true ); + Picture::rescalePicture( *cPicYuvTrueOrg, pcPicCurr->getTrueOrigBuf(), chromaFormatIDC, pSPS->getBitDepths(), true, true ); } else { diff --git a/source/Lib/Utilities/VideoIOYuv.cpp b/source/Lib/Utilities/VideoIOYuv.cpp index 86d0d7e44100616571eacc0eba5f8ee467cd3f59..9b0dcc1e4a0cef0245968cc7da336d8e3893c772 100644 --- a/source/Lib/Utilities/VideoIOYuv.cpp +++ b/source/Lib/Utilities/VideoIOYuv.cpp @@ -1249,7 +1249,7 @@ bool VideoIOYuv::writeUpscaledPicture( const SPS& sps, const PPS& pps, const CPe { PelStorage upscaledPic; upscaledPic.create( chromaFormatIDC, Area( Position(), Size( sps.getMaxPicWidthInLumaSamples(), sps.getMaxPicHeightInLumaSamples() ) ) ); - Picture::rescalePicture( pic, upscaledPic, chromaFormatIDC, sps.getBitDepths() ); + Picture::rescalePicture( pic, upscaledPic, chromaFormatIDC, sps.getBitDepths(), false ); const Window conf; ret = write( sps.getMaxPicWidthInLumaSamples(), sps.getMaxPicHeightInLumaSamples(), upscaledPic,