...
 
Commits (19)
......@@ -187,6 +187,9 @@ uint32_t DecApp::decode()
{
m_cDecLib.executeLoopFilters();
m_cDecLib.finishPicture( poc, pcListPic );
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
CodingStatistics::UpdateMaxStat(backupStats);
#endif
}
loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS);
if (nalu.m_nalUnitType == NAL_UNIT_EOS)
......
......@@ -43,6 +43,9 @@
#include "StreamMergeApp.h"
#include "DecoderLib/AnnexBread.h"
#include "DecoderLib/NALread.h"
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#include "CommonLib/CodingStatistics.h"
#endif
//! \ingroup DecoderApp
//! \{
......@@ -171,7 +174,7 @@ _byteStreamNALUnit(
while (bs.eofBeforeNBytes(24 / 8, istream) || bs.peekBytes(24 / 8, istream) > 2)
{
#if RExt__DECODER_DEBUG_BIT_STATISTICS
uint8_t thebyte = bs.readByte(); bodyStats.bits += 8; bodyStats.count++;
uint8_t thebyte = bs.readByte(istream); bodyStats.bits += 8; bodyStats.count++;
nalUnit.push_back(thebyte);
#else
nalUnit.push_back(bs.readByte(istream));
......
......@@ -111,8 +111,10 @@ struct AreaBuf : public Size
void copyClip ( const AreaBuf<const T> &src, const ClpRng& clpRng);
void subtract ( const AreaBuf<const T> &other );
#if !JVET_O0105_ICT
void copyAndNegate ( const AreaBuf<const T> &other );
void subtractAndHalve ( const AreaBuf<const T> &other );
#endif
void extendSingleBorderPel();
void extendBorderPel ( unsigned margin );
void addWeightedAvg ( const AreaBuf<const T> &other1, const AreaBuf<const T> &other2, const ClpRng& clpRng, const int8_t gbiIdx);
......@@ -357,6 +359,7 @@ void AreaBuf<T>::subtract( const AreaBuf<const T> &other )
#undef SUBS_INC
}
#if !JVET_O0105_ICT
template<typename T>
void AreaBuf<T>::copyAndNegate( const AreaBuf<const T> &other )
{
......@@ -398,6 +401,7 @@ void AreaBuf<T>::subtractAndHalve( const AreaBuf<const T> &other )
#undef SUBS_OP
#undef SUBS_INC
}
#endif
template<typename T>
void AreaBuf<T>::copyClip( const AreaBuf<const T> &src, const ClpRng& clpRng )
......@@ -924,5 +928,27 @@ private:
Pel *m_origin[MAX_NUM_COMPONENT];
};
#if JVET_O0105_ICT
struct CompStorage : public PelBuf
{
CompStorage () { m_memory = nullptr; }
~CompStorage() { if (valid()) delete [] m_memory; }
void create( const Size& size )
{
CHECK( m_memory, "Trying to re-create an already initialized buffer" );
m_memory = new Pel [ size.area() ];
*static_cast<PelBuf*>(this) = PelBuf( m_memory, size );
}
void destroy()
{
if (valid()) delete [] m_memory;
m_memory = nullptr;
}
bool valid() { return m_memory != nullptr; }
private:
Pel* m_memory;
};
#endif
#endif
......@@ -86,6 +86,14 @@ enum CodingStatisticsType
STATS__CABAC_BITS__GT2_FLAG,
STATS__CABAC_BITS__SIGN_BIT,
STATS__CABAC_BITS__ESCAPE_BITS,
#if TR_ONLY_COEFF_STATS
STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG_TS,
STATS__CABAC_BITS__PAR_FLAG_TS,
STATS__CABAC_BITS__GT1_FLAG_TS,
STATS__CABAC_BITS__GT2_FLAG_TS,
STATS__CABAC_BITS__SIGN_BIT_TS,
STATS__CABAC_BITS__ESCAPE_BITS_TS,
#endif
STATS__CABAC_BITS__SAO,
STATS__CABAC_BITS__ALF,
STATS__CABAC_TRM_BITS,
......@@ -171,6 +179,14 @@ static inline const char* getName(CodingStatisticsType name)
"CABAC_BITS__GT2_FLAG",
"CABAC_BITS__SIGN_BIT",
"CABAC_BITS__ESCAPE_BITS",
#if TR_ONLY_COEFF_STATS
"CABAC_BITS__SIG_COEFF_MAP_FLAG_TS",
"CABAC_BITS__PAR_FLAG_TS",
"CABAC_BITS__GT1_FLAG_TS",
"CABAC_BITS__GT2_FLAG_TS",
"CABAC_BITS__SIGN_BIT_TS",
"CABAC_BITS__ESCAPE_BITS_TS",
#endif
"CABAC_BITS__SAO",
"CABAC_BITS__LFNST",
"CABAC_BITS__ALF",
......@@ -309,6 +325,13 @@ public:
{
bits += src.bits; count += src.count; sum += src.sum; classCount += src.classCount; return *this;
}
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat &operator-=(const SStat &src)
{
bits -= src.bits; count -= src.count; sum -= src.sum; classCount -= src.classCount; return *this;
}
#endif
};
struct StatTool
......@@ -327,12 +350,45 @@ public:
}
};
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
struct SStat_max
{
SStat max_CABAC_state;
SStat max_EP_state;
SStat trf_CABAC_state;
SStat trf_EP_state;
SStat acc_trf_CABAC_state;
SStat acc_trf_EP_state;
SStat prev_CABAC_state;
SStat prev_EP_state;
SStat prev_trf_CABAC_state;
SStat prev_trf_EP_state;
void clear()
{
max_CABAC_state.clear();
max_EP_state.clear();
trf_CABAC_state.clear();
trf_EP_state.clear();
acc_trf_CABAC_state.clear();
acc_trf_EP_state.clear();
prev_CABAC_state.clear();
prev_EP_state.clear();
prev_trf_CABAC_state.clear();
prev_trf_EP_state.clear();
}
};
#endif
class CodingStatisticsData
{
private:
SStat statistics [STATS__NUM_STATS + 1][CODING_STATS_NUM_SUBCLASSES];
SStat statistics_ep [STATS__NUM_STATS + 1][CODING_STATS_NUM_SUBCLASSES];
StatTool statistics_tool [STATS__NUM_STATS + 1][CODING_STATS_NUM_SUBCLASSES];
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat_max statistics_max;
#endif
std::map<std::string, SStat> mappings_ep;
friend class CodingStatistics;
};
......@@ -429,6 +485,10 @@ private:
int64_t classCounts[STATS__NUM_STATS];
std::fill_n( classCounts, ( size_t ) STATS__NUM_STATS, 0 );
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
SStat_max &max = GetStatisticMax();
#endif
int64_t cr = 0; // CABAC remainder, which is added to "STATS__CABAC_INITIALISATION"
{
int64_t totalCABACbits = 0, roundedCABACbits = 0;
......@@ -522,6 +582,18 @@ private:
{
cabacSubTotal.classCount = classCounts[i];
OutputLine( pName, '~', "~~ST~~", "~~ST~~", "~~ST~~", cabacSubTotal, epSubTotal );
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
// For TRF
if ((i == STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG) || (i == STATS__CABAC_BITS__PAR_FLAG)
|| (i == STATS__CABAC_BITS__GT1_FLAG) || (i == STATS__CABAC_BITS__GT2_FLAG)
|| (i == STATS__CABAC_BITS__ESCAPE_BITS))
{
max.acc_trf_CABAC_state += cabacSubTotal;
max.acc_trf_EP_state += epSubTotal;
}
#endif
}
if( i == STATS__NAL_UNIT_TOTAL_BODY )
{
......@@ -604,6 +676,12 @@ private:
OutputDashedLine( "GRAND TOTAL" );
epTotalBits += cavlcTotalBits;
OutputLine ( "TOTAL", '~', "~~GT~~", "~~GT~~", "~~GT~~", cabacTotalBits, epTotalBits );
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
OutputDashedLine("");
OutputLine("CABAC MAX FRAME stat", '~', "~~ST~~", "~~ST~~", "~~ST~~", max.max_CABAC_state, max.max_EP_state);
OutputLine("CABAC MAX FRAME TRF stat", '~', "~~ST~~", "~~ST~~", "~~ST~~", max.trf_CABAC_state, max.trf_EP_state);
OutputLine("CABAC Accumulated TRF stat", '~', "~~ST~~", "~~ST~~", "~~ST~~", max.acc_trf_CABAC_state, max.acc_trf_EP_state);
#endif
}
void OutputToolStats()
......@@ -712,6 +790,10 @@ public:
static StatTool &GetStatisticTool ( const CodingStatisticsClassType &stat ) { return GetSingletonInstance().data.statistics_tool[stat.type][stat.subClass]; }
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static SStat_max &GetStatisticMax() { return GetSingletonInstance().data.statistics_max; }
#endif
static int getNumOnes( int bins )
{
CHECK( bins < 0, "Bins should not be nagative" );
......@@ -730,7 +812,11 @@ public:
CHECK( stat.type == STATS__CABAC_BITS__INVALID, "Should never be used." );
SStat &s = GetStatisticEP( stat );
s.bits += numBits;
#if EPBINCOUNT_FIX
s.count += numBits;
#else
s.count++;
#endif
s.sum += getNumOnes( value );
}
......@@ -738,7 +824,11 @@ public:
{
SStat &s = GetStatisticEP( str );
s.bits += numBits;
#if EPBINCOUNT_FIX
s.count += numBits;
#else
s.count++;
#endif
s.sum += getNumOnes( value );
}
......@@ -746,7 +836,11 @@ public:
{
SStat &s = GetStatisticEP( pKey );
s.bits += numBits;
#if EPBINCOUNT_FIX
s.count += numBits;
#else
s.count++;
#endif
s.sum += getNumOnes( value );
}
......@@ -776,6 +870,123 @@ public:
s.count++;
s.sum += val;
}
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static void UpdateMaxStat(CodingStatisticsData *data)
{
SStat_max & max = GetStatisticMax();
const int64_t es = CODINGSTATISTICS_ENTROPYSCALE;
int64_t countTotal = 0;
int64_t classCounts[STATS__NUM_STATS];
std::fill_n(classCounts, (size_t) STATS__NUM_STATS, 0);
int64_t cr = 0; // CABAC remainder, which is added to "STATS__CABAC_INITIALISATION"
int64_t totalCABACbits = 0, roundedCABACbits = 0;
for (int i = STATS__NAL_UNIT_PACKING; i < STATS__NUM_STATS; i++)
{
int64_t classCount = 0;
for (uint32_t c = 0; c < CODING_STATS_NUM_SUBCLASSES; c++)
{
totalCABACbits += data->statistics[i][c].bits;
roundedCABACbits += data->statistics[i][c].bits / es;
classCount += data->statistics[i][c].count;
}
for (uint32_t c = 0; c < CODING_STATS_NUM_SUBCLASSES; c++)
{
data->statistics[i][c].classCount = classCount;
}
classCounts[i] = classCount;
countTotal += classCount;
}
int64_t remainder = totalCABACbits - roundedCABACbits * es;
cr = (remainder + es / 2) / es;
classCounts[0] = countTotal;
SStat cabacTotalBits, epTotalBits, cabacTrfTotalBits, epTrfTotalBits;
cabacTotalBits.classCount = countTotal;
epTotalBits.classCount = countTotal;
cabacTrfTotalBits.classCount = countTotal;
epTrfTotalBits.classCount = countTotal;
// Calculate the actual bin and bit count
for (int i = 0; i < STATS__NUM_STATS; i++)
{
for (uint32_t c = 0; c < CODING_STATS_NUM_SUBCLASSES; c++)
{
SStat &sCABACorig = data->statistics[i][c];
SStat &sEP = data->statistics_ep[i][c];
if (sCABACorig.bits == 0 && sEP.bits == 0)
{
continue;
}
SStat sCABAC;
{
int64_t thisCABACbits = sCABACorig.bits / es;
if (i == STATS__CABAC_INITIALISATION && sCABACorig.bits != 0)
{
thisCABACbits += cr;
cr = 0;
}
sCABAC.bits = thisCABACbits;
sCABAC.count = sCABACorig.count;
sCABAC.sum = sCABACorig.sum;
sCABAC.classCount = classCounts[i];
}
if( i != STATS__NAL_UNIT_TOTAL_BODY )
{
cabacTotalBits += sCABAC;
epTotalBits += sEP;
// For TRF
if ((i == STATS__CABAC_BITS__SIG_COEFF_MAP_FLAG) || (i == STATS__CABAC_BITS__PAR_FLAG)
|| (i == STATS__CABAC_BITS__GT1_FLAG) || (i == STATS__CABAC_BITS__GT2_FLAG)
|| (i == STATS__CABAC_BITS__ESCAPE_BITS))
{
cabacTrfTotalBits += sCABAC;
epTrfTotalBits += sEP;
}
}
}
}
SStat delta_CABAC = cabacTotalBits;
SStat delta_EP = epTotalBits;
SStat delta_trf_CABAC = cabacTrfTotalBits;
SStat delta_trf_EP = epTrfTotalBits;
delta_CABAC -= max.prev_CABAC_state;
delta_EP -= max.prev_EP_state;
delta_trf_CABAC -= max.prev_trf_CABAC_state;
delta_trf_EP -= max.prev_trf_EP_state;
int64_t max_frame_bins = EPBIN_WEIGHT_FACTOR * max.max_CABAC_state.count + max.max_EP_state.count;
int64_t cur_frame_bins = EPBIN_WEIGHT_FACTOR * delta_CABAC.count + delta_EP.count;
if (cur_frame_bins > max_frame_bins)
{
max.max_CABAC_state = delta_CABAC;
max.max_EP_state = delta_EP;
max.trf_CABAC_state = delta_trf_CABAC;
max.trf_EP_state = delta_trf_EP;
}
max.prev_CABAC_state = cabacTotalBits;
max.prev_EP_state = epTotalBits;
max.prev_trf_CABAC_state = cabacTrfTotalBits;
max.prev_trf_EP_state = epTrfTotalBits;
}
#endif
};
#endif
......@@ -330,10 +330,15 @@ static const int MMVD_ADD_NUM = (MMVD_MAX_RE
static const int MMVD_MRG_MAX_RD_NUM = MRG_MAX_NUM_CANDS;
static const int MMVD_MRG_MAX_RD_BUF_NUM = (MMVD_MRG_MAX_RD_NUM + 1);///< increase buffer size by 1
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
static const int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA = 28;
static const int MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA = 28;
#else
static const int MAX_NUM_REG_BINS_4x4SUBBLOCK = 32; ///< max number of context-coded bins (incl. gt2 bins) per 4x4 subblock
static const int MAX_NUM_GT2_BINS_4x4SUBBLOCK = 4; ///< max number of gt2 bins per 4x4 subblock
static const int MAX_NUM_REG_BINS_2x2SUBBLOCK = 8; ///< max number of context-coded bins (incl. gt2 bins) per 2x2 subblock (chroma)
static const int MAX_NUM_GT2_BINS_2x2SUBBLOCK = 2; ///< max number of gt2 bins per 2x2 subblock (chroma)
#endif
static const int BIO_EXTEND_SIZE = 1;
static const int BIO_TEMP_BUFFER_SIZE = (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE) * (MAX_CU_SIZE + 2 * BIO_EXTEND_SIZE);
......@@ -454,6 +459,10 @@ static const int CSCALE_FP_PREC = 11;
static const int NEIG_NUM_LOG = 6;
static const int NEIG_NUM = 1 << NEIG_NUM_LOG;
#endif
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
static const int EPBIN_WEIGHT_FACTOR = 4;
#endif
// ====================================================================================================================
// Macro functions
// ====================================================================================================================
......
......@@ -231,6 +231,10 @@ public:
return auiGoRicePars[ std::min(sum, 31) ];
}
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int regBinLimit;
#endif
private:
// constant
const ComponentID m_compID;
......@@ -289,17 +293,36 @@ class CUCtx
public:
CUCtx() : isDQPCoded(false), isChromaQpAdjCoded(false),
qgStart(false),
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
numNonZeroCoeffNonTs(0)
{
violatesLfnstConstrained[CHANNEL_TYPE_LUMA ] = false;
violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false;
}
#else
numNonZeroCoeffNonTs(0) {}
#endif
CUCtx(int _qp) : isDQPCoded(false), isChromaQpAdjCoded(false),
qgStart(false),
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
numNonZeroCoeffNonTs(0), qp(_qp)
{
violatesLfnstConstrained[CHANNEL_TYPE_LUMA ] = false;
violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false;
}
#else
numNonZeroCoeffNonTs(0), qp(_qp) {}
#endif
~CUCtx() {}
public:
bool isDQPCoded;
bool isChromaQpAdjCoded;
bool qgStart;
uint32_t numNonZeroCoeffNonTs;
int8_t qp; // used as a previous(last) QP and for QP prediction
uint32_t numNonZeroCoeffNonTs;
int8_t qp; // used as a previous(last) QP and for QP prediction
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
bool violatesLfnstConstrained[MAX_NUM_CHANNEL_TYPE];
#endif
};
class MergeCtx
......
......@@ -784,10 +784,17 @@ const CtxSet ContextSetCfg::IBCFlag = ContextSetCfg::addCtxSet
const CtxSet ContextSetCfg::JointCbCrFlag = ContextSetCfg::addCtxSet
({
#if JVET_O0105_ICT
{ 156, 156, 156, },
{ 156, 156, 156, },
{ 184, 184, 184, },
{ 1, 1, 1, },
#else
{ 156, },
{ 156, },
{ 184, },
{ 1, },
#endif
});
const CtxSet ContextSetCfg::TsSigCoeffGroup = ContextSetCfg::addCtxSet
......
This diff is collapsed.
......@@ -476,7 +476,11 @@ void InterPrediction::xPredInterBi(PredictionUnit& pu, PelUnitBuf &pcYuvPred)
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
bool bioApplied = false;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->slice->getDisBdofDmvrFlag()))
#else
if (pu.cs->sps->getBDOFEnabledFlag())
#endif
{
if (pu.cu->affine || m_subPuMC)
{
......@@ -1245,7 +1249,11 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
bool bioApplied = false;
const Slice &slice = *pu.cs->slice;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
if (pu.cs->sps->getBDOFEnabledFlag() && (!pu.cs->slice->getDisBdofDmvrFlag()))
#else
if (pu.cs->sps->getBDOFEnabledFlag())
#endif
{
if (pu.cu->affine || m_subPuMC)
......
......@@ -58,9 +58,15 @@
const uint8_t IntraPrediction::m_aucIntraFilter[MAX_NUM_CHANNEL_TYPE][MAX_INTRA_FILTER_DEPTHS] =
{
{ // Luma
#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF
24, // 1xn
24, // 2xn
24, // 4xn
#else
20, // 1xn
20, // 2xn
20, // 4xn
#endif
14, // 8xn
2, // 16xn
0, // 32xn
......@@ -556,14 +562,19 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA
else if (!useISP)// HOR, VER and angular modes (MDIS)
{
bool filterFlag = false;
#if !JVET_O0277_INTRA_SMALL_BLOCK_DCTIF
if (predMode != dirMode ) // wide-anlge mode
{
filterFlag = true;
}
else
#endif
{
#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF
const int diff = std::min<int>( abs( predMode - HOR_IDX ), abs( predMode - VER_IDX ) );
#else
const int diff = std::min<int>( abs( dirMode - HOR_IDX ), abs( dirMode - VER_IDX ) );
#endif
const int log2Size = ((g_aucLog2[puSize.width] + g_aucLog2[puSize.height]) >> 1);
CHECK( log2Size >= MAX_INTRA_FILTER_DEPTHS, "Size not supported" );
filterFlag = (diff > m_aucIntraFilter[chType][log2Size]);
......@@ -573,7 +584,12 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA
if (filterFlag)
{
const bool isRefFilter = isIntegerSlope(absAng);
#if JVET_O0277_INTRA_SMALL_BLOCK_DCTIF
CHECK( puSize.width * puSize.height <= 32, "DCT-IF interpolation filter is always used for 4x4, 4x8, and 8x4 luma CB" );
m_ipaParam.refFilterFlag = isRefFilter;
#else
m_ipaParam.refFilterFlag = isRefFilter && puSize.width * puSize.height > 32;
#endif
m_ipaParam.interpolationFlag = !isRefFilter;
}
}
......
......@@ -667,12 +667,20 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De
tmpBs += BsSet(1, COMPONENT_Y);
}
// U
#if JVET_O0105_ICT
if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cb) || TU::getCbf(tuP, COMPONENT_Cb) || tuQ.jointCbCr || tuP.jointCbCr))
#else
if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cb) || TU::getCbf(tuP, COMPONENT_Cb)))
#endif
{
tmpBs += BsSet(1, COMPONENT_Cb);
}
// V
#if JVET_O0105_ICT
if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cr) || TU::getCbf(tuP, COMPONENT_Cr) || tuQ.jointCbCr || tuP.jointCbCr))
#else
if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cr) || TU::getCbf(tuP, COMPONENT_Cr)))
#endif
{
tmpBs += BsSet(1, COMPONENT_Cr);
}
......
......@@ -103,8 +103,15 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int
if (isChroma(compID))
{
#if JVET_O0105_ICT
const bool useJQP = ( abs(TU::getICTMode(tu)) == 2 );
chromaQpOffset += tu.cs->pps->getQpOffset ( useJQP ? JOINT_CbCr : compID );
chromaQpOffset += tu.cs->slice->getSliceChromaQpDelta( useJQP ? JOINT_CbCr : compID );
#else
chromaQpOffset += tu.cs->pps->getQpOffset ( tu.jointCbCr ? JOINT_CbCr : compID );
chromaQpOffset += tu.cs->slice->getSliceChromaQpDelta( tu.jointCbCr ? JOINT_CbCr : compID );
#endif
chromaQpOffset += tu.cs->pps->getPpsRangeExtension().getChromaQpOffsetListEntry( tu.cu->chromaQpAdj ).u.offset[int( compID ) - 1];
}
......
......@@ -108,7 +108,9 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double& rd64CodedCost,
const BinFracBits& fracBitsPar,
const BinFracBits& fracBitsGt1,
const BinFracBits& fracBitsGt2,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const int remGt2Bins,
#endif
const int remRegBins,
unsigned goRiceZero,
uint16_t ui16AbsGoRice,
......@@ -146,7 +148,11 @@ inline uint32_t QuantRDOQ::xGetCodedLevel( double& rd64CodedCost,
{
double dErr = double( lLevelDouble - ( Intermediate_Int(uiAbsLevel) << iQBits ) );
double dCurrCost = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
double dCurrCost = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
#else
double dCurrCost = dErr * dErr * errorScale + xGetICost( xGetICRate( uiAbsLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, ui16AbsGoRice, true, maxLog2TrDynamicRange ) );
#endif
dCurrCost += dCurrCostSig;
if( dCurrCost < rd64CodedCost )
......@@ -175,7 +181,9 @@ inline int QuantRDOQ::xGetICRate( const uint32_t uiAbsLevel,
const BinFracBits& fracBitsPar,
const BinFracBits& fracBitsGt1,
const BinFracBits& fracBitsGt2,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const int remGt2Bins,
#endif
const int remRegBins,
unsigned goRiceZero,
const uint16_t ui16AbsGoRice,
......@@ -639,9 +647,14 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
double d64BaseCost = 0;
int iLastScanPos = -1;
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA;
int remRegBins = (uiWidth * uiHeight * ctxBinSampleRatio) >> 4;
#else
bool is2x2subblock = ( iCGSizeM1 == 3 );
int remGt2Bins = ( is2x2subblock ? MAX_NUM_GT2_BINS_2x2SUBBLOCK : MAX_NUM_GT2_BINS_4x4SUBBLOCK );
int remRegBins = ( is2x2subblock ? MAX_NUM_REG_BINS_2x2SUBBLOCK : MAX_NUM_REG_BINS_4x4SUBBLOCK );
#endif
uint32_t goRiceParam = 0;
double *pdCostCoeffGroupSig = m_pdCostCoeffGroupSig;
......@@ -736,16 +749,26 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if( iScanPos == iLastScanPos )
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
lLevelDouble, uiMaxAbsLevel, nullptr, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, iQBits, errorScale, 1, extendedPrecision, maxLog2TrDynamicRange );
#else
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
lLevelDouble, uiMaxAbsLevel, nullptr, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, iQBits, errorScale, 1, extendedPrecision, maxLog2TrDynamicRange );
#endif
}
else
{
DTRACE_COND( ( uiMaxAbsLevel != 0 ), g_trace_ctx, D_RDOQ_MORE, " uiCtxSig=%d", ctxIdSig );
const BinFracBits fracBitsSig = fracBits.getFracBitsArray( ctxIdSig );
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
lLevelDouble, uiMaxAbsLevel, &fracBitsSig, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, iQBits, errorScale, 0, extendedPrecision, maxLog2TrDynamicRange );
#else
uiLevel = xGetCodedLevel( pdCostCoeff[ iScanPos ], pdCostCoeff0[ iScanPos ], pdCostSig[ iScanPos ],
lLevelDouble, uiMaxAbsLevel, &fracBitsSig, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, iQBits, errorScale, 0, extendedPrecision, maxLog2TrDynamicRange );
#endif
sigRateDelta[ uiBlkPos ] = ( remRegBins < 4 ? 0 : fracBitsSig.intBits[1] - fracBitsSig.intBits[0] );
}
......@@ -757,16 +780,27 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if( uiLevel > 0 )
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int rateNow = xGetICRate( uiLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange );
rateIncUp [ uiBlkPos ] = xGetICRate( uiLevel+1, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
#else
int rateNow = xGetICRate( uiLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange );
rateIncUp [ uiBlkPos ] = xGetICRate( uiLevel+1, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
rateIncDown [ uiBlkPos ] = xGetICRate( uiLevel-1, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
#endif
}
else // uiLevel == 0
{
if( remRegBins < 4 )
{
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int rateNow = xGetICRate( uiLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange );
rateIncUp [ uiBlkPos ] = xGetICRate( uiLevel+1, fracBitsPar, fracBitsGt1, fracBitsGt2, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
#else
int rateNow = xGetICRate( uiLevel, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange );
rateIncUp [ uiBlkPos ] = xGetICRate( uiLevel+1, fracBitsPar, fracBitsGt1, fracBitsGt2, remGt2Bins, remRegBins, goRiceZero, goRiceParam, extendedPrecision, maxLog2TrDynamicRange ) - rateNow;
#endif
}
else
{
......@@ -778,8 +812,10 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID,
if( ( (iScanPos & iCGSizeM1) == 0 ) && ( iScanPos > 0 ) )
{
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
remGt2Bins = ( is2x2subblock ? MAX_NUM_GT2_BINS_2x2SUBBLOCK : MAX_NUM_GT2_BINS_4x4SUBBLOCK );
remRegBins = ( is2x2subblock ? MAX_NUM_REG_BINS_2x2SUBBLOCK : MAX_NUM_REG_BINS_4x4SUBBLOCK ) - remGt2Bins;
#endif
goRiceParam = 0;
}
else if( remRegBins >= 4 )
......
......@@ -87,7 +87,9 @@ private:
const BinFracBits& fracBitsPar,
const BinFracBits& fracBitsGt1,
const BinFracBits& fracBitsGt2,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const int remGt2Bins,
#endif
const int remRegBins,
unsigned goRiceZero,
uint16_t ui16AbsGoRice,
......@@ -100,7 +102,9 @@ private:
const BinFracBits& fracBitsPar,
const BinFracBits& fracBitsGt1,
const BinFracBits& fracBitsGt2,
#if !JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
const int remGt2Bins,
#endif
const int remRegBins,
unsigned goRiceZero,
const uint16_t ui16AbsGoRice,
......
......@@ -585,6 +585,10 @@ int8_t g_aucLog2 [MAX_CU_SIZE + 1];
int8_t g_aucNextLog2[MAX_CU_SIZE + 1];
int8_t g_aucPrevLog2[MAX_CU_SIZE + 1];
#if JVET_O0105_ICT
const int g_ictModes[2][4] = { { 0, 3, 1, 2 }, { 0, -3, -1, -2 } };
#endif
UnitScale g_miScaling( MIN_CU_LOG2, MIN_CU_LOG2 );
......
......@@ -146,6 +146,10 @@ extern int8_t g_aucLog2 [MAX_CU_SIZE + 1];
extern int8_t g_aucNextLog2 [MAX_CU_SIZE + 1];
extern int8_t g_aucPrevLog2 [MAX_CU_SIZE + 1];
#if JVET_O0105_ICT
extern const int g_ictModes[2][4];
#endif
inline bool is34( const SizeType& size )
{
return ( size & ( ( int64_t ) 1 << ( g_aucLog2[size] - 1 ) ) );
......
......@@ -83,6 +83,9 @@ Slice::Slice()
, m_maxNumAffineMergeCand ( 0 )
, m_maxNumTriangleCand ( 0 )
, m_disFracMMVD ( false )
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
, m_disBdofDmvrFlag ( false )
#endif
, m_uiTLayer ( 0 )
, m_bTLayerSwitchingFlag ( false )
, m_sliceMode ( NO_SLICES )
......@@ -97,6 +100,9 @@ Slice::Slice()
, m_bTestWeightBiPred ( false )
, m_substreamSizes ( )
, m_cabacInitFlag ( false )
#if JVET_O0105_ICT
, m_jointCbCrSignFlag ( false )
#endif
, m_bLMvdL1Zero ( false )
, m_LFCrossSliceBoundaryFlag ( false )
, m_enableTMVPFlag ( true )
......@@ -190,8 +196,14 @@ void Slice::initSlice()
m_bFinalized=false;
m_disFracMMVD = false;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
m_disBdofDmvrFlag = false;
#endif
m_substreamSizes.clear();
m_cabacInitFlag = false;
#if JVET_O0105_ICT
m_jointCbCrSignFlag = false;
#endif
m_enableTMVPFlag = true;
}
......@@ -672,6 +684,9 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll)
}
m_cabacInitFlag = pSrc->m_cabacInitFlag;
#if JVET_O0105_ICT
m_jointCbCrSignFlag = pSrc->m_jointCbCrSignFlag;
#endif
memcpy(m_alfApss, pSrc->m_alfApss, sizeof(m_alfApss)); // this might be quite unsafe
memcpy( m_tileGroupAlfEnabledFlag, pSrc->m_tileGroupAlfEnabledFlag, sizeof(m_tileGroupAlfEnabledFlag));
m_tileGroupNumAps = pSrc->m_tileGroupNumAps;
......@@ -686,6 +701,9 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll)
m_maxNumAffineMergeCand = pSrc->m_maxNumAffineMergeCand;
m_maxNumTriangleCand = pSrc->m_maxNumTriangleCand;
m_disFracMMVD = pSrc->m_disFracMMVD;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
m_disBdofDmvrFlag = pSrc->m_disBdofDmvrFlag;
#endif
if( cpyAlmostAll ) m_encCABACTableIdx = pSrc->m_encCABACTableIdx;
m_splitConsOverrideFlag = pSrc->m_splitConsOverrideFlag;
m_uiMinQTSize = pSrc->m_uiMinQTSize;
......@@ -1392,6 +1410,9 @@ SPS::SPS()
, m_sbtmvpEnabledFlag (false)
, m_bdofEnabledFlag (false)
, m_fpelMmvdEnabledFlag ( false )
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
, m_BdofDmvrSlicePresentFlag ( false )
#endif
, m_uiBitsForPOC ( 8)
, m_numLongTermRefPicSPS ( 0)
#if MAX_TB_SIZE_SIGNALLING
......
......@@ -713,6 +713,9 @@ private:
bool m_sbtmvpEnabledFlag;
bool m_bdofEnabledFlag;
bool m_fpelMmvdEnabledFlag;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
bool m_BdofDmvrSlicePresentFlag;
#endif
uint32_t m_uiBitsForPOC;
uint32_t m_numLongTermRefPicSPS;
uint32_t m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS];
......@@ -911,6 +914,10 @@ public:
void setUseDMVR(bool b) { m_DMVR = b; }
bool getUseMMVD()const { return m_MMVD; }
void setUseMMVD(bool b) { m_MMVD = b; }
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
bool getBdofDmvrSlicePresentFlag()const { return m_BdofDmvrSlicePresentFlag; }
void setBdofDmvrSlicePresentFlag(bool b) { m_BdofDmvrSlicePresentFlag = b; }
#endif
uint32_t getMaxTLayers() const { return m_uiMaxTLayers; }
void setMaxTLayers( uint32_t uiMaxTLayers ) { CHECK( uiMaxTLayers > MAX_TLAYER, "Invalid number T-layers" ); m_uiMaxTLayers = uiMaxTLayers; }
......@@ -1438,6 +1445,9 @@ private:
uint32_t m_maxNumAffineMergeCand;
uint32_t m_maxNumTriangleCand;
bool m_disFracMMVD;
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
bool m_disBdofDmvrFlag;
#endif
double m_lambdas[MAX_NUM_COMPONENT];
bool m_abEqualRef [NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_REF];
......@@ -1467,6 +1477,10 @@ private:
bool m_cabacInitFlag;
#if JVET_O0105_ICT
bool m_jointCbCrSignFlag;
#endif
bool m_bLMvdL1Zero;
bool m_LFCrossSliceBoundaryFlag;
......@@ -1681,6 +1695,10 @@ public:
uint32_t getMaxNumTriangleCand() const { return m_maxNumTriangleCand;}
void setDisFracMMVD( bool val ) { m_disFracMMVD = val; }
bool getDisFracMMVD() const { return m_disFracMMVD; }
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
void setDisBdofDmvrFlag(bool val) { m_disBdofDmvrFlag = val; }
bool getDisBdofDmvrFlag() const { return m_disBdofDmvrFlag; }
#endif
void setNoOutputPriorPicsFlag( bool val ) { m_noOutputPriorPicsFlag = val; }
bool getNoOutputPriorPicsFlag() const { return m_noOutputPriorPicsFlag; }
......@@ -1739,6 +1757,12 @@ public:
void setCabacInitFlag( bool val ) { m_cabacInitFlag = val; } //!< set CABAC initial flag
bool getCabacInitFlag() const { return m_cabacInitFlag; } //!< get CABAC initial flag
#if JVET_O0105_ICT
void setJointCbCrSignFlag( bool b ) { m_jointCbCrSignFlag = b; }
bool getJointCbCrSignFlag() const { return m_jointCbCrSignFlag; }
#endif
void setLFCrossSliceBoundaryFlag( bool val ) { m_LFCrossSliceBoundaryFlag = val; }
bool getLFCrossSliceBoundaryFlag() const { return m_LFCrossSliceBoundaryFlag; }
......
This diff is collapsed.
......@@ -103,6 +103,12 @@ public:
void transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &compID, const TCoeff &resiDiff, TCoeff &coeff, const uint32_t &uiPos, const QpParam &cQP, const bool bUseHalfRoundingPoint);
void invTrSkipDeQuantOneSample (TransformUnit &tu, const ComponentID &compID, const TCoeff &pcCoeff, Pel &reconSample, const uint32_t &uiPos, const QpParam &cQP);
#if JVET_O0105_ICT
void invTransformICT ( const TransformUnit &tu, PelBuf &resCb, PelBuf &resCr );
std::pair<int64_t,int64_t> fwdTransformICT ( const TransformUnit &tu, const PelBuf &resCb, const PelBuf &resCr, PelBuf& resC1, PelBuf& resC2, int jointCbCr = -1 );
std::vector<int> selectICTCandidates ( const TransformUnit &tu, CompStorage* resCb, CompStorage* resCr );
#endif
void invRdpcmNxN(TransformUnit& tu, const ComponentID &compID, PelBuf &pcResidual);
#if RDOQ_CHROMA_LAMBDA
void setLambdas ( const double lambdas[MAX_NUM_COMPONENT] ) { m_quant->setLambdas( lambdas ); }
......@@ -128,10 +134,17 @@ protected:
bool m_scalingListEnabledFlag;
private:
DepQuant *m_quant; //!< Quantizer
DepQuant *m_quant; //!< Quantizer
TCoeff** m_mtsCoeffs;
TCoeff m_tempInMatrix [ 48 ];
TCoeff m_tempOutMatrix[ 48 ];
#if JVET_O0105_ICT
static const int maxAbsIctMode = 3;
void (*m_invICTMem[1+2*maxAbsIctMode])(PelBuf&,PelBuf&);
std::pair<int64_t,int64_t>(*m_fwdICTMem[1+2*maxAbsIctMode])(const PelBuf&,const PelBuf&,PelBuf&,PelBuf&);
void (**m_invICT)(PelBuf&,PelBuf&);
std::pair<int64_t,int64_t>(**m_fwdICT)(const PelBuf&,const PelBuf&,PelBuf&,PelBuf&);
#endif
// forward Transform
......
......@@ -50,8 +50,15 @@
#include <assert.h>
#include <cassert>
#define JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT 1 // JVET-O0052 Method-1: TU-level context coded bin constraint
#define JVET_O0105_ICT 1 // JVET-O0105: inter-chroma transform (ICT) as extension of joint chroma coding (JCC)
#define JVET_O0543_ICT_ICU_ONLY 1 // JVET-O0543: ICT only in Intra CUs (was Intra slices, modified during adoption)
#define JVET_O0216_ALF_COEFF_EG3 1 // JVET-O0216/O0302/O0648: using EG3 for ALF coefficients coding
#define JVET_O0256_ADJUST_THD_DEPQUANT 1 // JVET-O0256: Fast encoder with adjusted threshold in dependent quantization
#define JVET_O0272_LMCS_SIMP_INVERSE_MAPPING 1 // JVET-O0272: LMCS simplified inverse mapping
#define JVET_O0247_ALF_CTB_CODING_REDUNDANCY_REMOVAL 1 // JVET-O0247: not signal APS index when number APS is 2
......@@ -84,6 +91,8 @@
#define JVET_O0055_INT_DMVR_DIS_BDOF 1 // integer-distance DMVR cost to disable BDOF and disable BDOF early termination
#define JVET_O0277_INTRA_SMALL_BLOCK_DCTIF 1 // JVET-O0277: DCT-IF interpolation filter is always used for 4x4, 4x8, and 8x4 luma CB
#define JVET_O0267_IBC_SCALING_LIST 1
#define JVET_O0280_SIMD_TRIANGLE_WEIGHTING 1 // JVET-O0280: SIMD implementation for weighted sample prediction process of triangle prediction mode
......@@ -91,12 +100,18 @@
#define JVET_O0364_PDPC_DC 1 // JVET-O0364 Part 4: align PDPC process for DC with the one for Planar
#define JVET_O0364_PDPC_ANGULAR 1 // JVET-O0364 Part 5: simplify PDPC process for angular modes
#define JVET_O0094_LFNST_ZERO_PRIM_COEFFS 1 // JVET-O0049: CE6-2.1a, LFNST involves zeroing of primary only coefficient positions
#define JVET_O0294_TRANSFORM_CLEANUP 1 // JVET-O0294: Context modelling for MTS index
#define JVET_O1124_ALLOW_CCLM_COND 1 // JVET-O1124/JVET-O0196: CCLM restriction to reduce luma-chroma latency for chroma separate tree
#define JVET_O0078_SINGLE_HMVPLUT 1 // JVET-O0078Single HMVP table for all CUs inside the shared merge list region for IBC
#define JVET_O0126_BPWA_INDEX_CODING_FIX 1 // JVET-O0126 align BPWA index coding with specification
#define JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG 1 // JVET-O1140 slice level disable flag for BDOF and DMVR
#define FIX_DB_MAX_TRANSFORM_SIZE 1
#define MRG_SHARELIST_SHARSIZE 32
......@@ -193,6 +208,14 @@ typedef std::pair<int, int> TrCost;
#define RExt__DECODER_DEBUG_BIT_STATISTICS 0 ///< 0 (default) = decoder reports as normal, 1 = decoder produces bit usage statistics (will impact decoder run time by up to ~10%)
#endif
#ifndef RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
#define RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS (1 && RExt__DECODER_DEBUG_BIT_STATISTICS ) ///< 0 (default) = decoder reports as normal, 1 = decoder produces max frame bit usage statistics
#if RExt__DECODER_DEBUG_TOOL_MAX_FRAME_STATS
#define TR_ONLY_COEFF_STATS 1
#define EPBINCOUNT_FIX 1
#endif
#endif
#ifndef RExt__DECODER_DEBUG_TOOL_STATISTICS
#define RExt__DECODER_DEBUG_TOOL_STATISTICS 0 ///< 0 (default) = decoder reports as normal, 1 = decoder produces tool usage statistics
#endif
......
......@@ -764,5 +764,24 @@ void TransformUnit::checkTuNoResidual( unsigned idx )
noResidual = true;
}
}
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int TransformUnit::getTbAreaAfterCoefZeroOut(ComponentID compID) const
{
int tbArea = blocks[compID].width * blocks[compID].height;
int tbZeroOutWidth = blocks[compID].width;
int tbZeroOutHeight = blocks[compID].height;
if ((mtsIdx > MTS_SKIP || (cu->sbtInfo != 0 && blocks[compID].width <= 32 && blocks[compID].height <= 32)) && !cu->transQuantBypass && compID == COMPONENT_Y)
{
tbZeroOutWidth = (blocks[compID].width == 32) ? 16 : tbZeroOutWidth;
tbZeroOutHeight = (blocks[compID].height == 32) ? 16 : tbZeroOutHeight;
}
tbZeroOutWidth = std::min<int>(JVET_C0024_ZERO_OUT_TH, tbZeroOutWidth);
tbZeroOutHeight = std::min<int>(JVET_C0024_ZERO_OUT_TH, tbZeroOutHeight);
tbArea = tbZeroOutWidth * tbZeroOutHeight;
return tbArea;
}
#endif
int TransformUnit::getChromaAdj() const { return m_chromaResScaleInv; }
void TransformUnit::setChromaAdj(int i) { m_chromaResScaleInv = i; }
......@@ -466,6 +466,9 @@ struct TransformUnit : public UnitArea
TransformUnit& operator=(const TransformUnit& other);
void copyComponentFrom (const TransformUnit& other, const ComponentID compID);
void checkTuNoResidual( unsigned idx );
#if JVET_O0052_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT
int getTbAreaAfterCoefZeroOut(ComponentID compID) const;
#endif
CoeffBuf getCoeffs(const ComponentID id);
const CCoeffBuf getCoeffs(const ComponentID id) const;
......
......@@ -185,7 +185,7 @@ int CU::predictQP( const CodingUnit& cu, const int prevQP )
{
const CodingStructure &cs = *cu.cs;
if ( !cu.blocks[cu.chType].x && !( cu.blocks[cu.chType].y & ( cs.pcv->maxCUHeightMask >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) && ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType) != NULL ) )
if ( !cu.blocks[cu.chType].x && !( cu.blocks[cu.chType].y & ( cs.pcv->maxCUHeightMask >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) && ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType) != NULL ) && CU::isSameSliceAndTile( *cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType), cu ) )
{
return ( ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType ) )->qp );
}
......@@ -261,6 +261,7 @@ uint32_t CU::getNumNonZeroCoeffNonTs( const CodingUnit& cu, const bool lumaFlag,
return count;
}
#if !JVET_O0094_LFNST_ZERO_PRIM_COEFFS
uint32_t CU::getNumNonZeroCoeffNonTsCorner8x8( const CodingUnit& cu, const bool lumaFlag, const bool chromaFlag )
{
uint32_t count = 0;
......@@ -271,6 +272,7 @@ uint32_t CU::getNumNonZeroCoeffNonTsCorner8x8( const CodingUnit& cu, const bool
return count;
}
#endif
bool CU::divideTuInRows( const CodingUnit &cu )
{
......@@ -1595,13 +1597,17 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx,
}
bool PU::checkDMVRCondition(const PredictionUnit& pu)
{
WPScalingParam *wp0;
WPScalingParam *wp1;
int refIdx0 = pu.refIdx[REF_PIC_LIST_0];
int refIdx1 = pu.refIdx[REF_PIC_LIST_1];
pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
WPScalingParam *wp0;
WPScalingParam *wp1;
int refIdx0 = pu.refIdx[REF_PIC_LIST_0];
int refIdx1 = pu.refIdx[REF_PIC_LIST_1];
pu.cs->slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
pu.cs->slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
if (pu.cs->sps->getUseDMVR() && (!pu.cs->slice->getDisBdofDmvrFlag()))
#else
if (pu.cs->sps->getUseDMVR())
#endif
{
return pu.mergeFlag
&& pu.mergeType == MRG_TYPE_DEFAULT_N
......@@ -4497,6 +4503,17 @@ bool TU::isMTSAllowed(const TransformUnit &tu, const ComponentID compID)
return mtsAllowed;
}
#if JVET_O0105_ICT
int TU::getICTMode( const TransformUnit& tu, int jointCbCr )
{
if( jointCbCr < 0 )
{
jointCbCr = tu.jointCbCr;
}
return g_ictModes[ tu.cs->slice->getJointCbCrSignFlag() ][ jointCbCr ];
}
#endif
uint32_t TU::getGolombRiceStatisticsIndex(const TransformUnit &tu, const ComponentID &compID)
{
const bool transformSkip = tu.mtsIdx==MTS_SKIP;
......@@ -4541,7 +4558,7 @@ uint32_t TU::getNumNonZeroCoeffsNonTS( const TransformUnit& tu, const bool bLuma
}
return count;
}
#if !JVET_O0094_LFNST_ZERO_PRIM_COEFFS
uint32_t TU::getNumNonZeroCoeffsNonTSCorner8x8( const TransformUnit& tu, const bool lumaFlag, const bool chromaFlag )
{
const uint32_t lumaWidth = tu.blocks[ 0 ].width, chromaWidth = tu.blocks[ 1 ].width;
......@@ -4583,6 +4600,7 @@ uint32_t TU::getNumNonZeroCoeffsNonTSCorner8x8( const TransformUnit& tu, const b
}
return count;
}
#endif
bool TU::needsSqrt2Scale( const TransformUnit &tu, const ComponentID &compID )
{
......
......@@ -213,7 +213,9 @@ namespace TU
bool needsBlockSizeTrafoScale ( const TransformUnit &tu, const ComponentID &compID );
TransformUnit* getPrevTU ( const TransformUnit &tu, const ComponentID compID );
bool getPrevTuCbfAtDepth( const TransformUnit &tu, const ComponentID compID, const int trDepth );
#if JVET_O0105_ICT
int getICTMode ( const TransformUnit &tu, int jointCbCr = -1 );
#endif
}
uint32_t getCtuAddr (const Position& pos, const PreCalcValues &pcv);
......
......@@ -79,7 +79,11 @@ _byteStreamNALUnit(
{
uint8_t leading_zero_8bits = bs.readByte();
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if EPBINCOUNT_FIX
statBits.bits+=8; statBits.count+=8;
#else
statBits.bits+=8; statBits.count++;
#endif
#endif
if(leading_zero_8bits != 0) { THROW( "Leading zero bits not zero" ); }
stats.m_numLeadingZero8BitsBytes++;
......@@ -97,7 +101,11 @@ _byteStreamNALUnit(
{
uint8_t zero_byte = bs.readByte();
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if EPBINCOUNT_FIX
statBits.bits+=8; statBits.count+=8;
#else
statBits.bits+=8; statBits.count++;
#endif
#endif
CHECK( zero_byte != 0, "Zero byte not '0'" );
stats.m_numZeroByteBytes++;
......@@ -111,7 +119,11 @@ _byteStreamNALUnit(
/* NB, (1) guarantees that the next three bytes are 0x00 00 01 */
uint32_t start_code_prefix_one_3bytes = bs.readBytes(24/8);
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if EPBINCOUNT_FIX
statBits.bits+=24; statBits.count+=24;
#else
statBits.bits+=24; statBits.count+=3;
#endif
#endif
if(start_code_prefix_one_3bytes != 0x000001) { THROW( "Invalid code prefix" );}
stats.m_numStartCodePrefixBytes += 3;
......@@ -163,7 +175,11 @@ _byteStreamNALUnit(
{
uint8_t trailing_zero_8bits = bs.readByte();
#if RExt__DECODER_DEBUG_BIT_STATISTICS
#if EPBINCOUNT_FIX
statBits.bits+=8; statBits.count+=8;
#else
statBits.bits+=8; statBits.count++;
#endif
#endif
CHECK( trailing_zero_8bits != 0, "Trailing zero bits not '0'" );
stats.m_numTrailingZero8BitsBytes++;
......
This diff is collapsed.
......@@ -129,16 +129,28 @@ public:
void cu_chroma_qp_offset ( CodingUnit& cu );
// residual coding (clause 7.3.8.11)
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
void residual_coding ( TransformUnit& tu, ComponentID compID, CUCtx& cuCtx );
#else
void residual_coding ( TransformUnit& tu, ComponentID compID );
#endif
void mts_coding ( TransformUnit& tu, ComponentID compID );
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
void residual_lfnst_mode ( CodingUnit& cu, CUCtx& cuCtx );
#else
void residual_lfnst_mode ( CodingUnit& cu );
#endif
void isp_mode ( CodingUnit& cu );
void explicit_rdpcm_mode ( TransformUnit& tu, ComponentID compID );
int last_sig_coeff ( CoeffCodingContext& cctx, TransformUnit& tu, ComponentID compID );
void residual_coding_subblock ( CoeffCodingContext& cctx, TCoeff* coeff, const int stateTransTable, int& state );
void residual_codingTS ( TransformUnit& tu, ComponentID compID );
void residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* coeff );
#if JVET_O0105_ICT
void joint_cb_cr ( TransformUnit& tu, const int cbfMask );
#else
void joint_cb_cr ( TransformUnit& tu );
#endif
// cross component prediction (clause 7.3.8.12)
void cross_comp_pred ( TransformUnit& tu, ComponentID compID );
......
......@@ -228,10 +228,30 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
const QpParam cQP( tu, compID );
#if JVET_O0105_ICT
if( tu.jointCbCr && isChroma(compID) )
{
if( compID == COMPONENT_Cb )
{
PelBuf resiCr = cs.getResiBuf( tu.blocks[ COMPONENT_Cr ] );
if( tu.jointCbCr >> 1 )
{
m_pcTrQuant->invTransformNxN( tu, COMPONENT_Cb, piResi, cQP );
}
else
{
m_pcTrQuant->invTransformNxN( tu, COMPONENT_Cr, resiCr, cQP );
}
m_pcTrQuant->invTransformICT( tu, piResi, resiCr );
}
}
else
#else
// Joint chroma residual mode: Cr uses negative of the signalled Cb residual
if ( tu.jointCbCr && compID == COMPONENT_Cr )
piResi.copyAndNegate( cs.getResiBuf( tu.blocks[COMPONENT_Cb] ) );
else
#endif
if( TU::getCbf( tu, compID ) )
{
m_pcTrQuant->invTransformNxN( tu, compID, piResi, cQP );
......@@ -243,9 +263,14 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID )
//===== reconstruction =====
flag = flag && (tu.blocks[compID].width*tu.blocks[compID].height > 4);
#if JVET_O0105_ICT
if (flag && (TU::getCbf(tu, compID) || tu.jointCbCr) && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag())
{
#else
if (flag && TU::getCbf(tu, compID) && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag())
{
if ( !(tu.jointCbCr && compID == COMPONENT_Cr) ) // // Joint chroma residual mode: chroma scaling took place already when doing Cb
#endif
piResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID));
}
if( isChroma(compID) && tu.compAlpha[compID] != 0 )
......@@ -553,10 +578,30 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID )
const QpParam cQP(currTU, compID);
#if JVET_O0105_ICT
if( currTU.jointCbCr && isChroma(compID) )
{
if( compID == COMPONENT_Cb )
{
PelBuf resiCr = cs.getResiBuf( currTU.blocks[ COMPONENT_Cr ] );
if( currTU.jointCbCr >> 1 )
{
m_pcTrQuant->invTransformNxN( currTU, COMPONENT_Cb, resiBuf, cQP );
}
else
{
m_pcTrQuant->invTransformNxN( currTU, COMPONENT_Cr, resiCr, cQP );
}
m_pcTrQuant->invTransformICT( currTU, resiBuf, resiCr );
}
}
else
#else
// Joint chroma residual mode: Cr uses negative of the signalled Cb residual
if ( currTU.jointCbCr && compID == COMPONENT_Cr )
resiBuf.copyAndNegate( cs.getResiBuf( currTU.blocks[COMPONENT_Cb] ) );
else
#endif
if( TU::getCbf( currTU, compID ) )
{
m_pcTrQuant->invTransformNxN( currTU, compID, resiBuf, cQP );
......@@ -568,9 +613,15 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID )
//===== reconstruction =====
const Slice &slice = *cs.slice;
#if JVET_O0105_ICT
if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr)
&& slice.getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width * currTU.blocks[compID].height > 4)
{
#else
if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && isChroma(compID) && TU::getCbf(currTU, compID) && slice.getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width*currTU.blocks[compID].height > 4)
{
if ( !(currTU.jointCbCr && compID == COMPONENT_Cr) ) // Joint chroma residual mode: chroma scaling took place already when doing Cb
#endif
resiBuf.scaleSignal(currTU.getChromaAdj(), 0, currTU.cu->cs->slice->clpRng(compID));
}
if( isChroma( compID ) && currTU.compAlpha[compID] != 0 )
......
......@@ -1251,7 +1251,12 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS)
{
READ_FLAG( uiCode, "sps_fpel_mmvd_enabled_flag" ); pcSPS->setFpelMmvdEnabledFlag ( uiCode != 0 );
}
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
if (pcSPS->getBDOFEnabledFlag() || pcSPS->getUseDMVR())
{
READ_FLAG(uiCode, "sps_fpel_mmvd_enabled_flag"); pcSPS->setBdofDmvrSlicePresentFlag(uiCode != 0);
}
#endif
READ_FLAG( uiCode, "triangle_flag" ); pcSPS->setUseTriangle ( uiCode != 0 );
READ_FLAG( uiCode, "sps_mip_flag"); pcSPS->setUseMIP ( uiCode != 0 );
......@@ -1982,6 +1987,13 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
READ_FLAG( uiCode, "tile_group_fracmmvd_disabled_flag" );
pcSlice->setDisFracMMVD( uiCode ? true : false );
}
#if JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG
if (sps->getBdofDmvrSlicePresentFlag())
{
READ_FLAG(uiCode, "tile_group_bdof_dmvr_disabled_flag");
pcSlice->setDisBdofDmvrFlag(uiCode ? true : false);
}
#endif
if (sps->getUseTriangle() && pcSlice->getMaxNumMergeCand() >= 2)
{
READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_triangle_cand");
......@@ -1993,6 +2005,12 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, ParameterSetManager *para
pcSlice->setMaxNumTriangleCand(0);
}
}
#if JVET_O0105_ICT
if (bChroma)
{
READ_FLAG( uiCode, "joint_cb_cr_sign_flag" ); pcSlice->setJointCbCrSignFlag( uiCode != 0 );
}
#endif
READ_SVLC( iCode, "slice_qp_delta" );
pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
......
......@@ -823,9 +823,11 @@ void CABACWriter::cu_gbi_flag(const CodingUnit& cu)
const uint8_t gbiCodingIdx = (uint8_t)g_GbiCodingOrder[CU::getValidGbiIdx(cu)];
const int32_t numGBi = (cu.slice->getCheckLDC()) ? 5 : 3;
#if JVET_O0126_BPWA_INDEX_CODING_FIX
m_BinEncoder.encodeBin((gbiCodingIdx == 0 ? 0 : 1), Ctx::GBiIdx(0));
#else
m_BinEncoder.encodeBin((gbiCodingIdx == 0 ? 1 : 0), Ctx::GBiIdx(0));
#endif
if(numGBi > 2 && gbiCodingIdx != 0)
{
const uint32_t prefixNumBits = numGBi - 2;
......@@ -836,12 +838,20 @@ void CABACWriter::cu_gbi_flag(const CodingUnit& cu)
{
if (gbiCodingIdx == idx)
{
#if JVET_O0126_BPWA_INDEX_CODING_FIX
m_BinEncoder.encodeBinEP(0);
#else
m_BinEncoder.encodeBinEP(1);
#endif
break;
}
else
{
#if JVET_O0126_BPWA_INDEX_CODING_FIX
m_BinEncoder.encodeBinEP(1);
#else
m_BinEncoder.encodeBinEP(0);
#endif
idx += step;
}
}
......@@ -1253,6 +1263,10 @@ void CABACWriter::cu_residual( const CodingUnit& cu, Partitioner& partitioner, C
}
}
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_LUMA] = false;
cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false;
#endif
ChromaCbfs chromaCbfs;
if( cu.ispMode && isLuma( partitioner.chType ) )
......@@ -2201,6 +2215,14 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, ChromaC
}
cbfChroma = ( cbf[ COMPONENT_Cb ] || cbf[ COMPONENT_Cr ] );
}
#if JVET_O0105_ICT
if( !lumaOnly )
{
joint_cb_cr( tu, ( cbf[COMPONENT_Cb] ? 2 : 0 ) + ( cbf[COMPONENT_Cr] ? 1 : 0 ) );
}
#endif
if( cbfLuma || cbfChroma )
{
if( cu.cs->pps->getUseDQP() && !cuCtx.isDQPCoded )
......@@ -2219,7 +2241,11 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, ChromaC
}
if( cbfLuma )
{
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
residual_coding( tu, COMPONENT_Y, &cuCtx );
#else
residual_coding( tu, COMPONENT_Y );
#endif
}
if( !lumaOnly )
{
......@@ -2231,7 +2257,11 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, ChromaC
}
if( cbf[ compID ] )
{
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS