📄 umc_h264_segment_decoder_deblocking_prepare.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::PrepareDeblockingParametersISlice(DeblockingParameters *pParams)
{
// set deblocking flag(s)
pParams->DeblockingFlag[VERTICAL_DEBLOCKING] = 1;
pParams->DeblockingFlag[HORIZONTAL_DEBLOCKING] = 1;
// 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 (pParams->MBFieldCoded)
{
// 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);
} // void H264SegmentDecoder::PrepareDeblockingParametersISlice(DeblockingParameters *pParams)
void H264SegmentDecoder::PrepareDeblockingParametersPSlice(DeblockingParameters *pParams)
{
Ipp32s MBAddr = pParams->nMBAddr;
Ipp32s mbtype = (m_gmbinfo->mbs + MBAddr)->mbtype;
// when this macroblock is intra coded
if (IS_INTRA_MBTYPE(mbtype))
{
PrepareDeblockingParametersISlice(pParams);
return;
}
// try simplest function to prepare deblocking parameters
switch (mbtype)
{
// when macroblock has type inter 16 on 16
case MBTYPE_INTER:
case MBTYPE_FORWARD:
case MBTYPE_BACKWARD:
case MBTYPE_BIDIR:
PrepareDeblockingParametersPSlice16x16Vert(pParams);
PrepareDeblockingParametersPSlice16x16Horz(pParams);
break;
/*
// when macroblock has type inter 16 on 8
case MBTYPE_INTER_16x8:
PrepareDeblockingParametersPSlice8x16(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersPSlice16x8(HORIZONTAL_DEBLOCKING, pParams);
return;
// when macroblock has type inter 8 on 16
case MBTYPE_INTER_8x16:
PrepareDeblockingParametersPSlice16x8(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersPSlice8x16(HORIZONTAL_DEBLOCKING, pParams);
return;
*/
default:
PrepareDeblockingParametersPSlice4(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersPSlice4(HORIZONTAL_DEBLOCKING, pParams);
break;
}
} // void H264SegmentDecoder::PrepareDeblockingParametersPSlice(DeblockingParameters *pParams)
void H264SegmentDecoder::PrepareDeblockingParametersBSlice(DeblockingParameters *pParams)
{
Ipp32s MBAddr = pParams->nMBAddr;
Ipp32s mbtype = (m_gmbinfo->mbs + MBAddr)->mbtype;
// when this macroblock is intra coded
if (IS_INTRA_MBTYPE(mbtype))
{
PrepareDeblockingParametersISlice(pParams);
return;
}
// try simplest function to prepare deblocking parameters
switch (mbtype)
{
// when macroblock has type inter 16 on 16
case MBTYPE_INTER:
case MBTYPE_FORWARD:
case MBTYPE_BACKWARD:
case MBTYPE_BIDIR:
PrepareDeblockingParametersBSlice16x16Vert(pParams);
PrepareDeblockingParametersBSlice16x16Horz(pParams);/*
PrepareDeblockingParametersBSlice16(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersBSlice16(HORIZONTAL_DEBLOCKING, pParams);*/
break;
// when macroblock has type inter 16 on 8
case MBTYPE_INTER_16x8:
PrepareDeblockingParametersBSlice8x16(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersBSlice16x8(HORIZONTAL_DEBLOCKING, pParams);
return;
// when macroblock has type inter 8 on 16
case MBTYPE_INTER_8x16:
PrepareDeblockingParametersBSlice16x8(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersBSlice8x16(HORIZONTAL_DEBLOCKING, pParams);
return;
default:
PrepareDeblockingParametersBSlice4(VERTICAL_DEBLOCKING, pParams);
PrepareDeblockingParametersBSlice4(HORIZONTAL_DEBLOCKING, pParams);
break;
}
} // void H264SegmentDecoder::PrepareDeblockingParametersBSlice(DeblockingParameters *pParams)
enum
{
VERTICAL_OUTER_EDGE_MASK = 0x00a0a,
VERTICAL_OUTER_EDGE_BLOCK_0 = 0x00002,
VERTICAL_OUTER_EDGE_BLOCK_1 = 0x00008,
VERTICAL_OUTER_EDGE_BLOCK_2 = 0x00200,
VERTICAL_OUTER_EDGE_BLOCK_3 = 0x00800,
HORIZONTAL_OUTER_EDGE_MASK = 0x00066,
HORIZONTAL_OUTER_EDGE_BLOCK_0 = 0x00002,
HORIZONTAL_OUTER_EDGE_BLOCK_1 = 0x00004,
HORIZONTAL_OUTER_EDGE_BLOCK_2 = 0x00020,
HORIZONTAL_OUTER_EDGE_BLOCK_3 = 0x00040
};
static
Ipp8u InternalBlockDeblockingTable[2][16][4] =
{
// strength arrays for vertical deblocking
{
{0, 0, 0, 0},
{2, 0, 0, 0},
{0, 0, 2, 0},
{2, 0, 2, 0},
{0, 2, 0, 0},
{2, 2, 0, 0},
{0, 2, 2, 0},
{2, 2, 2, 0},
{0, 0, 0, 2},
{2, 0, 0, 2},
{0, 0, 2, 2},
{2, 0, 2, 2},
{0, 2, 0, 2},
{2, 2, 0, 2},
{0, 2, 2, 2},
{2, 2, 2, 2}
},
// strength arrays for horizontal deblocking
{
{0, 0, 0, 0},
{2, 0, 0, 0},
{0, 2, 0, 0},
{2, 2, 0, 0},
{0, 0, 2, 0},
{2, 0, 2, 0},
{0, 2, 2, 0},
{2, 2, 2, 0},
{0, 0, 0, 2},
{2, 0, 0, 2},
{0, 2, 0, 2},
{2, 2, 0, 2},
{0, 0, 2, 2},
{2, 0, 2, 2},
{0, 2, 2, 2},
{2, 2, 2, 2}
}
};
void H264SegmentDecoder::PrepareDeblockingParametersIntern16x16Vert(DeblockingParameters *pParams)
{
Ipp32u cbp4x4_luma = (m_mbinfo.mbs + pParams->nMBAddr)->cbp4x4_luma;
Ipp8u *pStrength = pParams->Strength[VERTICAL_DEBLOCKING];
//
// internal edge(s)
//
if (cbp4x4_luma & 0x1fffe)
{
Ipp32s a, b, res;
// set deblocking flag
pParams->DeblockingFlag[VERTICAL_DEBLOCKING] |= 1;
// deblocking strength depends on CBP only
// we use fast CBP comparison
a = cbp4x4_luma >> 1;
b = cbp4x4_luma >> 2;
res = (a | b) & 0x505;
res = (res & 0x05) | (res >> 7);
CopyEdgeStrength(pStrength + 4, InternalBlockDeblockingTable[VERTICAL_DEBLOCKING][res]);
a = cbp4x4_luma >> 5;
res = (a | b) & 0x505;
res = (res & 0x05) | (res >> 7);
CopyEdgeStrength(pStrength + 8, InternalBlockDeblockingTable[VERTICAL_DEBLOCKING][res]);
b = cbp4x4_luma >> 6;
res = (a | b) & 0x505;
res = (res & 0x05) | (res >> 7);
CopyEdgeStrength(pStrength + 12, InternalBlockDeblockingTable[VERTICAL_DEBLOCKING][res]);
}
else
{
// reset all strengths
SetEdgeStrength(pStrength + 4, 0);
SetEdgeStrength(pStrength + 8, 0);
SetEdgeStrength(pStrength + 12, 0);
}
} // void H264SegmentDecoder::PrepareDeblockingParametersIntern16x16Vert(DeblockingParameters *pParams)
void H264SegmentDecoder::PrepareDeblockingParametersIntern16x16Horz(DeblockingParameters *pParams)
{
Ipp32u cbp4x4_luma = (m_mbinfo.mbs + pParams->nMBAddr)->cbp4x4_luma;
Ipp8u *pStrength = pParams->Strength[HORIZONTAL_DEBLOCKING];
//
// internal edge(s)
//
if (cbp4x4_luma & 0x1fffe)
{
Ipp32s a, b, res;
// set deblocking flag
pParams->DeblockingFlag[HORIZONTAL_DEBLOCKING] |= 1;
// deblocking strength depends on CBP only
// we use fast CBP comparison
a = cbp4x4_luma >> 1;
b = cbp4x4_luma >> 3;
res = (a | b) & 0x33;
res = (res & 0x03) | (res >> 2);
CopyEdgeStrength(pStrength + 4, InternalBlockDeblockingTable[HORIZONTAL_DEBLOCKING][res]);
a = cbp4x4_luma >> 9;
res = (a | b) & 0x33;
res = (res & 0x03) | (res >> 2);
CopyEdgeStrength(pStrength + 8, InternalBlockDeblockingTable[HORIZONTAL_DEBLOCKING][res]);
b = cbp4x4_luma >> 11;
res = (a | b) & 0x33;
res = (res & 0x03) | (res >> 2);
CopyEdgeStrength(pStrength + 12, InternalBlockDeblockingTable[HORIZONTAL_DEBLOCKING][res]);
}
else
{
// reset all strengths
SetEdgeStrength(pStrength + 4, 0);
SetEdgeStrength(pStrength + 8, 0);
SetEdgeStrength(pStrength + 12, 0);
}
} // void H264SegmentDecoder::PrepareDeblockingParametersIntern16x16Horz(DeblockingParameters *pParams)
void H264SegmentDecoder::PrepareDeblockingParametersPSlice4(Ipp32u dir, DeblockingParameters *pParams)
{
Ipp32s MBAddr = pParams->nMBAddr;
Ipp32u cbp4x4_luma = (m_mbinfo.mbs + MBAddr)->cbp4x4_luma;
Ipp8u *pStrength = pParams->Strength[dir];
Ipp32s *pDeblockingFlag = &(pParams->DeblockingFlag[dir]);
//
// external edge
//
if (pParams->ExternalEdgeFlag[dir])
{
Ipp32s nNeighbour;
// select neighbour addres
nNeighbour = pParams->nNeighbour[dir];
// when neighbour macroblock isn't intra
if (!IS_INTRA_MBTYPE((m_gmbinfo->mbs + nNeighbour)->mbtype))
{
H264DecoderMacroblockLocalInfo *pNeighbour;
Ipp32s idx;
// select neighbour
pNeighbour = m_mbinfo.mbs + nNeighbour;
// cicle on blocks
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -