From b83c28e8d3e65479bd63f3ebe28f268fbfdd25d0 Mon Sep 17 00:00:00 2001 From: Roman Chernyak <chernyak@global.tencent.com> Date: Tue, 25 Jul 2023 11:26:40 -0700 Subject: [PATCH] JVET-AE0180: Add missing condition on PIC_RECON_WRAP buffer allocation --- source/Lib/CommonLib/Picture.cpp | 11 +++++++++-- source/Lib/CommonLib/Picture.h | 4 +++- source/Lib/CommonLib/Slice.cpp | 2 +- source/Lib/DecoderLib/DecLib.cpp | 6 +++--- source/Lib/EncoderLib/EncLib.cpp | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index d4a51a7ab..8e2633eaf 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -77,14 +77,21 @@ Picture::Picture() m_grainBuf = nullptr; } -void Picture::create( const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned _margin, const bool _decoder, const int _layerId, const bool enablePostFilteringForHFR, const bool gopBasedTemporalFilterEnabled, const bool fgcSEIAnalysisEnabled) +void Picture::create(const bool useWrapAround, const ChromaFormat& _chromaFormat, const Size& size, + const unsigned _maxCUSize, const unsigned _margin, const bool _decoder, const int _layerId, + const bool enablePostFilteringForHFR, const bool gopBasedTemporalFilterEnabled, + const bool fgcSEIAnalysisEnabled) { layerId = _layerId; UnitArea::operator=( UnitArea( _chromaFormat, Area( Position{ 0, 0 }, size ) ) ); margin = MAX_SCALING_RATIO*_margin; const Area a = Area( Position(), size ); M_BUFS( 0, PIC_RECONSTRUCTION ).create( _chromaFormat, a, _maxCUSize, margin, MEMORY_ALIGN_DEF_SIZE ); - M_BUFS( 0, PIC_RECON_WRAP ).create( _chromaFormat, a, _maxCUSize, margin, MEMORY_ALIGN_DEF_SIZE ); + + if (useWrapAround) + { + M_BUFS(0, PIC_RECON_WRAP).create(_chromaFormat, a, _maxCUSize, margin, MEMORY_ALIGN_DEF_SIZE); + } if (enablePostFilteringForHFR) { diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index c6f893657..8e816a6b7 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -72,7 +72,9 @@ struct Picture : public UnitArea uint32_t margin; Picture(); - void create(const ChromaFormat &_chromaFormat, const Size &size, const unsigned _maxCUSize, const unsigned margin, const bool bDecoder, const int layerId, const bool enablePostFilteringForHFR, const bool gopBasedTemporalFilterEnabled = false, const bool fgcSEIAnalysisEnabled = false); + void create(const bool useWrapAround, const ChromaFormat& _chromaFormat, const Size& size, const unsigned _maxCUSize, + const unsigned margin, const bool bDecoder, const int layerId, const bool enablePostFilteringForHFR, + const bool gopBasedTemporalFilterEnabled = false, const bool fgcSEIAnalysisEnabled = false); void destroy(); void createTempBuffers( const unsigned _maxCUSize ); diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index fdcde15c3..a85a20d91 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -3024,7 +3024,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS scaledRefPic[j]->poc = NOT_VALID; - scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, layerId, false); + scaledRefPic[j]->create(sps->getWrapAroundEnabledFlag(), sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, layerId, false); } scaledRefPic[j]->poc = poc; diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index d7a0ddc0a..7b9f02fe5 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -587,7 +587,7 @@ Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_ { pcPic = new Picture(); - pcPic->create(sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), + pcPic->create(sps.getWrapAroundEnabledFlag(), sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, true, layerId, getShutterFilterFlag() ); m_cListPic.push_back( pcPic ); @@ -624,7 +624,7 @@ Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_ m_cListPic.push_back( pcPic ); - pcPic->create(sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, true, layerId, getShutterFilterFlag()); + pcPic->create(sps.getWrapAroundEnabledFlag(), sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, true, layerId, getShutterFilterFlag()); } else { @@ -632,7 +632,7 @@ Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_ { pcPic->destroy(); - pcPic->create( sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, true, layerId, getShutterFilterFlag()); + pcPic->create(sps.getWrapAroundEnabledFlag(), sps.getChromaFormatIdc(), Size( pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples() ), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, true, layerId, getShutterFilterFlag()); } } diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 3f7e28d40..87a231205 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -505,7 +505,7 @@ void EncLib::init(AUWriterIf *auWriterIf) if (getUseCompositeRef()) { Picture *picBg = new Picture; - picBg->create(sps0.getChromaFormatIdc(), Size(pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples()), + picBg->create(sps0.getWrapAroundEnabledFlag(), sps0.getChromaFormatIdc(), Size(pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples()), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerId, getGopBasedTemporalFilterEnabled()); picBg->getRecoBuf().fill(0); @@ -514,7 +514,7 @@ void EncLib::init(AUWriterIf *auWriterIf) picBg->createSpliceIdx(pps0.pcv->sizeInCtus); m_cGOPEncoder.setPicBg(picBg); Picture *picOrig = new Picture; - picOrig->create(sps0.getChromaFormatIdc(), Size(pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples()), + picOrig->create(sps0.getWrapAroundEnabledFlag(), sps0.getChromaFormatIdc(), Size(pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples()), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerId, getGopBasedTemporalFilterEnabled()); picOrig->getOrigBuf().fill(0); @@ -1160,7 +1160,7 @@ void EncLib::xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Pict { rpcPic = new Picture; bool fgAnalysisEnabled = m_fgcSEIAnalysisEnabled && m_fgcSEIExternalDenoised.empty(); - rpcPic->create(sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), + rpcPic->create(sps.getWrapAroundEnabledFlag(), sps.getChromaFormatIdc(), Size(pps.getPicWidthInLumaSamples(), pps.getPicHeightInLumaSamples()), sps.getMaxCUWidth(), sps.getMaxCUWidth() + PIC_MARGIN, false, m_layerId, getShutterFilterFlag(), getGopBasedTemporalFilterEnabled(), fgAnalysisEnabled); -- GitLab