MIP技术原理介绍:https://blog.csdn.net/BigDream123/article/details/104939645
MIP的相关函数代码在estIntraPredLumaQT函数中首次被调用,如下代码所示,其中
注意:MIP使用存在块尺寸限制:宽高比不能超过1:8/8:1
//MIP允许使用标志
const bool mipAllowed = sps.getUseMIP() && isLuma(partitioner.chType) && ((cu.lfnstIdx == 0) || allowLfnstWithMip(cu.firstPU->lumaSize()));
//MIP模式测试标志:宽高比不能超过1:8/8:1
const bool testMip = mipAllowed && !(cu.lwidth() > (8 * cu.lheight()) || cu.lheight() > (8 * cu.lwidth()));
//MIP支持的最大块尺寸为64
const bool supportedMipBlkSize = pu.lwidth() <= MIP_MAX_WIDTH && pu.lheight() <= MIP_MAX_HEIGHT;
...
...
...
// 初始化Mip模式
initIntraPatternChType(cu, pu.Y());//获取参考像素并滤波
initIntraMip(pu, pu.Y());
// getNumModesMip函数根据当前CU的块尺寸获取不同的Mip模式数量16 8 6
const int transpOff = getNumModesMip(pu.Y());
const int numModesFull = (transpOff << 1);//MIP模式总数分别是32 16 12
for (uint32_t uiModeFull = 0; uiModeFull < numModesFull; uiModeFull++)
{
//对于另一半MIP模式,其需要进行转置
const bool isTransposed = (uiModeFull >= transpOff ? true : false);
const uint32_t uiMode = (isTransposed ? uiModeFull - transpOff : uiModeFull);
pu.mipTransposedFlag = isTransposed;
pu.intraDir[CHANNEL_TYPE_LUMA] = uiMode;
// Mip预测模式的函数入口,进行MIP预测
predIntraMip(COMPONENT_Y, piPred, pu);
// Use the min between SAD and HAD as the cost criterion
// SAD is scaled by 2 to align with the scaling of HAD
Distortion minSadHad =
std::min(distParamSad.distFunc(distParamSad) * 2, distParamHad.distFunc(distParamHad));
m_CABACEstimator->getCtx() = SubCtx(Ctx::MipFlag, ctxStartMipFlag);
uint64_t fracModeBits = xFracModeBitsIntra(pu, uiMode, CHANNEL_TYPE_LUMA);
double cost = double(minSadHad) + double(fracModeBits) * sqrtLambdaForFirstPass;
mipHadCost[uiModeFull] = cost;
DTRACE(g_trace_ctx, D_INTRA_COST, "IntraMIP: %u, %llu, %f (%d)\n", minSadHad, fracModeBits, cost,
uiModeFull);
// 更新候选列表,将最优的Mip模式加入到RDCost的候选列表中
updateCandList(ModeInfo(true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, uiMode), cost, uiRdModeList,
CandCostList, numModesForFullRD + 1);
updateCandList(ModeInfo(true, isTransposed, 0, NOT_INTRA_SUBPARTITIONS, uiMode),
0.8 * double(minSadHad), uiHadModeList, CandHadList, numHadCand);
}
MIP根据块尺寸可以分为以下三种情况:
块尺寸 | MIP模式 | |
mipSizeId = 0 | 4x4 | 32 |
mipSizeId = 1 | 4xN、Nx4、8x8 | 16 |
mipSizeId = 2 | 其余块 | 12 |
其中,MIP的转置标志和MIP的模式号有关:
getNumModesMip函数代码如下:
int getNumModesMip(const Size& block)
{
switch( getMipSizeId(block) )
{
case 0: return 16;
case 1: return 8;
case 2: return 6;
default: THROW( "Invalid mipSizeId" );
}
}
initIntraMip函数相关代码参考:https://blog.csdn.net/BigDream123/article/details/107018446
predIntraMip函数相关代码参考:https://blog.csdn.net/BigDream123/article/details/107019458