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

📄 umc_h264_dec_decode_mb_types_cabac.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*////              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_internal_cabac.h"#include "vm_types.h"#include "vm_debug.h"#include <ippi.h>namespace UMC{    extern        Ipp8u CodeToMBTypeB[];    // lookup table to extract prediction direction from MB type code for    // 16x8 and 8x16 MB types. Contains direction for first and second    // subblocks at each entry.    extern        Ipp8u CodeToBDir[][2];    const        vm_byte NIT2LIN[16] =    {        0,  1,  4,  5,        2,  3,  6,  7,        8,  9,  12, 13,        10, 11, 14, 15    };Ipp32u H264VideoDecoder::Intra_MB_type_CABAC(){    // this variable used only in debug purposes    Ipp32u left_c, top_c;    Ipp32u code;    Ipp32u curr_mb_type;    Ipp32s nBlockNum;    Ipp32u ctxIdxInc;    if (m_CurSliceHeader.MbaffFrameFlag)    {        if (pGetMBBottomFlag(m_cur_mb.GlobalMacroblockInfo) == 0)        {            Ipp32s nLeft, nTop;            left_c = top_c = 0;            nLeft = m_cur_mb.CurrentMacroblockNeighbours.mb_A;            nTop = m_cur_mb.CurrentMacroblockNeighbours.mb_B;            if (0 <= nLeft)            {                if (1 == GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[nLeft]))                    left_c = 1;            }            if (0 <= nTop)            {                if (1 == GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[nTop]))                    top_c = 1;            }            ctxIdxInc = left_c + top_c;            Ipp32u  bit = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_FIELD_DECODING_FLAG] + ctxIdxInc);            pSetPairMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,m_cur_mb.GlobalMacroblockPairInfo,bit);        }    }    else    {        pSetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo,0);    }    UpdateNeighbouringBlocks();    left_c = top_c = 0;    nBlockNum = m_cur_mb.CurrentBlockNeighbours.mbs_left[0].mb_num;    if (0 <= nBlockNum)    {        if (m_mbinfo.mbs[nBlockNum].mbtypeBS != MBTYPE_INTRA)            left_c = 1;    }    nBlockNum = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;    if (0 <= nBlockNum)    {        if (m_mbinfo.mbs[nBlockNum].mbtypeBS != MBTYPE_INTRA)            top_c = 1;    }    ctxIdxInc = left_c + top_c;    if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + ctxIdxInc)) // 4x4 Intra      return 0;    // 16x16 Intra    if (m_pBitStream->DecodeSymbolEnd_CABAC())        return 25;    code = 2;    code = (code << 1) |        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + 3);    code = (code << 1) |        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + 4);    if (code & 1)    {        code = (code << 1) |            m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + 5);    }    code = (code << 1) |        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + 6);    code = (code << 1) |        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_I] + 7);    // See table 9-26 of H.264    // for translating bin string (code) into mb_type (curr_mb_type)    if (35 >= code)        curr_mb_type = code - 31;    else if (43 >= code)        curr_mb_type = code - 27;    else if (79 >= code)        curr_mb_type = code - 67;    else // if (95 >= code)        curr_mb_type = code - 71;    return curr_mb_type;} // Ipp32u H264VideoDecoder::Intra_MB_type_CABAC()Ipp32u H264VideoDecoder::P_Picture_MB_type_CABAC(){    Ipp32u curr_mb_type;    Ipp32u code;    code =        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 0);    // decode predicted type(s)    if (0 == code)    {        code = (code << 1) |            m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 1);        code = (code << 1) |            m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] +                                                        ((code & 1) ? (3) : (2)));        // See table 9-27 of H.264 standard        // to translating bin string (code) to mb_type (curr_mb_type)        if (0 == code)            curr_mb_type = 0;        else if (3 == code)            curr_mb_type = 1;        else if (2 == code)            curr_mb_type = 2;        else // if (1 == code)            curr_mb_type = 3;    }    // decode intra type(0)    else    {        code = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 3);        // I_4x4 type        if (0 != code)        {            code = (code << 1) |                m_pBitStream->DecodeSymbolEnd_CABAC();            // I_PCM type            if(3 != code)            {                code = (code << 1) |                    m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 4);                code = (code << 1) |                    m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 5);                if (code & 1)                {                    code = (code << 1) |                        m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 5);                }                code = (code << 1) |                    m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 6);                code = (code << 1) |                    m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_P_SP] + 6);                // See table 9-26 of H.264                // for translating bin string (code) into mb_type (curr_mb_type)                if (35 >= code)                    curr_mb_type = code - 31 + 5;                else if (43 >= code)                    curr_mb_type = code - 27 + 5;                else if (79 >= code)                    curr_mb_type = code - 67 + 5;                else // if (95 >= code)                    curr_mb_type = code - 71 + 5;            }            else                curr_mb_type = 25 + 5;        }        else            curr_mb_type = 0 + 5;    }    return curr_mb_type;} // Ipp32u H264VideoDecoder::P_Picture_MB_type_CABAC()Ipp32u H264VideoDecoder::B_Picture_MB_type_CABAC(){    // this variable used only in debug purposes    Ipp32u left_c, top_c;    Ipp32u ctxIdxInc;    Ipp32u mbtype;    Ipp32s nMBNum;    left_c = top_c = 0;    // get number of left macroblock    nMBNum = m_cur_mb.CurrentBlockNeighbours.mbs_left[0].mb_num;    if (0 <= nMBNum)    {        if ((m_mbinfo.mbs[nMBNum].mbtypeBS != MBTYPE_SKIPPED) &&            (m_mbinfo.mbs[nMBNum].mbtypeBS != MBTYPE_DIRECT))            left_c = 1;    }    // get number of above macroblock    nMBNum = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;    if (0 <= nMBNum)    {        if ((m_mbinfo.mbs[nMBNum].mbtypeBS != MBTYPE_SKIPPED) &&            (m_mbinfo.mbs[nMBNum].mbtypeBS != MBTYPE_DIRECT))            top_c = 1;    }    ctxIdxInc = left_c + top_c;    if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + ctxIdxInc)) // prefix 0    {        mbtype = 0; // B_16x16_Direct    }    else    {        if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 3)) // prefix 1        {            // binStr 100 and 101            mbtype = 1 + m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5);        }        else        {            if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 4)) // prefix 2            {                // binStr = 110...                mbtype = 3;                mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5) << 2; // prefix 3                mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5) << 1; // prefix 4                mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5); // prefix 5            }            else            {                if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5)) // prefix 3                {                    // binStr = 1110...                    mbtype = 12 + (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5) << 2); // prefix 4                    mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5) << 1; // prefix 5                    mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5); // prefix 6                }                else                {                    if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5)) // prefix 4                    {                        if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5)) // prefix 5                        {                            // binStr = 1111000 and 1111001                            mbtype = 20 + m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5); // 20 or 21                        }                        else                        {                            // prefix binStr = 111101                            // ctxIdxOffset = 32                            if (!m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5)) // suffix 0                            {                                mbtype = 23; // I_4x4                            }                            else                            {                                if (m_pBitStream->DecodeSymbolEnd_CABAC()) // suffix 1                                {                                    mbtype = 48; // I_PCM                                }                                else // I_16x16                                {                                    mbtype = 24 + m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 6) * 12; // suffix 2                                    if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 7)) // suffix 3                                        mbtype += 4 + (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 7) << 2); // suffix 4                                    mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 8) << 1; // suffix 4 or 5                                    mbtype += m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 8); // suffix 5 or 6                                }                            }                        }                    }                    else                    {                        // binStr = 111110 and 111111                        mbtype = 11 << m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MB_TYPE_B] + 5); // 11 or 22                    }                }            }        }    }    return mbtype;} // Ipp32u H264VideoDecoder::B_Picture_MB_type_CABAC()const vm_byte block4_block8[16] ={    0,  0,  1,  1,    0,  0,  1,  1,    2,  2,  3,  3,    2,  2,  3,  3};//read block CBPIpp32u H264VideoDecoder::DecodeCBP_CABAC(Ipp8u color_format){    // this variable used only in debug purposes    Ipp32u left_c, top_c;    Ipp32u cbp = 0;    Ipp32u cbp_bit;    Ipp32u mask;    Ipp32u ctxIdxInc;    Ipp32u i, j;    Ipp32s nBNum;    Ipp32s nTop, nLeft;    //  coding of luma part (bit by bit)    for (i = 0; i < 2; i++)    {        for (j = 0; j < 2; j++)        {            if (!i)            {                // get number of above macroblock                nTop = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;                if (0 <= nTop)                {                    nBNum = m_cur_mb.CurrentBlockNeighbours.mb_above.block_num;                    top_c = (m_mbinfo.mbs[nTop].cbp &                             (1 << (block4_block8[nBNum + j * 2]))|| m_mbinfo.mbs[nTop].mbtypeBS==MBTYPE_PCM) ? (0) : (1);                }                else                    top_c = 0;            }            else

⌨️ 快捷键说明

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