📄 umc_h264_segment_decoder_deblocking_mbaff.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) 2003-2007 Intel Corporation. All Rights Reserved.
//
//
*/
#include "umc_defs.h"
#if defined (UMC_ENABLE_H264_VIDEO_DECODER)
#include "umc_h264_segment_decoder.h"
#include "umc_h264_dec_deblocking.h"
namespace UMC
{
void H264SegmentDecoder::DeblockMacroblockISliceMBAFF(Ipp32s MBAddr)
{
__align(16)
DeblockingParametersMBAFF params;
// prepare deblocking parameters
params.nMBAddr = MBAddr;
ResetDeblockingVariablesMBAFF(¶ms);
PrepareDeblockingParametersISliceMBAFF(¶ms);
// perform chroma deblocking
{
Ipp32u color_format = m_pCurrentFrame->m_chroma_format;
if (0 == params.UseComplexVerticalDeblocking)
(this->*DeblockChroma[color_format])(VERTICAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaVerticalMBAFF[color_format])(¶ms);
if (0 == params.ExtraHorizontalEdge)
(this->*DeblockChroma[color_format])(HORIZONTAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaHorizontalMBAFF[color_format])(¶ms);
}
// perform luma deblocking
if (0 == params.UseComplexVerticalDeblocking)
DeblockLuma(VERTICAL_DEBLOCKING, ¶ms);
else
DeblockLumaVerticalMBAFF(¶ms);
if (0 == params.ExtraHorizontalEdge)
DeblockLuma(HORIZONTAL_DEBLOCKING, ¶ms);
else
DeblockLumaHorizontalMBAFF(¶ms);
} // void H264SegmentDecoder::DeblockMacroblockISliceMBAFF(Ipp32s MBAddr)
void H264SegmentDecoder::DeblockMacroblockPSliceMBAFF(Ipp32s MBAddr)
{
__align(16)
DeblockingParametersMBAFF params;
// prepare deblocking parameters
params.nMBAddr = MBAddr;
ResetDeblockingVariablesMBAFF(¶ms);
PrepareDeblockingParametersPSliceMBAFF(¶ms);
// perform chroma deblocking
{
Ipp32u color_format = m_pCurrentFrame->m_chroma_format;
if (0 == params.UseComplexVerticalDeblocking)
(this->*DeblockChroma[color_format])(VERTICAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaVerticalMBAFF[color_format])(¶ms);
if (0 == params.ExtraHorizontalEdge)
(this->*DeblockChroma[color_format])(HORIZONTAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaHorizontalMBAFF[color_format])(¶ms);
}
// perform luma deblocking
if (0 == params.UseComplexVerticalDeblocking)
DeblockLuma(VERTICAL_DEBLOCKING, ¶ms);
else
DeblockLumaVerticalMBAFF(¶ms);
if (0 == params.ExtraHorizontalEdge)
DeblockLuma(HORIZONTAL_DEBLOCKING, ¶ms);
else
DeblockLumaHorizontalMBAFF(¶ms);
} // void H264SegmentDecoder::DeblockMacroblockPSliceMBAFF(Ipp32s MBAddr)
void H264SegmentDecoder::DeblockMacroblockBSliceMBAFF(Ipp32s MBAddr)
{
__align(16)
DeblockingParametersMBAFF params;
// prepare deblocking parameters
params.nMBAddr = MBAddr;
ResetDeblockingVariablesMBAFF(¶ms);
PrepareDeblockingParametersBSliceMBAFF(¶ms);
// perform chroma deblocking
{
Ipp32u color_format = m_pCurrentFrame->m_chroma_format;
if (0 == params.UseComplexVerticalDeblocking)
(this->*DeblockChroma[color_format])(VERTICAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaVerticalMBAFF[color_format])(¶ms);
if (0 == params.ExtraHorizontalEdge)
(this->*DeblockChroma[color_format])(HORIZONTAL_DEBLOCKING, ¶ms);
else
(this->*DeblockChromaHorizontalMBAFF[color_format])(¶ms);
}
// perform luma deblocking
if (0 == params.UseComplexVerticalDeblocking)
DeblockLuma(VERTICAL_DEBLOCKING, ¶ms);
else
DeblockLumaVerticalMBAFF(¶ms);
if (0 == params.ExtraHorizontalEdge)
DeblockLuma(HORIZONTAL_DEBLOCKING, ¶ms);
else
DeblockLumaHorizontalMBAFF(¶ms);
} // void H264SegmentDecoder::DeblockMacroblockBSliceMBAFF(Ipp32s MBAddr)
void H264SegmentDecoder::ResetDeblockingVariablesMBAFF(DeblockingParametersMBAFF *pParams)
{
PlanePtrYCommon pY;
PlanePtrUVCommon pU;
PlanePtrUVCommon pV;
Ipp32s offset;
Ipp32s mbXOffset, mbYOffset;
Ipp32s pitch_luma = m_pCurrentFrame->pitch_luma();
Ipp32s pitch_chroma = m_pCurrentFrame->pitch_chroma();
Ipp32s MBAddr = pParams->nMBAddr;
Ipp32s nCurrMB_X, nCurrMB_Y;
const H264SliceHeader *pHeader;
Ipp32s nFieldMacroblockMode;
// load slice header
pHeader = m_pSliceHeader;
pParams->bitDepthLuma = (Ipp8u)bit_depth_luma;
pParams->bitDepthChroma = (Ipp8u)bit_depth_chroma;
// load planes
pY = m_pCurrentFrame->m_pYPlane;
pU = m_pCurrentFrame->m_pUPlane;
pV = m_pCurrentFrame->m_pVPlane;
Ipp32s pixel_luma_sz = pParams->bitDepthLuma > 8 ? 2 : 1;
Ipp32s pixel_chroma_sz = pParams->bitDepthChroma > 8 ? 2 : 1;
// prepare macroblock variables
nCurrMB_X = ((MBAddr>>1) % mb_width);
nCurrMB_Y = ((MBAddr>>1) / mb_width)*2 + (MBAddr&1);
mbXOffset = nCurrMB_X * 16;
mbYOffset = nCurrMB_Y * 16;
// calc plane's offsets
offset = mbXOffset + (mbYOffset * pitch_luma);
pY += offset*pixel_luma_sz;
switch (m_pCurrentFrame->m_chroma_format)
{
case CHROMA_FORMAT_420:
offset = (mbXOffset + (mbYOffset * pitch_chroma)) >> 1;
break;
case CHROMA_FORMAT_422:
offset = (mbXOffset >> 1) + (mbYOffset * pitch_chroma);
break;
case CHROMA_FORMAT_400:
offset = 0;
case CHROMA_FORMAT_444:
break;
default:
VM_ASSERT(false);
break;
}
pU += offset*pixel_chroma_sz;
pV += offset*pixel_chroma_sz;
// obtain macroblock mode
nFieldMacroblockMode = GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr]);
// correct y, u & v offset
if (nFieldMacroblockMode)
{
if (MBAddr & 1)
{
pY -= 15 * pitch_luma * pixel_luma_sz;
Ipp32s ff_offset = (m_pCurrentFrame->m_chroma_format != 1) ? 15 : 7;
pU -= ff_offset * pitch_chroma * pixel_chroma_sz;
pV -= ff_offset * pitch_chroma * pixel_chroma_sz;
}
pitch_luma *= 2;
pitch_chroma *= 2;
}
// set external edge variables
// there are only two values:
// zero - do not deblocking
// nonzero - do deblocking
pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING] = nCurrMB_X;
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = (nFieldMacroblockMode) ? (1 < nCurrMB_Y) : (nCurrMB_Y);
if (DEBLOCK_FILTER_ON_NO_SLICE_EDGES == pHeader->disable_deblocking_filter_idc)
{
// don't filter at slice boundaries
if (pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING])
{
if (m_gmbinfo->mbs[MBAddr].slice_id !=
m_gmbinfo->mbs[MBAddr - 2].slice_id)
pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING] = 0;
}
if (pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING])
{
if (m_gmbinfo->mbs[MBAddr].slice_id !=
m_gmbinfo->mbs[MBAddr - mb_width * 2].slice_id
&& !(!nFieldMacroblockMode && (MBAddr & 1)))
pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0;
}
}
// set left MB couple adresses
{
pParams->nLeft[0] = pParams->nMBAddr - 2 - (MBAddr&1);
pParams->nLeft[1] = pParams->nLeft[0] + 1;
}
// set "complex deblocking" flag
// when left & current macroblock are coded in different modes
pParams->UseComplexVerticalDeblocking = 0;
if (pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING])
{
if (nFieldMacroblockMode !=
GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr - 2]))
{
// when left macroblocks aren't intra blocks
// or have different QP
//if (IS_INTER_MBTYPE((m_gmbinfo->mbs + pParams->nLeft[0])->mbtype) ||
// IS_INTER_MBTYPE((m_gmbinfo->mbs + pParams->nLeft[1])->mbtype) ||
// (m_mbinfo.mbs[pParams->nLeft[0]].QP != m_mbinfo.mbs[pParams->nLeft[1]].QP))
//{
pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING] = 0;
pParams->UseComplexVerticalDeblocking = 1;
//}
}
}
// obtain extra horizontal edge condition
// when above macroblock is field coded and
// current macroblock is frame coded
pParams->ExtraHorizontalEdge = 0;
if ((0 == (pParams->nMBAddr & 1)) &&
(pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING]))
{
if ((0 == nFieldMacroblockMode) &&
(0 != GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr - mb_width * 2])))
pParams->ExtraHorizontalEdge = 1;
}
// reset external edges strength
SetEdgeStrength(pParams->Strength[VERTICAL_DEBLOCKING], 0);
SetEdgeStrength(pParams->Strength[HORIZONTAL_DEBLOCKING], 0);
// set neighbour addreses
pParams->nNeighbour[VERTICAL_DEBLOCKING] = MBAddr - 2;
if (0 == nFieldMacroblockMode)
{
if ((MBAddr&1)==0)
{
if (GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr - mb_width * 2]))
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2;
else
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2 + 1;
}
else
{
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - 1;
}
}
else
{
if ((MBAddr&1)==0)
{
if (GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr - mb_width * 2]))
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2;
else
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2 + 1;
}
else
{
if (GetMBFieldDecodingFlag(m_gmbinfo->mbs[MBAddr - mb_width * 2]))
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2;
else
pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2;
}
}
// set deblocking flag(s)
pParams->DeblockingFlag[VERTICAL_DEBLOCKING] = 0;
pParams->DeblockingFlag[HORIZONTAL_DEBLOCKING] = 0;
// save variables
pParams->pLuma = pY;
pParams->pChroma[0] = pU;
pParams->pChroma[1] = pV;
pParams->pitch_luma = pitch_luma;
pParams->pitch_chroma = pitch_chroma;
pParams->nMBAddr = MBAddr;
pParams->nMaxMVector = (nFieldMacroblockMode) ? (2) : (4);
pParams->MBFieldCoded = nFieldMacroblockMode;
// set slice's variables
pParams->nAlphaC0Offset = pHeader->slice_alpha_c0_offset;
pParams->nBetaOffset = pHeader->slice_beta_offset;
} // void H264SegmentDecoder::ResetDeblockingVariablesMBAFF(DeblockingParametersMBAFF *pParams)
void H264SegmentDecoder::DeblockLumaVerticalMBAFF(DeblockingParametersMBAFF *pParams)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -