Commit 8420ed0d authored by Karsten Suehring's avatar Karsten Suehring

improve APS implementation

- remove duplicate ALF parameters from Slice
- add activation (to avoide overwriting when a new APS arrives)
- rename macro
parent 520aeb5f
......@@ -904,7 +904,7 @@ void EncApp::rateStatsAccum(const AccessUnit& au, const std::vector<uint32_t>& a
#endif
case NAL_UNIT_SPS:
case NAL_UNIT_PPS:
#if JVET_M0132
#if JVET_M0132_APS
case NAL_UNIT_APS:
#endif
m_essentialBytes += *it_stats;
......@@ -923,7 +923,7 @@ void EncApp::printRateSummary()
msg( DETAILS,"Bytes written to file: %u (%.3f kbps)\n", m_totalBytes, 0.008 * m_totalBytes / time );
if (m_summaryVerboseness > 0)
{
#if JVET_M0132
#if JVET_M0132_APS
msg(DETAILS, "Bytes for SPS/PPS/APS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time);
#else
msg( DETAILS,"Bytes for SPS/PPS/Slice (Incl. Annex B): %u (%.3f kbps)\n", m_essentialBytes, 0.008 * m_essentialBytes / time );
......
......@@ -174,7 +174,7 @@ void AdaptiveLoopFilter::reconstructCoeff( AlfSliceParam& alfSliceParam, Channel
for( int classIdx = 0; classIdx < numClasses; classIdx++ )
{
int filterIdx = alfSliceParam.filterCoeffDeltaIdx[classIdx];
memcpy( m_coeffFinal + classIdx * MAX_NUM_ALF_LUMA_COEFF, coeff + filterIdx * MAX_NUM_ALF_LUMA_COEFF, sizeof( int16_t ) * numCoeff );
memcpy( m_coeffFinal + classIdx * MAX_NUM_ALF_LUMA_COEFF, coeff + filterIdx * MAX_NUM_ALF_LUMA_COEFF, sizeof( short ) * numCoeff );
}
if( bRedo && alfSliceParam.alfLumaCoeffDeltaPredictionFlag )
......
......@@ -802,6 +802,9 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
subStruct.vps = vps;
#endif
subStruct.pps = pps;
#if JVET_M0132_APS
subStruct.aps = aps;
#endif
subStruct.slice = slice;
subStruct.baseQP = baseQP;
subStruct.prevQP[_chType]
......
......@@ -101,7 +101,7 @@ public:
bool isLossless;
const SPS *sps;
const PPS *pps;
#if JVET_M0132
#if JVET_M0132_APS
APS * aps;
#endif
#if HEVC_VPS
......
......@@ -192,7 +192,7 @@ static const int C2FLAG_NUMBER = 1; ///< maxi
static const int MAX_NUM_VPS = 16;
static const int MAX_NUM_SPS = 16;
static const int MAX_NUM_PPS = 64;
#if JVET_M0132
#if JVET_M0132_APS
static const int MAX_NUM_APS = 32; //Currently APS ID has 5 bits
#endif
......
......@@ -881,7 +881,7 @@ const CPelUnitBuf Picture::getRecoBuf(const UnitArea &unit) const { return g
PelUnitBuf Picture::getRecoBuf() { return M_BUFS(scheduler.getSplitPicId(), PIC_RECONSTRUCTION); }
const CPelUnitBuf Picture::getRecoBuf() const { return M_BUFS(scheduler.getSplitPicId(), PIC_RECONSTRUCTION); }
#if JVET_M0132
#if JVET_M0132_APS
void Picture::finalInit(const SPS& sps, const PPS& pps, APS& aps)
#else
void Picture::finalInit( const SPS& sps, const PPS& pps )
......@@ -921,7 +921,7 @@ void Picture::finalInit( const SPS& sps, const PPS& pps )
cs->picture = this;
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_M0132
#if JVET_M0132_APS
cs->aps = &aps;
#endif
#if HEVC_VPS
......@@ -946,7 +946,7 @@ void Picture::allocateNewSlice()
slices.push_back(new Slice);
Slice& slice = *slices.back();
#if JVET_M0132
#if JVET_M0132_APS
slice.setAPS(cs->aps);
#endif
slice.setPPS( cs->pps);
......@@ -962,7 +962,7 @@ Slice *Picture::swapSliceObject(Slice * p, uint32_t i)
{
p->setSPS(cs->sps);
p->setPPS(cs->pps);
#if JVET_M0132
#if JVET_M0132_APS
p->setAPS(cs->aps);
#endif
......@@ -970,7 +970,7 @@ Slice *Picture::swapSliceObject(Slice * p, uint32_t i)
slices[i] = p;
pTmp->setSPS(0);
pTmp->setPPS(0);
#if JVET_M0132
#if JVET_M0132_APS
pTmp->setAPS(0);
#endif
return pTmp;
......
......@@ -233,7 +233,7 @@ struct Picture : public UnitArea
const CPelUnitBuf getBuf(const UnitArea &unit, const PictureType &type) const;
void extendPicBorder();
#if JVET_M0132
#if JVET_M0132_APS
void finalInit(const SPS& sps, const PPS& pps, APS& aps);
#else
void finalInit( const SPS& sps, const PPS& pps );
......
......@@ -86,7 +86,7 @@ const char* nalUnitTypeToString(NalUnitType type)
#endif
case NAL_UNIT_SPS: return "SPS";
case NAL_UNIT_PPS: return "PPS";
#if JVET_M0132
#if JVET_M0132_APS
case NAL_UNIT_APS: return "APS";
#endif
case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD";
......
......@@ -138,7 +138,7 @@ Slice::Slice()
, m_uiMaxBTSizeIChroma ( 0 )
, m_uiMaxTTSizeIChroma ( 0 )
, m_uiMaxBTSize ( 0 )
#if JVET_M0132
#if JVET_M0132_APS
, m_apsId ( -1 )
, m_aps (NULL)
#endif
......@@ -1936,7 +1936,7 @@ PPS::~PPS()
delete pcv;
}
#if JVET_M0132
#if JVET_M0132_APS
APS::APS()
: m_APSId(0)
{
......@@ -2424,7 +2424,7 @@ ParameterSetManager::ParameterSetManager()
: m_spsMap(MAX_NUM_SPS)
#endif
, m_ppsMap(MAX_NUM_PPS)
#if JVET_M0132
#if JVET_M0132_APS
, m_apsMap(MAX_NUM_APS)
#endif
#if HEVC_VPS
......@@ -2537,7 +2537,7 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP)
return false;
}
#if JVET_M0132
#if JVET_M0132_APS
bool ParameterSetManager::activateAPS(int apsId)
{
APS *aps = m_apsMap.getPS(apsId);
......@@ -2684,7 +2684,7 @@ void xTracePPSHeader()
DTRACE( g_trace_ctx, D_HEADER, "=========== Picture Parameter Set ===========\n" );
}
#if JVET_M0132
#if JVET_M0132_APS
void xTraceAPSHeader()
{
DTRACE(g_trace_ctx, D_HEADER, "=========== Adaptation Parameter Set ===========\n");
......
......@@ -1563,7 +1563,7 @@ public:
PPSRExt& getPpsRangeExtension() { return m_ppsRangeExtension; }
};
#if JVET_M0132
#if JVET_M0132_APS
class APS
{
private:
......@@ -1578,7 +1578,7 @@ public:
void setAPSId(int i) { m_APSId = i; }
void setAlfAPSParam(AlfSliceParam& alfAPSParam) { m_alfAPSParam = alfAPSParam; }
AlfSliceParam getAlfAPSParam() { return m_alfAPSParam; }
const AlfSliceParam& getAlfAPSParam() const { return m_alfAPSParam; }
};
#endif
struct WPScalingParam
......@@ -1737,11 +1737,15 @@ private:
uint32_t m_uiMaxTTSizeIChroma;
uint32_t m_uiMaxBTSize;
#if JVET_M0132
#if JVET_M0132_APS
int m_apsId;
APS* m_aps;
#endif
#if !JVET_M0132_APS
AlfSliceParam m_alfSliceParam;
#else
bool m_tileGroupAlfEnabledFlag;
#endif
#if JVET_M0427_INLOOP_RESHAPER
SliceReshapeInfo m_sliceReshapeInfo;
#endif
......@@ -1762,7 +1766,7 @@ public:
void setPPSId( int PPSId ) { m_iPPSId = PPSId; }
int getPPSId() const { return m_iPPSId; }
#if JVET_M0132
#if JVET_M0132_APS
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; }
......@@ -2027,8 +2031,13 @@ public:
void resetProcessingTime() { m_dProcessingTime = m_iProcessingStartTime = 0; }
double getProcessingTime() const { return m_dProcessingTime; }
#if !JVET_M0132_APS
void setAlfSliceParam( AlfSliceParam& alfSliceParam ) { m_alfSliceParam = alfSliceParam; }
AlfSliceParam& getAlfSliceParam() { return m_alfSliceParam; }
#else
bool getTileGroupAlfEnabledFlag() const { return m_tileGroupAlfEnabledFlag; }
void setTileGroupAlfEnabledFlag(bool b) { m_tileGroupAlfEnabledFlag = b; }
#endif
#if JVET_M0427_INLOOP_RESHAPER
const SliceReshapeInfo& getReshapeInfo() const { return m_sliceReshapeInfo; }
......@@ -2225,7 +2234,7 @@ public:
//! \returns true, if activation is successful
bool activatePPS(int ppsId, bool isIRAP);
#if JVET_M0132
#if JVET_M0132_APS
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); }
......@@ -2244,7 +2253,7 @@ protected:
#endif
ParameterSetMap<SPS> m_spsMap;
ParameterSetMap<PPS> m_ppsMap;
#if JVET_M0132
#if JVET_M0132_APS
ParameterSetMap<APS> m_apsMap;
#endif
......@@ -2341,7 +2350,7 @@ void xTraceVPSHeader();
#endif
void xTraceSPSHeader();
void xTracePPSHeader();
#if JVET_M0132
#if JVET_M0132_APS
void xTraceAPSHeader();
#endif
void xTraceSliceHeader();
......
......@@ -278,6 +278,8 @@ typedef std::pair<int, int> TrCost;
#endif
#endif
#define JVET_M0132_APS 1 // APS
#define KEEP_PRED_AND_RESI_SIGNALS 0
......@@ -332,7 +334,6 @@ typedef std::pair<int, int> TrCost;
#define X0038_LAMBDA_FROM_QP_CAPABILITY 1 ///< This approach derives lambda from QP+QPoffset+QPoffset2. QPoffset2 is derived from QP+QPoffset using a linear model that is clipped between 0 and 3.
// To use this capability enable config parameter LambdaFromQpEnable
#define JVET_M0132 1
// ====================================================================================================================
// Tool Switches
// ====================================================================================================================
......@@ -978,7 +979,7 @@ enum NalUnitType
#endif
NAL_UNIT_SPS, // 33
NAL_UNIT_PPS, // 34
#if JVET_M0132
#if JVET_M0132_APS
NAL_UNIT_APS, //NAL unit type number needs to be reaaranged.
#endif
NAL_UNIT_ACCESS_UNIT_DELIMITER, // 35
......@@ -1644,6 +1645,11 @@ struct AlfSliceParam
bool alfLumaCoeffDeltaPredictionFlag; // alf_luma_coeff_delta_prediction_flag
std::vector<AlfFilterShape>* filterShapes;
AlfSliceParam()
{
reset();
}
void reset()
{
std::memset( enabledFlag, false, sizeof( enabledFlag ) );
......
......@@ -143,10 +143,16 @@ bool CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i
sao( cs, ctuRsAddr );
#if !JVET_M0132_APS
AlfSliceParam& alfSliceParam = cs.slice->getAlfSliceParam();
if( cs.sps->getALFEnabledFlag() && ( alfSliceParam.enabledFlag[COMPONENT_Y] || alfSliceParam.enabledFlag[COMPONENT_Cb] || alfSliceParam.enabledFlag[COMPONENT_Cr] ) )
if (cs.sps->getALFEnabledFlag() && (alfSliceParam.enabledFlag[COMPONENT_Y] || alfSliceParam.enabledFlag[COMPONENT_Cb] || alfSliceParam.enabledFlag[COMPONENT_Cr]))
{
#else
if (cs.sps->getALFEnabledFlag() && (cs.slice->getTileGroupAlfEnabledFlag()))
{
CHECK(cs.aps == nullptr, "APS not initialized");
const AlfSliceParam& alfSliceParam = cs.aps->getAlfAPSParam();
#endif
const PreCalcValues& pcv = *cs.pcv;
int frame_width_in_ctus = pcv.widthInCtus;
......
......@@ -220,7 +220,13 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri
for( int i = 0; i < pic->slices.size(); i++ )
{
#if JVET_M0132_APS
pcEncPic->slices[i]->setAPSId(pic->slices[i]->getAPSId());
pcEncPic->slices[i]->setAPS( pic->slices[i]->getAPS());
pcEncPic->slices[i]->setTileGroupAlfEnabledFlag( pic->slices[i]->getTileGroupAlfEnabledFlag());
#else
pcEncPic->slices[i]->getAlfSliceParam() = pic->slices[i]->getAlfSliceParam();
#endif
}
}
......@@ -581,7 +587,20 @@ void DecLib::executeLoopFilters()
if( cs.sps->getALFEnabledFlag() )
{
#if JVET_M0132_APS
if (cs.slice->getTileGroupAlfEnabledFlag())
{
// ALF decodes the differentially coded coefficients and stores them in the parameters structure.
// Code could be restructured to do directly after parsing. So far we just pass a fresh non-const
// copy in case the APS gets used more than once.
AlfSliceParam alfParamCopy = cs.aps->getAlfAPSParam();
m_cALF.ALFProcess(cs, alfParamCopy);
}
#else
m_cALF.ALFProcess( cs, cs.slice->getAlfSliceParam() );
#endif
}
}
......@@ -738,7 +757,7 @@ void DecLib::xActivateParameterSets()
{
if (m_bFirstSliceInPicture)
{
#if JVET_M0132
#if JVET_M0132_APS
APS *aps = m_parameterSetManager.getAPS(m_apcSlicePilot->getAPSId()); // this is a temporary APS object. Do not store this value
if (m_apcSlicePilot->getAPSId() != -1)
{
......@@ -758,16 +777,22 @@ void DecLib::xActivateParameterSets()
m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId());
m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId());
#if JVET_M0132 //Hendry
if (aps != 0)
m_parameterSetManager.clearAPSChangedFlag(aps->getAPSId());
#endif
if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP()))
{
THROW("Parameter set activation failed!");
}
#if JVET_M0132_APS
if (aps)
{
m_parameterSetManager.clearAPSChangedFlag(aps->getAPSId());
if (false == m_parameterSetManager.activateAPS(m_apcSlicePilot->getAPSId()))
{
THROW("APS activation failed!");
}
}
#endif
xParsePrefixSEImessages();
#if RExt__HIGH_BIT_DEPTH_SUPPORT==0
......@@ -782,7 +807,7 @@ void DecLib::xActivateParameterSets()
m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS());
#if JVET_M0132
#if JVET_M0132_APS
m_pcPic->finalInit(*sps, *pps, *aps);
#else
m_pcPic->finalInit( *sps, *pps );
......@@ -800,7 +825,7 @@ void DecLib::xActivateParameterSets()
Slice *pSlice = m_pcPic->slices[m_uiSliceSegmentIdx];
// Update the PPS and SPS pointers with the ones of the picture.
#if JVET_M0132
#if JVET_M0132_APS
aps= pSlice->getAPS();
#endif
pps=pSlice->getPPS();
......@@ -810,7 +835,7 @@ void DecLib::xActivateParameterSets()
m_pcPic->cs->slice = pSlice;
m_pcPic->cs->sps = sps;
m_pcPic->cs->pps = pps;
#if JVET_M0132
#if JVET_M0132_APS
m_pcPic->cs->aps = aps;
#endif
#if HEVC_VPS
......@@ -888,14 +913,14 @@ void DecLib::xActivateParameterSets()
const SPS *sps = pSlice->getSPS();
const PPS *pps = pSlice->getPPS();
#if JVET_M0132
#if JVET_M0132_APS
APS *aps = pSlice->getAPS();
#endif
// fix Parameter Sets, now that we have the real slice
m_pcPic->cs->slice = pSlice;
m_pcPic->cs->sps = sps;
m_pcPic->cs->pps = pps;
#if JVET_M0132
#if JVET_M0132_APS
m_pcPic->cs->aps = aps;
#endif
#if HEVC_VPS
......@@ -912,7 +937,7 @@ void DecLib::xActivateParameterSets()
{
EXIT("Error - a new PPS has been decoded while processing a picture");
}
#if JVET_M0132
#if JVET_M0132_APS
if (aps && m_parameterSetManager.getAPSChangedFlag(aps->getAPSId()))
{
EXIT("Error - a new APS has been decoded while processing a picture");
......@@ -1082,7 +1107,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
int iMaxPOClsb = 1 << sps->getBitsForPOC();
m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) );
xUpdatePreviousTid0POC(m_apcSlicePilot);
#if JVET_M0132
#if JVET_M0132_APS
if (m_apcSlicePilot->getAPSId() != -1)
{
APS *aps = m_parameterSetManager.getAPS(m_apcSlicePilot->getAPSId());
......@@ -1443,7 +1468,7 @@ void DecLib::xDecodePPS( InputNALUnit& nalu )
m_parameterSetManager.storePPS( pps, nalu.getBitstream().getFifo() );
}
#if JVET_M0132
#if JVET_M0132_APS
void DecLib::xDecodeAPS(InputNALUnit& nalu)
{
APS* aps = new APS();
......@@ -1477,7 +1502,7 @@ bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay)
case NAL_UNIT_PPS:
xDecodePPS( nalu );
return false;
#if JVET_M0132
#if JVET_M0132_APS
case NAL_UNIT_APS:
xDecodeAPS(nalu);
return false;
......
......@@ -184,7 +184,7 @@ protected:
#endif
void xDecodeSPS( InputNALUnit& nalu );
void xDecodePPS( InputNALUnit& nalu );
#if JVET_M0132
#if JVET_M0132_APS
void xDecodeAPS(InputNALUnit& nalu);
#endif
void xUpdatePreviousTid0POC( Slice *pSlice ) { if ((pSlice->getTLayer()==0) && (pSlice->isReferenceNalu() && (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RASL_R)&& (pSlice->getNalUnitType()!=NAL_UNIT_CODED_SLICE_RADL_R))) { m_prevTid0POC=pSlice->getPOC(); } }
......
......@@ -91,7 +91,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream )
cs.slice = slice;
cs.sps = sps;
cs.pps = slice->getPPS();
#if JVET_M0132
#if JVET_M0132_APS
cs.aps = slice->getAPS();
#endif
#if HEVC_VPS
......
......@@ -607,7 +607,7 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS )
xReadRbspTrailingBits();
}
#if JVET_M0132
#if JVET_M0132_APS
void HLSyntaxReader::parseAPS(APS* aps)
{
#if ENABLE_TRACING
......@@ -1647,22 +1647,20 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
if( sps->getALFEnabledFlag() )
{
#if JVET_M0132
#if JVET_M0132_APS
READ_FLAG(uiCode, "tile_group_alf_enabled_flag");
if (uiCode)
{
READ_CODE(5, uiCode, "tile_group_aps_id");
pcSlice->setAPSId(uiCode);
pcSlice->setAPS(parameterSetManager->getAPS(uiCode));
AlfSliceParam alfParam = pcSlice->getAPS()->getAlfAPSParam();
pcSlice->setAlfSliceParam(alfParam);
pcSlice->getAlfSliceParam().enabledFlag[COMPONENT_Y] = true;
pcSlice->setTileGroupAlfEnabledFlag(true);
}
else
{
pcSlice->getAlfSliceParam().enabledFlag[COMPONENT_Y] = false;
pcSlice->getAlfSliceParam().enabledFlag[COMPONENT_Cb] = false;
pcSlice->getAlfSliceParam().enabledFlag[COMPONENT_Cr] = false;
pcSlice->setTileGroupAlfEnabledFlag(false);
pcSlice->setAPSId(-1);
pcSlice->setAPS(nullptr);
}
#else
alf( pcSlice->getAlfSliceParam() );
......@@ -2491,7 +2489,7 @@ bool HLSyntaxReader::xMoreRbspData()
return (cnt>0);
}
#if !JVET_M0132
#if !JVET_M0132_APS
void HLSyntaxReader::alf( AlfSliceParam& alfSliceParam )
{
uint32_t code;
......
......@@ -149,7 +149,7 @@ public:
#endif
void parseSPS ( SPS* pcSPS );
void parsePPS ( PPS* pcPPS );
#if JVET_M0132
#if JVET_M0132_APS
void parseAPS ( APS* pcAPS);
#endif
void parseVUI ( VUI* pcVUI, SPS* pcSPS );
......@@ -168,7 +168,7 @@ public:
#if JVET_M0427_INLOOP_RESHAPER
void parseReshaper ( SliceReshapeInfo& sliceReshaperInfo, const SPS* pcSPS, const bool isIntra );
#endif
#if !JVET_M0132
#if !JVET_M0132_APS
void alf( AlfSliceParam& alfSliceParam );
#endif
void alfFilter( AlfSliceParam& alfSliceParam, const bool isChroma );
......
......@@ -3416,7 +3416,11 @@ void CABACWriter::codeAlfCtuEnableFlags( CodingStructure& cs, ComponentID compID
void CABACWriter::codeAlfCtuEnableFlag( CodingStructure& cs, uint32_t ctuRsAddr, const int compIdx, AlfSliceParam* alfParam)
{
#if JVET_M0132_APS
const AlfSliceParam& alfSliceParam = alfParam ? (*alfParam) : cs.aps->getAlfAPSParam();
#else
AlfSliceParam& alfSliceParam = alfParam ? (*alfParam) : cs.slice->getAlfSliceParam();
#endif
if( cs.sps->getALFEnabledFlag() && alfSliceParam.enabledFlag[compIdx] )
{
......
......@@ -237,7 +237,7 @@ int EncGOP::xWritePPS (AccessUnit &accessUnit, const PPS *pps)
return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
}
#if JVET_M0132
#if JVET_M0132_APS
int EncGOP::xWriteAPS(AccessUnit &accessUnit, APS *aps)
{
OutputNALUnit nalu(NAL_UNIT_APS);
......@@ -2213,7 +2213,13 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
if( pcSlice->getSPS()->getALFEnabledFlag() )
{
pcPic->resizeAlfCtuEnableFlag( numberOfCtusInFrame );
#if JVET_M0132_APS
// reset the APS ALF parameters
AlfSliceParam newALFParam;
pcSlice->getAPS()->setAlfAPSParam(newALFParam);
#else
std::memset( pcSlice->getAlfSliceParam().enabledFlag, false, sizeof( pcSlice->getAlfSliceParam().enabledFlag ) );
#endif
}
bool decPic = false;
......@@ -2484,10 +2490,14 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
#endif
alfSliceParam );
//assign ALF slice header
#if JVET_M0132_APS
pcPic->cs->aps->setAlfAPSParam(alfSliceParam);
#else
for( int s = 0; s< uiNumSliceSegments; s++ )
{
pcPic->slices[s]->setAlfSliceParam( alfSliceParam );
}
#endif
}
if (m_pcCfg->getUseCompositeRef() && getPrepareLTRef())
{
......@@ -2559,13 +2569,17 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic,
{
xWriteAccessUnitDelimiter(accessUnit, pcSlice);
}
#if JVET_M0132
if (pcSlice->getSPS()->getALFEnabledFlag() && pcSlice->getAlfSliceParam().enabledFlag[COMPONENT_Y])
#if JVET_M0132_APS
if (pcSlice->getSPS()->getALFEnabledFlag() && pcSlice->getAPS()->getAlfAPSParam().enabledFlag[COMPONENT_Y])
{
pcSlice->setTileGroupAlfEnabledFlag(true);
pcSlice->setAPSId(pcSlice->getAPS()->getAPSId());
pcSlice->getAPS()->setAlfAPSParam(pcSlice->getAlfSliceParam());
actualTotalBits += xWriteAPS(accessUnit, pcSlice->getAPS());
}
else
{
pcSlice->setTileGroupAlfEnabledFlag(false);
}
#endif
// reset presence of BP SEI indication
......
......@@ -281,7 +281,7 @@ protected:
#endif
int xWriteSPS (AccessUnit &accessUnit, const SPS *sps);
int xWritePPS (AccessUnit &accessUnit, const PPS *pps);
#if JVET_M0132
#if JVET_M0132_APS
int xWriteAPS(AccessUnit &accessUnit, APS *aps);
#endif
int xWriteParameterSets (AccessUnit &accessUnit, Slice *slice, const bool bSeqFirst);
......
......@@ -60,7 +60,7 @@
EncLib::EncLib()
: m_spsMap( MAX_NUM_SPS )
, m_ppsMap( MAX_NUM_PPS )
#if JVET_M0132
#if JVET_M0132_APS
, m_apsMap( MAX_NUM_APS )
#endif
, m_AUWriterIf( nullptr )
......@@ -217,7 +217,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf )
SPS &sps0=*(m_spsMap.allocatePS(0)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues.
PPS &pps0=*(m_ppsMap.allocatePS(0));
#if JVET_M0132
#if JVET_M0132_APS
APS &aps0=*(m_apsMap.allocatePS(0));
#endif
......@@ -257,7 +257,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf )
// initialize PPS
xInitPPS(pps0, sps0);
#if JVET_M0132
#if JVET_M0132_APS
// initialize APS
xInitAPS(aps0);
#endif
......@@ -395,7 +395,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf )
Picture *picBg = new Picture;
picBg->create(sps0.getChromaFormatIdc(), Size(sps0.getPicWidthInLumaSamples(), sps0.getPicHeightInLumaSamples()), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false);
picBg->getRecoBuf().fill(0);
#if JVET_M0132
#if JVET_M0132_APS
picBg->finalInit(sps0, pps0, aps0);
#else
picBg->finalInit(sps0, pps0);
......@@ -550,7 +550,7 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru
const SPS *sps = m_spsMap.getPS(pps->getSPSId());
picCurr->M_BUFS(0, PIC_ORIGINAL).copyFrom(m_cGOPEncoder.getPicBg()->getRecoBuf());
#if JVET_M0132
#if JVET_M0132_APS
APS *aps = m_apsMap.getPS(0);
picCurr->finalInit(*sps, *pps, *aps);
#else
......@@ -606,7 +606,7 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYuvTru
pcPicCurr->M_BUFS( 0, PIC_TRUE_ORIGINAL).swap(*cPicYuvTrueOrg);
#endif
#if JVET_M0132
#if JVET_M0132_APS
APS *pAPS = m_apsMap.getPS(0);
pcPicCurr->finalInit(*pSPS, *pPPS, *pAPS);
#else
......@@ -706,7 +706,7 @@ void EncLib::encode( bool flush, PelStorage* pcPicYuvOrg, PelStorage* pcPicYuvTr
const PPS *pPPS=(ppsID<0) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS(ppsID);
const SPS *pSPS=m_spsMap.getPS(pPPS->getSPSId());
#if JVET_M0132
#if JVET_M0132_APS
APS *pAPS = m_apsMap.getPS(0);
pcField->finalInit(*pSPS, *pPPS, *pAPS);
#else
......@@ -1516,7 +1516,7 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps)
pps.pcv = new PreCalcValues( sps, pps, true );
}
#if JVET_M0132