Commit 0c0323b9 authored by Adarsh Krishnan Ramasubramonian's avatar Adarsh Krishnan Ramasubramonian
Browse files

Merge branch 'master' into 'JVET-O0106-CompRed-ISP-4xN-PredRegions'

# Conflicts:
#   source/Lib/CommonLib/TypeDef.h
parents 163af3e6 829fd694
......@@ -1407,6 +1407,7 @@ const TransformUnit* CodingStructure::getTURestricted( const Position &pos, cons
}
}
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
IbcLumaCoverage CodingStructure::getIbcLumaCoverage(const CompArea& chromaArea) const
{
const unsigned int unitAreaSubBlock = MIN_PU_SIZE * MIN_PU_SIZE;
......@@ -1438,3 +1439,4 @@ IbcLumaCoverage CodingStructure::getIbcLumaCoverage(const CompArea& chromaArea)
return coverage;
}
#endif
\ No newline at end of file
......@@ -60,6 +60,7 @@ enum PictureType
PIC_RECON_WRAP,
NUM_PIC_TYPES
};
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
enum IbcLumaCoverage
{
IBC_LUMA_COVERAGE_FULL = 0,
......@@ -67,6 +68,7 @@ enum IbcLumaCoverage
IBC_LUMA_COVERAGE_NONE,
NUM_IBC_LUMA_COVERAGE,
};
#endif
extern XUCache g_globalUnitCache;
// ---------------------------------------------------------------------------
......@@ -153,7 +155,9 @@ public:
cCUTraverser traverseCUs(const UnitArea& _unit, const ChannelType _chType) const;
cPUTraverser traversePUs(const UnitArea& _unit, const ChannelType _chType) const;
cTUTraverser traverseTUs(const UnitArea& _unit, const ChannelType _chType) const;
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
IbcLumaCoverage getIbcLumaCoverage(const CompArea& chromaArea) const;
#endif
// ---------------------------------------------------------------------------
// encoding search utilities
// ---------------------------------------------------------------------------
......
......@@ -387,6 +387,7 @@ void InterPrediction::xSubPuBio(PredictionUnit& pu, PelUnitBuf& predBuf, const R
}
}
}
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
void InterPrediction::xChromaMC(PredictionUnit &pu, PelUnitBuf& pcYuvPred)
{
// separated tree, chroma
......@@ -414,7 +415,7 @@ void InterPrediction::xChromaMC(PredictionUnit &pu, PelUnitBuf& pcYuvPred)
}
}
}
#endif
void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& eRefPicList, PelUnitBuf& pcYuvPred, const bool& bi
, const bool& bioApplied
......@@ -1294,6 +1295,7 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
// dual tree handling for IBC as the only ref
if ((!luma || !chroma) && eRefPicList == REF_PIC_LIST_0)
{
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
if (!luma && chroma)
{
xChromaMC(pu, predBuf);
......@@ -1301,11 +1303,14 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu
}
else // (luma && !chroma)
{
#endif
xPredInterUni(pu, eRefPicList, predBuf, false
, false
, luma, chroma);
return;
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
}
#endif
}
// else, go with regular MC below
CodingStructure &cs = *pu.cs;
......
......@@ -161,7 +161,9 @@ protected:
MotionInfo m_SubPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)];
#if !JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
void xChromaMC(PredictionUnit &pu, PelUnitBuf& pcYuvPred);
#endif
#if JVET_J0090_MEMORY_BANDWITH_MEASURE
CacheModel *m_cacheModel;
#endif
......
......@@ -52,6 +52,8 @@
#define JVET_O0106_ISP_4xN_PREDREG_FOR_1xN_2xN 1 // JVET-O0106: use 4xN prediction regions for 1xN and 2xN subblocks
#define JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE 1 // JVET-O0258 Remove chroma IBC when dualtree is used
#define JVET_O1161_IBC_MAX_SIZE 1 // Limit largest IBC luma CU size to 64x64 per discussion of JVET-O1161
#define JVET_O0315_RDPCM_INTRAMODE_ALIGN 1 // JVET-O0200/O0205/O0296/O0342/O0463/O0542: Intra prediction mode alignment for BDPCM
......@@ -130,6 +132,8 @@
#define JVET_O1140_SLICE_DISABLE_BDOF_DMVR_FLAG 1 // JVET-O1140 slice level disable flag for BDOF and DMVR
#define JVET_O0596_CBF_SIG_ALIGN_TO_SPEC 1 // JVET-O0596 align cbf signaling with specification
#define FIX_DB_MAX_TRANSFORM_SIZE 1
#define MRG_SHARELIST_SHARSIZE 32
......
......@@ -955,8 +955,11 @@ void CABACReader::affine_amvr_mode( CodingUnit& cu, MergeCtx& mrgCtx )
void CABACReader::pred_mode( CodingUnit& cu )
{
RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__PRED_MODE );
#if JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
if (cu.cs->slice->getSPS()->getIBCFlag() && cu.chType != CHANNEL_TYPE_CHROMA)
#else
if (cu.cs->slice->getSPS()->getIBCFlag())
#endif
{
if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) )
{
......@@ -1394,11 +1397,19 @@ void CABACReader::cu_residual( CodingUnit& cu, Partitioner &partitioner, CUCtx&
if( cu.ispMode && isLuma( partitioner.chType ) )
{
TUIntraSubPartitioner subTuPartitioner( partitioner );
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( *cu.cs, subTuPartitioner, cuCtx, CU::getISPType(cu, getFirstComponentOfChannel(partitioner.chType)), 0 );
#else
transform_tree( *cu.cs, subTuPartitioner, cuCtx, chromaCbfs, CU::getISPType( cu, getFirstComponentOfChannel( partitioner.chType ) ), 0 );
#endif
}
else
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( *cu.cs, partitioner, cuCtx );
#else
transform_tree( *cu.cs, partitioner, cuCtx, chromaCbfs );
#endif
}
#if JVET_O0094_LFNST_ZERO_PRIM_COEFFS
residual_lfnst_mode( cu, cuCtx );
......@@ -2077,8 +2088,21 @@ void CABACReader::pcm_samples( TransformUnit& tu )
// bool cbf_comp ( area, depth )
//================================================================================
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, CUCtx& cuCtx, const PartSplit ispType, const int subTuIdx )
#else
void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner, CUCtx& cuCtx, ChromaCbfs& chromaCbfs, const PartSplit ispType, const int subTuIdx )
#endif
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const UnitArea& area = partitioner.currArea();
CodingUnit& cu = *cs.getCU(area.blocks[partitioner.chType], partitioner.chType);
int subTuCounter = subTuIdx;
// split_transform_flag
bool split = partitioner.canSplit(TU_MAX_TR_SPLIT, cs);
const unsigned trDepth = partitioner.currTrDepth;
#else
ChromaCbfs chromaCbfsLastDepth;
chromaCbfsLastDepth.Cb = chromaCbfs.Cb;
chromaCbfsLastDepth.Cr = chromaCbfs.Cr;
......@@ -2094,6 +2118,7 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
split = partitioner.canSplit( TU_MAX_TR_SPLIT, cs );
bool max_tu_split = split;
#endif
if( cu.sbtInfo && partitioner.canSplit( PartSplit( cu.getSbtTuSplit() ), cs ) )
{
......@@ -2104,6 +2129,7 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
{
split = partitioner.canSplit( ispType, cs );
}
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode && !split;
// cbf_cb & cbf_cr
......@@ -2126,6 +2152,7 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
{
chromaCbfs = ChromaCbfs( false );
}
#endif
if( split )
{
......@@ -2154,13 +2181,18 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
do
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( cs, partitioner, cuCtx, ispType, subTuCounter );
#else
ChromaCbfs subCbfs = chromaCbfs;
transform_tree( cs, partitioner, cuCtx, subCbfs, ispType, subTuCounter );
#endif
subTuCounter += subTuCounter != -1 ? 1 : 0;
} while( partitioner.nextPart( cs ) );
partitioner.exitCurrSplit();
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const UnitArea &currArea = partitioner.currArea();
const unsigned currDepth = partitioner.currTrDepth;
const unsigned numTBlocks = getNumberValidTBlocks( *cs.pcv );
......@@ -2185,14 +2217,17 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
TU::setCbfAtDepth(currTU, COMPONENT_Cr, currDepth, compCbf[COMPONENT_Cr]);
}
}
#endif
}
else
{
TransformUnit &tu = cs.addTU( CS::getArea( cs, area, partitioner.chType ), partitioner.chType );
unsigned numBlocks = ::getNumberValidTBlocks( *cs.pcv );
tu.checkTuNoResidual( partitioner.currPartIdx() );
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
chromaCbfs.Cb &= !tu.noResidual;
chromaCbfs.Cr &= !tu.noResidual;
#endif
for( unsigned compID = COMPONENT_Y; compID < numBlocks; compID++ )
{
......@@ -2205,6 +2240,9 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
tu.depth = trDepth;
DTRACE( g_trace_ctx, D_SYNTAX, "transform_unit() pos=(%d,%d) size=%dx%d depth=%d trDepth=%d\n", tu.blocks[tu.chType].x, tu.blocks[tu.chType].y, tu.blocks[tu.chType].width, tu.blocks[tu.chType].height, cu.depth, partitioner.currTrDepth );
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_unit(tu, cuCtx, partitioner, subTuCounter);
#else
if( !isChroma( partitioner.chType ) )
{
if( !CU::isIntra( cu ) && trDepth == 0 && !chromaCbfs.sigChroma( area.chromaFormat ) )
......@@ -2256,8 +2294,8 @@ void CABACReader::transform_tree( CodingStructure &cs, Partitioner &partitioner,
TU::setCbfAtDepth( tu, COMPONENT_Cr, trDepth, ( chromaCbfs.Cr ? 1 : 0 ) );
}
transform_unit( tu, cuCtx, chromaCbfs );
transform_unit(tu, cuCtx, chromaCbfs);
#endif
}
}
......@@ -2347,10 +2385,93 @@ void CABACReader::mvd_coding( Mv &rMvd )
// void cu_qp_delta ( cu )
// void cu_chroma_qp_offset ( cu )
//================================================================================
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& partitioner, const int subTuCounter)
#else
void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, ChromaCbfs& chromaCbfs )
#endif
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const UnitArea& area = partitioner.currArea();
const unsigned trDepth = partitioner.currTrDepth;
CodingStructure& cs = *tu.cs;
CodingUnit& cu = *tu.cu;
ChromaCbfs chromaCbfs;
chromaCbfs.Cb = chromaCbfs.Cr = false;
const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode;
// cbf_cb & cbf_cr
if (area.chromaFormat != CHROMA_400 && area.blocks[COMPONENT_Cb].valid() && (!CS::isDualITree(cs) || partitioner.chType == CHANNEL_TYPE_CHROMA) && (!cu.ispMode || chromaCbfISP))
{
const int cbfDepth = chromaCbfISP ? trDepth - 1 : trDepth;
{
if (!(cu.sbtInfo && tu.noResidual))
chromaCbfs.Cb = cbf_comp(cs, area.blocks[COMPONENT_Cb], cbfDepth);
if (!(cu.sbtInfo && tu.noResidual))
chromaCbfs.Cr = cbf_comp(cs, area.blocks[COMPONENT_Cr], cbfDepth, chromaCbfs.Cb);
}
}
else if (CS::isDualITree(cs))
{
chromaCbfs = ChromaCbfs(false);
}
if (!isChroma(partitioner.chType))
{
if (!CU::isIntra(cu) && trDepth == 0 && !chromaCbfs.sigChroma(area.chromaFormat))
{
TU::setCbfAtDepth(tu, COMPONENT_Y, trDepth, 1);
}
else if (cu.sbtInfo && tu.noResidual)
{
TU::setCbfAtDepth(tu, COMPONENT_Y, trDepth, 0);
}
else if (cu.sbtInfo && !chromaCbfs.sigChroma(area.chromaFormat))
{
assert(!tu.noResidual);
TU::setCbfAtDepth(tu, COMPONENT_Y, trDepth, 1);
}
else
{
bool previousCbf = false;
bool rootCbfSoFar = false;
bool lastCbfIsInferred = false;
if (cu.ispMode)
{
uint32_t nTus = cu.ispMode == HOR_INTRA_SUBPARTITIONS ? cu.lheight() >> g_aucLog2[tu.lheight()] : cu.lwidth() >> g_aucLog2[tu.lwidth()];
if (subTuCounter == nTus - 1)
{
TransformUnit* tuPointer = cu.firstTU;
for (int tuIdx = 0; tuIdx < nTus - 1; tuIdx++)
{
rootCbfSoFar |= TU::getCbfAtDepth(*tuPointer, COMPONENT_Y, trDepth);
tuPointer = tuPointer->next;
}
if (!rootCbfSoFar)
{
lastCbfIsInferred = true;
}
}
if (!lastCbfIsInferred)
{
previousCbf = TU::getPrevTuCbfAtDepth(tu, COMPONENT_Y, trDepth);
}
}
bool cbfY = lastCbfIsInferred ? true : cbf_comp(cs, tu.Y(), trDepth, previousCbf, cu.ispMode);
TU::setCbfAtDepth(tu, COMPONENT_Y, trDepth, (cbfY ? 1 : 0));
}
}
if (area.chromaFormat != CHROMA_400 && (!cu.ispMode || chromaCbfISP))
{
TU::setCbfAtDepth(tu, COMPONENT_Cb, trDepth, (chromaCbfs.Cb ? 1 : 0));
TU::setCbfAtDepth(tu, COMPONENT_Cr, trDepth, (chromaCbfs.Cr ? 1 : 0));
}
#else
CodingUnit& cu = *tu.cu;
#endif
bool lumaOnly = ( cu.chromaFormat == CHROMA_400 || !tu.blocks[COMPONENT_Cb].valid() );
bool cbfLuma = ( tu.cbf[ COMPONENT_Y ] != 0 );
bool cbfChroma = ( lumaOnly ? false : ( chromaCbfs.Cb || chromaCbfs.Cr ) );
......
......@@ -117,14 +117,22 @@ public:
void pcm_samples ( TransformUnit& tu );
// transform tree (clause 7.3.8.8)
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 );
#else
void transform_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, ChromaCbfs& chromaCbfs, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 );
#endif
bool cbf_comp ( CodingStructure& cs, const CompArea& area, unsigned depth, const bool prevCbCbf = false, const bool useISP = false );
// mvd coding (clause 7.3.8.9)
void mvd_coding ( Mv &rMvd );
// transform unit (clause 7.3.8.10)
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void transform_unit ( TransformUnit& tu, CUCtx& cuCtx, Partitioner& pm, const int subTuCounter = -1 );
#else
void transform_unit ( TransformUnit& tu, CUCtx& cuCtx, ChromaCbfs& chromaCbfs );
#endif
void cu_qp_delta ( CodingUnit& cu, int predQP, int8_t& qp );
void cu_chroma_qp_offset ( CodingUnit& cu );
......
......@@ -730,7 +730,11 @@ void CABACWriter::cu_skip_flag( const CodingUnit& cu )
void CABACWriter::pred_mode( const CodingUnit& cu )
{
#if JVET_O0258_REMOVE_CHROMA_IBC_FOR_DUALTREE
if (cu.cs->slice->getSPS()->getIBCFlag() && cu.chType != CHANNEL_TYPE_CHROMA)
#else
if (cu.cs->slice->getSPS()->getIBCFlag())
#endif
{
if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) )
{
......@@ -1288,15 +1292,25 @@ void CABACWriter::cu_residual( const CodingUnit& cu, Partitioner& partitioner, C
cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false;
#endif
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
ChromaCbfs chromaCbfs;
#endif
if( cu.ispMode && isLuma( partitioner.chType ) )
{
TUIntraSubPartitioner subTuPartitioner( partitioner );
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( *cu.cs, subTuPartitioner, cuCtx, CU::getISPType( cu, getFirstComponentOfChannel( partitioner.chType) ), 0 );
#else
transform_tree( *cu.cs, subTuPartitioner, cuCtx, chromaCbfs, CU::getISPType( cu, getFirstComponentOfChannel( partitioner.chType ) ), 0 );
#endif
}
else
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( *cu.cs, partitioner, cuCtx );
#else
transform_tree( *cu.cs, partitioner, cuCtx, chromaCbfs );
#endif
}
residual_lfnst_mode( cu, cuCtx );
......@@ -1982,9 +1996,20 @@ void CABACWriter::pcm_samples( const TransformUnit& tu )
// bool split_transform_flag( split, depth )
// bool cbf_comp ( cbf, area, depth )
//================================================================================
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partitioner, CUCtx& cuCtx, const PartSplit ispType, const int subTuIdx )
#else
void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partitioner, CUCtx& cuCtx, ChromaCbfs& chromaCbfs, const PartSplit ispType, const int subTuIdx )
#endif
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const UnitArea& area = partitioner.currArea();
int subTuCounter = subTuIdx;
const TransformUnit& tu = *cs.getTU(area.blocks[partitioner.chType].pos(), partitioner.chType, subTuIdx);
const CodingUnit& cu = *tu.cu;
const unsigned trDepth = partitioner.currTrDepth;
const bool split = (tu.depth > trDepth);
#else
ChromaCbfs chromaCbfsLastDepth;
chromaCbfsLastDepth.Cb = chromaCbfs.Cb;
chromaCbfsLastDepth.Cr = chromaCbfs.Cr;
......@@ -1996,11 +2021,14 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
const bool split = ( tu.depth > trDepth );
const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode && !split;
bool max_tu_split = false;
#endif
// split_transform_flag
if( partitioner.canSplit( TU_MAX_TR_SPLIT, cs ) )
{
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
max_tu_split = true;
#endif
CHECK( !split, "transform split implied" );
}
else if( cu.sbtInfo && partitioner.canSplit( PartSplit( cu.getSbtTuSplit() ), cs ) )
......@@ -2010,7 +2038,7 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
else
CHECK( split && !cu.ispMode, "transform split not allowed with QTBT" );
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
// cbf_cb & cbf_cr
if( area.chromaFormat != CHROMA_400 && area.blocks[COMPONENT_Cb].valid() && ( !CS::isDualITree( cs ) || partitioner.chType == CHANNEL_TYPE_CHROMA ) && ( !cu.ispMode || chromaCbfISP ) )
{
......@@ -2035,14 +2063,17 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
{
chromaCbfs = ChromaCbfs( false );
}
#endif
if( split )
{
#if !JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
if( area.chromaFormat != CHROMA_400 )
{
chromaCbfs.Cb = TU::getCbfAtDepth( tu, COMPONENT_Cb, trDepth );
chromaCbfs.Cr = TU::getCbfAtDepth( tu, COMPONENT_Cr, trDepth );
}
#endif
if( partitioner.canSplit( TU_MAX_TR_SPLIT, cs ) )
{
......@@ -2066,8 +2097,12 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
do
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_tree( cs, partitioner, cuCtx, ispType, subTuCounter );
#else
ChromaCbfs subChromaCbfs = chromaCbfs;
transform_tree( cs, partitioner, cuCtx, subChromaCbfs, ispType, subTuCounter );
#endif
subTuCounter += subTuCounter != -1 ? 1 : 0;
} while( partitioner.nextPart( cs ) );
......@@ -2077,6 +2112,9 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
{
DTRACE( g_trace_ctx, D_SYNTAX, "transform_unit() pos=(%d,%d) size=%dx%d depth=%d trDepth=%d\n", tu.blocks[tu.chType].x, tu.blocks[tu.chType].y, tu.blocks[tu.chType].width, tu.blocks[tu.chType].height, cu.depth, partitioner.currTrDepth );
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
transform_unit( tu, cuCtx, partitioner, subTuCounter);
#else
if( !isChroma( partitioner.chType ) )
{
if( !CU::isIntra( cu ) && trDepth == 0 && !chromaCbfs.sigChroma( area.chromaFormat ) )
......@@ -2127,6 +2165,7 @@ void CABACWriter::transform_tree( const CodingStructure& cs, Partitioner& partit
transform_unit( tu, cuCtx, chromaCbfs );
#endif
}
}
......@@ -2217,10 +2256,96 @@ void CABACWriter::mvd_coding( const Mv &rMvd, int8_t imv )
// void cu_qp_delta ( cu )
// void cu_chroma_qp_offset ( cu )
//================================================================================
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partitioner& partitioner, const int subTuCounter)
#else
void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, ChromaCbfs& chromaCbfs )
#endif
{
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
const CodingStructure& cs = *tu.cs;
const CodingUnit& cu = *tu.cu;
const UnitArea& area = partitioner.currArea();
const unsigned trDepth = partitioner.currTrDepth;
const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode;
ChromaCbfs chromaCbfs;
CHECK(tu.depth != trDepth, " transform unit should be not be futher partitioned");
// cbf_cb & cbf_cr
if (area.chromaFormat != CHROMA_400 && area.blocks[COMPONENT_Cb].valid() && (!CS::isDualITree(cs) || partitioner.chType == CHANNEL_TYPE_CHROMA) && (!cu.ispMode || chromaCbfISP))
{
{
unsigned cbfDepth = chromaCbfISP ? trDepth - 1 : trDepth;
{
chromaCbfs.Cb = TU::getCbfAtDepth(tu, COMPONENT_Cb, trDepth);
//if (!(cu.sbtInfo && trDepth == 1))
if (!(cu.sbtInfo && tu.noResidual))
cbf_comp(cs, chromaCbfs.Cb, area.blocks[COMPONENT_Cb], cbfDepth);
}
{
chromaCbfs.Cr = TU::getCbfAtDepth(tu, COMPONENT_Cr, trDepth);
//if (!(cu.sbtInfo && trDepth == 1))
if (!(cu.sbtInfo && tu.noResidual))
cbf_comp(cs, chromaCbfs.Cr, area.blocks[COMPONENT_Cr], cbfDepth, chromaCbfs.Cb);
}
}
}
else if (CS::isDualITree(cs))
{
chromaCbfs = ChromaCbfs(false);
}
if (!isChroma(partitioner.chType))
{
if (!CU::isIntra(cu) && trDepth == 0 && !chromaCbfs.sigChroma(area.chromaFormat))
{
CHECK(!TU::getCbfAtDepth(tu, COMPONENT_Y, trDepth), "Luma cbf must be true for inter units with no chroma coeffs");
}
else if (cu.sbtInfo && tu.noResidual)
{
CHECK(TU::getCbfAtDepth(tu, COMPONENT_Y, trDepth), "Luma cbf must be false for inter sbt no-residual tu");
}
else if (cu.sbtInfo && !chromaCbfs.sigChroma(area.chromaFormat))
{
assert(!tu.noResidual);
CHECK(!TU::getCbfAtDepth(tu, COMPONENT_Y, trDepth), "Luma cbf must be true for inter sbt residual tu");
}
else
{
bool previousCbf = false;
bool rootCbfSoFar = false;
bool lastCbfIsInferred = false;
if (cu.ispMode)
{
uint32_t nTus = cu.ispMode == HOR_INTRA_SUBPARTITIONS ? cu.lheight() >> g_aucLog2[tu.lheight()] : cu.lwidth() >> g_aucLog2[tu.lwidth()];
if (subTuCounter == nTus - 1)
{
TransformUnit* tuPointer = cu.firstTU;
for (int tuIdx = 0; tuIdx < subTuCounter; tuIdx++)
{
rootCbfSoFar |= TU::getCbfAtDepth(*tuPointer, COMPONENT_Y, trDepth);
tuPointer = tuPointer->next;
}
if (!rootCbfSoFar)
{
lastCbfIsInferred = true;
}
}
if (!lastCbfIsInferred)
{
previousCbf = TU::getPrevTuCbfAtDepth(tu, COMPONENT_Y, partitioner.currTrDepth);
}
}
if (!lastCbfIsInferred)
{
cbf_comp(cs, TU::getCbfAtDepth(tu, COMPONENT_Y, trDepth), tu.Y(), trDepth, previousCbf, cu.ispMode);
}
}
}
#else
CodingUnit& cu = *tu.cu;
#endif
bool lumaOnly = ( cu.chromaFormat == CHROMA_400 || !tu.blocks[COMPONENT_Cb].valid() );
bool cbf[3] = { TU::getCbf( tu, COMPONENT_Y ), chromaCbfs.Cb, chromaCbfs.Cr };
bool cbfLuma = ( cbf[ COMPONENT_Y ] != 0 );
......
......@@ -130,13 +130,21 @@ public:
void pcm_samples ( const TransformUnit& tu );
// transform tree (clause 7.3.8.8)
#if JVET_O0596_CBF_SIG_ALIGN_TO_SPEC
void transform_tree ( const CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, const PartSplit ispType = TU_NO_ISP, const int subTuIdx = -1 );