diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index df9517a409fe54b2ea5c216f1503278897f333c2..8d924ac29ee555047cc000836dec35d402218524 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -1508,7 +1508,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ( "RPR", m_rprEnabledFlag, true, "Reference Sample Resolution" ) #if JVET_AG0130_UNIFIED_SR || JVET_AC0196_NNSR ( "NnsrOption", m_nnsrOption, false, "NN-based super resolution option") - ( "NnsrModelName", m_nnsrModelName, string("models/super_resolution/NNVC_SR_int16.sadl"), "unified nnsr model name.") + ( "NnsrModelName", m_nnsrModelName, string("models/super_resolution/NNVC_SR_int16.sadl"), "unified nnsr model name. if set to default_rpr, use rpr instead of NN") ( "NnsrQpOffset", m_nnsrQpOffset, 5, "Base QP offset for Rate matching") ( "NnsrQpOffsetOverrideByQp", m_sNnsrQpOffsetOverrideByQp, string(""), "Override QP offset for Rate matching") ( "ScalingRatioHor", m_scalingRatioHor, 2.0, "Scaling ratio in hor direction" ) diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index af65818f33e9a21bbbb64feb27a2acd914223b2c..30c4e52fdaf0d06d400c5ab1af19d614edfaf9d8 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -4675,27 +4675,37 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni std::pair<int, int> scalingRatio = std::pair<int, int>( xScale, yScale ); #if JVET_AG0130_UNIFIED_SR || JVET_AC0196_NNSR - PelUnitBuf predBuf = pcPic->getPredBufCustom(); - int sliceQP = pcPic->cs->slice->getSliceQp(); + if (m_pcCfg->getNnsrUnifiedModelName()=="default_rpr") { + Picture::rescalePicture(scalingRatio, picC, pcPic->getScalingWindow(), upscaledRec, pps->getScalingWindow(), + format, sps.getBitDepths(), false, false, sps.getHorCollocatedChromaFlag(), + sps.getVerCollocatedChromaFlag()); + } else { + PelUnitBuf predBuf = pcPic->getPredBufCustom(); + int sliceQP = pcPic->cs->slice->getSliceQp(); #if JVET_AG0130_UNIFIED_SR - PelUnitBuf bsBuf = pcPic->getBsMapBuf(); - PelUnitBuf bpmBuf = pcPic->getBlockPredModeBuf(); - int baseQP = pcPic->cs->pps->getPicInitQPMinus26() + 26; + PelUnitBuf bsBuf = pcPic->getBsMapBuf(); + PelUnitBuf bpmBuf = pcPic->getBlockPredModeBuf(); + int baseQP = pcPic->cs->pps->getPicInitQPMinus26() + 26; #endif - SliceType sliceType = pcPic->cs->slice->getSliceType(); + SliceType sliceType = pcPic->cs->slice->getSliceType(); - PelStorage upscaledPic; - upscaledPic.create( pic.chromaFormat, Area( Position(), upscaledOrg ) ); - Picture::rescalePicture( scalingRatio, picC, pcPic->getScalingWindow(), upscaledPic, pps->getScalingWindow(), format, sps.getBitDepths(), false, false, sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag() ); - - if (picC.get(COMPONENT_Y).width == upscaledPic.get(COMPONENT_Y).width && picC.get(COMPONENT_Y).height == upscaledPic.get(COMPONENT_Y).height) - upscaledRec.copyFrom(upscaledPic); - else + PelStorage upscaledPic; + upscaledPic.create(pic.chromaFormat, Area(Position(), upscaledOrg)); + Picture::rescalePicture(scalingRatio, picC, pcPic->getScalingWindow(), upscaledPic, pps->getScalingWindow(), + format, sps.getBitDepths(), false, false, sps.getHorCollocatedChromaFlag(), + sps.getVerCollocatedChromaFlag()); + + if (picC.get(COMPONENT_Y).width == upscaledPic.get(COMPONENT_Y).width + && picC.get(COMPONENT_Y).height == upscaledPic.get(COMPONENT_Y).height) + upscaledRec.copyFrom(upscaledPic); + else #if JVET_AG0130_UNIFIED_SR - Picture::rescalePictureCNN(picC, predBuf, upscaledPic, bsBuf, bpmBuf, upscaledRec, sliceQP, baseQP, sliceType, m_pcCfg->getNnsrUnifiedModelName()); + Picture::rescalePictureCNN(picC, predBuf, upscaledPic, bsBuf, bpmBuf, upscaledRec, sliceQP, baseQP, sliceType, + m_pcCfg->getNnsrUnifiedModelName()); #elif JVET_AC0196_NNSR - Picture::rescalePictureCNN(picC, predBuf, upscaledPic, upscaledRec, sliceQP, baseQP, sliceType); + Picture::rescalePictureCNN(picC, predBuf, upscaledPic, upscaledRec, sliceQP, baseQP, sliceType); #endif + } #else Picture::rescalePicture( scalingRatio, picC, pcPic->getScalingWindow(), upscaledRec, pps->getScalingWindow(), format, sps.getBitDepths(), false, false, sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag() ); #endif diff --git a/source/Lib/Utilities/VideoIOYuv.cpp b/source/Lib/Utilities/VideoIOYuv.cpp index e6ca60d6cc16a5c3108e08c7fcf0e8412e88fa36..7a1022f260abbd953e92345e106000d9a75dd351 100644 --- a/source/Lib/Utilities/VideoIOYuv.cpp +++ b/source/Lib/Utilities/VideoIOYuv.cpp @@ -1351,16 +1351,24 @@ bool VideoIOYuv::writeUpscaledPicture( const SPS& sps, const PPS& pps, const CPe int yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; #if JVET_AG0130_UNIFIED_SR || JVET_AC0196_NNSR - PelStorage upscaledRPR; - upscaledRPR.create(chromaFormatIDC, Area( Position(), Size( sps.getMaxPicWidthInLumaSamples(), sps.getMaxPicHeightInLumaSamples() ) )); - Picture::rescalePicture(std::pair<int, int>(xScale, yScale), pic, pps.getScalingWindow(), upscaledRPR, - afterScaleWindowFullResolution, chromaFormatIDC, sps.getBitDepths(), false, false, - sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag()); + if (srModelPath=="default_rpr") { + Picture::rescalePicture(std::pair<int, int>(xScale, yScale), pic, pps.getScalingWindow(), upscaledPic, + afterScaleWindowFullResolution, chromaFormatIDC, sps.getBitDepths(), false, false, + sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag()); + } else { + PelStorage upscaledRPR; + upscaledRPR.create(chromaFormatIDC, Area(Position(), Size(sps.getMaxPicWidthInLumaSamples(), + sps.getMaxPicHeightInLumaSamples()))); + Picture::rescalePicture(std::pair<int, int>(xScale, yScale), pic, pps.getScalingWindow(), upscaledRPR, + afterScaleWindowFullResolution, chromaFormatIDC, sps.getBitDepths(), false, false, + sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag()); #if JVET_AG0130_UNIFIED_SR - Picture::rescalePictureCNN(pic, predBuf, upscaledRPR, bsBuf, bpmBuf, upscaledPic, sliceQP, baseQP, sliceType, srModelPath); + Picture::rescalePictureCNN(pic, predBuf, upscaledRPR, bsBuf, bpmBuf, upscaledPic, sliceQP, baseQP, sliceType, + srModelPath); #elif JVET_AC0196_NNSR - Picture::rescalePictureCNN(pic, predBuf, upscaledRPR, upscaledPic, sliceQP, baseQP, sliceType); + Picture::rescalePictureCNN(pic, predBuf, upscaledRPR, upscaledPic, sliceQP, baseQP, sliceType); #endif + } #else Picture::rescalePicture( std::pair<int, int>( xScale, yScale ), pic, pps.getScalingWindow(), upscaledPic, afterScaleWindowFullResolution, chromaFormatIDC, sps.getBitDepths(), false, false, sps.getHorCollocatedChromaFlag(), sps.getVerCollocatedChromaFlag() ); #endif