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

📄 umc_color_space_converter_ycbcr.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*////              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.//*/#include <stdlib.h>#include <ippi.h>#include <ippcc.h>#include "umc_color_space_converter.h"#include "vm_debug.h"namespace UMC{class PIXEL_YCBCR{public:    vm_var32 Y;    vm_var32 U;    vm_var32 V;    PIXEL_YCBCR &operator = (vm_var32 lValue)    {        Y = U = V = lValue;        return *this;    };    PIXEL_YCBCR &operator += (PIXEL_YCBCR &Value)    {        Y += Value.Y;        U += Value.U;        V += Value.V;        return *this;    };    PIXEL_YCBCR &operator -= (PIXEL_YCBCR &Value)    {        Y -= Value.Y;        U -= Value.U;        V -= Value.V;        return *this;    };    PIXEL_YCBCR &operator *= (vm_var32 lValue)    {        Y *= lValue;        U *= lValue;        V *= lValue;        return *this;    };    PIXEL_YCBCR &operator /= (vm_var32 lValue)    {        Y /= lValue;        U /= lValue;        V /= lValue;        return *this;    };};class POINTER_YCBCR{public:    POINTER_YCBCR(void)    {        m_lpbData = NULL;        m_bOdd = true;    };    POINTER_YCBCR &operator = (void *lpv)    {        m_lpbData = reinterpret_cast<vm_byte *> (lpv);        m_bOdd = true;        return *this;    };    POINTER_YCBCR &operator += (size_t lValue)    {        if (0 < (signed) lValue)        {            // we set pointer only to UYVY quad potion            if (m_bOdd)            {                m_lpbData += (lValue & ~(1)) * 2;                m_bOdd = (lValue & 1) ? (false) : (true);            }            else            {                m_lpbData += ((lValue + 1) & ~(1)) * 2;                m_bOdd = (lValue & 1) ? (true) : (false);            };        }        else if (0 > (signed) lValue)        {            if (m_bOdd)            {                m_lpbData += ((lValue - 1) & ~(1)) * 2;                m_bOdd = (lValue & 1) ? (false) : (true);            }            else            {                m_lpbData += (lValue & ~(1)) * 2;                m_bOdd = (lValue & 1) ? (true) : (false);            };        };        return *this;    };    POINTER_YCBCR &operator -= (size_t lValue)    {        return operator += ((unsigned) -((signed) lValue));    };    POINTER_YCBCR &operator ++ (void)    {        return operator += (1);    };    POINTER_YCBCR &operator -- (void)    {        return operator += ((unsigned) -1);    };    operator PIXEL_YCBCR(void)    {        PIXEL_YCBCR yuv = {(m_bOdd) ? (m_lpbData[0]) : (m_lpbData[2]), m_lpbData[1], m_lpbData[3]};        return yuv;    };    void operator = (PIXEL_YCBCR yuv)    {        if (m_bOdd)        {            m_lpbData[0] = static_cast<vm_byte> (yuv.Y);            m_lpbData[1] = static_cast<vm_byte> (yuv.U);            m_lpbData[3] = static_cast<vm_byte> (yuv.V);        }        else        {            m_lpbData[2] = static_cast<vm_byte> (yuv.Y);            m_lpbData[1] = static_cast<vm_byte> ((yuv.U + m_lpbData[1]) / 2);            m_lpbData[3] = static_cast<vm_byte> ((yuv.V + m_lpbData[3]) / 2);        };    };    POINTER_YCBCR operator *(void)    {        POINTER_YCBCR ptr = *this;        return ptr;    };    POINTER_YCBCR operator [](size_t lValue)    {        POINTER_YCBCR ptr = *this;        ptr.operator += (lValue);        return ptr;    };protected:    vm_byte *m_lpbData;    bool m_bOdd;};// Intel compiler makes a remark// "value copied to temporary, reference to temporary used"#ifdef __ICL#pragma warning(disable : 383)#endif // __ICLstaticvoid resize_hor_YCbCr(void *lpvSrc, IppiSize SizeSrc, size_t lPitchSrc,                      void *lpvDst, IppiSize SizeDst, size_t lPitchDst){    // if images are equal    if (SizeDst.width == SizeSrc.width)    {        IppiSize SizeDest = {SizeDst.width * 2, SizeDst.height};        ippiCopy_8u_C1R(reinterpret_cast<vm_byte *> (lpvSrc),                        (vm_var32) lPitchSrc,                        reinterpret_cast<vm_byte *> (lpvDst),                        (vm_var32) lPitchDst,                        SizeDest);    }    // stretching image in    else if (SizeDst.width < SizeSrc.width)    {        vm_var32 nWeight = SizeSrc.width, nPixelWeight = SizeDst.width;        PIXEL_YCBCR Pixel, Value;        vm_var32 x, y;        vm_var32 nCurWeight;        POINTER_YCBCR lpSrc, lpDst;        for (y = 0;y < (unsigned) SizeSrc.height;y++)        {            lpSrc = reinterpret_cast<vm_byte *> (lpvSrc) + lPitchSrc * y;            lpDst = reinterpret_cast<vm_byte *> (lpvDst) + lPitchDst * y;            Pixel = 0;            nCurWeight = nWeight;            for (x = 0;x < (unsigned) SizeDst.width;x++)            {                // get whole pixels                while (nCurWeight >= nPixelWeight)                {                    PIXEL_YCBCR Temp = lpSrc[0];                    Pixel += Temp;                    nCurWeight -= nPixelWeight;                    ++lpSrc;                };                // get pixel part                if (nCurWeight)                {                    PIXEL_YCBCR Tail;                    Tail = static_cast<PIXEL_YCBCR> (*lpSrc);                    Tail *= nCurWeight;                    Tail /= nPixelWeight;                    Value = Pixel;                    Value += Tail;                    Pixel = static_cast<PIXEL_YCBCR> (*lpSrc);                    Pixel -= Tail;                    ++lpSrc;                    nCurWeight = nWeight - (nPixelWeight - nCurWeight);                }                // only whole pixels used                else                {                    Value = Pixel;                    Pixel = 0;                    nCurWeight = nWeight;                };                // write new pixel                Value *= nPixelWeight;                Value /= nWeight;                lpDst = Value;                ++lpDst;            };        };    }    // stretching image out    else    {        vm_var32 nWeight = SizeSrc.width, nPixelWeight = SizeDst.width;        PIXEL_YCBCR Pixel;        vm_var32 x, y;        vm_var32 nCurWeight;        POINTER_YCBCR lpSrc, lpDst;        for (y = 0;y < (unsigned) SizeDst.height;y++)        {            lpSrc = reinterpret_cast<vm_byte *> (lpvSrc) + lPitchSrc * y;            lpDst = reinterpret_cast<vm_byte *> (lpvDst) + lPitchDst * y;            nCurWeight = nPixelWeight;            for (x = 0;x < (unsigned) SizeDst.width;x++)            {                Pixel = *lpSrc;                if (nCurWeight < nWeight)                {                    PIXEL_YCBCR Tail;                    ++lpSrc;                    Pixel *= nCurWeight;                    Tail = *lpSrc;

⌨️ 快捷键说明

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