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

📄 umc_vc1_deblock.cpp

📁 audio-video-codecs.rar语音编解码器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* /////////////////////////////////////////////////////////////////////////////
//
//                  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) 2004-2007 Intel Corporation. All Rights Reserved.
//
//
//          VC-1 (VC1) decoder, deblocking
//
*/
#include "umc_defs.h"

#if defined (UMC_ENABLE_VC1_VIDEO_DECODER)

#include "umc_vc1_dec_seq.h"
#include "umc_vc1_common_defs.h"
#include "umc_vc1_dec_debug.h"

typedef enum
{
    LFilterSimplePFrame    = 0,
    LFilterMainPFrame      = 1,
    LFilterAdvancePFrame   = 3, /* 2 - VC1_PROFILE_RESERVED */
    LFilterMainPInterFrame = 4
} LFilterType;

static const Ipp32s deblock_table[16] = {IPPVC_EDGE_ALL ,
                                      IPPVC_EDGE_QUARTER_1 +  IPPVC_EDGE_HALF_2,
                                      IPPVC_EDGE_QUARTER_2 +  IPPVC_EDGE_HALF_2,
                                      IPPVC_EDGE_HALF_2,

                                      IPPVC_EDGE_HALF_1 + IPPVC_EDGE_QUARTER_3,
                                      IPPVC_EDGE_QUARTER_1 +  IPPVC_EDGE_QUARTER_3,
                                      IPPVC_EDGE_QUARTER_2 + IPPVC_EDGE_QUARTER_3,
                                      IPPVC_EDGE_QUARTER_3,

                                      IPPVC_EDGE_HALF_1+ IPPVC_EDGE_QUARTER_4,
                                      IPPVC_EDGE_QUARTER_1+ IPPVC_EDGE_QUARTER_4,
                                      IPPVC_EDGE_QUARTER_2+ IPPVC_EDGE_QUARTER_4,
                                      IPPVC_EDGE_QUARTER_4,

                                      IPPVC_EDGE_HALF_1,
                                      IPPVC_EDGE_QUARTER_1,
                                      IPPVC_EDGE_QUARTER_2,
                                      0};


//static const Ipp32s deblock_table_2[4] = {IPPVC_EDGE_HALF_1,
//                                       IPPVC_EDGE_QUARTER_1,
//                                       IPPVC_EDGE_QUARTER_2,
//                                       0};

static const Ipp32s deblock_table_2[4] = {IPPVC_EDGE_ALL,
                                          IPPVC_EDGE_HALF_1,
                                          IPPVC_EDGE_HALF_2,
                                          0};

static void HorizontalDeblockingLumaP(Ipp8u* pUUpBlock,
                                      Ipp32u Pquant,
                                      Ipp32s Pitch,
                                      const VC1MB* _pMB,
                                      const VC1MB* _pnMB,
                                      LFilterType _type)
{
    Ipp32s SBP = 0;

    Ipp32s count = 0;
    Ipp32s flag_ext = 0;
    Ipp32s flag_int = 0;

    Ipp32s Edge_ext = 3; /* Mark bottom left and right subblocks */
    Ipp32s Edge_int = 0;

    Ipp32s SBP_cur_count  = 0;
    Ipp32s SBP_next_count = 2;
    if (_pMB != _pnMB)
    {
        SBP_next_count = 0;
        SBP_cur_count  = 2;
    }
    for(count = 0; count<2;count++)
    {
        Edge_ext = 3;
        Edge_int = 0;
        SBP = _pMB->m_pBlocks[SBP_cur_count].SBlkPattern;
        if (_pnMB)
        {
            if ((LFilterMainPInterFrame != _type)
                &&(_pMB->m_pBlocks[SBP_cur_count].blkType < VC1_BLK_INTRA_TOP)
                &&(_pnMB->m_pBlocks[SBP_next_count].blkType < VC1_BLK_INTRA_TOP)
                &&(_pMB->m_pBlocks[SBP_cur_count].mv[0][0] == _pnMB->m_pBlocks[SBP_next_count].mv[0][0])
                &&(_pMB->m_pBlocks[SBP_cur_count].mv[0][1] == _pnMB->m_pBlocks[SBP_next_count].mv[0][1])
                )
            {
                Ipp32s DSBP = _pnMB->m_pBlocks[SBP_next_count].SBlkPattern;
                Ipp32s TSBP = SBP;
                Edge_ext = TSBP | (DSBP>>2);
                if (LFilterMainPFrame == _type)
                {
                    /* Historical fix for 4x4 blocks */
                    if (_pMB->m_pBlocks[SBP_cur_count].blkType==VC1_BLK_INTER4X4 && TSBP)
                        TSBP = 0xF;
                    if (_pnMB->m_pBlocks[SBP_next_count].blkType==VC1_BLK_INTER4X4 && DSBP)
                        DSBP = 0xF;
                }
                Edge_ext = TSBP | (DSBP>>2);
            }
            flag_ext += ((Edge_ext&3) << (count*2));
        }
        else
            flag_ext = 0;
        if ((_pMB->m_pBlocks[SBP_cur_count].blkType==VC1_BLK_INTER8X4) || (_pMB->m_pBlocks[SBP_cur_count].blkType==VC1_BLK_INTER4X4))
        {
            if ((SBP & 8) || (SBP & 2))
                Edge_int |= 2;
            if ((SBP & 4) || (SBP & 1))
                Edge_int |= 1;
        }
        flag_int += (Edge_int << (count*2));
        ++SBP_next_count;
        ++SBP_cur_count;
    }
    _own_FilterDeblockingLuma_HorEdge_VC1(pUUpBlock + 8*Pitch, Pquant,Pitch, deblock_table[flag_ext]);
    _own_FilterDeblockingLuma_HorEdge_VC1(pUUpBlock + 4*Pitch, Pquant,Pitch, deblock_table[flag_int]);
}

static void HorizontalDeblockingChromaP(Ipp8u* pUUpBlock,
                                      Ipp32u Pquant,
                                      Ipp32s Pitch,
                                      VC1Block* _pBlk,
                                      VC1Block* _pnBlk,
                                      LFilterType _type)
{

    Ipp32s SBP = _pBlk->SBlkPattern;
    Ipp32s Edge_int = 0;
    Ipp32s Edge_ext = 3;
    if (_pnBlk)
    {
        if ((LFilterMainPInterFrame != _type)
            &&(_pBlk->blkType < VC1_BLK_INTRA_TOP)
            &&(_pnBlk->blkType < VC1_BLK_INTRA_TOP)
            &&(_pBlk->mv[0][0] == _pnBlk->mv[0][0])
            &&(_pBlk->mv[0][1] == _pnBlk->mv[0][1])
            )
        {
            Ipp32s DSBP = _pnBlk->SBlkPattern;
            Ipp32s TSBP = SBP;
            if (LFilterMainPFrame == _type)
            {
                /* Historical fix for 4x4 blocks */
                if (_pBlk->blkType==VC1_BLK_INTER4X4 && TSBP)
                    TSBP = 0xF;
                if (_pnBlk->blkType==VC1_BLK_INTER4X4 && DSBP)
                    DSBP = 0xF;
            }
            Edge_ext = TSBP | (DSBP>>2);
        }
    }
    else
        Edge_ext  = 0;
    if ((_pBlk->blkType==VC1_BLK_INTER8X4) || (_pBlk->blkType==VC1_BLK_INTER4X4))
    {
        if ((SBP & 8) || (SBP & 2))
            Edge_int |= 2;
        if ((SBP & 4) || (SBP & 1))
            Edge_int |= 1;
    }

    _own_FilterDeblockingChroma_HorEdge_VC1(pUUpBlock + 8*Pitch, Pquant,Pitch, deblock_table_2[Edge_ext&3]);
    _own_FilterDeblockingChroma_HorEdge_VC1(pUUpBlock + 4*Pitch, Pquant,Pitch, deblock_table_2[Edge_int]);
}

static void VerticalDeblockingLumaP(Ipp8u* pUUpLBlock,
                                    Ipp32u Pquant,
                                    Ipp32s Pitch,
                                    VC1MB* _pMB,
                                    const VC1MB* _pnMB,
                                    LFilterType _type)
{
    Ipp32s SBP = 0;
    Ipp32s LSBP = 0;
    VC1Block* pL   = 0;


    Ipp32s count = 0;
    Ipp32s flag_ext = 0;
    Ipp32s flag_int = 0;

    Ipp32s Edge_ext = 3; /* Mark bottom left and right subblocks */
    Ipp32s Edge_int = 0;

    Ipp32s SBP_cur_count  = 0;
    Ipp32s SBP_next_count = 1;
    if (_pMB != _pnMB)
    {
        SBP_next_count = 0;
        SBP_cur_count  = 1;
    }

    for(count = 0; count<2;count++)
    {
        pL   = &_pMB->m_pBlocks[SBP_cur_count];
        Edge_ext = 3;
        Edge_int = 0;
        SBP = _pMB->m_pBlocks[SBP_cur_count].SBlkPattern;
        LSBP = SBP;
        if (_pnMB)
        {
            if (2 == SBP_cur_count)
            {
                pL   = &_pMB->m_pBlocks[SBP_cur_count-1];
                LSBP = pL->SBlkPattern;
            }
            if ((LFilterMainPInterFrame != _type)
                &&(_pMB->m_pBlocks[SBP_cur_count].blkType  < VC1_BLK_INTRA_TOP)
                &&(_pnMB->m_pBlocks[SBP_next_count].blkType < VC1_BLK_INTRA_TOP)
                &&(_pMB->m_pBlocks[SBP_cur_count].mv[0][0] == _pnMB->m_pBlocks[SBP_next_count].mv[0][0])
                &&(_pMB->m_pBlocks[SBP_cur_count].mv[0][1] == _pnMB->m_pBlocks[SBP_next_count].mv[0][1])
                )
            {
                Ipp32s RSBP = _pnMB->m_pBlocks[SBP_next_count].SBlkPattern;
                if (LFilterMainPFrame == _type)
                {
                    /* Historical reasons of VC-1 implementation */
                    /* Historical fix for 4x4 blocks */
                    if (pL->blkType==VC1_BLK_INTER4X4 && LSBP)
                        LSBP = 0xF;
                    if (_pnMB->m_pBlocks[SBP_next_count].blkType==VC1_BLK_INTER4X4 && RSBP)
                        RSBP = 0xF;
                }
                Edge_ext = LSBP | (RSBP>>1);
                Edge_ext = ( ((Edge_ext&4)>>1) + (Edge_ext&1));
            }
            flag_ext += ((Edge_ext&3) << (count*2));
        }
        else
            flag_ext = 0;
        if ((_pMB->m_pBlocks[SBP_cur_count].blkType==VC1_BLK_INTER4X8) || (_pMB->m_pBlocks[SBP_cur_count].blkType==VC1_BLK_INTER4X4))
        {
            if ((SBP & 8) || (SBP & 4))
                Edge_int |= 2;
            if ((SBP & 2) || (SBP & 1))
                Edge_int |= 1;
        }
        flag_int += (Edge_int << (count*2));
        SBP_next_count +=2;
        SBP_cur_count +=2;
    }
    _own_FilterDeblockingLuma_VerEdge_VC1(pUUpLBlock + 8, Pquant,Pitch, deblock_table[flag_ext]);
    _own_FilterDeblockingLuma_VerEdge_VC1(pUUpLBlock + 4, Pquant,Pitch, deblock_table[flag_int]);
}

static void VerticalDeblockingChromaP(Ipp8u* pUUpLBlock,
                                      Ipp32u Pquant,
                                      Ipp32s Pitch,
                                      VC1Block* _pBlk,
                                      VC1Block* _pnBlk,
                                      LFilterType _type)
{
    Ipp32s SBP =  _pBlk->SBlkPattern;
    Ipp32s LSBP = SBP;
    VC1Block* pL   = _pBlk;

    Ipp32s Edge_ext = 3; /* Mark bottom left and right subblocks */
    Ipp32s Edge_int = 0;


        if (_pnBlk)
        {
            if ((LFilterMainPInterFrame != _type)
                &&(_pBlk->blkType < VC1_BLK_INTRA_TOP)
                &&(_pnBlk->blkType < VC1_BLK_INTRA_TOP)
                &&(_pBlk->mv[0][0] == _pnBlk->mv[0][0])
                &&(_pBlk->mv[0][1] == _pnBlk->mv[0][1])
            )
            {
                Ipp32s RSBP = _pnBlk->SBlkPattern;
                if (LFilterMainPFrame == _type)

⌨️ 快捷键说明

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