CCLMテクノロジは、再構築された輝度ピクセルの上の行および(または)左の列を介して輝度-クロミナンス線形モデルを確立し、そのモデルを使用してクロミナンスブロック全体を予測します。CCLMは、次の3つのカテゴリに分類されます。
- LMモード(67):前の行と左の列を使用します
- LM-Lモード(68):左側の列のみを使用
- LM-Aモード(69):前の行のみを使用
基本的なプロセスは次のとおりです。
1.明るさの再構築とダウンサンプリングのための参照ピクセルを取得します
このステップでは、輝度再構成ピクセルブロックと、輝度再構成ピクセルブロックの上部の行と左の列(使用可能な場合)をダウンサンプリングして(ダウンサンプリングタイプはYUVビデオタイプに関連します)、ダウンサンプリング後に輝度再構成ピクセルブロックを取得します。xGetLumaRecPixelsは実現機能します。基本的なプロセスは次のとおりです。
- 現在のクロミナンスに対応するルミナンスブロックの再構成されたルミナンスピクセルを取得します
- 再構成された輝度ピクセルブロックの上の行と左の列で再構成されたピクセルを導出します
- 輝度再構成ピクセルブロックをダウンサンプリングするダウンサンプリング方法は、YUVタイプに関連しています
コードは次のように表示されます。
// LumaRecPixels
// 将亮度2Nx2N的块,用1:2:1下采样变成亮度NxN的亮度块,为了能和其对应的NxN的色度块一一对应。
void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chromaArea)
{
int iDstStride = 0; // 下采样后的一行
Pel* pDst0 = 0;// 下采样后的缓存
int curChromaMode = pu.intraDir[1];
if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX))//LM-A模式和LM-T模式
{
iDstStride = 2 * MAX_CU_SIZE + 1;
pDst0 = m_pMdlmTemp + iDstStride + 1;
}
else
{
iDstStride = MAX_CU_SIZE + 1;
pDst0 = m_piTemp + iDstStride + 1; //MMLM_SAMPLE_NEIGHBOR_LINES;
}
//assert 420 chroma subsampling
//正确的pos/size(4x4 Tus)需要
CompArea lumaArea = CompArea( COMPONENT_Y, pu.chromaFormat, chromaArea.lumaPos(), recalcSize( pu.chromaFormat, CHANNEL_TYPE_CHROMA, CHANNEL_TYPE_LUMA, chromaArea.size() ) );//needed for correct pos/size (4x4 Tus)
CHECK(lumaArea.width == chromaArea.width && CHROMA_444 != pu.chromaFormat, "");
CHECK(lumaArea.height == chromaArea.height && CHROMA_444 != pu.chromaFormat && CHROMA_422 != pu.chromaFormat, "");
const SizeType uiCWidth = chromaArea.width;
const SizeType uiCHeight = chromaArea.height;
const CPelBuf Src = pu.cs->picture->getRecoBuf( lumaArea );//获得亮度重建像素
Pel const* pRecSrc0 = Src.bufAt( 0, 0 );//下采样前的缓存
int iRecStride = Src.stride;
int logSubWidthC = getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, pu.chromaFormat);
int logSubHeightC = getChannelTypeScaleY(CHANNEL_TYPE_CHROMA, pu.chromaFormat);
int iRecStride2 = iRecStride << logSubHeightC;
const CodingUnit& lumaCU = isChroma( pu.chType ) ? *pu.cs->picture->cs->getCU( lumaArea.pos(), CH_L ) : *pu.cu;//亮度CU
const CodingUnit& cu = *pu.cu;//CU
const CompArea& area = isChroma( pu.chType ) ? chromaArea : lumaArea;
const uint32_t uiTuWidth = area.width;//TU宽
const uint32_t uiTuHeight = area.height;//TU高
int iBaseUnitSize = ( 1 << MIN_CU_LOG2 );//4
//基本单元的宽度和高度
const int iUnitWidth = iBaseUnitSize >> getComponentScaleX( area.compID, area.chromaFormat );
const int iUnitHeight = iBaseUnitSize >> getComponentScaleY(area.compID, area.chromaFormat);
const int iTUWidthInUnits = uiTuWidth / iUnitWidth;
const int iTUHeightInUnits = uiTuHeight / iUnitHeight;
const int iAboveUnits = iTUWidthInUnits;//上边用几个基本单元
const int iLeftUnits = iTUHeightInUnits;//左边用几个基本单元
const int chromaUnitWidth = iBaseUnitSize >> getComponentScaleX(COMPONENT_Cb, area.chromaFormat);
const int chromaUnitHeight = iBaseUnitSize >> getComponentScaleY(COMPONENT_Cb, area.chromaFormat);
/* 下面是对MDLM的定义 */
const int topTemplateSampNum = 2 * uiCWidth; // for MDLM, the number of template samples is 2W or 2H.
const int leftTemplateSampNum = 2 * uiCHeight;
assert(m_topRefLength >= topTemplateSampNum);
assert(m_leftRefLength >= leftTemplateSampNum);
const int totalAboveUnits = (topTemplateSampNum + (chromaUnitWidth - 1)) / chromaUnitWidth;//上面用几个
const int totalLeftUnits = (leftTemplateSampNum + (chromaUnitHeight - 1)) / chromaUnitHeight;//左侧用几个
const int totalUnits = totalLeftUnits + totalAboveUnits + 1;
const int aboveRightUnits = totalAboveUnits - iAboveUnits;//右上用几个基本单元
const int leftBelowUnits = totalLeftUnits - iLeftUnits;//左下用几个基本单元
int avaiAboveRightUnits = 0;//右上可用单元数
int avaiLeftBelowUnits = 0;//左下可用单元数
bool bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1];
memset(bNeighborFlags, 0, totalUnits);
bool aboveIsAvailable, leftIsAvailable;
//确定左侧单元是否可用
int availlableUnit = isLeftAvailable( isChroma( pu.chType ) ? cu : lumaCU, toChannelType( area.compID ), area.pos(), iLeftUnits, iUnitHeight,
( bNeighborFlags + iLeftUnits + leftBelowUnits - 1 ) );
leftIsAvailable = availlableUnit == iTUHeightInUnits;
//确定上侧单元是否可用
availlableUnit = isAboveAvailable( isChroma( pu.chType ) ? cu : lumaCU, toChannelType( area.compID ), area.pos(), iAboveUnits, iUnitWidth,
( bNeighborFlags + iLeftUnits + leftBelowUnits + 1 ) );
aboveIsAvailable = availlableUnit == iTUWidthInUnits;
if (leftIsAvailable) // if left is not available, then the below left is not available
{
//如果左边不可用,则左下不可用
avaiLeftBelowUnits = isBelowLeftAvailable(isChroma(pu.chType) ? cu : lumaCU, toChannelType(area.compID), area.bottomLeftComp(area.compID), leftBelowUnits, iUnitHeight, (bNeighborFlags + leftBelowUnits - 1));
}
if (aboveIsAvailable) // if above is not available, then the above right is not available.
{//如果上边不可用,则右上不可用
avaiAboveRightUnits = isAboveRightAvailable(isChroma(pu.chType) ? cu : lumaCU, toChannelType(area.compID), area.topRightComp(area.compID), aboveRightUnits, iUnitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + iAboveUnits + 1));
}
Pel* pDst = nullptr;
Pel const* piSrc = nullptr;
bool isFirstRowOfCtu = (lumaArea.y & ((pu.cs->sps)->getCTUSize() - 1)) == 0;
if (aboveIsAvailable)//如果上方可用
{
pDst = pDst0 - iDstStride;
int addedAboveRight = 0;
//当前模式是LM-L或者LM-T模式
if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX))
{
addedAboveRight = avaiAboveRightUnits*chromaUnitWidth;//加入右上方
}
for (int i = 0; i < uiCWidth + addedAboveRight; i++)
{
const bool leftPadding = i == 0 && !leftIsAvailable;
if (pu.chromaFormat == CHROMA_444) //如果是YUV444
{
piSrc = pRecSrc0 - iRecStride;
pDst[i] = piSrc[i];
}
else if (isFirstRowOfCtu)//如果是CTU的第一行
{
piSrc = pRecSrc0 - iRecStride;
pDst[i] = (piSrc[2 * i] * 2 + piSrc[2 * i - (leftPadding ? 0 : 1)] + piSrc[2 * i + 1] + 2) >> 2;
}
else if (pu.chromaFormat == CHROMA_422)//如果是YUV422
{
piSrc = pRecSrc0 - iRecStride2;
int s = 2;
s += piSrc[2 * i] * 2;
s += piSrc[2 * i - (leftPadding ? 0 : 1)];
s += piSrc[2 * i + 1];
pDst[i] = s >> 2;
}
else if (pu.cs->sps->getCclmCollocatedChromaFlag())
{
piSrc = pRecSrc0 - iRecStride2;
int s = 4;
s += piSrc[2 * i - iRecStride];
s += piSrc[2 * i] * 4;
s += piSrc[2 * i - (leftPadding ? 0 : 1)];
s += piSrc[2 * i + 1];
s += piSrc[2 * i + iRecStride];
pDst[i] = s >> 3;
}
else
{
piSrc = pRecSrc0 - iRecStride2;
int s = 4;
s += piSrc[2 * i] * 2;
s += piSrc[2 * i + 1];
s += piSrc[2 * i - (leftPadding ? 0 : 1)];
s += piSrc[2 * i + iRecStride] * 2;
s += piSrc[2 * i + 1 + iRecStride];
s += piSrc[2 * i + iRecStride - (leftPadding ? 0 : 1)];
pDst[i] = s >> 3;
}
}
}
if (leftIsAvailable)
{
pDst = pDst0 - 1;
piSrc = pRecSrc0 - 1 - logSubWidthC;
int addedLeftBelow = 0;
if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX))
{
addedLeftBelow = avaiLeftBelowUnits*chromaUnitHeight;
}
for (int j = 0; j < uiCHeight + addedLeftBelow; j++)
{
if (pu.chromaFormat == CHROMA_444)
{
pDst[0] = piSrc[0];
}
else if (pu.chromaFormat == CHROMA_422)
{
int s = 2;
s += piSrc[0] * 2;
s += piSrc[-1];
s += piSrc[1];
pDst[0] = s >> 2;
}
else if (pu.cs->sps->getCclmCollocatedChromaFlag())
{
const bool abovePadding = j == 0 && !aboveIsAvailable;
int s = 4;
s += piSrc[-(abovePadding ? 0 : iRecStride)];
s += piSrc[0] * 4;
s += piSrc[-1];
s += piSrc[1];
s += piSrc[iRecStride];
pDst[0] = s >> 3;
}
else
{
int s = 4;
s += piSrc[0] * 2;
s += piSrc[1];
s += piSrc[-1];
s += piSrc[iRecStride] * 2;
s += piSrc[iRecStride + 1];
s += piSrc[iRecStride - 1];
pDst[0] = s >> 3;
}
piSrc += iRecStride2;
pDst += iDstStride;
}
}
// inner part from reconstructed picture buffer
/*********************************************** 1:2:1下采样除了边缘的内部部分 *****************************************/
for( int j = 0; j < uiCHeight; j++ )
{
for( int i = 0; i < uiCWidth; i++ )
{
if (pu.chromaFormat == CHROMA_444)
{
pDst0[i] = pRecSrc0[i];
}
else if (pu.chromaFormat == CHROMA_422)
{
const bool leftPadding = i == 0 && !leftIsAvailable;
int s = 2;
s += pRecSrc0[2 * i] * 2;
s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)];
s += pRecSrc0[2 * i + 1];
pDst0[i] = s >> 2;
}
else if (pu.cs->sps->getCclmCollocatedChromaFlag())
{
const bool leftPadding = i == 0 && !leftIsAvailable;
const bool abovePadding = j == 0 && !aboveIsAvailable;
int s = 4;
s += pRecSrc0[2 * i - (abovePadding ? 0 : iRecStride)];
s += pRecSrc0[2 * i] * 4;
s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)];
s += pRecSrc0[2 * i + 1];
s += pRecSrc0[2 * i + iRecStride];
pDst0[i] = s >> 3;
}
else
{
CHECK(pu.chromaFormat != CHROMA_420, "Chroma format must be 4:2:0 for vertical filtering");
const bool leftPadding = i == 0 && !leftIsAvailable;
int s = 4;
s += pRecSrc0[2 * i] * 2;
s += pRecSrc0[2 * i + 1];
s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)];
s += pRecSrc0[2 * i + iRecStride] * 2;
s += pRecSrc0[2 * i + 1 + iRecStride];
s += pRecSrc0[2 * i + iRecStride - (leftPadding ? 0 : 1)];
pDst0[i] = s >> 3;
}
}
pDst0 += iDstStride;
pRecSrc0 += iRecStride2;
}
}
2.線形モデルを構築します
このステップは、ダウンサンプリングされた明るさに応じて、左の列および/または前の行のピクセルの特定の位置にある4つのピクセルを再構築し、4つの比較の後に2つの小さい値と2つの大きい値を取得することです。対応する位置のクロミナンスピクセルに従って関連するパラメータαとβを計算し、関数xGetLMParametersによって実装される線形モデルを構築します。
基本的なプロセスは次のとおりです。
- CCLMモードに従って取得された4つのピクセルの位置を導き出します
- 4つのピクセルのサイズを比較して、2つの大きな点と2つの小さな点を見つけます
- 式に従ってαとβを計算します(CCLMテクノロジー関連のブログを参照)
//主要工作:根据NxN的亮度块的左边和上边像素,取点,找到Y的最大值和最小值点,根据他们的C值求得线性模型参数a和b。
void IntraPrediction::xGetLMParameters(const PredictionUnit &pu, const ComponentID compID,
const CompArea &chromaArea,
int &a, int &b, int &iShift)
{
CHECK(compID == COMPONENT_Y, "");
const SizeType cWidth = chromaArea.width;
const SizeType cHeight = chromaArea.height;
const Position posLT = chromaArea;//左上角
CodingStructure & cs = *(pu.cs);
const CodingUnit &cu = *(pu.cu);
const SPS & sps = *cs.sps;
const uint32_t tuWidth = chromaArea.width;
const uint32_t tuHeight = chromaArea.height;
const ChromaFormat nChromaFormat = sps.getChromaFormatIdc();
const int baseUnitSize = 1 << MIN_CU_LOG2;//基本单元尺寸
const int unitWidth = baseUnitSize >> getComponentScaleX(chromaArea.compID, nChromaFormat);
const int unitHeight = baseUnitSize >> getComponentScaleY(chromaArea.compID, nChromaFormat);
const int tuWidthInUnits = tuWidth / unitWidth;
const int tuHeightInUnits = tuHeight / unitHeight;
const int aboveUnits = tuWidthInUnits;//上边可用单元数
const int leftUnits = tuHeightInUnits;//左侧可用单元数
int topTemplateSampNum = 2 * cWidth; // for MDLM, the template sample number is 2W or 2H;
int leftTemplateSampNum = 2 * cHeight;
assert(m_topRefLength >= topTemplateSampNum);
assert(m_leftRefLength >= leftTemplateSampNum);
int totalAboveUnits = (topTemplateSampNum + (unitWidth - 1)) / unitWidth;
int totalLeftUnits = (leftTemplateSampNum + (unitHeight - 1)) / unitHeight;
int totalUnits = totalLeftUnits + totalAboveUnits + 1;
int aboveRightUnits = totalAboveUnits - aboveUnits;//右上单元数
int leftBelowUnits = totalLeftUnits - leftUnits;//左下单元数
int avaiAboveRightUnits = 0;
int avaiLeftBelowUnits = 0;
int avaiAboveUnits = 0;
int avaiLeftUnits = 0;
int curChromaMode = pu.intraDir[1];//当前色度预测模式
bool neighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1];
memset(neighborFlags, 0, totalUnits);
bool aboveAvailable, leftAvailable;
//判断上方参考像素是否可用
int availableUnit =
isAboveAvailable(cu, CHANNEL_TYPE_CHROMA, posLT, aboveUnits, unitWidth,
(neighborFlags + leftUnits + leftBelowUnits + 1));
aboveAvailable = availableUnit == tuWidthInUnits;
//判断左侧参考像素是否可用
availableUnit =
isLeftAvailable(cu, CHANNEL_TYPE_CHROMA, posLT, leftUnits, unitHeight,
(neighborFlags + leftUnits + leftBelowUnits - 1));
leftAvailable = availableUnit == tuHeightInUnits;
if (leftAvailable) // if left is not available, then the below left is not available
{
//左不可用,左下一定不可用
avaiLeftUnits = tuHeightInUnits;
avaiLeftBelowUnits = isBelowLeftAvailable(cu, CHANNEL_TYPE_CHROMA, chromaArea.bottomLeftComp(chromaArea.compID), leftBelowUnits, unitHeight, (neighborFlags + leftBelowUnits - 1));
}
if (aboveAvailable) // if above is not available, then the above right is not available.
{
//上不可用,右上一定不可用
avaiAboveUnits = tuWidthInUnits;
avaiAboveRightUnits = isAboveRightAvailable(cu, CHANNEL_TYPE_CHROMA, chromaArea.topRightComp(chromaArea.compID), aboveRightUnits, unitWidth, (neighborFlags + leftUnits + leftBelowUnits + aboveUnits + 1));
}
Pel *srcColor0, *curChroma0;
int srcStride;
PelBuf temp;
if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX))
{ //LM_T和LM_L模式
srcStride = 2 * MAX_CU_SIZE + 1;
temp = PelBuf(m_pMdlmTemp + srcStride + 1, srcStride, Size(chromaArea));
}
else
{
srcStride = MAX_CU_SIZE + 1;
temp = PelBuf(m_piTemp + srcStride + 1, srcStride, Size(chromaArea));
}
srcColor0 = temp.bufAt(0, 0);
curChroma0 = getPredictorPtr(compID);//获得色度块参考像素
unsigned internalBitDepth = sps.getBitDepth(CHANNEL_TYPE_CHROMA);
/********** Y是横坐标,C是纵坐标。这里找到最左和最右两个点,即亮度值最小和最大的两个点,拿这个做线性模型 ********/
int minLuma[2] = { MAX_INT, 0 };//下标0表示minY,下标1表示minC
int maxLuma[2] = { -MAX_INT, 0 };//下标0表示maxY,下标1表示maxC
Pel *src = srcColor0 - srcStride;//这里对应亮度下采样后得到的buffer(NxN),减去是因为应指向往前的一行
int actualTopTemplateSampNum = 0;
int actualLeftTemplateSampNum = 0;
if (curChromaMode == MDLM_T_IDX)//MDLM_T的情况:只用上*2
{
leftAvailable = 0;
avaiAboveRightUnits = avaiAboveRightUnits > (cHeight/unitWidth) ? cHeight/unitWidth : avaiAboveRightUnits;
actualTopTemplateSampNum = unitWidth*(avaiAboveUnits + avaiAboveRightUnits);
}
else if (curChromaMode == MDLM_L_IDX)//MDLM_L的情况:只用左*2
{
aboveAvailable = 0;
avaiLeftBelowUnits = avaiLeftBelowUnits > (cWidth/unitHeight) ? cWidth/unitHeight : avaiLeftBelowUnits;
actualLeftTemplateSampNum = unitHeight*(avaiLeftUnits + avaiLeftBelowUnits);
}
else if (curChromaMode == LM_CHROMA_IDX)//CCLM的情况:用左和上
{
actualTopTemplateSampNum = cWidth;
actualLeftTemplateSampNum = cHeight;
}
/****************************** 取点,根据一一对应的亮度和色度找到最大最小 *************************************/
int startPos[2]; //0:Above, 1: Left
int pickStep[2];
int aboveIs4 = leftAvailable ? 0 : 1;
int leftIs4 = aboveAvailable ? 0 : 1;
//上方的起始位置和步长
startPos[0] = actualTopTemplateSampNum >> (2 + aboveIs4);
pickStep[0] = std::max(1, actualTopTemplateSampNum >> (1 + aboveIs4));
//左侧的起始位置和步长
startPos[1] = actualLeftTemplateSampNum >> (2 + leftIs4);
pickStep[1] = std::max(1, actualLeftTemplateSampNum >> (1 + leftIs4));
Pel selectLumaPix[4] = { 0, 0, 0, 0 };//所选的亮度像素
Pel selectChromaPix[4] = { 0, 0, 0, 0 };//所选的色度像素
int cntT, cntL;
cntT = cntL = 0;
int cnt = 0;
//根据起始位置和步长选择上方的亮度和色度像素
if (aboveAvailable)
{
cntT = std::min(actualTopTemplateSampNum, (1 + aboveIs4) << 1);
src = srcColor0 - srcStride;
const Pel *cur = curChroma0 + 1;
for (int pos = startPos[0]; cnt < cntT; pos += pickStep[0], cnt++)
{
selectLumaPix[cnt] = src[pos];
selectChromaPix[cnt] = cur[pos];
}
}
//根据起始位置和步长选择左侧的亮度和色度像素
if (leftAvailable)
{
cntL = std::min(actualLeftTemplateSampNum, ( 1 + leftIs4 ) << 1 );
src = srcColor0 - 1;
const Pel *cur = curChroma0 + m_refBufferStride[compID] + 1;
for (int pos = startPos[1], cnt = 0; cnt < cntL; pos += pickStep[1], cnt++)
{
selectLumaPix[cnt + cntT] = src[pos * srcStride];
selectChromaPix[cnt + cntT] = cur[pos];
}
}
// 推导maxY,minY,maxC,minC
cnt = cntL + cntT;
if (cnt == 2)
{
selectLumaPix[3] = selectLumaPix[0]; selectChromaPix[3] = selectChromaPix[0];
selectLumaPix[2] = selectLumaPix[1]; selectChromaPix[2] = selectChromaPix[1];
selectLumaPix[0] = selectLumaPix[1]; selectChromaPix[0] = selectChromaPix[1];
selectLumaPix[1] = selectLumaPix[3]; selectChromaPix[1] = selectChromaPix[3];
}
int minGrpIdx[2] = { 0, 2 };
int maxGrpIdx[2] = { 1, 3 };
int *tmpMinGrp = minGrpIdx;
int *tmpMaxGrp = maxGrpIdx;
if (selectLumaPix[tmpMinGrp[0]] > selectLumaPix[tmpMinGrp[1]]) std::swap(tmpMinGrp[0], tmpMinGrp[1]);
if (selectLumaPix[tmpMaxGrp[0]] > selectLumaPix[tmpMaxGrp[1]]) std::swap(tmpMaxGrp[0], tmpMaxGrp[1]);
if (selectLumaPix[tmpMinGrp[0]] > selectLumaPix[tmpMaxGrp[1]]) std::swap(tmpMinGrp, tmpMaxGrp);
if (selectLumaPix[tmpMinGrp[1]] > selectLumaPix[tmpMaxGrp[0]]) std::swap(tmpMinGrp[1], tmpMaxGrp[0]);
minLuma[0] = (selectLumaPix[tmpMinGrp[0]] + selectLumaPix[tmpMinGrp[1]] + 1 )>>1;//minY
minLuma[1] = (selectChromaPix[tmpMinGrp[0]] + selectChromaPix[tmpMinGrp[1]] + 1) >> 1;//minC
maxLuma[0] = (selectLumaPix[tmpMaxGrp[0]] + selectLumaPix[tmpMaxGrp[1]] + 1 )>>1;//maxY
maxLuma[1] = (selectChromaPix[tmpMaxGrp[0]] + selectChromaPix[tmpMaxGrp[1]] + 1) >> 1;//maxC
if (leftAvailable || aboveAvailable) //如果左侧或者上侧像素可用时
{
int diff = maxLuma[0] - minLuma[0];//maxY - minY
if (diff > 0)
{
int diffC = maxLuma[1] - minLuma[1];//maxC - minC
int x = floorLog2( diff );
static const uint8_t DivSigTable[1 << 4] = {
// 4bit significands - 8 ( MSB is omitted )
0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0
};
int normDiff = (diff << 4 >> x) & 15;
int v = DivSigTable[normDiff] | 8;
x += normDiff != 0;
int y = floorLog2( abs( diffC ) ) + 1;
int add = 1 << y >> 1;
a = (diffC * v + add) >> y;
iShift = 3 + x - y;
if ( iShift < 1 )
{
iShift = 1;
a = ( (a == 0)? 0: (a < 0)? -15 : 15 ); // a=Sign(a)*15
}
b = minLuma[1] - ((a * minLuma[0]) >> iShift);
}
else
{
a = 0;
b = minLuma[1];
iShift = 0;
}
}
else //如果左侧和上侧像素都不可用时,则预测像素为1 << ( BitDepth − 1 )
{
a = 0;
b = 1 << (internalBitDepth - 1);
iShift = 0;
}
}
3.最終予測
linearTransform関数を使用して最終的な予測結果を計算します。このプロセスは線形計算のプロセスです。次のように計算されます。
pred [x] [y] = Clip1(((pDsY [x] [y] * a)>> k)+ b)