CodingStructure类是VTM代码中的最基础的类,其地位相当于JEM代码中的TComDataCU类。视频的编解码都是基于CodingStructure类来进行,参考VTM说明文档,可以看到CodingStructure就是将它所处理区域的cu、pu、tu综合在一起统一操作的一个类。
可以将CodingStructure看做是一个包装盒,将area区域的cu、pu、tu等所有信息封装在一起的一个类。CodingStructure一般可以理解为代表一个CTU,它里面包含了CTU中所有划分得到的cu、pu、tu的数据。
在编码端compress过程中,CodingStructure在递归迭代过程中也可以代表子cu。
编码端的encode过程,解码端的decode过程,以及解码端的decompress过程中,可以看到用到的只有一个CodingStructure的对象cs,这个cs其实存储在它所归属的picture中,表示统一包含了该帧内的所有cu、pu、tu的信息
CodingStructure中的cu、pu、tu都是按照vector形式线性存储的。按照Z-scan扫描一个ctu中的cu,按照raster-scan扫描一帧中的所有ctu,一帧中所有的cu、pu、tu都按照这种扫描方式最终存储在picture的CodingStructure中
class CodingStructure
{
public:
UnitArea area; //CodingStructure的处理区域
Picture *picture; //CodingStructure所归属的picture
CodingStructure *parent; //compress递归迭代过程中,子cu递归的上一级的的划分块cu
Slice *slice;
UnitScale unitScale[MAX_NUM_COMPONENT]; //VTM处理亮度最小单元为4x4,色度2x2,将像素单位进行scale
int baseQP;
int prevQP[MAX_NUM_CHANNEL_TYPE];
int currQP[MAX_NUM_CHANNEL_TYPE];
int chromaQpAdj;
bool isLossless;
const SPS *sps;
const PPS *pps;
#if HEVC_VPS
const VPS *vps;
#endif
const PreCalcValues* pcv; //存储CodingStructure相关的一些通用数据
CodingStructure(CUCache&, PUCache&, TUCache&);
void create( const UnitArea &_unit, const bool isTopLayer );
void create( const ChromaFormat &_chromaFormat, const Area& _area, const bool isTopLayer );
void destroy();
void releaseIntermediateData();
void rebindPicBufs();
void createCoeffs();
void destroyCoeffs();
void allocateVectorsAtPicLevel();
// ---------------------------------------------------------------------------
// global accessors
// ---------------------------------------------------------------------------
bool isDecomp (const Position &pos, const ChannelType _chType) const;
bool isDecomp (const Position &pos, const ChannelType _chType);
void setDecomp(const CompArea &area, const bool _isCoded = true);
void setDecomp(const UnitArea &area, const bool _isCoded = true); //标记该区域已经完成解码
const CodingUnit *getCU(const Position &pos, const ChannelType _chType) const; //获取对应pos的cu、pu、tu
const PredictionUnit *getPU(const Position &pos, const ChannelType _chType) const;
const TransformUnit *getTU(const Position &pos, const ChannelType _chType) const;
CodingUnit *getCU(const Position &pos, const ChannelType _chType);
PredictionUnit *getPU(const Position &pos, const ChannelType _chType);
TransformUnit *getTU(const Position &pos, const ChannelType _chType);
const CodingUnit *getCU(const ChannelType &_chType) const {
return getCU(area.blocks[_chType].pos(), _chType