📄 umc_h264_deblocking_mbaff.cpp
字号:
} // void H264CoreEncoder::DeblockLumaHorizontalMBAFF(DeblockingParametersMBAFF<PixType>*pParams)
template <class PixType, class CoeffsType>
void H264CoreEncoder<PixType,CoeffsType>::DeblockChromaHorizontalMBAFF(DeblockingParametersMBAFF<PixType> *pParams)
{
Ipp8u bTmp[16];
Ipp32s pitchPixels = pParams->pitchPixels;
//
// chroma deblocking
//
//
// step 1. Deblock origin external edge
//
{
// save internal edges strength
CopyEdgeStrength(bTmp + 0, pParams->Strength[HORIZONTAL_DEBLOCKING] + 0);
CopyEdgeStrength(bTmp + 4, pParams->Strength[HORIZONTAL_DEBLOCKING] + 4);
CopyEdgeStrength(bTmp + 8, pParams->Strength[HORIZONTAL_DEBLOCKING] + 8);
CopyEdgeStrength(bTmp + 12, pParams->Strength[HORIZONTAL_DEBLOCKING] + 12);
// skip all internal edges
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 4, 0);
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 8, 0);
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 12, 0);
// set pitch
pParams->pitchPixels *= 2;
// perform deblocking
DeblockChroma(HORIZONTAL_DEBLOCKING, pParams);
}
//
// step 2. Deblock extra external edge
//
{
// set extra edge strength
CopyEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING], pParams->StrengthExtra);
// correct neighbour MB info
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] += ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
// correct U & V pointer
pParams->pU += pitchPixels;
pParams->pV += pitchPixels;
// perform deblocking
DeblockChroma(HORIZONTAL_DEBLOCKING, pParams);
// restore values
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] -= ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
pParams->pU -= pitchPixels;
pParams->pV -= pitchPixels;
pParams->pitchPixels = pitchPixels;
}
//
// step 3. Deblock internal edges
//
{
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
// set internal edge strength
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 0, 0);
CopyEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 4, bTmp + 4);
CopyEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 8, bTmp + 8);
CopyEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 12, bTmp + 12);
// perform deblocking
DeblockChroma(HORIZONTAL_DEBLOCKING, pParams);
// restore strength
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 1;
CopyEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 0, bTmp + 0);
}
} // void H264CoreEncoder::DeblockChromaHorizontalMBAFF(DeblockingParametersMBAFF<PixType>*pParams)
template <class PixType, class CoeffsType>
void H264CoreEncoder<PixType,CoeffsType>::PrepareDeblockingParametersISliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams)
{
// set deblocking flag(s)
pParams->DeblockingFlag[VERTICAL_DEBLOCKING] = 1;
pParams->DeblockingFlag[HORIZONTAL_DEBLOCKING] = 1;
// fill "complex deblocking" strength
if (pParams->UseComplexVerticalDeblocking)
{
SetEdgeStrength(pParams->StrengthComplex + 0, 4);
SetEdgeStrength(pParams->StrengthComplex + 4, 4);
}
// calculate strengths
if (pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING])
{
// deblocking with strong deblocking of external edge
SetEdgeStrength(pParams->Strength[VERTICAL_DEBLOCKING] + 0, 4);
}
SetEdgeStrength(pParams->Strength[VERTICAL_DEBLOCKING] + 4, 3);
SetEdgeStrength(pParams->Strength[VERTICAL_DEBLOCKING] + 8, 3);
SetEdgeStrength(pParams->Strength[VERTICAL_DEBLOCKING] + 12, 3);
if (pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING])
{
if ((pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + pParams->nMBAddr)) ||
(pParams->ExtraHorizontalEdge))
{
// deblocking field macroblock with external edge
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 0, 3);
}
else
{
// deblocking with strong deblocking of external edge
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 0, 4);
}
}
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 4, 3);
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 8, 3);
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING] + 12, 3);
if (pParams->ExtraHorizontalEdge)
{
// set extra edge strength
SetEdgeStrength(pParams->StrengthExtra + 0, 3);
SetEdgeStrength(pParams->StrengthExtra + 4, 0);
SetEdgeStrength(pParams->StrengthExtra + 8, 0);
SetEdgeStrength(pParams->StrengthExtra + 12, 0);
}
} // void H264CoreEncoder::PrepareDeblockingParametersISliceMBAFF(DeblockingParametersMBAFF<PixType>*pParams)
template <class PixType, class CoeffsType>
void H264CoreEncoder<PixType,CoeffsType>::PrepareDeblockingParametersPSliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams)
{
Ipp32u mbtype = (m_pCurrentFrame->m_mbinfo.mbs + pParams->nMBAddr)->mbtype;
Ipp32u nAboveMBFieldCoded;
// when this macroblock is intra coded
if (IS_INTRA_MBTYPE(mbtype))
{
PrepareDeblockingParametersISliceMBAFF(pParams);
return;
}
nAboveMBFieldCoded = pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + pParams->nNeighbour[HORIZONTAL_DEBLOCKING]);
// when there are no special cases
if ((0 == nAboveMBFieldCoded) &&
(0 == pParams->MBFieldCoded) &&
(0 == pParams->UseComplexVerticalDeblocking))
{
// prepare whole macroblock parameters
PrepareDeblockingParametersPSlice(pParams);
return;
}
// when current macroblock is frame coded
if (0 == pParams->MBFieldCoded)
{
// prepare "complex vertical deblocking" parameters
if (pParams->UseComplexVerticalDeblocking)
PrepareDeblockingParametersPSlice4MBAFFComplexFrameExternalEdge(pParams);
// fill vertical edges parameters
PrepareDeblockingParametersPSlice4(VERTICAL_DEBLOCKING, pParams);
// fill extra edge parameters
if (pParams->ExtraHorizontalEdge)
{
// set correct above neighbour
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] += ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
// obtain parameters
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
// restore above neighbour
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] -= ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
// copy parameters to right place
CopyEdgeStrength(pParams->StrengthExtra, pParams->Strength[HORIZONTAL_DEBLOCKING]);
// fill horizontal edges parameters
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
PrepareDeblockingParametersPSlice4(HORIZONTAL_DEBLOCKING, pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 1;
}
else
PrepareDeblockingParametersPSlice4(HORIZONTAL_DEBLOCKING, pParams);
}
// when current macroblock is field coded
else
{
// prepare "complex vertical deblocking" parameters
if (pParams->UseComplexVerticalDeblocking)
PrepareDeblockingParametersPSlice4MBAFFComplexFieldExternalEdge(pParams);
// fill vertical edges parameters
PrepareDeblockingParametersPSlice4MBAFFField(VERTICAL_DEBLOCKING, pParams);
// when above macroblock is frame coded
if (nAboveMBFieldCoded != pParams->MBFieldCoded)
{
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
PrepareDeblockingParametersPSlice4MBAFFField(HORIZONTAL_DEBLOCKING, pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 1;
}
else
PrepareDeblockingParametersPSlice4MBAFFField(HORIZONTAL_DEBLOCKING, pParams);
}
} // void H264CoreEncoder::PrepareDeblockingParametersPSliceMBAFF(DeblockingParametersMBAFF<PixType>*pParams)
template <class PixType, class CoeffsType>
void H264CoreEncoder<PixType,CoeffsType>::PrepareDeblockingParametersBSliceMBAFF(DeblockingParametersMBAFF<PixType> *pParams)
{
Ipp32u mbtype = (m_pCurrentFrame->m_mbinfo.mbs + pParams->nMBAddr)->mbtype;
Ipp32u nAboveMBFieldCoded;
// when this macroblock is intra coded
if (IS_INTRA_MBTYPE(mbtype))
{
PrepareDeblockingParametersISliceMBAFF(pParams);
return;
}
nAboveMBFieldCoded = pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + pParams->nNeighbour[HORIZONTAL_DEBLOCKING]);
// when there are no special cases
if ((0 == nAboveMBFieldCoded) &&
(0 == pParams->MBFieldCoded) &&
(0 == pParams->UseComplexVerticalDeblocking))
{
// prepare whole macroblock parameters
PrepareDeblockingParametersBSlice(pParams);
return;
}
// when current macroblock is frame coded
if (0 == pParams->MBFieldCoded)
{
// prepare "complex vertical deblocking" parameters
if (pParams->UseComplexVerticalDeblocking)
PrepareDeblockingParametersPSlice4MBAFFComplexFrameExternalEdge(pParams);
// fill vertical edges parameters
PrepareDeblockingParametersBSlice4(VERTICAL_DEBLOCKING, pParams);
// fill extra edge parameters
if (pParams->ExtraHorizontalEdge)
{
// set correct above neighbour
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] += ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
// obtain parameters
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
// restore above neighbour
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] -= ((pParams->nMBAddr) & 1) ? 2*m_WidthInMBs - 1: 1;
// copy parameters to right place
CopyEdgeStrength(pParams->StrengthExtra, pParams->Strength[HORIZONTAL_DEBLOCKING]);
// fill horizontal edges parameters
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
PrepareDeblockingParametersBSlice4(HORIZONTAL_DEBLOCKING, pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 1;
}
else
PrepareDeblockingParametersBSlice4(HORIZONTAL_DEBLOCKING, pParams);
}
// when current macroblock is field coded
else
{
// prepare "complex vertical deblocking" parameters
if (pParams->UseComplexVerticalDeblocking)
PrepareDeblockingParametersPSlice4MBAFFComplexFieldExternalEdge(pParams);
// fill vertical edges parameters
PrepareDeblockingParametersBSlice4MBAFFField(VERTICAL_DEBLOCKING, pParams);
// when above macroblock is frame coded
if ((nAboveMBFieldCoded != pParams->MBFieldCoded) &&
(pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING]))
{
PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
PrepareDeblockingParametersBSlice4MBAFFField(HORIZONTAL_DEBLOCKING, pParams);
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 1;
}
else
PrepareDeblockingParametersBSlice4MBAFFField(HORIZONTAL_DEBLOCKING, pParams);
}
} // void H264CoreEncoder::PrepareDeblockingParametersBSliceMBAFF(DeblockingParametersMBAFF<PixType>*pParams)
template <class PixType, class CoeffsType>
void H264CoreEncoder<PixType,CoeffsType>::PrepareDeblockingParametersPSlice4MBAFFMixedExternalEdge(DeblockingParameters<PixType> *pParams)
{
Ipp32u MBAddr = pParams->nMBAddr;
Ipp32u cbp_luma = (m_mbinfo.mbs + MBAddr)->cbp_luma;
Ipp8u *pStrength = pParams->Strength[HORIZONTAL_DEBLOCKING];
Ipp32u nNeighbour;
//
// external edge
//
// mixed edge is always deblocked
{
Ipp32u *pDeblockingFlag = &(pParams->DeblockingFlag[HORIZONTAL_DEBLOCKING]);
*pDeblockingFlag = 1;
}
// select neighbour addres
nNeighbour = pParams->nNeighbour[HORIZONTAL_DEBLOCKING];
// when neighbour macroblock isn't intra
if (!IS_INTRA_MBTYPE((m_pCurrentFrame->m_mbinfo.mbs + nNeighbour)->mbtype))
{
H264MacroblockLocalInfo *pNeighbour;
Ipp32u idx;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -