coding_tree函数通过递归调用,寻址ctu中的所有cu,对每个cu调用coding_unit解码cu信息。
其实,coding_tree函数根据解码得到的QT和MT的flag,逐步递归划分当前区域直到cu,本质就是在解码端重建编码端的划分树,直到叶子节点解码cu。
本函数与VTM1中代码的大致流程一致,最大区别就是对>64的DualITree块进行特别处理:
对于>64的DualITree块,在QT时要对亮度和色度统一进行,保持QT对亮度和色度划分一致。
对于>64的DualITree块,本函数入口参数既有亮度partitioner,又有色度chromaPartitioner。
对于>64的DualITree块的情况时,最后会将luma和chroma的cu拆分为两条,并将chromaCU的头接到lumaCU的尾,有何必要?
bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CUCtx& cuCtx, Partitioner* pPartitionerChroma, CUCtx* pCuCtxChroma)
{
const PPS &pps = *cs.pps;
const UnitArea &currArea = partitioner.currArea(); //当前处理的区域
bool lastSegment = false;
// Reset delta QP coding flag and ChromaQPAdjustemt coding flag
if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() )
{
cuCtx.isDQPCoded = false;
}
if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() )
{
cuCtx.isChromaQpAdjCoded = false;
}
// Reset delta QP coding flag and ChromaQPAdjustemt coding flag
if (CS::isDualITree(cs) && pPartitionerChroma != nullptr)//即:I帧DualITree且CTU为128x128时的情况
{
if (pps.getUseDQP() && pPartitionerChroma->currDepth <= pps.getMaxCuDQPDepth())
{
pCuCtxChroma->isDQPCoded = false;
}
if (cs.slice->getUseChromaQpAdj() && pPartitionerChroma->currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth())
{
pCuCtxChroma->isChromaQpAdjCoded = false;
}
}
const PartSplit implicitSplit = partitioner.getImplicitSplit( cs );
// QT
bool canQtSplit = partitioner.canSplit( CU_QUAD_SPLIT, cs ); //当前区域是否满足qt划分条件
if( canQtSplit )
{
// force QT split enabling on the edges and if the current area exceeds maximum transformation size
bool qtSplit = implicitSplit == CU_QUA