📄 umc_avs_dec_deblocker.cpp
字号:
return ippStsOk;
}
IppStatus AVSDeblocker::FilterDeblockingLuma_HorEdge(Ipp8u* pSrcDst,
Ipp32s srcdstStep,
Ipp8u* pAlpha,
Ipp8u* pBeta,
Ipp8u* pBS,
Ipp32s* pThreshold,
Ipp32s /*bit_depth*/)
{
Ipp8u p2,p1,p0,q0,q1,q2;
Ipp8u* pCurDst = pSrcDst;
for (Ipp32u edgeCount = 0; edgeCount < 2; edgeCount++)
{
for (Ipp32u pixel = 0; pixel < 16; pixel++)
{
if (0 == pBS[(pixel >> 3) + edgeCount*2])
{
// go to next edge
pixel += 7;
pCurDst += 8;// ????
}
else
{
p2 = pCurDst[-3*srcdstStep];
p1 = pCurDst[-2*srcdstStep];
p0 = pCurDst[-1*srcdstStep];
q0 = pCurDst[0];
q1 = pCurDst[srcdstStep];
q2 = pCurDst[2*srcdstStep];
if ( (pAlpha[edgeCount] > abs(q0 - p0))&&
(pBeta[edgeCount] > abs(p1 - p0))&&
(pBeta[edgeCount] > abs(q1 - q0)))
{
Ipp32u ap = abs(p2-p0);
Ipp32u aq = abs(q2-q0);
if (2 == pBS[(pixel >> 3) + edgeCount*2])
{
if (ap < pBeta[edgeCount] &&
abs(p0-q0) < ((pAlpha[edgeCount] >> 2)+2))
{
pCurDst[-1*srcdstStep] = (p1 + 2*p0 + q0 + 2) >> 2;
pCurDst[-2*srcdstStep] = (2*p1 + p0 + q0 + 2) >> 2;
}
else
pCurDst[-1*srcdstStep] = (2*p1 + p0 + q0 + 2 ) >> 2;
if (aq < pBeta[edgeCount] &&
abs(p0-q0) < ((pAlpha[edgeCount] >> 2)+2))
{
pCurDst[0] = (q1 + 2*q0 + p0 + 2) >> 2;
pCurDst[srcdstStep] = (2*q1 + q0 + p0 + 2) >> 2;
}
else
pCurDst[0] = (2*q1 + q0 + p0 + 2 ) >> 2;
}
else if (1 == pBS[(pixel >> 3) + edgeCount*2])
{
Ipp32s delta = ICLIP( -pThreshold[edgeCount], pThreshold[edgeCount], ( (q0 - p0)*3 + (p1 - q1) + 4) >> 3 );
pCurDst[-1*srcdstStep] = ICLIP<Ipp8u> (0, 255, p0 + delta);
pCurDst[0] = ICLIP<Ipp8u> (0, 255, q0 - delta);
p0 = pCurDst[-1*srcdstStep];
q0 = pCurDst[0];
if (ap < pBeta[edgeCount]) // differ from reference
{
delta = ICLIP(-pThreshold[edgeCount], pThreshold[edgeCount], ( (p0 - p1)*3 + (p2 - q0) + 4) >> 3);
pCurDst[-2*srcdstStep] = ICLIP<Ipp8u> (0, 255, p1 + delta);
}
if (aq < pBeta[edgeCount]) // pixel >> 3 ??????
{
delta = ICLIP(-pThreshold[edgeCount], pThreshold[edgeCount], ( (q1 - q0)*3 + (p0 - q2) + 4) >> 3);
pCurDst[srcdstStep] = ICLIP<Ipp8u> (0, 255, q1 - delta);
}
}
}
pCurDst += 1;
}
}
pCurDst = pSrcDst + 8*srcdstStep;
}
return ippStsOk;
}
IppStatus AVSDeblocker::FilterDeblockingChroma_VerEdge(Ipp8u* pSrcDst,
Ipp32s srcdstStep,
Ipp8u* pAlpha,
Ipp8u* pBeta,
Ipp8u* pBS,
Ipp32s* pThreshold,
Ipp32s /*bit_depth*/)
{
Ipp8u p2,p1,p0,q0,q1,q2;
for (Ipp32u pixel = 0; pixel < 8; pixel++)
{
if (0 == pBS[(pixel >> 2) << 1])
{
// go to next edge
pixel += 3;
pSrcDst += 4*srcdstStep;
}
else
{
p2 = pSrcDst[-3];
p1 = pSrcDst[-2];
p0 = pSrcDst[-1];
q0 = pSrcDst[0];
q1 = pSrcDst[1];
q2 = pSrcDst[2];
if ( (pAlpha[0] > abs(q0 - p0))&&
(pBeta[0] > abs(p1 - p0))&&
(pBeta[0] > abs(q1 - q0)))
{
Ipp32u ap = abs(p2-p0);
Ipp32u aq = abs(q2-q0);
if (2 == pBS[(pixel >> 2) << 1])
{
if (ap < pBeta[0] &&
abs(p0-q0) < ((pAlpha[0] >> 2)+2))
{
pSrcDst[-1] = (p1 + 2*p0 + q0 + 2) >> 2;
}
else
pSrcDst[-1] = (2*p1 + p0 + q0 + 2 ) >> 2;
if (aq < pBeta[0] &&
abs(p0-q0) < ((pAlpha[0] >> 2)+2))
{
pSrcDst[0] = (q1 + 2*q0 + p0 + 2) >> 2;
}
else
pSrcDst[0] = (2*q1 + q0 + p0 + 2 ) >> 2;
}
else if (1 == pBS[(pixel >> 2) << 1])
{
Ipp32s delta = ICLIP( -pThreshold[0], pThreshold[0], ( (q0 - p0)*3 + (p1 - q1) + 4) >> 3 );
pSrcDst[-1] = ICLIP<Ipp8u> (0, 255, p0 + delta);
pSrcDst[0] = ICLIP<Ipp8u> (0, 255, q0 - delta);
}
}
pSrcDst += srcdstStep;
}
}
return ippStsOk;
}
IppStatus AVSDeblocker::FilterDeblockingChroma_HorEdge(Ipp8u* pSrcDst,
Ipp32s srcdstStep,
Ipp8u* pAlpha,
Ipp8u* pBeta,
Ipp8u* pBS,
Ipp32s* pThreshold,
Ipp32s /*bit_depth*/)
{
Ipp8u p2,p1,p0,q0,q1,q2;
for (Ipp32u pixel = 0; pixel < 8; pixel++)
{
if (0 == pBS[pixel >> 2])
{
// go to next edge
pixel += 3;
pSrcDst += 4;
}
else
{
p2 = pSrcDst[-3*srcdstStep];
p1 = pSrcDst[-2*srcdstStep];
p0 = pSrcDst[-1*srcdstStep];
q0 = pSrcDst[0];
q1 = pSrcDst[srcdstStep];
q2 = pSrcDst[2*srcdstStep];
if ( (pAlpha[0] > abs(q0 - p0))&&
(pBeta[0] > abs(p1 - p0))&&
(pBeta[0] > abs(q1 - q0)))
{
Ipp32u ap = abs(p2-p0);
Ipp32u aq = abs(q2-q0);
if (2 == pBS[pixel >> 2])
{
if (ap < pBeta[0] &&
abs(p0-q0) < ((pAlpha[0] >> 2)+2))
{
pSrcDst[-1*srcdstStep] = (p1 + 2*p0 + q0 + 2) >> 2;
}
else
pSrcDst[-1*srcdstStep] = (2*p1 + p0 + q0 + 2 ) >> 2;
if (aq < pBeta[0] &&
abs(p0-q0) < ((pAlpha[0] >> 2)+2))
{
pSrcDst[0] = (q1 + 2*q0 + p0 + 2) >> 2;
}
else
pSrcDst[0] = (2*q1 + q0 + p0 + 2 ) >> 2;
}
else if (1 == pBS[pixel >> 2])
{
Ipp32s delta = ICLIP( -pThreshold[0], pThreshold[0], ( (q0 - p0)*3 + (p1 - q1) + 4) >> 3 );
pSrcDst[-1*srcdstStep] = ICLIP<Ipp8u> (0, 255, p0 + delta);
pSrcDst[0] = ICLIP<Ipp8u> (0, 255, q0 - delta);
}
}
pSrcDst += 1;
}
}
return ippStsOk;
}
void AVSDeblocker::FinalizeDeblocking(void)
{
// update variables
m_debCtx.MbIndex += m_debCtx.MbWidth;
m_debCtx.m_pMBInfo += m_debCtx.MbWidth;
m_debCtx.MbX = 0;
m_debCtx.MbY = m_debCtx.MbY + 1;
// update pointers to the video planes
if (1 == m_debCtx.m_pSeqHeader->sample_precission)
{
Ipp32s iPitch = m_debCtx.m_iPitch;
m_debCtx.m_pPlanes8u[0] = m_debCtx.m_pPlanes8u[0] -
m_debCtx.MbWidth * 16 +
iPitch * 16;
if (AVS_CHROMA_420_FORMAT == m_debCtx.m_pSeqHeader->chroma_format)
{
m_debCtx.m_pPlanes8u[1] = m_debCtx.m_pPlanes8u[1] -
m_debCtx.MbWidth * 8 +
iPitch * 8;
m_debCtx.m_pPlanes8u[2] = m_debCtx.m_pPlanes8u[2] -
m_debCtx.MbWidth * 8 +
iPitch * 8;
}
else
{
m_debCtx.m_pPlanes8u[1] = m_debCtx.m_pPlanes8u[1] -
m_debCtx.MbWidth * 8 +
iPitch * 16;
m_debCtx.m_pPlanes8u[2] = m_debCtx.m_pPlanes8u[2] -
m_debCtx.MbWidth * 8 +
iPitch * 16;
}
}
} // void AVSDeblocker::FinalizeDeblocking(void)
} // namespace UMC
#endif // #if defined(UMC_ENABLE_AVS_VIDEO_DECODER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -