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

📄 umc_h264_dec_decode_mb_cabac.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                                          m++,                                          &mvpx,                                          &mvpy);            // new & old            mv.mvx  = (Ipp16s) (mvpx + (Ipp32s) mvd.mvx);            mv.mvy  = (Ipp16s) (mvpy + (Ipp32s) mvd.mvy);            // new            pMV[k] = mv;            pMVd[k] = mvd;            break;        case CodLeft:            pMV[k] = pMV[k - 1];            pMVd[k] = pMVd[k - 1];            break;        case CodAbov:            pMV[k]  = pMV[k - 4];            pMVd[k]  = pMVd[k - 4];            break;        case CodSkip:            pMVd[k] = MV0;            break;        }    } // for i    return status;} // Status H264VideoDecoder::GetMVD4x4_CABAC(Ipp32u* pBlkIdx,// ---------------------------------------------------------------------------//  H264VideoDecoder::GetSE_RefIdx_CABAC()//    read syntax element ref_idx_lx (section 9.3.3.1.1.6)// ---------------------------------------------------------------------------Ipp32s H264VideoDecoder::GetSE_RefIdx_CABAC(                                            Ipp32s ListNum,                                            Ipp32s BlockNum                                            ){    // this variable used only in debug purposes    Ipp32u ctxIdxInc = 0;    Ipp32s ref_idx = 0;    bool isLeftAvail=true, isTopAvail=true;    // new    Ipp8s *LeftRefIdx = m_cur_mb.RefIdxs[ListNum]->RefIdxs + BlockNum - 1;    Ipp8s *TopRefIdx = m_cur_mb.RefIdxs[ListNum]->RefIdxs + BlockNum - 4;    Ipp8s *LeftMVFlag = m_cur_mb.MVFlags[ListNum]->MVFlags + BlockNum - 1;    Ipp8s *TopMVFlag = m_cur_mb.MVFlags[ListNum]->MVFlags + BlockNum - 4;    Ipp32s iTopMB = m_CurMBAddr, iLeftMB = m_CurMBAddr;    if (BLOCK_IS_ON_LEFT_EDGE(BlockNum))    {        iLeftMB = m_cur_mb.CurrentBlockNeighbours.mbs_left[BlockNum / 4].mb_num;        isLeftAvail = (0 <= iLeftMB);        if (isLeftAvail)        {            Ipp32s iNum;            iNum = m_cur_mb.CurrentBlockNeighbours.mbs_left[BlockNum / 4].block_num;            LeftRefIdx = m_pCurrentFrame->m_mbinfo.RefIdxs[ListNum][iLeftMB].RefIdxs + iNum;            LeftMVFlag = m_mbinfo.MVFlags[ListNum][iLeftMB].MVFlags + iNum;        }    }    if (BLOCK_IS_ON_TOP_EDGE(BlockNum))    {        iTopMB = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;        isTopAvail = (0 <= iTopMB);        if (isTopAvail)        {            Ipp32s iNum;            iNum = m_cur_mb.CurrentBlockNeighbours.mb_above.block_num;            TopRefIdx = m_pCurrentFrame->m_mbinfo.RefIdxs[ListNum][iTopMB].RefIdxs + iNum + BlockNum;            TopMVFlag = m_mbinfo.MVFlags[ListNum][iTopMB].MVFlags + iNum + BlockNum;        }    }    Ipp8u lval = (Ipp8u) (pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo) <                          GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iLeftMB]));    Ipp8u tval = (Ipp8u) (pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo) <                          GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iTopMB]));    if (isLeftAvail && (*LeftRefIdx > lval) && (*LeftMVFlag))        ctxIdxInc ++;    if (isTopAvail && (*TopRefIdx > tval) && (*TopMVFlag))        ctxIdxInc += 2;    if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[REF_IDX_L0] + ctxIdxInc)) // binIdx 0    {        ref_idx ++;        if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[REF_IDX_L0] + 4)) // binIdx 1        {            ref_idx ++;            while (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[REF_IDX_L0] + 5)) // binIdx 2+                ref_idx ++;        }    }    return ref_idx;} // Ipp32s H264VideoDecoder::GetSE_RefIdx_CABAC(Ipp32s ListNum,// ---------------------------------------------------------------------------//  H264VideoDecoder::GetSE_MVD_CABAC()//    read syntax element mvd_lx (section 9.3.3.1.1.7)// ---------------------------------------------------------------------------H264DecoderMotionVector H264VideoDecoder::GetSE_MVD_CABAC(                                                          Ipp32s ListNum,                                                          Ipp32s BlockNum                                                          ){    // this variable used only in debug purposes    bool isLeftAvail=true,isTopAvail=true;    Ipp32u ctxIdxIncx=0;    Ipp32u ctxIdxIncy=0;    Ipp32s sign;    Ipp32u mvdx,mvdy,lcode,k;    Ipp32s symbol,binary_symbol;    H264DecoderMotionVector *LeftMVd = m_cur_mb.MVs[ListNum + 2]->MotionVectors + BlockNum - 1;    H264DecoderMotionVector *TopMVd = m_cur_mb.MVs[ListNum + 2]->MotionVectors + BlockNum - 4;    Ipp32s iTopMB = m_CurMBAddr, iLeftMB = m_CurMBAddr;    if (BLOCK_IS_ON_LEFT_EDGE(BlockNum))    {        Ipp32s iBlock;        iLeftMB = m_cur_mb.CurrentBlockNeighbours.mbs_left[BlockNum / 4].mb_num;        iBlock = m_cur_mb.CurrentBlockNeighbours.mbs_left[BlockNum / 4].block_num;        isLeftAvail = (0 <= iLeftMB);        if (isLeftAvail)        {            LeftMVd = m_mbinfo.MVDeltas[ListNum][iLeftMB].MotionVectors + iBlock;        }    }    if (BLOCK_IS_ON_TOP_EDGE(BlockNum))    {        iTopMB = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;        Ipp32s iBlock;        iBlock = m_cur_mb.CurrentBlockNeighbours.mb_above.block_num + BlockNum;        isTopAvail = (0 <= iTopMB);        if (isTopAvail)        {            TopMVd = m_mbinfo.MVDeltas[ListNum][iTopMB].MotionVectors + iBlock;        }    }    Ipp32u mv_y;    if (isLeftAvail)    {        ctxIdxIncx += ABS(LeftMVd->mvx);        mv_y = ABS(LeftMVd->mvy);        if (GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iLeftMB]) >            pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo))            mv_y <<= 1;        else if (GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iLeftMB]) <                 pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo))            mv_y >>= 1;        ctxIdxIncy += mv_y;    }    if (isTopAvail)    {        ctxIdxIncx += ABS(TopMVd->mvx);        mv_y = ABS(TopMVd->mvy);        if (GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iTopMB]) >            pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo))            mv_y <<= 1;        else if (GetMBFieldDecodingFlag(m_pCurrentFrame->m_mbinfo.mbs[iTopMB]) <                 pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo))            mv_y >>= 1;        ctxIdxIncy += mv_y;    }    ctxIdxIncx = ctxIdxIncx < 3 ? 0 : (ctxIdxIncx > 32 ? 2 : 1);    ctxIdxIncy = ctxIdxIncy < 3 ? 0 : (ctxIdxIncy > 32 ? 2 : 1);    Ipp32s ctxIdxInc = ctxIdxIncx;    Ipp32s code = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_0] + ctxIdxInc);    if(!code)    {        mvdx = 0;    }    else    {        ctxIdxInc = 3;        code = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_0] + ctxIdxInc);        if (code)        {            code = 0;            ctxIdxInc += 1;            for(;;)            {                lcode = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_0] + ctxIdxInc);                if (6 > ctxIdxInc)                    ctxIdxInc += 1;                code++;                if(!lcode || code == 7) break;            }            if (lcode != 0)            {                symbol = 0;                binary_symbol = 0;                k = 3;                for(;;)                {                    if (0 == m_pBitStream->DecodeBypass_CABAC())                        break;                    symbol += (1<<k);                    k++;                }                while (k--)                             //next binary part                {                    if (m_pBitStream->DecodeBypass_CABAC())                      binary_symbol |= (1<<k);                };                code += symbol + binary_symbol + 1;            }        }        code++;        sign = m_pBitStream->DecodeBypass_CABAC();        mvdx = ((sign != 0) ? (-code) : code);    }    ctxIdxInc = ctxIdxIncy;    code = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_1] + ctxIdxInc);    if(!code)    {        mvdy = 0;    }    else    {        ctxIdxInc = 3;        code = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_1] + ctxIdxInc);        if (code)        {            code = 0;            ctxIdxInc += 1;            for(;;)            {                lcode = m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[MVD_L0_1] + ctxIdxInc);                if (6 > ctxIdxInc)                    ctxIdxInc += 1;                code++;                if(!lcode || code == 7) break;            }            if (lcode != 0)            {                symbol = 0;                binary_symbol = 0;                k = 3;                for(;;)                {                    if (0 == m_pBitStream->DecodeBypass_CABAC())                        break;                    symbol += (1<<k);                    k++;                }                while (k--)                             //next binary part                {                    if (m_pBitStream->DecodeBypass_CABAC())                      binary_symbol |= (1<<k);                };                code += symbol + binary_symbol + 1;            }        }        code++;        sign = m_pBitStream->DecodeBypass_CABAC();        mvdy = ((sign != 0) ? (-code) : code);    }    H264DecoderMotionVector mvd;    mvd.mvx = (Ipp16s) mvdx;    mvd.mvy = (Ipp16s) mvdy;    return mvd;} // H264DecoderMotionVector H264VideoDecoder::GetSE_MVD_CABAC(Ipp32s ListNum,//my CABAC insertionStatus H264VideoDecoder::DecodeCoefficients4x4_CABAC(Ipp32u cbp){    // this variable used only in debug purposes    #define BIT_CHECK(x,n)  ((int)(((x)&(1<<(n)))>>(n)))    Status ps = UMC_OK;    //Ipp32u blockcbp;    // 1 bit per 4x4 block of possible coeffs (1=coeffs present)                    //  bit 0: 16x16 intra DC                    //  bit 1-4: luma 8x8 luma block 0, 4x4 blocks 0..3                    //  bit 5-8: luma 8x8 luma block 1, 4x4 blocks 4..7                    //  bit 9-12: luma 8x8 luma block 2, 4x4 blocks 8..11                    //  bit 13-16: luma 8x8 luma block 3, 4x4 blocks 12..15                    //  bit 17: chroma DC, U                    //  bit 18: chroma DC, V                    //  bit 19-22: chroma blocks 0..3 U                    //  bit 23-26: chroma blocks 0..3 V    Ipp32u uBlockBit;    Ipp32s pos;    Ipp16s *pPosCoefbuf = m_pCoeffBlocksWrite;    Ipp32u uMBType = m_cur_mb.GlobalMacroblockInfo->mbtype;    Ipp32u uNumCoeff;    int i, j, k;    int coef_ctr;    int start_scan;    int context;    int run, level;    Ipp16s coeff[17]; // one more for EOB    int coeff_count = -1;    int index       =  0;    int bit         = 0;    int top_bit     = 1;    int left_bit    = 1;    int cbp_bit     = 1;    int sb_x[16] = {0, 1, 0, 1,                    2, 3, 2, 3,                    0, 1, 0, 1,                    2, 3, 2, 3};    int sb_y[16] = {0, 0, 1, 1,                    0, 0, 1, 1,                    2, 2, 3, 3,                    2, 2, 3, 3};    int crsb_x, crsb_y;    int def_bit = ((uMBType == MBTYPE_INTRA ||                    uMBType == MBTYPE_INTRA_16x16) ?                   (1) : (0));    const Ipp32u *ctxBase;    const Ipp32s *single_scan;    Ipp32s iMBAbove, iMBLeft;    Ipp32u ctxIdxInc;//this code need additional checking    if (pGetMBFieldDecodingFlag(m_cur_mb.GlobalMacroblockInfo))    {        ctxBase = ctxIdxOffset4x4FieldCoded;        single_scan = mp_scan4x4[1];    }    else    {

⌨️ 快捷键说明

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