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

📄 umc_h264_dec_decode_reconstruct.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        else        {            DeblockFrame(0,m_pCurrentFrame->totalMBs);        }    }    m_broken_buffer = 0;    return status;}StatusH264VideoDecoder::DecRecSegment_CABAC(                                      Ipp32u unumMBs        // updated on return with actual number decoded                                      ){    Status             status = UMC_OK;/*    Ipp32s             i;*/    Ipp32u             mbcount; // counts number of MB's decoded in loop    Ipp8u              mbtype = 0, quant_prev;    Ipp32s             iSQUANT;    bool               bIsBSlice;    bool               bClearMV;    //bool               bClearNC;    //Ipp32u             uSubBlockWidth = m_pCurrentFrame->subBlockSize().width;    Ipp32u            *pMBIntraTypes;    Ipp32u             mbXOffset, mbYOffset;    Ipp16s             SliceNum;    Ipp8u              CurrPicParamSetId;    Ipp8u              CurrSeqParamSetId;    bool               bUseConstrainedIntra;    bool               bUseDirect8x8Inference;    Ipp32u             MBSkipFlag=0;    bool               skip_next_fdf = 0;    Ipp32s             DBCount;    H264DecoderMBAddr  NextMB;    //    int                end_of_slice = 0;    Ipp32s             QPChromaIndex = 0;    Ipp8u              QPChroma;    Ipp8s*             pMVfL0Tmp = NULL;    Ipp8s*             pMVfL1Tmp = NULL;    H264DecoderMotionVector* pL0MVdTmp = NULL;    H264DecoderMotionVector* pL1MVdTmp = NULL;    Ipp8s*             pRefIndexes = NULL;    // new    mb_width = m_pCurrentFrame->macroBlockSize().width;    mb_height = m_pCurrentFrame->macroBlockSize().height;    quant_prev = m_mbinfo.mbs[m_CurSliceHeader.first_mb_in_slice].QP;    SliceNum = m_pCurrentFrame->m_mbinfo.mbs[m_CurSliceHeader.first_mb_in_slice].slice_id;    // Reset buffer pointers to start    bIsBSlice = (m_CurSliceHeader.slice_type == BPREDSLICE);    CurrPicParamSetId = m_CurSliceHeader.pic_parameter_set_id;    bUseConstrainedIntra =        m_PicParamSet[CurrPicParamSetId].constrained_intra_pred_flag != 0;    CurrSeqParamSetId = m_PicParamSet[CurrPicParamSetId].seq_parameter_set_id;    bUseDirect8x8Inference =        m_SeqParamSet[CurrSeqParamSetId].direct_8x8_inference_flag != 0;    H264DecoderFrame  **pRefPicList0;    H264DecoderFrame  **pRefPicList1;    pRefPicList0 = m_pCurrentFrame->GetRefPicList(SliceNum, 0)->m_RefPicList;    pRefPicList1 = m_pCurrentFrame->GetRefPicList(SliceNum, 1)->m_RefPicList;    Ipp8s          pFields_stub=0;    m_CurMBAddr = m_CurSliceHeader.first_mb_in_slice;    bool mbaff = (0 != m_CurSliceHeader.MbaffFrameFlag);    // reconstruct Data    IppStatus          sts        = ippStsNoErr;    bool                intra;    bool                intra16x16;    Ipp8u              *pYPlane, *pUPlane, *pVPlane;    Ipp32u              uPitch = m_pCurrentFrame->pitch();    Ipp32u              offsetY, offsetC;    Ipp32s              ChromaQPOffset = m_PicParamSet[m_CurrentPicParamSet].chroma_qp_index_offset;    // Current plane pointers    pYPlane = m_pCurrentFrame->m_pYPlane;    pUPlane = m_pCurrentFrame->m_pUPlane;    pVPlane = m_pCurrentFrame->m_pVPlane;    // Reset buffer pointers to start    // This works only as long as "batch size" for VLD and reconstruct    // is the same. When/if want to make them different, need to change this.    if (m_broken_buffer)    {        mbcount = m_broken_buffer_start_mb;        SliceNum = m_broken_buffer_start_slice;        DBCount = -1;        goto start_slice_header;    }    for (mbcount=0,DBCount=0; mbcount<unumMBs; mbcount++,DBCount++)    {        // Reset buffer pointers to start        m_pCoeffBlocksWrite = m_pCoeffBlocksBufStatic.Coeffs();        // Reset buffer pointers to start        // This works only as long as "batch size" for VLD and reconstruct        // is the same. When/if want to make them different, need to change this.        m_pCoeffBlocksRead = m_pCoeffBlocksBufStatic.Coeffs();        pMBIntraTypes = m_pMBIntraTypes + m_CurMBAddr*NUM_INTRA_TYPE_ELEMENTS;        // pel position of current macroblock in the luma plane        m_CurMB_X = (m_CurMBAddr % mb_width);        m_CurMB_Y = (m_CurMBAddr / mb_width);        mbXOffset = m_CurMB_X * 16;        mbYOffset = m_CurMB_Y * 16;        VM_ASSERT(mbXOffset < m_pCurrentFrame->lumaSize().width);        VM_ASSERT(mbYOffset < m_pCurrentFrame->lumaSize().height);        UpdateCurrentMBInfo();        // MV and RefIndex store for subblock 0 of the current macroblock.        bClearMV = true;        NextMB = m_mbinfo.active_next_mb_table[m_CurMBAddr];        m_cur_mb.LocalMacroblockInfo->QP = quant_prev;        m_cur_mb.GlobalMacroblockInfo->slice_id = SliceNum;        m_cur_mb.LocalMacroblockInfo->cbp4x4 =        m_cur_mb.LocalMacroblockInfo->cbp_bits =        m_cur_mb.LocalMacroblockInfo->cbp =        m_cur_mb.LocalMacroblockInfo->intra_chroma_mode = 0;        m_cur_mb.LocalMacroblockInfo->sbdir[0] =        m_cur_mb.LocalMacroblockInfo->sbdir[1] =        m_cur_mb.LocalMacroblockInfo->sbdir[2] =        m_cur_mb.LocalMacroblockInfo->sbdir[3] =D_DIR_FWD;        // Assume all subblocks have no transmitted coefficients initially.        // Update cbp4x4 when we see a coefficient.        UpdateNeighbouringAddresses();        pRefIndexes = m_cur_mb.RefIdxs[1]->RefIdxs;        Ipp32u i;        for (i = 0;i < 16;i += 1)            pRefIndexes[i] = -1;        pL0MVdTmp = m_cur_mb.MVs[2]->MotionVectors;        pL1MVdTmp = m_cur_mb.MVs[3]->MotionVectors;        pMVfL0Tmp = m_cur_mb.MVFlags[0]->MVFlags;        pMVfL1Tmp = m_cur_mb.MVFlags[1]->MVFlags;        // Reset intra_chroma_pred_mode        // Clear MVd buffers and initialize MV coding flags        for (i = 0;i < 16;i += 1)        {            pL0MVdTmp[i].mvx =                pL0MVdTmp[i].mvy = 0;            pL1MVdTmp[i].mvx =                pL1MVdTmp[i].mvy = 0;            pMVfL0Tmp[i] =                pMVfL1Tmp[i] = 0;        }        // when MB type is obtained calculate adresses        //UpdateNeighbouringAddress();        if (skip_next_fdf) UpdateNeighbouringBlocks();//need to calc this        if (bIsBSlice)        {            VM_ASSERT(pRefPicList1[0]);        }        while (1) // not really a loop, while used to enable use of break        {            // First decode the "macroblock header", e.g., macroblock type,            // intra-coding types, motion vectors and CBP.            // Get MB type, possibly change MBSKipCount to non-zero            status = DecodeMBType_CABAC(pMBIntraTypes,&MBSkipFlag,skip_next_fdf);            skip_next_fdf = false;            if (status != UMC_OK)                break;            mbtype = m_cur_mb.GlobalMacroblockInfo->mbtype;            if (mbtype == MBTYPE_SKIPPED)                break;            if (mbtype == MBTYPE_INTRA)            {                status = DecodeIntraTypes4x4_CABAC(/*pMB, */pMBIntraTypes, bUseConstrainedIntra);                if (status != UMC_OK)                    break;            }            if (mbtype == MBTYPE_PCM)            {                status = DecodeCoefficients_PCM(1);                // For PCM type MB, num coeffs are set by above call, cbp is                // set to all blocks coded (for deblock filter), MV are set to zero,                // QP is unchanged.                m_cur_mb.LocalMacroblockInfo->cbp4x4 = D_CBP_LUMA_DC | D_CBP_LUMA_AC | D_CBP_CHROMA_DC | D_CBP_CHROMA_AC;                m_cur_mb.LocalMacroblockInfo->cbp_bits = 0xffffffff;                m_prev_dquant = 0;                break; // no more to read from bitstream            }            if (IS_INTRA_MBTYPE(mbtype))            {                // Get chroma prediction mode                Ipp32u left_c, top_c;                Ipp32s nNum;                Ipp32u ctxIdxInc;                left_c =                    top_c = 0;                // get number of left macrobock                nNum = m_cur_mb.CurrentBlockNeighbours.mbs_left[0].mb_num;                if (0 <= nNum)                {                    if (m_mbinfo.mbs[nNum].intra_chroma_mode)                        left_c = 1;                }                // get number of above macroblock                nNum = m_cur_mb.CurrentBlockNeighbours.mb_above.mb_num;                if (0 <= nNum)                {                    if (m_mbinfo.mbs[nNum].intra_chroma_mode)                        top_c = 1;                }                ctxIdxInc = left_c + top_c;                if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[INTRA_CHROMA_PRED_MODE] + ctxIdxInc))                {                    ctxIdxInc = 3;                    if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[INTRA_CHROMA_PRED_MODE] + ctxIdxInc))                    {                        if (m_pBitStream->DecodeSingleBin_CABAC(ctxIdxOffset[INTRA_CHROMA_PRED_MODE] + ctxIdxInc))                        {                            m_cur_mb.LocalMacroblockInfo->intra_chroma_mode = 3;                        }                        else                        {                            m_cur_mb.LocalMacroblockInfo->intra_chroma_mode = 2;                        }                    }                    else                    {                        m_cur_mb.LocalMacroblockInfo->intra_chroma_mode = 1;                    }                }                else                {                    m_cur_mb.LocalMacroblockInfo->intra_chroma_mode = 0;                }            }            if ( (!IS_INTRA_MBTYPE(mbtype)) && (mbtype != MBTYPE_DIRECT))            {                // Motion Vector Computation                if (bIsBSlice && (m_cur_mb.GlobalMacroblockInfo->mbtype == MBTYPE_INTER_8x8 ||                    m_cur_mb.GlobalMacroblockInfo->mbtype == MBTYPE_INTER_8x8_REF0))                {                    // First, if B slice and MB is 8x8, set the MV for any DIRECT                    // 8x8 partitions. The MV for the 8x8 DIRECT partition need to                    // be properly set before the MV for subsequent 8x8 partitions                    // can be computed, due to prediction. The DIRECT MV are computed                    // by a separate function and do not depend upon block neighbors for                    // predictors, so it is done here first.                    if (!m_bUseSpatialDirectMode)                    {                        // temporal DIRECT prediction                        Ipp32u sb, sboffset;                        sboffset = 0;                        for (sb = 0; sb < 4; sb++)                        {                            if (m_cur_mb.GlobalMacroblockInfo->sbtype[sb] == SBTYPE_DIRECT)                            {                                // set DIRECT motion vectors                                Ipp32s yM=subblock_block_mapping[sb];                                Ipp32s mb_col = GetColocatedLocation(pRefPicList1[0],0,yM);                                if (!bUseDirect8x8Inference &&                                    IS_INTER_MBTYPE(pRefPicList1[0]->m_mbinfo.mbs[mb_col].mbtype))                                    DecodeDirectMotionVectorsTemporal(sboffset,                                    pRefPicList0, pRefPicList1,&pFields_stub,&pFields_stub,                                    true);                                else                                    DecodeDirectMotionVectorsTemporal_8x8Inference(                                    pRefPicList0, pRefPicList1,&pFields_stub,&pFields_stub,                                    sb);                            }                            if (sb == 1)                                sboffset += 4*2 - 2;                            else                                sboffset += 2;                        }    // for sb                    }    // temporal DIRECT                    else                    {                        if (m_cur_mb.GlobalMacroblockInfo->sbtype[0] == SBTYPE_DIRECT ||                            m_cur_mb.GlobalMacroblockInfo->sbtype[1] == SBTYPE_DIRECT ||                            m_cur_mb.GlobalMacroblockInfo->sbtype[2] == SBTYPE_DIRECT ||                            m_cur_mb.GlobalMacroblockInfo->sbtype[3] == SBTYPE_DIRECT)                        {

⌨️ 快捷键说明

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