Commit 3ff7f0b0 authored by Karsten Suehring's avatar Karsten Suehring
Browse files

Merge branch 'JVET-N0805_LMCS-APS' into 'master'

JVET-N0805: APS for LMCS (using different APS types)

See merge request !577
parent 1666ad0e
......@@ -718,7 +718,11 @@ void AdaptiveLoopFilter::ALFProcess( CodingStructure& cs, AlfSliceParam& alfSlic
void AdaptiveLoopFilter::reconstructCoeffAPSs(CodingStructure& cs, bool luma, bool chroma, bool isRdo)
{
//luma
#if JVET_N0805_APS_LMCS
APS** aps = cs.slice->getAlfAPSs();
#else
APS** aps = cs.slice->getAPSs();
#endif
AlfSliceParam alfSliceParamTmp;
APS* curAPS;
if (luma)
......
......@@ -779,10 +779,19 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
#endif
subStruct.pps = pps;
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memcpy(subStruct.alfApss, alfApss, sizeof(alfApss));
#else
memcpy(subStruct.apss, apss, sizeof(apss));
#endif
#else
subStruct.aps = aps;
#endif
#if JVET_N0805_APS_LMCS
subStruct.lmcsAps = lmcsAps;
#endif
subStruct.slice = slice;
subStruct.baseQP = baseQP;
subStruct.prevQP[_chType]
......
......@@ -95,10 +95,17 @@ public:
const SPS *sps;
const PPS *pps;
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
APS* alfApss[MAX_NUM_APS];
#else
APS* apss[MAX_NUM_APS];
#endif
#else
APS * aps;
#endif
#if JVET_N0805_APS_LMCS
APS * lmcsAps;
#endif
#if HEVC_VPS
const VPS *vps;
#elif JVET_N0278_HLS
......
......@@ -213,6 +213,10 @@ static const int MAX_NUM_DPS = 16;
static const int MAX_NUM_SPS = 16;
static const int MAX_NUM_PPS = 64;
static const int MAX_NUM_APS = 32; //Currently APS ID has 5 bits
#if JVET_N0805_APS_LMCS
static const int NUM_APS_TYPE_LEN = 3; //Currently APS Type has 3 bits
static const int MAX_NUM_APS_TYPE = 8; //Currently APS Type has 3 bits so the max type is 8
#endif
static const int MLS_GRP_NUM = 1024; ///< Max number of coefficient groups, max(16, 256)
......
......@@ -1175,7 +1175,11 @@ const CPelUnitBuf Picture::getRecoBuf(const UnitArea &unit) const { return g
const CPelUnitBuf Picture::getRecoBuf() const { return M_BUFS(scheduler.getSplitPicId(), PIC_RECONSTRUCTION); }
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
void Picture::finalInit(const SPS& sps, const PPS& pps, APS** alfApss, APS& lmcsAps)
#else
void Picture::finalInit(const SPS& sps, const PPS& pps, APS** apss)
#endif
#else
void Picture::finalInit(const SPS& sps, const PPS& pps, APS& aps)
#endif
......@@ -1222,10 +1226,18 @@ void Picture::finalInit(const SPS& sps, const PPS& pps, APS& aps)
cs->slice = nullptr; // the slices for this picture have not been set at this point. update cs->slice after swapSliceObject()
cs->pps = &pps;
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memcpy(cs->alfApss, alfApss, sizeof(cs->alfApss));
#else
memcpy(cs->apss, apss, sizeof(cs->apss));
#endif
#else
cs->aps = &aps;
#endif
#if JVET_N0805_APS_LMCS
cs->lmcsAps = &lmcsAps;
#endif
#if HEVC_VPS
cs->vps = nullptr;
#endif
......@@ -1251,10 +1263,19 @@ void Picture::allocateNewSlice()
slices.push_back(new Slice);
Slice& slice = *slices.back();
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memcpy(slice.getAlfAPSs(), cs->alfApss, sizeof(cs->alfApss));
#else
memcpy(slice.getAPSs(), cs->apss, sizeof(cs->apss));
#endif
#else
slice.setAPS(cs->aps);
#endif
#if JVET_N0805_APS_LMCS
slice.setLmcsAPS(cs->lmcsAps);
#endif
slice.setPPS( cs->pps);
slice.setSPS( cs->sps);
if(slices.size()>=2)
......@@ -1269,20 +1290,36 @@ Slice *Picture::swapSliceObject(Slice * p, uint32_t i)
p->setSPS(cs->sps);
p->setPPS(cs->pps);
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
p->setAlfAPSs(cs->alfApss);
#else
p->setAPSs(cs->apss);
#endif
#else
p->setAPS(cs->aps);
#endif
#if JVET_N0805_APS_LMCS
p->setLmcsAPS(cs->lmcsAps);
#endif
Slice * pTmp = slices[i];
slices[i] = p;
pTmp->setSPS(0);
pTmp->setPPS(0);
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memset(pTmp->getAlfAPSs(), 0, sizeof(*pTmp->getAlfAPSs())*MAX_NUM_APS);
#else
memset(pTmp->getAPSs(), 0, sizeof(*pTmp->getAPSs())*MAX_NUM_APS);
#endif
#else
pTmp->setAPS(0);
#endif
#if JVET_N0805_APS_LMCS
pTmp->setLmcsAPS(0);
#endif
return pTmp;
}
......
......@@ -291,7 +291,11 @@ struct Picture : public UnitArea
void extendPicBorder();
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
void finalInit(const SPS& sps, const PPS& pps, APS** alfApss, APS& lmcsAps);
#else
void finalInit(const SPS& sps, const PPS& pps, APS** apss);
#endif
#else
void finalInit(const SPS& sps, const PPS& pps, APS& aps);
#endif
......
......@@ -753,7 +753,11 @@ void SampleAdaptiveOffset::xPCMSampleRestoration(CodingUnit& cu, const Component
PelBuf dstBuf = cu.cs->getRecoBuf( currTU.block(compID) );
dstBuf.copyFrom( pcmBuf );
#if JVET_N0805_APS_LMCS
if (cu.slice->getLmcsEnabledFlag() && isLuma(compID))
#else
if (cu.slice->getReshapeInfo().getUseSliceReshaper() && isLuma(compID))
#endif
{
dstBuf.rspSignal(m_pcReshape->getInvLUT());
}
......@@ -775,7 +779,11 @@ void SampleAdaptiveOffset::xPCMSampleRestoration(CodingUnit& cu, const Component
dstBuf.at(x,y) = (pcmBuf.at(x,y) << uiPcmLeftShiftBit);
}
}
#if JVET_N0805_APS_LMCS
if (cu.slice->getLmcsEnabledFlag()&& isLuma(compID))
#else
if (cu.slice->getReshapeInfo().getUseSliceReshaper() && isLuma(compID))
#endif
{
dstBuf.rspSignal(m_pcReshape->getInvLUT());
}
......
......@@ -130,6 +130,12 @@ Slice::Slice()
, m_apsId ( -1 )
, m_aps (NULL)
#endif
#if JVET_N0805_APS_LMCS
, m_lmcsApsId ( -1 )
, m_lmcsAps (nullptr)
, m_tileGroupLmcsEnabledFlag (false)
, m_tileGroupLmcsChromaResidualScaleFlag (false)
#endif
{
for(uint32_t i=0; i<NUM_REF_PIC_LIST_01; i++)
{
......@@ -169,15 +175,21 @@ Slice::Slice()
m_saoEnabledFlag[ch] = false;
}
#if !JVET_N0805_APS_LMCS
m_sliceReshapeInfo.setUseSliceReshaper(false);
m_sliceReshapeInfo.setSliceReshapeModelPresentFlag(false);
m_sliceReshapeInfo.setSliceReshapeChromaAdj(0);
m_sliceReshapeInfo.reshaperModelMinBinIdx = 0;
m_sliceReshapeInfo.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1;
memset(m_sliceReshapeInfo.reshaperModelBinCWDelta, 0, PIC_CODE_CW_BINS * sizeof(int));
#endif
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memset(m_alfApss, 0, sizeof(m_alfApss));
#else
memset(m_apss, 0, sizeof(m_apss));
#endif
#endif
}
Slice::~Slice()
......@@ -842,7 +854,11 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll)
m_cabacInitFlag = pSrc->m_cabacInitFlag;
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
memcpy(m_alfApss, pSrc->m_alfApss, sizeof(m_alfApss)); // this might be quite unsafe
#else
memcpy(m_apss, pSrc->m_apss, sizeof(m_apss)); // this might be quite unsafe
#endif
memcpy( m_tileGroupAlfEnabledFlag, pSrc->m_tileGroupAlfEnabledFlag, sizeof(m_tileGroupAlfEnabledFlag));
m_tileGroupNumAps = pSrc->m_tileGroupNumAps;
m_tileGroupLumaApsId = pSrc->m_tileGroupLumaApsId;
......@@ -879,7 +895,14 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll)
m_depQuantEnabledFlag = pSrc->m_depQuantEnabledFlag;
m_signDataHidingEnabledFlag = pSrc->m_signDataHidingEnabledFlag;
#if JVET_N0805_APS_LMCS
m_tileGroupLmcsEnabledFlag = pSrc->m_tileGroupLmcsEnabledFlag;
m_tileGroupLmcsChromaResidualScaleFlag = pSrc->m_tileGroupLmcsChromaResidualScaleFlag;
m_lmcsAps = pSrc->m_lmcsAps;
m_lmcsApsId = pSrc->m_lmcsApsId;
#else
m_sliceReshapeInfo = pSrc->m_sliceReshapeInfo;
#endif
}
......@@ -2582,7 +2605,11 @@ ParameterSetManager::ParameterSetManager()
: m_spsMap(MAX_NUM_SPS)
#endif
, m_ppsMap(MAX_NUM_PPS)
#if JVET_N0805_APS_LMCS
, m_apsMap(MAX_NUM_APS * MAX_NUM_APS_TYPE)
#else
, m_apsMap(MAX_NUM_APS)
#endif
#if JVET_N0349_DPS
, m_dpsMap(MAX_NUM_DPS)
#endif
......@@ -2737,6 +2764,22 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP)
return false;
}
#if JVET_N0805_APS_LMCS
bool ParameterSetManager::activateAPS(int apsId, int apsType)
{
APS *aps = m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType);
if (aps)
{
m_apsMap.setActive((apsId << NUM_APS_TYPE_LEN) + apsType);
return true;
}
else
{
msg(WARNING, "Warning: tried to activate non-existing APS.");
}
return false;
}
#else
bool ParameterSetManager::activateAPS(int apsId)
{
APS *aps = m_apsMap.getPS(apsId);
......@@ -2751,6 +2794,7 @@ bool ParameterSetManager::activateAPS(int apsId)
}
return false;
}
#endif
template <>
void ParameterSetMap<APS>::setID(APS* parameterSet, const int psId)
......
......@@ -1944,7 +1944,13 @@ class APS
{
private:
int m_APSId; // adaptation_parameter_set_id
#if JVET_N0805_APS_LMCS
int m_APSType; // aps_params_type
#endif
AlfSliceParam m_alfAPSParam;
#if JVET_N0805_APS_LMCS
SliceReshapeInfo m_reshapeAPSInfo;
#endif
public:
APS();
......@@ -1953,6 +1959,11 @@ public:
int getAPSId() const { return m_APSId; }
void setAPSId(int i) { m_APSId = i; }
#if JVET_N0805_APS_LMCS
int getAPSType() const { return m_APSType; }
void setAPSType(int type) { m_APSType = type; }
#endif
void setAlfAPSParam(AlfSliceParam& alfAPSParam) { m_alfAPSParam = alfAPSParam; }
#if JVET_N0415_CTB_ALF
void setTemporalId(int i) { m_alfAPSParam.tLayer = i; }
......@@ -1961,6 +1972,11 @@ public:
#else
const AlfSliceParam& getAlfAPSParam() const { return m_alfAPSParam; }
#endif
#if JVET_N0805_APS_LMCS
void setReshaperAPSInfo(SliceReshapeInfo& reshapeAPSInfo) { m_reshapeAPSInfo = reshapeAPSInfo; }
SliceReshapeInfo& getReshaperAPSInfo() { return m_reshapeAPSInfo; }
#endif
};
struct WPScalingParam
{
......@@ -2116,7 +2132,11 @@ private:
uint32_t m_uiMaxBTSize;
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
APS* m_alfApss[MAX_NUM_APS];
#else
APS* m_apss[MAX_NUM_APS];
#endif
bool m_tileGroupAlfEnabledFlag[MAX_NUM_COMPONENT];
int m_tileGroupNumAps;
std::vector<int> m_tileGroupLumaApsId;
......@@ -2129,7 +2149,14 @@ private:
#if JVET_N0329_IBC_SEARCH_IMP
bool m_disableSATDForRd;
#endif
#if JVET_N0805_APS_LMCS
int m_lmcsApsId;
APS* m_lmcsAps;
bool m_tileGroupLmcsEnabledFlag;
bool m_tileGroupLmcsChromaResidualScaleFlag;
#else
SliceReshapeInfo m_sliceReshapeInfo;
#endif
public:
Slice();
virtual ~Slice();
......@@ -2153,13 +2180,30 @@ public:
void setPPSId( int PPSId ) { m_iPPSId = PPSId; }
int getPPSId() const { return m_iPPSId; }
#if JVET_N0415_CTB_ALF
#if JVET_N0805_APS_LMCS
void setAlfAPSs(APS** apss) { memcpy(m_alfApss, apss, sizeof(m_alfApss)); }
APS** getAlfAPSs() { return m_alfApss; }
#else
void setAPSs(APS** apss) { memcpy(m_apss, apss, sizeof(m_apss)); }
APS** getAPSs() { return m_apss; }
#endif
#else
void setAPS(APS* aps) { m_aps = aps; m_apsId = (aps) ? aps->getAPSId() : -1; }
APS* getAPS() { return m_aps; }
void setAPSId(int apsId) { m_apsId = apsId; }
int getAPSId() const { return m_apsId; }
#endif
#if JVET_N0805_APS_LMCS
void setLmcsAPS(APS* lmcsAps) { m_lmcsAps = lmcsAps; m_lmcsApsId = (lmcsAps) ? lmcsAps->getAPSId() : -1; }
APS* getLmcsAPS() { return m_lmcsAps; }
void setLmcsAPSId(int lmcsApsId) { m_lmcsApsId = lmcsApsId; }
int getLmcsAPSId() const { return m_lmcsApsId; }
void setLmcsEnabledFlag(bool b) { m_tileGroupLmcsEnabledFlag = b; }
bool getLmcsEnabledFlag() { return m_tileGroupLmcsEnabledFlag; }
const bool getLmcsEnabledFlag() const { return m_tileGroupLmcsEnabledFlag; }
void setLmcsChromaResidualScaleFlag(bool b) { m_tileGroupLmcsChromaResidualScaleFlag = b; }
bool getLmcsChromaResidualScaleFlag() { return m_tileGroupLmcsChromaResidualScaleFlag; }
const bool getLmcsChromaResidualScaleFlag() const { return m_tileGroupLmcsChromaResidualScaleFlag; }
#endif
void setPicOutputFlag( bool b ) { m_PicOutputFlag = b; }
bool getPicOutputFlag() const { return m_PicOutputFlag; }
......@@ -2429,7 +2473,11 @@ public:
int getTileGroupApsIdChroma() const { return m_tileGroupChromaApsId; }
void setTileGroupApsIdChroma(int i) { m_tileGroupChromaApsId = i; }
std::vector<int32_t> getTileGroupApsIdLuma() const { return m_tileGroupLumaApsId; }
#if JVET_N0805_APS_LMCS
void setAlfAPSs(std::vector<int> ApsIDs)
#else
void setAPSs(std::vector<int> ApsIDs)
#endif
{
m_tileGroupLumaApsId.resize(m_tileGroupNumAps);
for (int i = 0; i < m_tileGroupNumAps; i++)
......@@ -2445,8 +2493,10 @@ public:
void setDisableSATDForRD(bool b) { m_disableSATDForRd = b; }
bool getDisableSATDForRD() { return m_disableSATDForRd; }
#endif
#if !JVET_N0805_APS_LMCS
const SliceReshapeInfo& getReshapeInfo() const { return m_sliceReshapeInfo; }
SliceReshapeInfo& getReshapeInfo() { return m_sliceReshapeInfo; }
#endif
protected:
Picture* xGetRefPic (PicList& rcListPic, int poc);
Picture* xGetLongTermRefPic(PicList& rcListPic, int poc, bool pocHasMsb);
......@@ -2670,12 +2720,21 @@ public:
APS** getAPSs() { return &m_apss[0]; }
ParameterSetMap<APS>* getApsMap() { return &m_apsMap; }
#endif
#if JVET_N0805_APS_LMCS
void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS((aps->getAPSId() << NUM_APS_TYPE_LEN) + aps->getAPSType(), aps, &naluData); };
APS* getAPS(int apsId, int apsType) { return m_apsMap.getPS((apsId << NUM_APS_TYPE_LEN) + apsType); };
bool getAPSChangedFlag(int apsId, int apsType) const { return m_apsMap.getChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
void clearAPSChangedFlag(int apsId, int apsType) { m_apsMap.clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + apsType); }
APS* getFirstAPS() { return m_apsMap.getFirstPS(); };
bool activateAPS(int apsId, int apsType);
#else
void storeAPS(APS *aps, const std::vector<uint8_t> &naluData) { m_apsMap.storePS(aps->getAPSId(), aps, &naluData); };
APS* getAPS(int apsId) { return m_apsMap.getPS(apsId); };
bool getAPSChangedFlag(int apsId) const { return m_apsMap.getChangedFlag(apsId); }
void clearAPSChangedFlag(int apsId) { m_apsMap.clearChangedFlag(apsId); }
APS* getFirstAPS() { return m_apsMap.getFirstPS(); };
bool activateAPS(int apsId);
#endif
#if HEVC_VPS
const VPS* getActiveVPS()const { return m_vpsMap.getPS(m_activeVPSId); };
#endif
......
......@@ -54,6 +54,8 @@
#define JVET_N0278_HLS 1 // JVET-N0278: HLS for MPEG requirements on immersive media delivery and access
#define JVET_N0805_APS_LMCS 1 // JVET-N0805: Reference to APS from slice header for LMCS
#define JVET_N0063_VUI 1 // JVET-N0063: Video Usability Information
#define JVET_N0847_SCALING_LISTS 1 //1: default mode, 2: user defined mode
......@@ -465,6 +467,14 @@ typedef uint64_t Distortion; ///< distortion measurement
// ====================================================================================================================
// Enumeration
// ====================================================================================================================
#if JVET_N0805_APS_LMCS
enum ApsTypeValues
{
ALF_APS = 0,
LMCS_APS = 1,
};
#endif
enum QuantFlags
{
Q_INIT = 0x0,
......
......@@ -213,9 +213,17 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
#endif
}
const Slice &slice = *cs.slice;
#if JVET_N0805_APS_LMCS
bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag()));
#else
bool flag = slice.getReshapeInfo().getUseSliceReshaper() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag()));
#endif
#if JVET_N0477_LMCS_CLEANUP
#if JVET_N0805_APS_LMCS
if (flag && slice.getLmcsChromaResidualScaleFlag() && (compID != COMPONENT_Y) && (tu.cbf[COMPONENT_Cb] || tu.cbf[COMPONENT_Cr]))
#else
if (flag && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID != COMPONENT_Y) && (tu.cbf[COMPONENT_Cb] || tu.cbf[COMPONENT_Cr]))
#endif
#else
if (flag && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID != COMPONENT_Y))
#endif
......@@ -250,7 +258,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
//===== reconstruction =====
flag = flag && (tu.blocks[compID].width*tu.blocks[compID].height > 4);
#if JVET_N0805_APS_LMCS
if (flag && TU::getCbf(tu, compID) && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag())
#else
if (flag && TU::getCbf(tu, compID) && isChroma(compID) && slice.getReshapeInfo().getSliceReshapeChromaAdj())
#endif
{
#if JVET_N0054_JOINT_CHROMA
if ( !(tu.jointCbCr && compID == COMPONENT_Cr) ) // // Joint chroma residual mode: chroma scaling took place already when doing Cb
......@@ -277,7 +289,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size());
PelBuf tmpPred;
#endif
#if JVET_N0805_APS_LMCS
if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y)
#else
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y)
#endif
{
#if REUSE_CU_RESULTS
{
......@@ -294,7 +310,11 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
#if !KEEP_PRED_AND_RESI_SIGNALS
pReco.copyFrom( piPred );
#endif
#if JVET_N0805_APS_LMCS
if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y)
#else
if (slice.getReshapeInfo().getUseSliceReshaper() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y)
#endif
{
#if REUSE_CU_RESULTS
{
......@@ -476,7 +496,11 @@ void DecCu::xReconInter(CodingUnit &cu)
if (cu.firstPU->mhIntraFlag)
{
#if JVET_N0805_APS_LMCS
if (cu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())
#else
if (cu.cs->slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag())
#endif
{
cu.cs->getPredBuf(*cu.firstPU).Y().rspSignal(m_pcReshape->getFwdLUT());
}
......@@ -501,7 +525,11 @@ void DecCu::xReconInter(CodingUnit &cu)
CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size());
PelBuf tmpPred;
#endif
#if JVET_N0805_APS_LMCS
if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())
#else
if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag())
#endif
{
#if REUSE_CU_RESULTS
if (cs.pcv->isEncoder)
......@@ -519,7 +547,11 @@ void DecCu::xReconInter(CodingUnit &cu)
cs.getResiBuf( cu ).reconstruct( cs.getPredBuf( cu ), cs.getResiBuf( cu ), cs.slice->clpRngs() );
cs.getRecoBuf( cu ).copyFrom ( cs.getResiBuf( cu ) );
#endif
#if JVET_N0805_APS_LMCS
if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())
#else
if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag())
#endif
{
#if REUSE_CU_RESULTS
if (cs.pcv->isEncoder)
......@@ -532,7 +564,11 @@ void DecCu::xReconInter(CodingUnit &cu)
else
{
cs.getRecoBuf(cu).copyClip(cs.getPredBuf(cu), cs.slice->clpRngs());
#if JVET_N0805_APS_LMCS
if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && !cu.firstPU->mhIntraFlag && !CU::isIBC(cu))
#else
if (cs.slice->getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && !cu.firstPU->mhIntraFlag && !CU::isIBC(cu))
#endif
{
cs.getRecoBuf(cu).get(COMPONENT_Y).rspSignal(m_pcReshape->getFwdLUT());
}
......@@ -574,7 +610,11 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID )
//===== reconstruction =====
const Slice &slice = *cs.slice;
#if JVET_N0805_APS_LMCS
if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && isChroma(compID) && TU::getCbf(currTU, compID) && slice.getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width*currTU.blocks[compID].height > 4)
#else
if ( slice.getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && isChroma(compID) && TU::getCbf(currTU, compID) && slice.getReshapeInfo().getSliceReshapeChromaAdj() && currTU.blocks[compID].width*currTU.blocks[compID].height > 4 )
#endif
{
#if JVET_N0054_JOINT_CHROMA
if ( !(currTU.jointCbCr && compID == COMPONENT_Cr) ) // Joint chroma residual mode: chroma scaling took place already when doing Cb
......@@ -605,7 +645,11 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu)
CodingStructure &cs = *cu.cs;
const Slice &slice = *cs.slice;
#if JVET_N0477_LMCS_CLEANUP
#if JVET_N0805_APS_LMCS
if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && slice.getLmcsChromaResidualScaleFlag() && (compID == COMPONENT_Y) && (currTU.cbf[COMPONENT_Cb] || currTU.cbf[COMPONENT_Cr]))
#else
if (slice.getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID == COMPONENT_Y) && (currTU.cbf[COMPONENT_Cb] || currTU.cbf[COMPONENT_Cr]))
#endif
#else
if (slice.getReshapeInfo().getUseSliceReshaper() && m_pcReshape->getCTUFlag() && slice.getReshapeInfo().getSliceReshapeChromaAdj() && (compID == COMPONENT_Y))
#endif
......
......@@ -213,8 +213,13 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri
{
#if JVET_N0415_CTB_ALF
pcEncPic->slices[i]->setTileGroupNumAps(pic->slices[i]->getTileGroupNumAps());
#if JVET_N0805_APS_LMCS
pcEncPic->slices[i]->setAlfAPSs(pic->slices[i]->getTileGroupApsIdLuma());
pcEncPic->slices[i]->setAlfAPSs(pic->slices[i]->getAlfAPSs());
#else
pcEncPic->slices[i]->setAPSs(pic->slices[i]->getTileGroupApsIdLuma());
pcEncPic->slices[i]->setAPSs(pic->slices[i]->getAPSs());
#endif
pcEncPic->slices[i]->setTileGroupApsIdChroma(pic->slices[i]->getTileGroupApsIdChroma());
pcEncPic->slices[i]->setTileGroupAlfEnabledFlag(COMPONENT_Y, pic->slices[i]->getTileGroupAlfEnabledFlag(COMPONENT_Y));
pcEncPic->slices[i]->setTileGroupAlfEnabledFlag(COMPONENT_Cb, pic->slices[i]->getTileGroupAlfEnabledFlag(COMPONENT_Cb));
......@@ -782,13 +787,25 @@ void DecLib::xActivateParameterSets()
for (int i = 0; i < m_apcSlicePilot->getTileGroupApsIdLuma().size(); i++)
{
int apsId = m_apcSlicePilot->getTileGroupApsIdLuma()[i];
#if JVET_N0805_APS_LMCS
APS* aps = m_parameterSetManager.getAPS(apsId, ALF_APS);
#else
APS* aps = m_parameterSetManager.getAP