Commit 95324f25 authored by Brian Heng's avatar Brian Heng

Fix for Ticket #235

  - Merge in latest updates from master branch to resolve merge conflict.
parents 63bac246 7195e405
This diff is collapsed.
......@@ -84,9 +84,17 @@ public:
AdaptiveLoopFilter();
virtual ~AdaptiveLoopFilter() {}
#if JVET_N0415_CTB_ALF
void reconstructCoeffAPSs(CodingStructure& cs, bool luma, bool chroma, bool isRdo);
void ALFProcess(CodingStructure& cs);
#else
void ALFProcess( CodingStructure& cs, AlfSliceParam& alfSliceParam );
void reconstructCoeff( AlfSliceParam& alfSliceParam, ChannelType channel, const bool bRedo = false );
#endif
void reconstructCoeff( AlfSliceParam& alfSliceParam, ChannelType channel,
#if JVET_N0415_CTB_ALF
const bool isRdo = false,
#endif
const bool isRedo = false );
void create( const int picWidth, const int picHeight, const ChromaFormat format, const int maxCUWidth, const int maxCUHeight, const int maxCUDepth, const int inputBitDepth[MAX_NUM_CHANNEL_TYPE] );
void destroy();
#if JVET_N0180_ALF_LINE_BUFFER_REDUCTION
......@@ -146,6 +154,18 @@ public:
#endif
protected:
#if JVET_N0415_CTB_ALF
static const int m_classToFilterMapping[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES];
static const int m_fixedFilterSetCoeff[ALF_FIXED_FILTER_NUM][MAX_NUM_ALF_LUMA_COEFF];
short m_fixedFilterSetCoeffDec[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF];
short m_coeffApsLuma[6][MAX_NUM_ALF_LUMA_COEFF * MAX_NUM_ALF_CLASSES];
#if JVET_N0242_NON_LINEAR_ALF
short m_clippApsLuma[6][MAX_NUM_ALF_LUMA_COEFF * MAX_NUM_ALF_CLASSES];
short m_clipDefault[MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF];
#endif
bool m_created = false;
short m_chromaCoeffFinal[MAX_NUM_ALF_LUMA_COEFF];
#endif
#if JVET_N0242_NON_LINEAR_ALF
Pel m_alfClippingValues[MAX_NUM_CHANNEL_TYPE][MaxAlfNumClippingValues];
#endif
......@@ -157,7 +177,7 @@ protected:
short m_chromaClippFinal[MAX_NUM_ALF_LUMA_COEFF];
#endif
int** m_laplacian[NUM_DIRECTIONS];
uint8_t* m_ctuEnableFlag[MAX_NUM_COMPONENT];
uint8_t* m_ctuEnableFlag[MAX_NUM_COMPONENT];
PelStorage m_tempBuf;
int m_inputBitDepth[MAX_NUM_CHANNEL_TYPE];
int m_picWidth;
......
......@@ -776,7 +776,11 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe
subStruct.vps = vps;
#endif
subStruct.pps = pps;
#if JVET_N0415_CTB_ALF
memcpy(subStruct.apss, apss, sizeof(apss));
#else
subStruct.aps = aps;
#endif
subStruct.slice = slice;
subStruct.baseQP = baseQP;
subStruct.prevQP[_chType]
......
......@@ -94,7 +94,11 @@ public:
bool isLossless;
const SPS *sps;
const PPS *pps;
#if JVET_N0415_CTB_ALF
APS* apss[MAX_NUM_APS];
#else
APS * aps;
#endif
#if HEVC_VPS
const VPS *vps;
#endif
......@@ -257,6 +261,9 @@ public:
const CPelBuf getRecoBuf(const CompArea &blk) const;
PelUnitBuf getRecoBuf(const UnitArea &unit);
const CPelUnitBuf getRecoBuf(const UnitArea &unit) const;
#if JVET_N0415_CTB_ALF
PelUnitBuf& getRecoBufRef() { return m_reco; }
#endif
PelBuf getOrgResiBuf(const CompArea &blk);
const CPelBuf getOrgResiBuf(const CompArea &blk) const;
......@@ -309,8 +316,5 @@ private:
static inline uint32_t getNumberValidTBlocks(const PreCalcValues& pcv) { return (pcv.chrFormat==CHROMA_400) ? 1 : ( pcv.multiBlock422 ? MAX_NUM_TBLOCKS : MAX_NUM_COMPONENT ); }
inline unsigned toWSizeIdx( const CodingStructure* cs ) { return gp_sizeIdxInfo->idxFrom( cs->area.lwidth() ); }
inline unsigned toHSizeIdx( const CodingStructure* cs ) { return gp_sizeIdxInfo->idxFrom( cs->area.lheight() ); }
#endif
......@@ -178,6 +178,13 @@ static const int MIP_MAX_WIDTH = 64;
static const int MIP_MAX_HEIGHT = 64;
#endif
#if JVET_N0415_CTB_ALF
static const int ALF_FIXED_FILTER_NUM = 64;
static const int ALF_CTB_MAX_NUM_APS = 6;
static const int NUM_FIXED_FILTER_SETS = 16;
static const int NUM_TOTAL_FILTER_SETS = NUM_FIXED_FILTER_SETS + ALF_CTB_MAX_NUM_APS;
#endif
#if JVET_N0178_IMPLICIT_BDOF_SPLIT
static const int MAX_BDOF_APPLICATION_REGION = 16;
#endif
......
......@@ -92,7 +92,7 @@ CoeffCodingContext::CoeffCodingContext(const TransformUnit& tu, ComponentID comp
, m_lastOffsetY (0)
, m_lastShiftX (0)
, m_lastShiftY (0)
, m_TrafoBypass (tu.cs->sps->getSpsRangeExtension().getTransformSkipContextEnabledFlag() && (tu.cu->transQuantBypass || tu.mtsIdx==1))
, m_TrafoBypass (tu.cs->sps->getSpsRangeExtension().getTransformSkipContextEnabledFlag() && (tu.cu->transQuantBypass || tu.mtsIdx==MTS_SKIP))
, m_scanPosLast (-1)
, m_subSetId (-1)
, m_subSetPos (-1)
......@@ -615,4 +615,4 @@ unsigned DeriveCtx::CtxMipFlag( const CodingUnit& cu )
return ctxId;
}
#endif
\ No newline at end of file
#endif
......@@ -696,10 +696,17 @@ const CtxSet ContextSetCfg::TransquantBypassFlag = ContextSetCfg::addCtxSet
#if JVET_N0193_LFNST
const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet
( {
#if JVET_N0105_LFNST_CTX_MODELLING
{ CNU, CNU, },
{ CNU, CNU, },
{ CNU, CNU, },
{ DWS, DWS, },
#else
{ CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, },
{ CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, },
{ CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, },
{ DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, },
#endif
} );
#endif
......@@ -824,6 +831,29 @@ const CtxSet ContextSetCfg::ctbAlfFlag =
} )
};
#if JVET_N0415_CTB_ALF
const CtxSet ContextSetCfg::AlfUseLatestFilt =
{
ContextSetCfg::addCtxSet
({
{ 154, }, // B
{ 154, }, // P
{ 185, }, // I
{ DWS, },
})
};
const CtxSet ContextSetCfg::AlfUseTemporalFilt =
{
ContextSetCfg::addCtxSet
({
{ 154, },
{ 154, },
{ 154, },
{ DWS, },
})
};
#endif
const CtxSet ContextSetCfg::MHIntraFlag = ContextSetCfg::addCtxSet
({
{ 225, },
......@@ -952,7 +982,9 @@ const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_Ini
// combined sets
const CtxSet ContextSetCfg::Sao = { ContextSetCfg::SaoMergeFlag, ContextSetCfg::SaoTypeIdx };
#if JVET_N0415_CTB_ALF
const CtxSet ContextSetCfg::Alf = { ContextSetCfg::ctbAlfFlag, ContextSetCfg::AlfUseLatestFilt, ContextSetCfg::AlfUseTemporalFilt };
#endif
template <class BinProbModel>
CtxStore<BinProbModel>::CtxStore()
......
......@@ -265,6 +265,11 @@ public:
static const CtxSet ImvFlag;
static const CtxSet GBiIdx;
static const CtxSet ctbAlfFlag;
#if JVET_N0415_CTB_ALF
static const CtxSet AlfUseLatestFilt;
static const CtxSet AlfUseTemporalFilt;
static const CtxSet Alf;
#endif
static const CtxSet MHIntraFlag;
#if !JVET_N0302_SIMPLFIED_CIIP
static const CtxSet MHIntraPredMode;
......
......@@ -756,7 +756,7 @@ namespace DQIntern
const int channelBitDepth = sps.getBitDepth( chType );
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange( chType );
const int nomTransformShift = getTransformShift( channelBitDepth, area.size(), maxLog2TrDynamicRange );
const bool clipTransformShift = ( tu.mtsIdx==1 && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag() );
const bool clipTransformShift = ( tu.mtsIdx==MTS_SKIP && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag() );
#if JVET_N0246_MODIFIED_QUANTSCALES
const bool needsSqrt2ScaleAdjustment = TU::needsSqrt2Scale(tu, compID);
const int transformShift = ( clipTransformShift ? std::max<int>( 0, nomTransformShift ) : nomTransformShift ) + (needsSqrt2ScaleAdjustment?-1:0);
......@@ -859,7 +859,7 @@ namespace DQIntern
const TCoeff minTCoeff = -( 1 << maxLog2TrDynamicRange );
const TCoeff maxTCoeff = ( 1 << maxLog2TrDynamicRange ) - 1;
const int nomTransformShift = getTransformShift( channelBitDepth, area.size(), maxLog2TrDynamicRange );
const bool clipTransformShift = ( tu.mtsIdx==1 && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag() );
const bool clipTransformShift = ( tu.mtsIdx==MTS_SKIP && sps.getSpsRangeExtension().getExtendedPrecisionProcessingFlag() );
#if JVET_N0246_MODIFIED_QUANTSCALES
const bool needsSqrt2ScaleAdjustment = TU::needsSqrt2Scale(tu, compID);
const int transformShift = ( clipTransformShift ? std::max<int>( 0, nomTransformShift ) : nomTransformShift ) + (needsSqrt2ScaleAdjustment?-1:0);
......@@ -1678,7 +1678,7 @@ namespace DQIntern
//===== find first test position =====
int firstTestPos = numCoeff - 1;
#if JVET_N0193_LFNST
if( lfnstIdx > 0 && tu.mtsIdx != 1 && ( ( width == 4 && height == 4 ) || ( width == 8 && height == 8 ) ) )
if( lfnstIdx > 0 && tu.mtsIdx != MTS_SKIP && ( ( width == 4 && height == 4 ) || ( width == 8 && height == 8 ) ) )
{
firstTestPos = 7;
}
......@@ -1707,7 +1707,7 @@ namespace DQIntern
int effWidth = tuPars.m_width, effHeight = tuPars.m_height;
bool zeroOut = false;
if( ( tu.mtsIdx > 1 || ( tu.cu->sbtInfo != 0 && tuPars.m_height <= 32 && tuPars.m_width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
if( ( tu.mtsIdx > MTS_SKIP || ( tu.cu->sbtInfo != 0 && tuPars.m_height <= 32 && tuPars.m_width <= 32 ) ) && !tu.cu->transQuantBypass && compID == COMPONENT_Y )
{
effHeight = ( tuPars.m_height == 32 ) ? 16 : tuPars.m_height;
effWidth = ( tuPars.m_width == 32 ) ? 16 : tuPars.m_width;
......@@ -1719,7 +1719,7 @@ namespace DQIntern
{
const ScanInfo& scanInfo = tuPars.m_scanInfo[ scanIdx ];
#if JVET_N0193_LFNST
bool lfnstZeroOut = lfnstIdx > 0 && tu.mtsIdx != 1 && width >= 4 && height >= 4 &&
bool lfnstZeroOut = lfnstIdx > 0 && tu.mtsIdx != MTS_SKIP && width >= 4 && height >= 4 &&
( ( ( ( width >= 8 && height >= 8 ) && scanIdx >= 16 ) || ( ( ( width == 4 && height == 4 ) || ( width == 8 && height == 8 ) ) && scanIdx >= 8 ) ) && scanIdx < 48 );
xDecideAndUpdate( abs( tCoeff[ scanInfo.rasterPos ] ), scanInfo, ( zeroOut && ( scanInfo.posX >= effWidth || scanInfo.posY >= effHeight ) ) || lfnstZeroOut );
#else
......@@ -1776,7 +1776,7 @@ DepQuant::~DepQuant()
void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeffBuf &pSrc, TCoeff &uiAbsSum, const QpParam &cQP, const Ctx& ctx )
{
#if JVET_N0280_RESIDUAL_CODING_TS
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != 1 || !isLuma(compID)) )
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != MTS_SKIP || !isLuma(compID)) )
#else
if( tu.cs->slice->getDepQuantEnabledFlag() )
#endif
......@@ -1792,7 +1792,7 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff
void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const ComponentID &compID, const QpParam &cQP )
{
#if JVET_N0280_RESIDUAL_CODING_TS
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != 1 || !isLuma(compID)) )
if( tu.cs->slice->getDepQuantEnabledFlag() && (tu.mtsIdx != MTS_SKIP || !isLuma(compID)) )
#else
if( tu.cs->slice->getDepQuantEnabledFlag() )
#endif
......
......@@ -841,6 +841,7 @@ bool InterPrediction::isSubblockVectorSpreadOverLimit( int a, int b, int c, int
#endif
void InterPrediction::xPredAffineBlk( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng )
{
#if !JVET_N0196_SIX_TAP_FILTERS
if ( (pu.cu->affineType == AFFINEMODEL_6PARAM && _mv[0] == _mv[1] && _mv[0] == _mv[2])
|| (pu.cu->affineType == AFFINEMODEL_4PARAM && _mv[0] == _mv[1])
)
......@@ -855,6 +856,7 @@ void InterPrediction::xPredAffineBlk( const ComponentID& compID, const Predictio
);
return;
}
#endif
JVET_J0090_SET_REF_PICTURE( refPic, compID );
const ChromaFormat chFmt = pu.chromaFormat;
......
......@@ -871,7 +871,11 @@ 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_N0415_CTB_ALF
void Picture::finalInit(const SPS& sps, const PPS& pps, APS** apss)
#else
void Picture::finalInit(const SPS& sps, const PPS& pps, APS& aps)
#endif
{
for( auto &sei : SEIs )
{
......@@ -905,7 +909,11 @@ void Picture::finalInit(const SPS& sps, const PPS& pps, APS& aps)
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_N0415_CTB_ALF
memcpy(cs->apss, apss, sizeof(cs->apss));
#else
cs->aps = &aps;
#endif
#if HEVC_VPS
cs->vps = nullptr;
#endif
......@@ -925,8 +933,11 @@ void Picture::allocateNewSlice()
{
slices.push_back(new Slice);
Slice& slice = *slices.back();
#if JVET_N0415_CTB_ALF
memcpy(slice.getAPSs(), cs->apss, sizeof(cs->apss));
#else
slice.setAPS(cs->aps);
#endif
slice.setPPS( cs->pps);
slice.setSPS( cs->sps);
if(slices.size()>=2)
......@@ -940,13 +951,21 @@ Slice *Picture::swapSliceObject(Slice * p, uint32_t i)
{
p->setSPS(cs->sps);
p->setPPS(cs->pps);
#if JVET_N0415_CTB_ALF
p->setAPSs(cs->apss);
#else
p->setAPS(cs->aps);
#endif
Slice * pTmp = slices[i];
slices[i] = p;
pTmp->setSPS(0);
pTmp->setPPS(0);
#if JVET_N0415_CTB_ALF
memset(pTmp->getAPSs(), 0, sizeof(*pTmp->getAPSs())*MAX_NUM_APS);
#else
pTmp->setAPS(0);
#endif
return pTmp;
}
......
......@@ -225,7 +225,11 @@ struct Picture : public UnitArea
const CPelUnitBuf getBuf(const UnitArea &unit, const PictureType &type) const;
void extendPicBorder();
#if JVET_N0415_CTB_ALF
void finalInit(const SPS& sps, const PPS& pps, APS** apss);
#else
void finalInit(const SPS& sps, const PPS& pps, APS& aps);
#endif
int getPOC() const { return poc; }
void setBorderExtension( bool bFlag) { m_bIsBorderExtended = bFlag;}
......@@ -324,6 +328,18 @@ public:
std::fill( m_alfCtuEnableFlag[compIdx].begin(), m_alfCtuEnableFlag[compIdx].end(), 0 );
}
}
#if JVET_N0415_CTB_ALF
std::vector<short> m_alfCtbFilterIndex;
short* getAlfCtbFilterIndex() { return m_alfCtbFilterIndex.data(); }
void resizeAlfCtbFilterIndex(int numEntries)
{
m_alfCtbFilterIndex.resize(numEntries);
for (int i = 0; i < numEntries; i++)
{
m_alfCtbFilterIndex[i] = 0;
}
}
#endif
};
int calcAndPrintHashStatus(const CPelUnitBuf& pic, const class SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths, const MsgLevel msgl);
......
......@@ -373,7 +373,7 @@ void Quant::dequant(const TransformUnit &tu,
const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange);
const TCoeff transformMaximum = (1 << maxLog2TrDynamicRange) - 1;
#if HEVC_USE_SCALING_LISTS
const bool isTransformSkip = tu.mtsIdx==1 && isLuma(compID);
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip);
const int scalingListType = getScalingListType(tu.cu->predMode, compID);
#endif
......@@ -398,7 +398,7 @@ void Quant::dequant(const TransformUnit &tu,
CHECK(uiWidth > m_uiMaxTrSize, "Unsupported transformation size");
// Represents scaling through forward transform
const bool bClipTransformShiftTo0 = tu.mtsIdx!=1 && sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag();
const bool bClipTransformShiftTo0 = tu.mtsIdx!=MTS_SKIP && sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag();
const int originalTransformShift = getTransformShift(channelBitDepth, area.size(), maxLog2TrDynamicRange);
#if JVET_N0246_MODIFIED_QUANTSCALES
const bool needSqrtAdjustment = TU::needsBlockSizeTrafoScale( tu, compID );
......@@ -847,7 +847,7 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf
const CCoeffBuf &piCoef = pSrc;
CoeffBuf piQCoef = tu.getCoeffs(compID);
const bool useTransformSkip = tu.mtsIdx==1;
const bool useTransformSkip = tu.mtsIdx==MTS_SKIP;
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID));
{
......@@ -975,7 +975,7 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff
const CCoeffBuf piCoef = pSrc;
const bool useTransformSkip = tu.mtsIdx==1;
const bool useTransformSkip = tu.mtsIdx==MTS_SKIP;
const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID));
#if HEVC_USE_SCALING_LISTS
......
......@@ -560,7 +560,7 @@ void QuantRDOQ::quant(TransformUnit &tu, const ComponentID &compID, const CCoeff
const CCoeffBuf &piCoef = pSrc;
CoeffBuf piQCoef = tu.getCoeffs(compID);
const bool useTransformSkip = tu.mtsIdx==1;
const bool useTransformSkip = tu.mtsIdx==MTS_SKIP;
bool useRDOQ = useTransformSkip ? m_useRDOQTS : m_useRDOQ;
......@@ -640,7 +640,7 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
// Represents scaling through forward transform
int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange);
if (tu.mtsIdx==1 && extendedPrecision)
if (tu.mtsIdx==MTS_SKIP && extendedPrecision)
{
iTransformShift = std::max<int>(0, iTransformShift);
}
......@@ -689,7 +689,7 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
#if HEVC_USE_SCALING_LISTS
const double *const pdErrScale = xGetErrScaleCoeff(scalingListType, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1), cQP.rem);
const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1));
const bool isTransformSkip = tu.mtsIdx==1 && isLuma(compID);
const bool isTransformSkip = tu.mtsIdx==MTS_SKIP && isLuma(compID);
const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip);
const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem];
const double defaultErrorScale = xGetErrScaleCoeffNoScalingList(scalingListType, (uiLog2BlockWidth-1), (uiLog2BlockHeight-1), cQP.rem);
......
......@@ -139,8 +139,10 @@ Slice::Slice()
, m_uiMaxBTSizeIChroma ( 0 )
, m_uiMaxTTSizeIChroma ( 0 )
, m_uiMaxBTSize ( 0 )
#if !JVET_N0415_CTB_ALF
, m_apsId ( -1 )
, m_aps (NULL)
#endif
{
for(uint32_t i=0; i<NUM_REF_PIC_LIST_01; i++)
{
......@@ -186,6 +188,9 @@ Slice::Slice()
m_sliceReshapeInfo.reshaperModelMinBinIdx = 0;
m_sliceReshapeInfo.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1;
memset(m_sliceReshapeInfo.reshaperModelBinCWDelta, 0, PIC_CODE_CW_BINS * sizeof(int));
#if JVET_N0415_CTB_ALF
memset(m_apss, 0, sizeof(m_apss));
#endif
}
Slice::~Slice()
......@@ -2518,6 +2523,9 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP)
}
else
{
#endif
#if JVET_N0415_CTB_ALF
m_spsMap.clear();
#endif
m_spsMap.setActive(spsId);
#if HEVC_VPS
......@@ -2536,6 +2544,9 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP)
}
#else
m_activeSPSId = spsId;
#if JVET_N0415_CTB_ALF
m_ppsMap.clear();
#endif
m_ppsMap.setActive(ppsId);
return true;
#endif
......
......@@ -1716,7 +1716,13 @@ public:
void setAPSId(int i) { m_APSId = i; }
void setAlfAPSParam(AlfSliceParam& alfAPSParam) { m_alfAPSParam = alfAPSParam; }
const AlfSliceParam& getAlfAPSParam() const { return m_alfAPSParam; }
#if JVET_N0415_CTB_ALF
void setTemporalId(int i) { m_alfAPSParam.tLayer = i; }
int getTemporalId() { return m_alfAPSParam.tLayer; }
AlfSliceParam& getAlfAPSParam() { return m_alfAPSParam; }
#else
const AlfSliceParam& getAlfAPSParam() const { return m_alfAPSParam; }
#endif
};
struct WPScalingParam
{
......@@ -1741,8 +1747,6 @@ struct WPACDCParam
int64_t iDC;
};
/// slice header class
class Slice
{
......@@ -1877,11 +1881,19 @@ private:
uint32_t m_uiMaxBTDepthIChroma;
uint32_t m_uiMaxBTSizeIChroma;
uint32_t m_uiMaxTTSizeIChroma;
uint32_t m_uiMaxBTSize;
uint32_t m_uiMaxBTSize;
#if JVET_N0415_CTB_ALF
APS* m_apss[MAX_NUM_APS];
bool m_tileGroupAlfEnabledFlag[MAX_NUM_COMPONENT];
int m_tileGroupNumAps;
std::vector<int> m_tileGroupLumaApsId;
int m_tileGroupChromaApsId;
#else
int m_apsId;
APS* m_aps;
bool m_tileGroupAlfEnabledFlag;
#endif
#if JVET_N0329_IBC_SEARCH_IMP
bool m_disableSATDForRd;
#endif
......@@ -1903,10 +1915,15 @@ public:
void setPPSId( int PPSId ) { m_iPPSId = PPSId; }
int getPPSId() const { return m_iPPSId; }
#if JVET_N0415_CTB_ALF
void setAPSs(APS** apss) { memcpy(m_apss, apss, sizeof(m_apss)); }
APS** getAPSs() { return m_apss; }
#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
void setPicOutputFlag( bool b ) { m_PicOutputFlag = b; }
bool getPicOutputFlag() const { return m_PicOutputFlag; }
void setSaoEnabledFlag(ChannelType chType, bool s) {m_saoEnabledFlag[chType] =s; }
......@@ -2173,8 +2190,27 @@ public:
void resetProcessingTime() { m_dProcessingTime = m_iProcessingStartTime = 0; }
double getProcessingTime() const { return m_dProcessingTime; }
#if JVET_N0415_CTB_ALF
void resetTileGroupAlfEnabledFlag() { memset(m_tileGroupAlfEnabledFlag, 0, sizeof(m_tileGroupAlfEnabledFlag)); }
bool getTileGroupAlfEnabledFlag(ComponentID compId) const { return m_tileGroupAlfEnabledFlag[compId]; }
void setTileGroupAlfEnabledFlag(ComponentID compId, bool b) { m_tileGroupAlfEnabledFlag[compId] = b; }
int getTileGroupNumAps() const { return m_tileGroupNumAps; }
void setTileGroupNumAps(int i) { m_tileGroupNumAps = i; }
int getTileGroupApsIdChroma() const { return m_tileGroupChromaApsId; }
void setTileGroupApsIdChroma(int i) { m_tileGroupChromaApsId = i; }
std::vector<int32_t> getTileGroupApsIdLuma() const { return m_tileGroupLumaApsId; }
void setAPSs(std::vector<int> ApsIDs)
{
m_tileGroupLumaApsId.resize(m_tileGroupNumAps);
for (int i = 0; i < m_tileGroupNumAps; i++)
{
m_tileGroupLumaApsId[i] = ApsIDs[i];
}
}
#else
bool getTileGroupAlfEnabledFlag() const { return m_tileGroupAlfEnabledFlag; }
void setTileGroupAlfEnabledFlag(bool b) { m_tileGroupAlfEnabledFlag = b; }
#endif
#if JVET_N0329_IBC_SEARCH_IMP
void setDisableSATDForRD(bool b) { m_disableSATDForRd = b; }
bool getDisableSATDForRD() { return m_disableSATDForRd; }
......@@ -2186,10 +2222,6 @@ protected:
Picture* xGetLongTermRefPic(PicList& rcListPic, int poc, bool pocHasMsb);
};// END CLASS DEFINITION Slice
void calculateParameterSetChangedFlag(bool &bChanged, const std::vector<uint8_t> *pOldData, const std::vector<uint8_t> *pNewData);
template <class T> class ParameterSetMap
......@@ -2205,9 +2237,15 @@ public:
ParameterSetMap(int maxId)
:m_maxId (maxId)
#if !JVET_N0415_CTB_ALF
,m_activePsId(-1)
#endif
,m_lastActiveParameterSet(NULL)
{}
{
#if JVET_N0415_CTB_ALF
m_activePsId.clear();
#endif
}
~ParameterSetMap()
{
......@@ -2232,6 +2270,13 @@ public:
return m_paramsetMap[psId].parameterSet;
}
#if JVET_N0415_CTB_ALF
void clearMap()
{
m_paramsetMap.clear();
}
#endif
void storePS(int psId, T *ps, const std::vector<uint8_t> *pNaluData)
{
CHECK( psId >= m_maxId, "Invalid PS id" );
......@@ -2249,7 +2294,11 @@ public:
return;
}
#if JVET_N0415_CTB_ALF
if (find(m_activePsId.begin(), m_activePsId.end(), psId) != m_activePsId.end())
#else
if( m_activePsId == psId )
#endif
{
std::swap( m_paramsetMap[psId].parameterSet, m_lastActiveParameterSet );
}
......@@ -2317,17 +2366,25 @@ public:
return (m_paramsetMap.begin() == m_paramsetMap.end() ) ? NULL : m_paramsetMap.begin()->second.parameterSet;
}
#if JVET_N0415_CTB_ALF
void setActive(int psId) { m_activePsId.push_back(psId); }
void clear() { m_activePsId.clear(); }
#else
void setActive(int psId ) { m_activePsId = psId;}
#endif
private:
std::map<int,MapData<T> > m_paramsetMap;
int m_maxId;
#if JVET_N0415_CTB_ALF
std::vector<int> m_activePsId;
#else
int m_activePsId;
#endif
T* m_lastActiveParameterSet;
static void setID(T* parameterSet, const int psId);
};
class ParameterSetManager
{
public:
......@@ -2371,7 +2428,10 @@ public:
#endif
//! \returns true, if activation is successful
bool activatePPS(int ppsId, bool isIRAP);
#if JVET_N0415_CTB_ALF
APS** getAPSs() { return &m_apss[0]; }
ParameterSetMap<APS>* getApsMap() { return &m_apsMap; }
#endif
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); }
......@@ -2391,6 +2451,10 @@ protected:
ParameterSetMap<PPS> m_ppsMap;
ParameterSetMap<APS> m_apsMap;
#if JVET_N0415_CTB_ALF
APS* m_apss[MAX_NUM_APS];
#endif
#if HEVC_VPS
int m_activeVPSId; // -1 for nothing active
#endif
......
......@@ -256,7 +256,7 @@ void TrQuant::xInvLfnst( const TransformUnit &tu, const ComponentID compID )
const uint32_t height = area.height;