⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_h264_dec_deblocking.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*////              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 "umc_h264_deblocking_tools.h"#include "vm_types.h"#include "vm_debug.h"namespace UMC{// alpha tableIpp8u ALPHA_TABLE[52] ={    0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,    4,  4,  5,  6,  7,  8,  9,  10,    12, 13, 15, 17, 20, 22, 25, 28,    32, 36, 40, 45, 50, 56, 63, 71,    80, 90, 101,113,127,144,162,182,    203,226,255,255};// beta tableIpp8u BETA_TABLE[52] ={    0,  0,  0,  0,  0,  0,  0,  0,    0,  0,  0,  0,  0,  0,  0,  0,    2,  2,  2,  3,  3,  3,  3,  4,    4,  4,  6,  6,  7,  7,  8,  8,    9,  9,  10, 10, 11, 11, 12, 12,    13, 13, 14, 14, 15, 15, 16, 16,    17, 17, 18, 18};// clipping tableIpp8u CLIP_TAB[52][5] ={    { 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},    { 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},    { 0, 0, 0, 0, 0},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 1, 1, 1, 1},    { 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 2, 3, 3},    { 0, 1, 2, 3, 3},{ 0, 2, 2, 3, 3},{ 0, 2, 2, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 3, 3, 5, 5},{ 0, 3, 4, 6, 6},{ 0, 3, 4, 6, 6},    { 0, 4, 5, 7, 7},{ 0, 4, 5, 8, 8},{ 0, 4, 6, 9, 9},{ 0, 5, 7,10,10},{ 0, 6, 8,11,11},{ 0, 6, 8,13,13},{ 0, 7,10,14,14},{ 0, 8,11,16,16},    { 0, 9,12,18,18},{ 0,10,13,20,20},{ 0,11,15,23,23},{ 0,13,17,25,25}};// this pretty table was designed to// avoid coincidencies with any GPL code// chroma scaling QP tableIpp8u QP_SCALE_CR[52] ={    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,     29,             30,     31,             32,    32,     33,         34,         34,         35,    35,     36, 36, 37,             37, 37, 38,    38,     38,                     39,    39,     39,                     39};// masks for external blocks pair "coded bits"Ipp32u EXTERNAL_BLOCK_MASK[NUMBER_OF_DIRECTION][2][4] ={    // block mask for vertical deblocking    {        {2 << 0, 2 << 2, 2 << 8, 2 << 10},        {2 << 5, 2 << 7, 2 << 13,2 << 15}    },    // block mask for horizontal deblocking    {        {2 << 0, 2 << 1, 2 << 4, 2 << 5},        {2 << 10,2 << 11,2 << 14,2 << 15}    }};#define DECL(prev, cur) (2 << (prev) | 2 << (cur))// masks for internal blocks pair "coded bits"Ipp32u INTERNAL_BLOCKS_MASK[NUMBER_OF_DIRECTION][12] ={    // blocks pair-mask for vertical deblocking    {        DECL(0, 1),  DECL(2, 3),  DECL(8, 9),  DECL(10, 11),        DECL(1, 4),  DECL(3, 6),  DECL(9, 12), DECL(11, 14),        DECL(4, 5),  DECL(6, 7),  DECL(12, 13),DECL(14, 15)    },    // blocks pair-mask for horizontal deblocking    {        DECL(0, 2),  DECL(1, 3),  DECL(4, 6),  DECL(5, 7),        DECL(2, 8),  DECL(3, 9),  DECL(6, 12), DECL(7, 13),        DECL(8, 10), DECL(9, 11), DECL(12, 14),DECL(13, 15)    }};#undef DECL// implement array of IPP optimized luma deblocking functions#if defined(_WIN32_WCE) && defined(_M_IX86) && defined(__stdcall)#define _IPP_STDCALL_CDECL#undef __stdcall#endif // defined(_WIN32_WCE) && defined(_M_IX86) && defined(__stdcall)IppStatus (__STDCALL *(IppLumaDeblocking[])) (Ipp8u *, Ipp32s, Ipp8u *, Ipp8u *, Ipp8u *, Ipp8u *) ={    &(ippiFilterDeblockingLuma_VerEdge_H264_8u_C1IR),    &(ippiFilterDeblockingLuma_HorEdge_H264_8u_C1IR)};// implement array of IPP optimized chroma deblocking functionsIppStatus (__STDCALL *(IppChromaDeblocking[])) (Ipp8u *, Ipp32s, Ipp8u *, Ipp8u *, Ipp8u *, Ipp8u *) ={    &(ippiFilterDeblockingChroma_VerEdge_H264_8u_C1IR),    &(ippiFilterDeblockingChroma_HorEdge_H264_8u_C1IR)};#if defined(_IPP_STDCALL_CDECL)#undef _IPP_STDCALL_CDECL#define __stdcall __cdecl#endif // defined(_IPP_STDCALL_CDECL)void H264VideoDecoder::DeblockFrame(Ipp32u uFirstMB, Ipp32u uNumMB){    // update slice info    UpdateLimitedSliceInfo(&m_CurSliceHeader);    // perform deblocking process by several threads    if (m_pThreadedDeblockingTools)    {        m_pThreadedDeblockingTools->DeblockSliceTwoThreaded(uFirstMB,                                                            uNumMB,                                                            &H264VideoDecoder::DeblockMacroblockMSlice);    }    else    {        Ipp32u i;        // perform deblocking process on every macroblock        for (i = uFirstMB; i < uFirstMB+uNumMB; i++)            DeblockMacroblockMSlice(i);    }} // void H264VideoDecoder::DeblockFrame(Ipp32u uFirstMB, Ipp32u uNumMB)void H264VideoDecoder::DeblockSlice(Ipp32u uFirstMB, Ipp32u unumMBs, bool bLast){    DeblockingFunction pDeblocking = NULL;    // no filtering edges of this slice    if (DEBLOCK_FILTER_OFF == m_CurSliceHeader.disable_deblocking_filter_idc)        return;    // update slice info    UpdateLimitedSliceInfo(&m_CurSliceHeader);    // MBAFF case    if (m_CurSliceHeader.MbaffFrameFlag)    {        // select optimized deblocking function        switch (m_CurSliceHeader.slice_type)        {        case INTRASLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockISliceMBAFF;            break;        case PREDSLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockPSliceMBAFF;            break;        case BPREDSLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockBSliceMBAFF;            break;        default:            pDeblocking = NULL;            break;        }    }    // non-MBAFF case    else    {        // select optimized deblocking function        switch (m_CurSliceHeader.slice_type)        {        case INTRASLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockISlice;            break;        case PREDSLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockPSlice;            break;        case BPREDSLICE:            pDeblocking = &H264VideoDecoder::DeblockMacroblockBSlice;            break;        default:            pDeblocking = NULL;            break;        }    }    if (NULL == pDeblocking)        return;    // perform deblocking process by several threads    if (m_pThreadedDeblockingTools)    {        // wait for previous end of slice        m_pThreadedDeblockingTools->WaitEndOfSlice();        // start new slice        if (false == bLast)            m_pThreadedDeblockingTools->DeblockSliceAsync(uFirstMB, unumMBs, pDeblocking);        else        {            m_pThreadedDeblockingTools->m_nMBAFF = (m_CurSliceHeader.MbaffFrameFlag) ? (1) : (0);            m_pThreadedDeblockingTools->DeblockSliceTwoThreaded(uFirstMB, unumMBs, pDeblocking);        }    }    else    {        Ipp32u i;        // perform deblocking process on every macroblock        for (i = uFirstMB; i < uFirstMB + unumMBs; i++)            (this->*(pDeblocking))(i);    }} // void H264VideoDecoder::DeblockSlice(Ipp32u uFirstMB, Ipp32u unumMBs)void H264VideoDecoder::DeblockMacroblockMSlice(Ipp32u MBAddr){    H264LimitedSliceHeader *pHeader = m_pLimitedSliceInfo + m_pCurrentFrame->m_mbinfo.mbs[MBAddr].slice_id;    // when deblocking isn't required    if (DEBLOCK_FILTER_OFF == pHeader->disable_deblocking_filter_idc)        return;    // select optimized deblocking function    switch (pHeader->slice_type)    {    case INTRASLICE:        DeblockMacroblockISlice(MBAddr);        break;    case PREDSLICE:        DeblockMacroblockPSlice(MBAddr);        break;    case BPREDSLICE:        DeblockMacroblockBSlice(MBAddr);        break;    default:        // illegal case. it should never hapen.        break;    }} // void H264VideoDecoder::DeblockMacroblockMSlice(Ipp32u MBAddr)void H264VideoDecoder::DeblockMacroblockISlice(Ipp32u MBAddr){    __align(16)    DeblockingParameters params;    // prepare deblocking parameters    params.nMBAddr = MBAddr;    ResetDeblockingVariables(&params);    PrepareDeblockingParametersISlice(&params);    // perform deblocking    DeblockLuma(VERTICAL_DEBLOCKING, &params);    DeblockLuma(HORIZONTAL_DEBLOCKING, &params);    DeblockChroma(VERTICAL_DEBLOCKING, &params);    DeblockChroma(HORIZONTAL_DEBLOCKING, &params);} // void H264VideoDecoder::DeblockMacroblockISlice(Ipp32u MBAddr)void H264VideoDecoder::DeblockMacroblockPSlice(Ipp32u MBAddr){    __align(16)    DeblockingParameters params;    // prepare deblocking parameters    params.nMBAddr = MBAddr;    ResetDeblockingVariables(&params);    PrepareDeblockingParametersPSlice(&params);    // perform deblocking    DeblockLuma(VERTICAL_DEBLOCKING, &params);    DeblockLuma(HORIZONTAL_DEBLOCKING, &params);    DeblockChroma(VERTICAL_DEBLOCKING, &params);    DeblockChroma(HORIZONTAL_DEBLOCKING, &params);} // void H264VideoDecoder::DeblockMacroblockPSlice(Ipp32u MBAddr)void H264VideoDecoder::DeblockMacroblockBSlice(Ipp32u MBAddr){    __align(16)    DeblockingParameters params;    // prepare deblocking parameters    params.nMBAddr = MBAddr;    ResetDeblockingVariables(&params);    PrepareDeblockingParametersBSlice(&params);    // perform deblocking    DeblockLuma(VERTICAL_DEBLOCKING, &params);    DeblockLuma(HORIZONTAL_DEBLOCKING, &params);    DeblockChroma(VERTICAL_DEBLOCKING, &params);    DeblockChroma(HORIZONTAL_DEBLOCKING, &params);} // void H264VideoDecoder::DeblockMacroblockBSlice(Ipp32u MBAddr)void H264VideoDecoder::DeblockLuma(Ipp32u dir, DeblockingParameters *pParams)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -