📄 umc_h264_dec_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-2005 Intel Corporation. All Rights Reserved.////*/#include "umc_h264_dec.h"#include "umc_h264_dec_deblocking.h"#include "vm_types.h"#include "vm_debug.h"namespace UMC{void H264VideoDecoder::DeblockMacroblockISliceMBAFF(Ipp32u MBAddr){ __align(16) DeblockingParametersMBAFF params; // prepare deblocking parameters params.nMBAddr = MBAddr; ResetDeblockingVariablesMBAFF(¶ms); PrepareDeblockingParametersISliceMBAFF(¶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); // perform chroma deblocking if (0 == params.UseComplexVerticalDeblocking) DeblockChroma(VERTICAL_DEBLOCKING, ¶ms); else DeblockChromaVerticalMBAFF(¶ms); if (0 == params.ExtraHorizontalEdge) DeblockChroma(HORIZONTAL_DEBLOCKING, ¶ms); else DeblockChromaHorizontalMBAFF(¶ms);} // void H264VideoDecoder::DeblockMacroblockISliceMBAFF(Ipp32u MBAddr)void H264VideoDecoder::DeblockMacroblockPSliceMBAFF(Ipp32u MBAddr){ __align(16) DeblockingParametersMBAFF params; // prepare deblocking parameters params.nMBAddr = MBAddr; ResetDeblockingVariablesMBAFF(¶ms); PrepareDeblockingParametersPSliceMBAFF(¶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); // perform chroma deblocking if (0 == params.UseComplexVerticalDeblocking) DeblockChroma(VERTICAL_DEBLOCKING, ¶ms); else DeblockChromaVerticalMBAFF(¶ms); if (0 == params.ExtraHorizontalEdge) DeblockChroma(HORIZONTAL_DEBLOCKING, ¶ms); else DeblockChromaHorizontalMBAFF(¶ms);} // void H264VideoDecoder::DeblockMacroblockPSliceMBAFF(Ipp32u MBAddr)void H264VideoDecoder::DeblockMacroblockBSliceMBAFF(Ipp32u MBAddr){ __align(16) DeblockingParametersMBAFF params; // prepare deblocking parameters params.nMBAddr = MBAddr; ResetDeblockingVariablesMBAFF(¶ms); PrepareDeblockingParametersBSliceMBAFF(¶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); // perform chroma deblocking if (0 == params.UseComplexVerticalDeblocking) DeblockChroma(VERTICAL_DEBLOCKING, ¶ms); else DeblockChromaVerticalMBAFF(¶ms); if (0 == params.ExtraHorizontalEdge) DeblockChroma(HORIZONTAL_DEBLOCKING, ¶ms); else DeblockChromaHorizontalMBAFF(¶ms);} // void H264VideoDecoder::DeblockMacroblockBSliceMBAFF(Ipp32u MBAddr)void H264VideoDecoder::ResetDeblockingVariablesMBAFF(DeblockingParametersMBAFF *pParams){ Ipp8u *pY, *pU, *pV; Ipp32u offset; Ipp32u mbXOffset, mbYOffset; Ipp32s pic_pitch = m_pCurrentFrame->pitch(); Ipp32u MBAddr = pParams->nMBAddr; Ipp32u nCurrMB_X, nCurrMB_Y; H264LimitedSliceHeader *pHeader; Ipp32u nFieldMacroblockMode; // from linear MB number to MBAFF MB number { Ipp32u nRemain; nRemain = MBAddr % (mb_width * 2); MBAddr = MBAddr - nRemain + nRemain / 2; if (nRemain & 1) MBAddr += mb_width; } // load slice header pHeader = m_pLimitedSliceInfo + m_pCurrentFrame->m_mbinfo.mbs[MBAddr].slice_id; // load planes pY = m_pCurrentFrame->m_pYPlane; pU = m_pCurrentFrame->m_pUPlane; pV = m_pCurrentFrame->m_pVPlane; // prepare macroblock variables nCurrMB_X = (MBAddr % mb_width); nCurrMB_Y = (MBAddr / mb_width); mbXOffset = nCurrMB_X * 16; mbYOffset = nCurrMB_Y * 16; // calc plane's offsets offset = mbXOffset + (mbYOffset * pic_pitch); pY += offset; offset >>= 1; pU += offset; pV += offset; // obtain macroblock mode nFieldMacroblockMode = pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr); // correct y, u & v offset if (nFieldMacroblockMode) { if (pGetMBBottomFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr)) { pY -= 15 * pic_pitch; pU -= 7 * pic_pitch; pV -= 7 * pic_pitch; } pic_pitch *= 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_pCurrentFrame->m_mbinfo.mbs[MBAddr].slice_id != m_pCurrentFrame->m_mbinfo.mbs[MBAddr - 1].slice_id) pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING] = 0; } if (pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING]) { if (m_pCurrentFrame->m_mbinfo.mbs[MBAddr].slice_id != m_pCurrentFrame->m_mbinfo.mbs[MBAddr - mb_width * 2].slice_id) pParams->ExternalEdgeFlag[HORIZONTAL_DEBLOCKING] = 0; } } // set left MB couple adresses { Ipp32u nRemain; nRemain = pParams->nMBAddr % (mb_width * 2); pParams->nLeft[0] = pParams->nMBAddr - nRemain + nRemain / 2 - 1; pParams->nLeft[1] = pParams->nLeft[0] + mb_width; } // set "complex deblocking" flag // when left & current macroblock are coded in different modes pParams->UseComplexVerticalDeblocking = 0; if (pParams->ExternalEdgeFlag[VERTICAL_DEBLOCKING]) { if (nFieldMacroblockMode != (Ipp32u) pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr - 1)) { // when left macroblocks aren't intra blocks // or have different QP if (IS_INTER_MBTYPE((m_pCurrentFrame->m_mbinfo.mbs + pParams->nLeft[0])->mbtype) || IS_INTER_MBTYPE((m_pCurrentFrame->m_mbinfo.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 != pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.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 - 1; if (0 == nFieldMacroblockMode) { if (0 == pGetMBBottomFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr)) { if (pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr - mb_width * 2)) pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2; else pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width; } else { if (pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr - mb_width * 2)) pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width; else pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width; } } else { if (0 == pGetMBBottomFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr)) { if (pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs + MBAddr - mb_width * 2)) pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width * 2; else pParams->nNeighbour[HORIZONTAL_DEBLOCKING] = MBAddr - mb_width; } else { if (pGetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.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->pY = pY; pParams->pU = pU; pParams->pV = pV; pParams->pitch = pic_pitch; 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 H264VideoDecoder::ResetDeblockingVariablesMBAFF(DeblockingParametersMBAFF *pParams)void H264VideoDecoder::DeblockLumaVerticalMBAFF(DeblockingParametersMBAFF *pParams){ // // step 1. Perform complex deblocking on external edge // { Ipp32u MBAddr = pParams->nMBAddr; Ipp8u Clipping[16]; Ipp8u Alpha[2]; Ipp8u Beta[2]; Ipp32s AlphaC0Offset = pParams->nAlphaC0Offset; Ipp32s BetaOffset = pParams->nBetaOffset; Ipp32s pmq_QP = m_mbinfo.mbs[MBAddr].QP; Ipp32s pmp_QP; Ipp8u *pClipTab; Ipp32s QP; Ipp32s index; Ipp8u *pStrength = pParams->StrengthComplex;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -