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

📄 umc_h264_dec_ipplevel.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
字号:
/*////              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.////*//*THIS FILE IS A TEMPORAL SOLUTION AND IT WILL BE REMOVED AS SOON AS THE NEW FUNCTIONS ARE ADDED*/#include "umc_h264_dec.h"#include "umc_h264_bitstream.h"namespace IppLevel{static  Ipp8u* CopyBlockFromTop(        Ipp8u *pRefPlane,        Ipp8u *TemporalPixels,        Ipp32s pitch,        Ipp32s temp_pitch,        Ipp32s outPixels,        Ipp32s xh,        Ipp32s yh,        IppiSize roi)    {        Ipp8u *pOut;        Ipp8u *pOutReturn;        int i;        pOutReturn = pOut = TemporalPixels;        Ipp32s padded_y = yh>0?3:0;        Ipp32s padded_x = xh>0?3:0;        pRefPlane+=pitch*outPixels;        Ipp32s num_outs = outPixels+padded_y;        Ipp32s sbheight = roi.height+padded_y*2;        VM_ASSERT(num_outs>=0);        pRefPlane-=padded_x;        pOut-=padded_y*temp_pitch;        pOut-=padded_x;        if (num_outs>sbheight) //starting point outside bottom boundary        {            num_outs = roi.height+2*padded_y;            for(i=0;i<num_outs;i++,pOut+=temp_pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);        }        else        {            for(i=0;i<num_outs;i++,pOut+=temp_pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);            for(i=0;i<sbheight-num_outs;i++,pOut+=temp_pitch,pRefPlane+=pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);        }        return pOutReturn;    }static  Ipp8u* CopyBlockFromBottom( Ipp8u *pRefPlane,        Ipp8u *TemporalPixels,        Ipp32s pitch,        Ipp32s temp_pitch,        Ipp32s outPixels,        Ipp32s xh,        Ipp32s yh,        IppiSize roi)    {        Ipp8u *pOut;        Ipp8u *pOutReturn;        int i;        pOutReturn = pOut = TemporalPixels;        Ipp32s padded_y = yh>0?3:0;        Ipp32s padded_x = xh>0?3:0;        Ipp32s sbheight = roi.height+padded_y*2;        Ipp32s num_outs = outPixels+padded_y;        pOut-=padded_y*temp_pitch;        pOut-=padded_x;        pRefPlane-=padded_x;        VM_ASSERT(num_outs>=0);        if (num_outs>sbheight) //starting point outside bottom boundary        {            num_outs = sbheight;            pRefPlane-=(outPixels-roi.height+1)*pitch;//get boundary pixel location            for(i=0;i<num_outs;i++,pOut+=temp_pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);        }        else        {            pRefPlane -=padded_y*pitch;            for(i=0;i<sbheight-num_outs;i++,pOut+=temp_pitch,pRefPlane+=pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);            pRefPlane-=pitch;            for(i=0;i<num_outs;i++,pOut+=temp_pitch)                memcpy(pOut,pRefPlane,roi.width+2*padded_x);        }        return pOutReturn;    }    IppStatus InterpolateLumaTop (        const Ipp8u*   pSrc,        Ipp32s   srcStep,        Ipp8u*   pDst,        Ipp32s   dstStep,        Ipp32s   dx,        Ipp32s   dy,        Ipp32s   outPixels,        IppiSize roiSize)    {        Ipp8u *pTemp;        Ipp8u TemporalPixels[32*24];        pTemp=CopyBlockFromTop((Ipp8u *)pSrc,TemporalPixels+32*4,srcStep,32,outPixels,dx,dy,roiSize);        return ippiInterpolateLuma_H264_8u_C1R(pTemp,32,pDst,dstStep,dx,dy,roiSize);    }    IppStatus InterpolateLumaBottom (        const Ipp8u*   pSrc,        Ipp32s   srcStep,        Ipp8u*   pDst,        Ipp32s   dstStep,        Ipp32s   dx,        Ipp32s   dy,        Ipp32s   outPixels,        IppiSize roiSize)    {        Ipp8u *pTemp;        Ipp8u TemporalPixels[32*24];        pTemp=CopyBlockFromBottom((Ipp8u *)pSrc,TemporalPixels+32*4,srcStep,32,outPixels,dx,dy,roiSize);        return ippiInterpolateLuma_H264_8u_C1R(pTemp,32,pDst,dstStep,dx,dy,roiSize);    }    IppStatus InterpolateChromaTop (        const Ipp8u*   pSrc,        Ipp32s   srcStep,        Ipp8u*   pDst,        Ipp32s   dstStep,        Ipp32s   dx,        Ipp32s   dy,        Ipp32s   outPixels,        IppiSize roiSize)    {        Ipp8u *pTemp;        Ipp8u TemporalPixels[32*24];        pTemp=CopyBlockFromTop((Ipp8u *)pSrc,TemporalPixels+32*4,srcStep,32,outPixels,dx,dy,roiSize);        return ippiInterpolateChroma_H264_8u_C1R(pTemp,32,pDst,dstStep,dx,dy,roiSize);    }    IppStatus InterpolateChromaBottom (        const Ipp8u*   pSrc,        Ipp32s   srcStep,        Ipp8u*   pDst,        Ipp32s   dstStep,        Ipp32s   dx,        Ipp32s   dy,        Ipp32s   outPixels,        IppiSize roiSize)    {        Ipp8u *pTemp;        Ipp8u TemporalPixels[32*24];        pTemp=CopyBlockFromBottom((Ipp8u *)pSrc,TemporalPixels+32*4,srcStep,32,outPixels,dx,dy,roiSize);        return ippiInterpolateChroma_H264_8u_C1R(pTemp,32,pDst,dstStep,dx,dy,roiSize);    }    void UniDirWeightBlock(        Ipp8u *pSrcDst,        Ipp32u pitch,        Ipp32u uWidth,        Ipp32u uHeight,        Ipp32u ulog2wd,    // log2 weight denominator        Ipp32s iWeight,        Ipp32s iOffset        )    {        Ipp32u uRound;        Ipp32u xpos, ypos;        Ipp32s weighted_sample;        if (ulog2wd > 0)            uRound = 1<<(ulog2wd - 1);        else            uRound = 0;        for (ypos=0; ypos<uHeight; ypos++)        {            for (xpos=0; xpos<uWidth; xpos++)            {                weighted_sample = (((Ipp32s)pSrcDst[xpos]*iWeight + (Ipp32s)uRound)>>ulog2wd) + iOffset;                // clamp to 0..255. May be able to use ClampVal table for this,                // if range of unclamped weighted_sample can be guaranteed not                // to exceed table bounds.                if (weighted_sample > 255) weighted_sample = 255;                if (weighted_sample < 0) weighted_sample = 0;                pSrcDst[xpos] = (Ipp8u)weighted_sample;            }            pSrcDst += pitch;        }    }    // C_UniDirWeightBlock    //////////////////////////////////////////////////////////////////    // C_BiDirWeightBlock    //  Apply specified weighting and offset to all samples of the blocks,    //  and combine them.    //    //        Sw = clip( (S0*weight0 + S1*weight1 + round) >> (ulog2wd+1) +    //                ((offset0 + offset1 + 1)>>1) )    //    //////////////////////////////////////////////////////////////////    void BiDirWeightBlock(        Ipp8u *pSrc1,        Ipp8u *pSrc2,        Ipp8u *pDst,        // may be same as pSrc1 or pSrc2        Ipp32u pitch,        // of pSrc1, pSrc2, pDst        Ipp32u uWidth,        Ipp32u uHeight,        Ipp32u ulog2wd,    // log2 weight denominator        Ipp32s iWeight1,        Ipp32s iOffset1,        Ipp32s iWeight2,        Ipp32s iOffset2        )    {        Ipp32u uRound;        Ipp32u xpos, ypos;        Ipp32s weighted_sample;        uRound = 1<<ulog2wd;        for (ypos=0; ypos<uHeight; ypos++)        {            for (xpos=0; xpos<uWidth; xpos++)            {                weighted_sample = ((((Ipp32s)pSrc1[xpos]*iWeight1 +                    (Ipp32s)pSrc2[xpos]*iWeight2 + (Ipp32s)uRound)>>(ulog2wd+1))) +                    ((iOffset1 + iOffset2 + 1)>>1);                // clamp to 0..255. May be able to use ClampVal table for this,                // if range of unclamped weighted_sample can be guaranteed not                // to exceed table bounds.                if (weighted_sample > 255) weighted_sample = 255;                if (weighted_sample < 0) weighted_sample = 0;                pDst[xpos] = (Ipp8u)weighted_sample;            }            pSrc1 += pitch;            pSrc2 += pitch;            pDst += pitch;        }    }    // C_BiDirWeightBlock    //////////////////////////////////////////////////////////////////    // C_BiDirWeightBlockImplicit    //    //    Implicit bidir prediction weighting using simplified weighting with    //    no offsets.    //    //        Sw = clip( (S0*weight0 + S1*weight1 + 32) >> 6) )    //    //////////////////////////////////////////////////////////////////    void BiDirWeightBlockImplicit(        const Ipp8u *pSrc1,        const Ipp8u *pSrc2,        Ipp8u *pDst,        // may be same as pSrc1 or pSrc2        Ipp32u pitch,        // of pSrc1, pSrc2, pDst        Ipp32u dstpitch,    // of pDst        Ipp32u uWidth,        Ipp32u uHeight,        Ipp32s iWeight1,        Ipp32s iWeight2        )    {        Ipp32u xpos, ypos;        Ipp32s weighted_sample;        for (ypos=0; ypos<uHeight; ypos++)        {            for (xpos=0; xpos<uWidth; xpos++)            {                weighted_sample = ((Ipp32s)pSrc1[xpos]*iWeight1 +                    (Ipp32s)pSrc2[xpos]*iWeight2 + 32) >> 6;                // clamp to 0..255. May be able to use ClampVal table for this,                // if range of unclamped weighted_sample can be guaranteed not                // to exceed table bounds.                if (weighted_sample > 255) weighted_sample = 255;                if (weighted_sample < 0) weighted_sample = 0;                pDst[xpos] = (Ipp8u)weighted_sample;            }            pSrc1 += pitch;            pSrc2 += pitch;            pDst += dstpitch;        }    }    // C_BiDirWeightBlock} // namespace IppLevel

⌨️ 快捷键说明

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