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

📄 umc_h264_dec_reconstruct_mb_fld.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) 2005 Intel Corporation. All Rights Reserved.////*/#include "umc_h264_dec.h"using namespace IppLevel;namespace UMC{static     Ipp16s        zeroArray[16] = {0};static const     Ipp32u    BLK_NUM_MASK[2][4][4]  = {                                     {{2<<0,2<<2,2<<8,2<<10},{2<<1,2<<3,2<<9,2<<11},{2<<4,2<<6,2<<12,2<<14},{2<<5,2<<7,2<<13,2<<15}},                                     {{2<<0,2<<1,2<<4,2<<5}, {2<<2,2<<3,2<<6,2<<7}, {2<<8,2<<9,2<<12,2<<13},{2<<10,2<<11,2<<14,2<<15}}                                    };voidH264VideoDecoder::ReconstructMacroblock_FLD( Ipp8u               *pDstY, Ipp8u               *pDstV, Ipp8u               *pDstU, Ipp32u mbXOffset,        // for edge clipping Ipp32u mbYOffset, bool bUseDirect8x8Inference, H264DecoderFrame **pRefPicList0, H264DecoderFrame **pRefPicList1, Ipp8s *pFields0, Ipp8s *pFields1, Ipp8u  color_format ){    // this variable is used only in debug purposes    Ipp8u   *pRefYPlane;    Ipp8u   *pRefVPlane;    Ipp8u   *pRefUPlane;    Ipp8u   *pRef;    H264DecoderMotionVector *pMV;    Ipp8s   *pRefIndex;    Ipp32u mbtype = m_cur_mb.GlobalMacroblockInfo->mbtype;    Ipp32u blocktype;    Ipp8u *psbtype = m_cur_mb.GlobalMacroblockInfo->sbtype;    Ipp8u *psbdir = m_cur_mb.LocalMacroblockInfo->sbdir;    Ipp32s offsetY;    Ipp32u offsetMV;    Ipp32u offsetToBlock;    Ipp32s pitch;    Ipp32u /*subBlockPitch,*/ block, i, loopCnt;    Ipp32s xint, yint, xh, yh;    Ipp32s mvx, mvy, mvyc;    Ipp32s width;    Ipp32s height;    Ipp32s xpos, ypos, sbwidth, sbheight;    IppiSize        roi, roi_cr;    // pointers for current subblock    H264DecoderMotionVector *pMV_sb;    Ipp8u *pRefY_sb;    Ipp8u *pDstY_sb;    Ipp8u *pRefV_sb;    Ipp8u *pDstV_sb;    Ipp8u *pRefU_sb;    Ipp8u *pDstU_sb;    bool bIsDirect = false;    Ipp32s MBRef;    Ipp8u *psbtype_ref;    Ipp8u ref_pic_struct;    Ipp32u uBlockDir;        // one of D_DIR_FWD, D_DIR_BWD, D_DIR_BIDIR    bool bBidirWeightMB = false;    // is bidir weighting in effect for the MB?    bool bUnidirWeightMB = false;    // is explicit L0 weighting in effect for the MB?    bool bUnidirWeightSB = false;    // is explicit L0 weighting in effect for the subblock?    Ipp32u uSliceNum;    // Optional weighting vars    Ipp32u CurrPicParamSetId;    Ipp32u weighted_bipred_idc = 0;    Ipp32u luma_log2_weight_denom;    Ipp32u chroma_log2_weight_denom;    PredWeightTable *pPredWeight[2] = {NULL, NULL};        // [L0,L1]    Ipp32s iDistScaleFactor;    Ipp8s RefFieldTop;    const Ipp32s *pDistScaleFactors;    H264DecoderMotionVector *pMVFwd = NULL;    H264DecoderMotionVector *pMVBwd = NULL;    Ipp8s *pRefIndexL0 = NULL;    Ipp8s *pRefIndexL1 = NULL;    Ipp8s RefIndexL0 = NULL;    Ipp8s RefIndexL1 = NULL;    VM_ASSERT(IS_INTER_MBTYPE(m_cur_mb.GlobalMacroblockInfo->mbtype));    width = m_pCurrentFrame->lumaSize().width;    height = m_pCurrentFrame->lumaSize().height;    pitch = m_pCurrentFrame->pitch();    //    subBlockPitch = m_pCurrentFrame->subBlockSize().width;    pitch *= 2;    offsetY = mbXOffset + mbYOffset*pitch;    offsetMV = 0;    uSliceNum = m_cur_mb.GlobalMacroblockInfo->slice_id;    CurrPicParamSetId = m_CurSliceHeader.pic_parameter_set_id;    pMVFwd = m_cur_mb.MVs[0]->MotionVectors;    pRefIndexL0 = m_cur_mb.RefIdxs[0]->RefIdxs;    if (((PREDSLICE == m_CurSliceHeader.slice_type) ||        (S_PREDSLICE == m_CurSliceHeader.slice_type)) &&        (m_PicParamSet[CurrPicParamSetId].weighted_pred_flag != 0))    {        // L0 weighting specified in pic param set. Get weighting params        // for the slice.        pPredWeight[0] = &m_pPredWeight_L0[uSliceNum*MAX_NUM_REF_FRAMES];        luma_log2_weight_denom = m_CurSliceHeader.luma_log2_weight_denom;        chroma_log2_weight_denom = m_CurSliceHeader.chroma_log2_weight_denom;        bUnidirWeightMB = true;    }    // get luma interp func pointer table in cache    if (m_CurSliceHeader.slice_type == BPREDSLICE)    {        VM_ASSERT(pRefPicList1[0]);        Ipp32s yM=0;        MBRef = GetColocatedLocation(pRefPicList1[0],pFields1[0],yM);        pMVBwd = m_cur_mb.MVs[1]->MotionVectors;        pRefIndexL1 = m_cur_mb.RefIdxs[1]->RefIdxs;        psbtype_ref = pRefPicList1[0]->m_mbinfo.mbs[MBRef].sbtype;        // DIRECT MB have the same subblock partition structure as the        // colocated MB. Take advantage of that to perform motion comp        // for the direct MB using the largest partitions possible.        if (mbtype == MBTYPE_DIRECT || mbtype == MBTYPE_SKIPPED)        {            //if (pRefPicList1[0]->m_mbinfo.mbs->mbtype == MBTYPE_INTER_8x8 ||            //    pRefPicList1[0]->m_mbinfo.mbs->mbtype == MBTYPE_INTER_8x8_REF0 ||            //    IS_INTRA_MBTYPE(mbtype))                mbtype = pRefPicList1[0]->m_mbinfo.mbs[MBRef].mbtype;                //mbtype = MBTYPE_INTER_8x8; //???            bIsDirect = true;            // If the colocated MB is INTRA, all MV are zero            //if (IS_INTRA_MBTYPE(mbtype))            //    mbtype = MBTYPE_SKIPPED;            //else                mbtype = MBTYPE_INTER_8x8;        }        // Bi-dir weighting?        weighted_bipred_idc = m_PicParamSet[CurrPicParamSetId].weighted_bipred_idc;        if (weighted_bipred_idc == 1)        {            // explicit bidir weighting            pPredWeight[0] = &m_pPredWeight_L0[uSliceNum*MAX_NUM_REF_FRAMES];            pPredWeight[1] = &m_pPredWeight_L1[uSliceNum*MAX_NUM_REF_FRAMES];            luma_log2_weight_denom = m_CurSliceHeader.luma_log2_weight_denom;            chroma_log2_weight_denom = m_CurSliceHeader.chroma_log2_weight_denom;            bUnidirWeightMB = true;            bBidirWeightMB = true;        }        if (weighted_bipred_idc == 2)        {            pDistScaleFactors = m_CurSliceInfo.DistScaleFactor;            bBidirWeightMB = true;        }    }    if (mbtype != MBTYPE_INTER_8x8 && mbtype != MBTYPE_INTER_8x8_REF0)    {        if (mbtype == MBTYPE_INTER_16x8)        {            sbwidth = 16;            sbheight = 8;            roi.width        = 16;            roi.height        = 8;            roi_cr.width    = 8;            roi_cr.height    = 4;        }        else if (mbtype == MBTYPE_INTER_8x16)        {            sbwidth = 8;            sbheight = 16;            roi.width        = 8;            roi.height        = 16;            roi_cr.width    = 4;            roi_cr.height    = 8;        }        else        {            sbwidth = sbheight = 16;            roi.width        = 16;            roi.height        = 16;            roi_cr.width    = 8;            roi_cr.height    = 8;        }        block = 0;        for (ypos=0; ypos<16; ypos+=sbheight)        {            for (xpos=0; xpos<16; xpos+=sbwidth)            {                if ((mbtype == MBTYPE_BIDIR) ||                    (psbdir[block] == D_DIR_BIDIR) /*|| bIsDirect*/)                {                    uBlockDir = D_DIR_BIDIR;                    loopCnt = 2;                    bUnidirWeightSB = false;                }                else                {                    loopCnt = 1;                    if ((mbtype == MBTYPE_BACKWARD) ||                        (psbdir[block] == D_DIR_BWD))                        uBlockDir = D_DIR_BWD;                    else                        uBlockDir = D_DIR_FWD;                    bUnidirWeightSB =  bUnidirWeightMB;                }                for (i=0; i<loopCnt; i++)                {                    if ((uBlockDir == D_DIR_BWD) || (i > 0))                    {                        pRefIndex = pRefIndexL1 + (xpos>>2) + (ypos>>2)*4;                        RefIndexL1 = *pRefIndex;                        VM_ASSERT(RefIndexL1 >= 0 && RefIndexL1 <                            (Ipp8s)m_CurSliceHeader.num_ref_idx_l1_active);                        RefFieldTop = GetReferenceField(pFields1,RefIndexL1);                        pRefYPlane = pRefPicList1[RefIndexL1]->m_pYPlane;                        pRefVPlane = pRefPicList1[RefIndexL1]->m_pVPlane;                        pRefUPlane = pRefPicList1[RefIndexL1]->m_pUPlane;                        ref_pic_struct = pRefPicList1[RefIndexL1]->m_PictureStructureForDec;                        VM_ASSERT(pRefYPlane);                        VM_ASSERT(pRefVPlane);                        VM_ASSERT(pRefUPlane);                        if(RefFieldTop)                        {                            Ipp32u pitch_2 = pitch >> 1;                            pRefYPlane += pitch_2;                            pRefUPlane += pitch_2;                            pRefVPlane += pitch_2;                        }                        pMV = pMVBwd;                    }                    else                    {                        pRefIndex = pRefIndexL0 + (xpos>>2) + (ypos>>2)*4;                        RefIndexL0 = *pRefIndex;                        VM_ASSERT(RefIndexL0 >= 0 && RefIndexL0 <                            (Ipp8s)m_CurSliceHeader.num_ref_idx_l0_active);                        RefFieldTop = GetReferenceField(pFields0,RefIndexL0);                        pRefYPlane = pRefPicList0[RefIndexL0]->m_pYPlane;                        pRefVPlane = pRefPicList0[RefIndexL0]->m_pVPlane;                        pRefUPlane = pRefPicList0[RefIndexL0]->m_pUPlane;                        ref_pic_struct = pRefPicList0[RefIndexL0]->m_PictureStructureForDec;                        VM_ASSERT(pRefYPlane);                        VM_ASSERT(pRefVPlane);                        VM_ASSERT(pRefUPlane);                        if(RefFieldTop)                        {                            Ipp32u pitch_2 = pitch >> 1;                            pRefYPlane += pitch_2;                            pRefUPlane += pitch_2;                            pRefVPlane += pitch_2;                        }                        pMV = pMVFwd;                    }                    // set pointers for this subblock                    pMV_sb = pMV + (xpos>>2) + (ypos>>2)*4;                    mvx = pMV_sb->mvx;                    mvy = pMV_sb->mvy;                    offsetToBlock = xpos + ypos*pitch;                    pDstY_sb = pDstY + offsetToBlock;                    pRefY_sb = pRefYPlane + offsetToBlock;                    pDstV_sb = pDstV + (offsetToBlock>>1);                    pRefV_sb = pRefVPlane + (offsetToBlock>>1);                    pDstU_sb = pDstU + (offsetToBlock>>1);                    pRefU_sb = pRefUPlane + (offsetToBlock>>1);                    if (i > 0)                    {                        // advance Dst ptrs to next MB position, used as temp store                        // for backward prediction. This is always OK because the Dst                        // buffer is padded at the edges.                        pDstY_sb += 16;                        pDstV_sb += 8;                        pDstU_sb += 8;                    }                    xh = mvx & (INTERP_FACTOR-1);                    yh = mvy & (INTERP_FACTOR-1);                    // Note must select filter (get xh, yh) before clipping in                    // order to preserve selection. Makes a difference only

⌨️ 快捷键说明

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