diff --git a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp index a048e366d9a302f393798f6aeaa650b54a0f729a..d4defbcb88a82b38b10381c13863ac52589a6dcf 100644 --- a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp +++ b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp @@ -662,6 +662,12 @@ void SampleAdaptiveOffset::xPCMSampleRestoration(CodingUnit& cu, const Component PelBuf dstBuf = cu.cs->getRecoBuf( currTU.block(compID) ); dstBuf.copyFrom( pcmBuf ); +#if JVET_M0427_INLOOP_RESHAPER + if (cu.slice->getReshapeInfo().getUseSliceReshaper() && isLuma(compID)) + { + dstBuf.rspSignal(m_pcReshape->getInvLUT()); + } +#endif } return; @@ -680,6 +686,12 @@ void SampleAdaptiveOffset::xPCMSampleRestoration(CodingUnit& cu, const Component dstBuf.at(x,y) = (pcmBuf.at(x,y) << uiPcmLeftShiftBit); } } +#if JVET_M0427_INLOOP_RESHAPER + if (cu.slice->getReshapeInfo().getUseSliceReshaper() && isLuma(compID)) + { + dstBuf.rspSignal(m_pcReshape->getInvLUT()); + } +#endif } void SampleAdaptiveOffset::deriveLoopFilterBoundaryAvailibility(CodingStructure& cs, const Position &pos, diff --git a/source/Lib/CommonLib/SampleAdaptiveOffset.h b/source/Lib/CommonLib/SampleAdaptiveOffset.h index f71861dcc399e974beb58f1cd9ce8a1620e810d4..77591fa8d8aa9f28e32fc3bf3bcc01e61d654494 100644 --- a/source/Lib/CommonLib/SampleAdaptiveOffset.h +++ b/source/Lib/CommonLib/SampleAdaptiveOffset.h @@ -40,7 +40,9 @@ #include "CommonDef.h" #include "Unit.h" - +#if JVET_M0427_INLOOP_RESHAPER +#include "Reshape.h" +#endif //! \ingroup CommonLib //! \{ @@ -70,7 +72,9 @@ public: void create( int picWidth, int picHeight, ChromaFormat format, uint32_t maxCUWidth, uint32_t maxCUHeight, uint32_t maxCUDepth, uint32_t lumaBitShift, uint32_t chromaBitShift ); void destroy(); static int getMaxOffsetQVal(const int channelBitDepth) { return (1<<(std::min<int>(channelBitDepth,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; } //Table 9-32, inclusive - +#if JVET_M0427_INLOOP_RESHAPER + void setReshaper(Reshape * p) { m_pcReshape = p; } +#endif protected: void deriveLoopFilterBoundaryAvailibility(CodingStructure& cs, const Position &pos, bool& isLeftAvail, @@ -93,7 +97,9 @@ protected: void xPCMCURestoration(CodingStructure& cs, const UnitArea &ctuArea); void xPCMSampleRestoration(CodingUnit& cu, const ComponentID compID); void xReconstructBlkSAOParams(CodingStructure& cs, SAOBlkParam* saoBlkParams); - +#if JVET_M0427_INLOOP_RESHAPER + Reshape* m_pcReshape; +#endif protected: uint32_t m_offsetStepLog2[MAX_NUM_COMPONENT]; //offset step PelStorage m_tempBuf; diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index 6190cfb5b474d53e4570dcd60527186eca241b33..1394abaea47505bcaf981a5e3681bc564e2829e6 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -564,6 +564,7 @@ void DecLib::executeLoopFilters() CHECK((m_cReshaper.getRecReshaped() == false), "Rec picture is not reshaped!"); m_pcPic->getRecoBuf(COMPONENT_Y).rspSignal(m_cReshaper.getInvLUT()); m_cReshaper.setRecReshaped(false); + m_cSAO.setReshaper(&m_cReshaper); } #endif // deblocking filter diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index 6f1fea353ba76aad59d885ecea53f4da5bf1f025..415ce339c6e844529e146b628a7283ba550f19a2 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -1893,7 +1893,18 @@ void EncCu::xFillPCMBuffer( CodingUnit &cu ) const CPelBuf source = tu.cs->getOrgBuf( compArea ); PelBuf destination = tu.getPcmbuf( compID ); - destination.copyFrom( source ); +#if JVET_M0427_INLOOP_RESHAPER + if (tu.cs->slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) + { + CompArea tmpArea(COMPONENT_Y, compArea.chromaFormat, Position(0, 0), compArea.size()); + PelBuf tempOrgBuf = m_tmpStorageLCU->getBuf(tmpArea); + tempOrgBuf.copyFrom(source); + tempOrgBuf.rspSignal(m_pcReshape->getFwdLUT()); + destination.copyFrom(tempOrgBuf); + } + else +#endif + destination.copyFrom( source ); } } } diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index d4cab58f9f0efe39e92d5b59fcee262e28b6c893..50731aa02e47c342218d6e75934165d946eb7883 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -1338,13 +1338,25 @@ void IntraSearch::xEncPCM(CodingStructure &cs, Partitioner& partitioner, const C CPelBuf orgBuf = cs.getOrgBuf ( area ); CHECK(pcmShiftRight < 0, "Negative shift"); - +#if JVET_M0427_INLOOP_RESHAPER + CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); + PelBuf tempOrgBuf = m_tmpStorageLCU.getBuf(tmpArea); + tempOrgBuf.copyFrom(orgBuf); + if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) + { + tempOrgBuf.rspSignal(m_pcReshape->getFwdLUT()); + } +#endif for (uint32_t uiY = 0; uiY < pcmBuf.height; uiY++) { for (uint32_t uiX = 0; uiX < pcmBuf.width; uiX++) { // Encode +#if JVET_M0427_INLOOP_RESHAPER + pcmBuf.at(uiX, uiY) = tempOrgBuf.at(uiX, uiY) >> pcmShiftRight; +#else pcmBuf.at(uiX, uiY) = orgBuf.at(uiX, uiY) >> pcmShiftRight; +#endif // Reconstruction recBuf.at(uiX, uiY) = pcmBuf.at(uiX, uiY) << pcmShiftRight; }