📄 umc_avs_dec_deblocker.cpp
字号:
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined(UMC_ENABLE_AVS_VIDEO_DECODER)
#include "umc_avs_dec_deblocker.h"
#include "umc_avs_sequence_header.h"
#include "umc_avs_picture_header.h"
#include "umc_avs_dec_mb_info.h"
namespace UMC
{
// alpha table
Ipp8u AVS_ALPHA_TABLE[64] =
{
0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 2, 2, 2, 3, 3,
4, 4, 5, 5, 6, 7, 8, 9,
10,11,12,13,15,16,18,20,
22,24,26,28,30,33,33,35,
35,36,37,37,39,39,42,44,
46,48,50,52,53,54,55,56,
57,58,59,60,61,62,63,64
};
// beta table
Ipp8u AVS_BETA_TABLE[64] =
{
0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 6, 6,
6, 7, 7, 7, 8, 8, 8, 9,
9,10,10,11,11,12,13,14,
15,16,17,18,19,20,21,22,
23,23,24,24,25,25,26,27
};
Ipp8u AVS_QP_SCALE_CR[64] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,42,43,43,44,44,45,45,
46,46,47,47,48,48,48,49,49,49,
50,50,50,51,
};
Ipp8u AVS_CLIP_TABlE[64] =
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 3, 3, 4, 4, 4,
5, 5, 5, 6, 6, 6, 7, 7,
7, 7, 8, 8, 8, 9, 9, 9
} ;
AVSDeblocker::AVSDeblocker(void)
{
AVSDeblockingTbl[0] = &AVSDeblocker::FilterDeblockingLuma_VerEdge;
AVSDeblockingTbl[1] = &AVSDeblocker::FilterDeblockingLuma_HorEdge;
AVSDeblockingTbl[2] = &AVSDeblocker::FilterDeblockingChroma_VerEdge;
AVSDeblockingTbl[3] = &AVSDeblocker::FilterDeblockingChroma_HorEdge;
} // AVSDeblocker::AVSDeblocker(void)
AVSDeblocker::~AVSDeblocker(void)
{
} // AVSDeblocker::AVSDeblocker(void)
void AVSDeblocker::PrepareNeighbours(AVS_BASE_CONTEXT *pCtx)
{
// set the current macroblock
m_pMbInfo = pCtx->m_pMBInfo;
// set the pointer to the left macroblock
m_pMbInfoLeft = NULL;
// set the pointer to the upper macroblock
m_pMbInfoTop = (pCtx->MbIndex > pCtx->MbFirst) ?
(pCtx->m_pMBInfo - pCtx->MbWidth) :
(NULL);
} // void AVSDeblocker::PrepareNeighbours(AVS_BASE_CONTEXT *pCtx)
void AVSDeblocker::AdvanceDeblocking(void)
{
// update plane pointers
if (1 == m_debCtx.m_pSeqHeader->sample_precission)
{
// advance luminance pointer
m_debCtx.m_pPlanes8u[0] += 16;
// advance chrominance pointer
m_debCtx.m_pPlanes8u[1] += 8;
m_debCtx.m_pPlanes8u[2] += 8;
}
// dont forget about MbY and reset of MbX !!!!!!!!
// update macroblock position
m_debCtx.MbX += 1;
} // void AVSDeblocker::AdvanceDeblocking(void)
void AVSDeblocker::AdvanceNeighbours(void)
{
// update pointer to the upper neighbour
if (m_pMbInfoTop)
m_pMbInfoTop += 1;
// update pointer to the left neighbour
m_pMbInfoLeft = m_pMbInfo;
// update pointer to the current macroblock
m_pMbInfo += 1;
} // void AVSDeblocker::AdvanceNeighbours(void)
void AVSDeblocker::DeblockIMacroBlocksRow(void)
{
Ipp32s iMbMax = m_debCtx.MbIndex + m_debCtx.MbWidth;
// we can use MbIndex either from decoding and reconstructing contexts
MbIndex = m_debCtx.MbIndex;
PrepareNeighbours(&m_debCtx);
do
{
// deblock next macroblock
// ...
DeblockOneIMb(VerticalEdge);
DeblockOneIMb(HorizontalEdge);
MbIndex += 1;
AdvanceDeblocking();
AdvanceNeighbours();
} while (MbIndex < iMbMax);
// update context
FinalizeDeblocking();
} // void AVSDeblocker::DeblockIMacroBlocksRow(void)
void AVSDeblocker::DeblockOneIMb(Ipp32s direction)
{
Ipp8u* pY = m_debCtx.m_pPlanes8u[0];
Ipp8u* pU = m_debCtx.m_pPlanes8u[1];
Ipp8u* pV = m_debCtx.m_pPlanes8u[2];
Ipp8u pStrengt[4] = {2,2,2,2};
AVS_MB_INFO *pMbPrev = (direction == HorizontalEdge)?m_pMbInfoTop:m_pMbInfoLeft;
Ipp32s QPprev;
Ipp32s QPprevchr;
Ipp8u Alpha[2];
Ipp8u Beta[2];
Ipp32s Treshold[2];
if (NULL == pMbPrev)
{
pStrengt[0] = 0;
if (direction == HorizontalEdge)
pStrengt[1] = 0;
else
pStrengt[2] = 0;
}
else
{
QPprev = (pMbPrev->QP + m_pMbInfo->QP + 1) >> 1;
Alpha[0] = AVS_ALPHA_TABLE[ICLIP(0,63,QPprev + m_debCtx.m_pPicHeader->alpha_c_offset)];
Beta[0] = AVS_BETA_TABLE[ICLIP(0,63,QPprev + m_debCtx.m_pPicHeader->beta_offset)];
}
Alpha[1] = AVS_ALPHA_TABLE[ICLIP(0,63,m_pMbInfo->QP + m_debCtx.m_pPicHeader->alpha_c_offset)];
Beta[1] = AVS_BETA_TABLE[ICLIP(0,63,m_pMbInfo->QP + m_debCtx.m_pPicHeader->beta_offset)];
//luma deblocking
(this->*(AVSDeblockingTbl[direction]))(pY,
m_debCtx.m_iPitch,
Alpha,
Beta,
pStrengt,
Treshold,
0);
// no internal deblocking for chroma
if (NULL != pMbPrev)
{
QPprevchr=(AVS_QP_SCALE_CR[pMbPrev->QP]+AVS_QP_SCALE_CR[m_pMbInfo->QP]+1) >> 1;
// chroma deblocking
Alpha[0] = AVS_ALPHA_TABLE[ICLIP(0,63,QPprevchr + m_debCtx.m_pPicHeader->alpha_c_offset)];
Beta[0] = AVS_BETA_TABLE[ICLIP(0,63,QPprevchr + m_debCtx.m_pPicHeader->beta_offset)];
(this->*(AVSDeblockingTbl[2+direction]))(pU,
m_debCtx.m_iPitch,
Alpha,
Beta,
pStrengt,
Treshold,
0);
(this->*(AVSDeblockingTbl[2+direction]))(pV,
m_debCtx.m_iPitch,
Alpha,
Beta,
pStrengt,
Treshold,
0);
}
}
void AVSDeblocker::DeblockPBMacroBlocksRow(void)
{
Ipp32s iMbMax = m_debCtx.MbIndex + m_debCtx.MbWidth;
// we can use MbIndex either from decoding and reconstructing contexts
MbIndex = m_debCtx.MbIndex;
PrepareNeighbours(&m_debCtx);
do
{
// deblock next macroblock
// ...
DeblockOnePBMb(VerticalEdge);
DeblockOnePBMb(HorizontalEdge);
MbIndex += 1;
AdvanceDeblocking();
AdvanceNeighbours();
} while (MbIndex < iMbMax);
// update context
FinalizeDeblocking();
}
void AVSDeblocker::DeblockOnePBMb(Ipp32s direction)
{
Ipp8u* pY = m_debCtx.m_pPlanes8u[0];
Ipp8u* pU = m_debCtx.m_pPlanes8u[1];
Ipp8u* pV = m_debCtx.m_pPlanes8u[2];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -