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

📄 umc_h264_dec_reconstruct_mb.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
                            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);                            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);                            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);                        Ipp8u pred_method=SelectPredictionMethod(                            mbYOffset+ypos,                            mvy,                            sbheight,                            height);                        // See comment above about clipping & xh,yh.                        mvx = MIN(mvx, (width - ((Ipp32s)mbXOffset + xpos + sbwidth - 1                            - D_MV_CLIP_LIMIT))*INTERP_FACTOR);                        mvx = MAX(mvx, -((Ipp32s)(mbXOffset + xpos + D_MV_CLIP_LIMIT)*INTERP_FACTOR));                        mvy = MIN(mvy, (height - ((Ipp32s)mbYOffset + ypos + sbheight -                            1 - D_MV_CLIP_LIMIT))*INTERP_FACTOR);                        mvy = MAX(mvy, -((Ipp32s)(mbYOffset + ypos + D_MV_CLIP_LIMIT)*INTERP_FACTOR));                        mvyc = mvy;                        xint = mvx >> INTERP_SHIFT;                        yint = mvy >> INTERP_SHIFT;                        switch(pred_method)                        {                        case ALLOK:                            pRef = pRefY_sb + offsetY + xint + yint * pitch;                            ippiInterpolateLuma_H264_8u_C1R(pRef, pitch,                                pDstY_sb, pitch,                                xh, yh, roi);                            break;                        case PREDICTION_FROM_TOP:                            pRef = pRefY_sb + offsetY + xint + yint * pitch;                            InterpolateLumaTop(pRef, pitch,                                pDstY_sb, pitch,                                xh, yh, - ((Ipp32s)mbYOffset+ypos+yint),roi);                            break;                        case PREDICTION_FROM_BOTTOM:                            pRef = pRefY_sb + offsetY + xint + yint * pitch;                            InterpolateLumaBottom(pRef, pitch,                                pDstY_sb, pitch,                                xh, yh, ((Ipp32s)mbYOffset+ypos+yint+roi.height)-height,roi);                            break;                        default:VM_ASSERT(0);                            break;                        }                        // optional prediction weighting                        if (bUnidirWeightSB &&                            pPredWeight[uBlockDir][*pRefIndex].luma_weight_flag != 0)                        {                            UniDirWeightBlock(pDstY_sb, pitch, sbwidth, sbheight,                                luma_log2_weight_denom,                                pPredWeight[uBlockDir][*pRefIndex].luma_weight,                                pPredWeight[uBlockDir][*pRefIndex].luma_offset);                        }                        if (color_format==1)                        {                            // chroma (1/8 pixel MV)                            xh = mvx & (INTERP_FACTOR*2-1);                            yh = mvyc & (INTERP_FACTOR*2-1);                            xint = mvx >> (INTERP_SHIFT+1);                            yint = mvyc >> (INTERP_SHIFT+1);                            switch(pred_method)                            {                            case ALLOK:                                pRef = pRefV_sb + (offsetY>>1) + xint + yint * pitch;                                ippiInterpolateChroma_H264_8u_C1R(pRef, pitch,                                    pDstV_sb, pitch,                                    xh, yh,   roi_cr);                                pRef = pRefU_sb + (offsetY>>1) + xint + yint * pitch;                                ippiInterpolateChroma_H264_8u_C1R(pRef, pitch,                                    pDstU_sb, pitch,                                    xh, yh,   roi_cr);                                break;                            case PREDICTION_FROM_TOP:                                pRef = pRefV_sb + (offsetY>>1) + xint + yint * pitch;                                InterpolateChromaTop(pRef, pitch,                                    pDstV_sb, pitch,                                    xh, yh,  - (((Ipp32s)mbYOffset+ypos)/2+yint), roi_cr);                                pRef = pRefU_sb + (offsetY>>1) + xint + yint * pitch;                                InterpolateChromaTop(pRef, pitch,                                    pDstU_sb, pitch,                                    xh, yh,  - (((Ipp32s)mbYOffset+ypos)/2+yint), roi_cr);                                break;                            case PREDICTION_FROM_BOTTOM:                                pRef = pRefV_sb + (offsetY>>1) + xint + yint * pitch;                                InterpolateChromaBottom(pRef, pitch,                                    pDstV_sb, pitch,                                    xh, yh,   (((Ipp32s)mbYOffset+ypos)/2+yint+roi_cr.height)-height/2,roi_cr);                                pRef = pRefU_sb + (offsetY>>1) + xint + yint * pitch;                                InterpolateChromaBottom(pRef, pitch,                                    pDstU_sb, pitch,                                    xh, yh,   (((Ipp32s)mbYOffset+ypos)/2+yint+roi_cr.height)-height/2,roi_cr);                                break;                            default:VM_ASSERT(0);                                break;                            }                            // optional prediction weighting                            if (bUnidirWeightSB &&                                pPredWeight[uBlockDir][*pRefIndex].chroma_weight_flag != 0)                            {                                UniDirWeightBlock(pDstV_sb, pitch, sbwidth>>1, sbheight>>1,                                    chroma_log2_weight_denom,                                    pPredWeight[uBlockDir][*pRefIndex].chroma_weight[1],                                    pPredWeight[uBlockDir][*pRefIndex].chroma_offset[1]);                                UniDirWeightBlock(pDstU_sb, pitch, sbwidth>>1, sbheight>>1,                                    chroma_log2_weight_denom,                                    pPredWeight[uBlockDir][*pRefIndex].chroma_weight[0],                                    pPredWeight[uBlockDir][*pRefIndex].chroma_offset[0]);                            }                        }                    }    // loopCnt                    if (loopCnt > 1)                    {                        if (!bBidirWeightMB)                        {                            // combine bidir predictions into one, no weighting                            // luma                            ippiInterpolateBlock_H264_8u_P2P1R(pDstY_sb-16, pDstY_sb, pDstY_sb-16,                                roi.width,                                roi.height,                                pitch);                            if (color_format==1)                            {                                ippiInterpolateBlock_H264_8u_P2P1R(pDstV_sb-8, pDstV_sb, pDstV_sb-8,                                    roi_cr.width,                                    roi_cr.height,                                    pitch);                                ippiInterpolateBlock_H264_8u_P2P1R(pDstU_sb-8, pDstU_sb, pDstU_sb-8,                                    roi_cr.width,                                    roi_cr.height,                                    pitch);                            }                        }                        else                        {                            // combine bidir predictions into one with weighting                            // combine bidir predictions into one with weighting                            if (weighted_bipred_idc == 1)                            {                                // combine bidir predictions into one, explicit weighting                                // luma                                BiDirWeightBlock(pDstY_sb-16, pDstY_sb, pDstY_sb-16,                                    pitch, sbwidth, sbheight,                                    luma_log2_weight_denom,                                    pPredWeight[0][RefIndexL0].luma_weight,                                    pPredWeight[0][RefIndexL0].luma_offset,                                    pPredWeight[1][RefIndexL1].luma_weight,                                    pPredWeight[1][RefIndexL1].luma_offset);                                if (color_format==1)                                {                                    // chroma                                    BiDirWeightBlock(pDstV_sb-8, pDstV_sb, pDstV_sb-8,                                        pitch, sbwidth>>1, sbheight>>1,                                        chroma_log2_weight_denom,                                        pPredWeight[0][RefIndexL0].chroma_weight[1],                                        pPredWeight[0][RefIndexL0].chroma_offset[1],                                        pPredWeight[1][RefIndexL1].chroma_weight[1],                                        pPredWeight[1][RefIndexL1].chroma_offset[1]);                                    BiDirWeightBlock(pDstU_sb-8, pDstU_sb, pDstU_sb-8,                                        pitch, sbwidth>>1, sbheight>>1,                                        chroma_log2_weight_denom,                                        pPredWeight[0][RefIndexL0].chroma_weight[0],                                        pPredWeight[0][RefIndexL0].chroma_offset[0],                                        pPredWeight[1][RefIndexL1].chroma_weight[0],                                        pPredWeight[1][RefIndexL1].chroma_offset[0]);                                }                            }                            else if (weighted_bipred_idc == 2)                            {                                // combine bidir predictions into one, implicit weighting                                iDistScaleFactor = pDistScaleFactors[RefIndexL0]>>2;                                // luma                                BiDirWeightBlockImplicit(pDstY_sb-16, pDstY_sb, pDstY_sb-16,                                    pitch, pitch, sbwidth, sbheight,                                    64 - iDistScaleFactor,                                    iDistScaleFactor);                                if (color_format==1)                                {                                    // chroma                                    BiDirWeightBlockImplicit(pDstV_sb-8, pDstV_sb, pDstV_sb-8,                                        pitch, pitch, sbwidth>>1, sbheight>>1,                                        64 - iDistScaleFactor,                                        iDistScaleFactor);                                    BiDirWeightBlockImplicit(pDstU_sb-8, pDstU_sb, pDstU_sb-8,                                        pitch, pitch, sbwidth>>1, sbheight>>1,                                        64 - iDistScaleFactor,                                        iDistScaleFactor);                                }                            }                            else                                VM_ASSERT(0);                        }    //  weighted                    }    // LoopCnt >1                }    // for xpos            }    // for ypos        }    // for block    }    // 8x8}    // ReconstructMacroblock////////////////////////////////////////////////////////////////////////////////// Copy raw pixel values from the bitstream to the reconstructed frame for// all luma and chroma blocks of one macroblock.////////////////////////////////////////////////////////////////////////////////void H264VideoDecoder::ReconstructPCMMB(Ipp32u lumaOffset,Ipp8u color_format){    Ipp8u *pDstY;    Ipp8u *pDstU;    Ipp8u *pDstV;    Ipp32u pitch, i;    // to retrieve non-aligned pointer from m_pCoeffBlocksRead    pitch = m_pCurrentFrame->pitch()<<(Ipp32u) (m_pCurrentFrame->m_PictureStructureForDec<FRM_STRUCTURE);    pDstY = m_pCurrentFrame->m_pYPlane + lumaOffset;    pDstU = m_pCurrentFrame->m_pUPlane + (lumaOffset>>1);    pDstV = m_pCurrentFrame->m_pVPlane + (lumaOffset>>1);    // get pointer to raw bytes from m_pCoeffBlocksRead    for (i = 0; i<16; i++)        memcpy(&pDstY[i*pitch],&m_pCoeffBlocksRead[i*8],16);    if (color_format==1)    {        for (i = 0; i<8; i++)            memcpy(&pDstU[i*pitch],&m_pCoeffBlocksRead[i*4+128],8);        for (i = 0; i<8; i++)            memcpy(&pDstV[i*pitch],&m_pCoeffBlocksRead[i*4+160],8);    }}    // reconstructPCMMacroblock} // end namespace UMC

⌨️ 快捷键说明

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