(个人理解)
该技术(称为CCLM)是JEM里新加的分量间线性模型预测技术,顾名思义就是利用亮度分量预测色度分量,目的是减少分量间的冗余。该函数的作用是利用重建的亮度采样计算色度分量的预测值。计算之前,还要利用当前块的邻近亮度采样和色度采样通过线性回归计算两个系数。CCLM又分为单一模型CCLM和多模型CCLM(MMLM)。单一模型可以计算出一组系数α和β。而MMLM根据阈值将亮度和色度采样分为两组,每组可计算一个α和β。最后利用α,β和重建的亮度分量计算出色度分量的预测值。
Void TComPrediction::predLMIntraChroma( TComTU& rTu, const ComponentID compID, Pel* pPred, UInt uiPredStride, UInt uiCWidth, UInt uiCHeight
#if JVET_E0077_ENHANCED_LM
, Int LMtype
#endif
)
{
#if JVET_E0077_MMLM
if (LMtype == MMLM_CHROMA_IDX
#if JVET_E0077_LM_MF
|| (LMtype >= LM_CHROMA_F1_IDX && LMtype < (LM_CHROMA_F1_IDX + LM_FILTER_NUM))
#endif
)//68<=LMtype<=72时,采用多模型CCLM;
{
#if JVET_E0077_LM_MF
Pel *pLumaSaved = m_pLumaRecBuffer;
if (LMtype >= LM_CHROMA_F1_IDX && LMtype < (LM_CHROMA_F1_IDX + LM_FILTER_NUM))
{
Int iLumaIdx = LMtype - LM_CHROMA_F1_IDX;
m_pLumaRecBuffer = m_pLumaRecBufferMul[iLumaIdx];
}
#endif
// LLS parameters estimation -->
TComPrediction::MMLM_parameter parameters[2];
Int iGroupNum = 2;
xGetMMLMParameters(rTu, compID, uiCWidth, uiCHeight, iGroupNum, parameters);//计算MMLM时的参数;
// get prediction -->
Int iLumaStride = m_iLumaRecStride;
//所以69,70,71,72的不同之处在于m_pLumaRecBuffer(重建亮度采样)不一样;
Pel *pLuma = m_pLumaRecBuffer + (iLumaStride + 1) * MMLM_SAMPLE_NEIGHBOR_LINES;
#if !JVET_D0033_ADAPTIVE_CLIPPING
const TComSPS &sps = *(rTu.getCU()->getSlice()->getSPS());
Int maxV = (1 << sps.getBitDepth(CHANNEL_TYPE_CHROMA)) - 1;
#endif
for (Int i = 0; i < uiCHeight; i++)
{
for (Int j = 0; j < uiCWidth; j++)
{
Int a, b, iShift;
if (pLuma[j] <= parameters[0].Sup)//parameters[0].Sup应该是分组时候的阈值;
{
a = parameters[0].a;
b = parameters[0].b;
iShift = parameters[0].shift;
}
else
{
a = parameters[1].a;
b = parameters[1].b;
iShift = parameters[1].shift;
}
#if JVET_D0033_ADAPTIVE_CLIPPING
//Y分量是40--1004,Cb分量是0--1023,Cr分量是0--1023,因为采用的10比特;
pPred[j] = ClipA(((a * pLuma[j]) >> iShift) + b, compID);//将预测值限制在compID对应分量的取值范围里;
#else
pPred[j] = Clip3(0, maxV, ((a * pLuma[j]) >> iShift) + b);
#endif
}
pPred += uiPredStride;
pLuma += iLumaStride;
}
#if JVET_E0077_LM_MF
m_pLumaRecBuffer = pLumaSaved;
#endif
}
else //单一模型CCLM
#endif
#if JVET_E0077_MMLM
{
#endif
// LLS parameters estimation -->
Int a, b, iShift;
xGetLMParameters( rTu, compID, uiCWidth, uiCHeight, 0, a, b, iShift );//计算单一模式CCLM时的参数;
// get prediction -->
Int iLumaStride = m_iLumaRecStride;
#if JVET_E0077_MMLM
Pel *pLuma = m_pLumaRecBuffer + (iLumaStride + 1) * MMLM_SAMPLE_NEIGHBOR_LINES;
#else
Pel *pLuma = m_pLumaRecBuffer + iLumaStride + 1;
#endif
#if !JVET_D0033_ADAPTIVE_CLIPPING
const TComSPS &sps = *(rTu.getCU()->getSlice()->getSPS());
Int maxV = (1 << sps.getBitDepth(CHANNEL_TYPE_CHROMA)) - 1;
#endif
for( Int i = 0; i < uiCHeight; i++ )
{
for( Int j = 0; j < uiCWidth; j++ )
{
#if JVET_D0033_ADAPTIVE_CLIPPING
pPred[j] = ClipA(( ( a * pLuma[j] ) >> iShift ) + b , compID);//色度分量的预测值;
#else
pPred[j] = Clip3(0, maxV, ( ( a * pLuma[j] ) >> iShift ) + b );
#endif
}
pPred += uiPredStride;
pLuma += iLumaStride;
}
// <-- end of get prediction
#if JVET_E0077_MMLM
}
#endif
}