📄 umc_h264_segment_decoder_deblocking_prepare.cpp
字号:
nNeighbourBlock = nBlock + 3;
}
else
{
nBlock = idx;
nNeighbourBlock = idx + 12;
}
// field coded image
if (FRM_STRUCTURE > m_pCurrentFrame->m_PictureStructureForDec)
{
H264DecoderFrame **pRefPicList;
Ipp32s index;
ReferenceFlags *pFields;
// select reference index for current block
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_Flags;
iRefQFrw = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
}
else
iRefQFrw = -1;
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_Flags;
iRefQBck = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
}
else
iRefQBck = -1;
// select reference index for previous block
index = m_gmbinfo->RefIdxs[0][nNeighbour].RefIdxs[nNeighbourBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_Flags;
iRefPFrw = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
}
else
iRefPFrw = -1;
index = m_gmbinfo->RefIdxs[1][nNeighbour].RefIdxs[nNeighbourBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 1)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 1)->m_Flags;
iRefPBck = pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
}
else
iRefPBck = -1;
}
// frame coded image
else
{
H264DecoderFrame **pRefPicList;
Ipp32s index;
// select reference index for current block
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
iRefQFrw = pRefPicList[index]->DeblockPicID(0);
}
else
iRefQFrw = -1;
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_RefPicList;
iRefQBck = pRefPicList[index]->DeblockPicID(0);
}
else
iRefQBck = -1;
// select reference index for previous block
index = m_gmbinfo->RefIdxs[0][nNeighbour].RefIdxs[nNeighbourBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 0)->m_RefPicList;
iRefPFrw = pRefPicList[index]->DeblockPicID(0);
}
else
iRefPFrw = -1;
index = m_gmbinfo->RefIdxs[1][nNeighbour].RefIdxs[nNeighbourBlock];
if (0 <= index)
{
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + nNeighbour)->slice_id, 1)->m_RefPicList;
iRefPBck = pRefPicList[index]->DeblockPicID(0);
}
else
iRefPBck = -1;
}
// when reference indexes are equal
if (((iRefQFrw == iRefPFrw) && (iRefQBck == iRefPBck)) ||
((iRefQFrw == iRefPBck) && (iRefQBck == iRefPFrw)))
{
// set initial value of strength
pStrength[idx] = 0;
// when forward and backward reference pictures of previous block are different
if (iRefPFrw != iRefPBck)
{
H264DecoderMotionVector *pVectorQFrw, *pVectorQBck;
H264DecoderMotionVector *pVectorPFrw, *pVectorPBck;
// select current block motion vectors
pVectorQFrw = m_gmbinfo->MV[0][MBAddr].MotionVectors + nBlock;
pVectorQBck = m_gmbinfo->MV[1][MBAddr].MotionVectors + nBlock;
// select previous block motion vectors
if (iRefQFrw == iRefPFrw)
{
pVectorPFrw = m_gmbinfo->MV[0][nNeighbour].MotionVectors + nNeighbourBlock;
pVectorPBck = m_gmbinfo->MV[1][nNeighbour].MotionVectors + nNeighbourBlock;
}
else
{
pVectorPFrw = m_gmbinfo->MV[1][nNeighbour].MotionVectors + nNeighbourBlock;
pVectorPBck = m_gmbinfo->MV[0][nNeighbour].MotionVectors + nNeighbourBlock;
}
// compare motion vectors
if ((4 <= abs(pVectorQFrw->mvx - pVectorPFrw->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQFrw->mvy - pVectorPFrw->mvy)) ||
(4 <= abs(pVectorQBck->mvx - pVectorPBck->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQBck->mvy - pVectorPBck->mvy)))
{
pStrength[idx] = 1;
*pDeblockingFlag = 1;
}
}
// when forward and backward reference pictures of previous block are equal
else
{
H264DecoderMotionVector *pVectorQFrw, *pVectorQBck;
H264DecoderMotionVector *pVectorPFrw, *pVectorPBck;
// select current block motion vectors
pVectorQFrw = m_gmbinfo->MV[0][MBAddr].MotionVectors + nBlock;
pVectorQBck = m_gmbinfo->MV[1][MBAddr].MotionVectors + nBlock;
// select previous block motion vectors
pVectorPFrw = m_gmbinfo->MV[0][nNeighbour].MotionVectors + nNeighbourBlock;
pVectorPBck = m_gmbinfo->MV[1][nNeighbour].MotionVectors + nNeighbourBlock;
// compare motion vectors
if ((4 <= abs(pVectorQFrw->mvx - pVectorPFrw->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQFrw->mvy - pVectorPFrw->mvy)) ||
(4 <= abs(pVectorQBck->mvx - pVectorPBck->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQBck->mvy - pVectorPBck->mvy)))
{
if ((4 <= abs(pVectorQFrw->mvx - pVectorPBck->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQFrw->mvy - pVectorPBck->mvy)) ||
(4 <= abs(pVectorQBck->mvx - pVectorPFrw->mvx)) ||
(nVectorDiffLimit <= abs(pVectorQBck->mvy - pVectorPFrw->mvy)))
{
pStrength[idx] = 1;
*pDeblockingFlag = 1;
}
}
}
}
// when reference indexes are different
else
{
pStrength[idx] = 1;
*pDeblockingFlag = 1;
}
}
}
}
// external edge required in strong filtering
else
{
if ((HORIZONTAL_DEBLOCKING == dir) &&
(pParams->MBFieldCoded))
SetEdgeStrength(pStrength + 0, 3);
else
SetEdgeStrength(pStrength + 0, 4);
*pDeblockingFlag = 1;
}
}
//
// internal edge(s)
//
{
Ipp32s idx;
// cicle of edge(s)
// we do all edges in one cicle
for (idx = 4;idx < 16;idx += 1)
{
Ipp32s blkQ;
blkQ = INTERNAL_BLOCKS_MASK[dir][idx - 4];
if (cbp4x4_luma & blkQ)
{
pStrength[idx] = 2;
*pDeblockingFlag = 1;
}
// compare motion vectors & reference indexes
else
{
Ipp32s nBlock, nNeighbourBlock;
Ipp32s iRefQFrw, iRefQBck, iRefPFrw, iRefPBck;
Ipp32s nVectorDiffLimit = pParams->nMaxMVector;
// calc block and neighbour block number
if (VERTICAL_DEBLOCKING == dir)
{
nBlock = (idx & 3) * 4 + (idx >> 2);
nNeighbourBlock = nBlock - 1;
}
else
{
nBlock = idx;
nNeighbourBlock = idx - 4;
}
// field coded image
if (FRM_STRUCTURE > m_pCurrentFrame->m_PictureStructureForDec)
{
H264DecoderFrame **pRefPicList;
Ipp32s index;
ReferenceFlags *pFields;
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_Flags;
// select forward reference index for blocks
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
iRefQFrw = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nNeighbourBlock];
iRefPFrw = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_RefPicList;
// select reference fields number array
pFields = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_Flags;
// select backward reference index for blocks
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nBlock];
iRefQBck = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nNeighbourBlock];
iRefPBck = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(pRefPicList[index]->GetNumberByParity(GetReferenceField(pFields, index)));
}
// frame coded image
else
{
H264DecoderFrame **pRefPicList;
Ipp32s index;
// select forward reference pictures list
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 0)->m_RefPicList;
// select forward reference index for block(s)
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nBlock];
iRefQFrw = (index < 0) ?
(-1) :
(pRefPicList[index]->DeblockPicID(0));
index = m_gmbinfo->RefIdxs[0][MBAddr].RefIdxs[nNeighbourBlock];
iRefPFrw = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(0);
// select backward reference pictures list
pRefPicList = m_pCurrentFrame->GetRefPicList((m_gmbinfo->mbs + MBAddr)->slice_id, 1)->m_RefPicList;
// select backward reference index for block(s)
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nBlock];
iRefQBck = (index < 0) ?
(-1) :
(pRefPicList[index]->DeblockPicID(0));
index = m_gmbinfo->RefIdxs[1][MBAddr].RefIdxs[nNeighbourBlock];
iRefPBck = (index < 0) ?
(-1) :
pRefPicList[index]->DeblockPicID(0);
}
// when reference indexes are equal
if (((iRefQFrw == iRefPFrw) && (iRefQBck == iRefPBck)) ||
((iRefQFrw == iRefPBck) && (iRefQBck == iRefPFrw)))
{
// set initial value of strength
pStrength[idx] = 0;
// when forward and backward reference pictures of previous block are different
if (iRefPFrw != iRefPBck)
{
H264DecoderMotionVector *pVectorQFrw, *pVectorQBck;
H264DecoderMotionVector *pVectorPFrw, *pVectorPBck;
// select current block motion vectors
pVectorQFrw = m_gmbinfo->MV[0][MBAddr].MotionVectors + nBlock;
pVectorQBck = m_gmbinfo->MV[1][MBAddr].MotionVectors + nBlock;
// select previous block motion vectors
if (iRefQFrw == iRefPFrw)
{
pVectorPFrw = m_gmbinfo->MV[0][MBAddr].MotionVectors + nNeighbourBlock;
pVectorPBck = m_gmbinfo->MV[1][MBAddr].MotionVectors + nNeighbourBlock;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -