xIntraCodingTUBlock在xRecurIntraCodingLumaQT函数和xRecurIntraChromaCodingQT函数中均会被调用,进行给定变换模式和帧内预测模式下的一系列操作。
调用xIntraCodingTUBlock函数的目的,就是对tu在给定变换模式和帧内模式的情况下,求得解码端reco像素和orig的失真。
函数流程:
对pu进行帧内预测得到pred像素,由pred像素和orig像素得到残差像素resi,将resi通过调用transformNxN和invTransformNxN函数,得到解码端得到的resi像素,其与pred求和即的reco像素;最后通过reco像素和orig像素,求得失真,返回。
具体的会有很多种情况,函数中都有注释。
与VTM1中的代码相比,没太大差别,就多了LM预测。
void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &compID, const bool &checkCrossCPrediction, Distortion& ruiDist, const int &default0Save1Load2, uint32_t* numSig )
{
if (!tu.blocks[compID].valid())
{
return;
}
CodingStructure &cs = *tu.cs;
const CompArea &area = tu.blocks[compID]; //tu的area
const SPS &sps = *cs.sps;
const PPS &pps = *cs.pps;
const ChannelType chType = toChannelType(compID);
const int bitDepth = sps.getBitDepth(chType);
PelBuf piOrg = cs.getOrgBuf (area); //原始像素
PelBuf piPred = cs.getPredBuf (area); //预测像素
PelBuf piResi = cs.getResiBuf (area); //残差像素
PelBuf piOrgResi