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

📄 gdi_video_render.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
struct RGB24T{    BYTE rgbRed;    BYTE rgbGreen;    BYTE rgbBlue;};inlinevm_byte Saturate(int iY, int iC){    iC = (iY + iC) >> 4;    iC = min(255, max(0, iC));    return static_cast<vm_byte>(iC);} // vm_byte Saturate(int iY, int iC)inlinevoid CookUXV(int U, int V, int& iU, int& iV, int& iG){    iU = (U - 128) << 7;    iV = (V - 128) << 7;    iG = ((0x1A04 * iU) >> 16) + ((0x0C8B * iV) >> 16);    iU = (0x3312 * iU) >> 16;    iV = (0x408b * iV) >> 16;} // void CookUXV(int U, int V, int& iU, int& iV, int& iG)void myYUY2toRGB32(vm_byte *pucSrc,                   vm_byte *pucDst,                   vm_var32 uiWidth,                   vm_var32 uiHeight){    YUY2QUAD* pYUV = (YUY2QUAD *)pucSrc;    RGBQUAD* pRGB = (RGBQUAD *)pucDst;    for (unsigned int i = 0; i < uiWidth * uiHeight; i += 2)    {        YUY2QUAD YUV = pYUV[i >> 1];        register int iU;        register int iV;        register int iG;        CookUXV(YUV.U, YUV.V, iU, iV, iG);        register int iY = YUV.Y1 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i].rgbRed = Saturate(iY, iU);        pRGB[i].rgbGreen = Saturate(iY, -iG);        pRGB[i].rgbBlue = Saturate(iY, iV);        iY = YUV.Y2 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i+1].rgbRed = Saturate(iY, iU);        pRGB[i+1].rgbGreen = Saturate(iY, -iG);        pRGB[i+1].rgbBlue = Saturate(iY, iV);    }} // void myYUY2toRGB32(vm_byte *pucSrc,void myYUY2toRGB24(vm_byte *pucSrc,                   vm_byte *pucDst,                   vm_var32 uiWidth,                   vm_var32 uiHeight){    YUY2QUAD *pYUV = (YUY2QUAD *)pucSrc;    RGB24T *pRGB = (RGB24T *)pucDst;    for (unsigned int i = 0; i < uiWidth * uiHeight; i += 2)    {        YUY2QUAD YUV = pYUV[i >> 1];        register int iU;        register int iV;        register int iG;        CookUXV(YUV.U, YUV.V, iU, iV, iG);        register int iY = YUV.Y1 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i].rgbRed = Saturate(iY, iU);        pRGB[i].rgbGreen = Saturate(iY, -iG);        pRGB[i].rgbBlue = Saturate(iY, iV);        iY = YUV.Y2 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i+1].rgbRed = Saturate(iY, iU);        pRGB[i+1].rgbGreen = Saturate(iY, -iG);        pRGB[i+1].rgbBlue = Saturate(iY, iV);    }} // void myYUY2toRGB24(vm_byte *pucSrc,void myYUY2toRGB555(vm_byte *pucSrc,                    vm_byte *pucDst,                    vm_var32 uiWidth,                    vm_var32 uiHeight){    YUY2QUAD *pYUV = (YUY2QUAD *)pucSrc;    vm_var16 *pRGB = (vm_var16 *)pucDst;    for (unsigned int i = 0; i < uiWidth * uiHeight; i += 2)    {        YUY2QUAD YUV = pYUV[i >> 1];        register int iU;        register int iV;        register int iG;        CookUXV(YUV.U, YUV.V, iU, iV, iG);        register int iY = YUV.Y1 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i] = static_cast<vm_var16>((Saturate(iY, iV) >> 3) |                                        ((Saturate(iY, -iG) >> 3) << 5) |                                        ((Saturate(iY, iU) >> 3) << 10));        iY = YUV.Y2 - 16;        iY = ((iY << 7) * 0x253f) >> 16;        pRGB[i+1] = static_cast<vm_var16>((Saturate(iY, iV) >> 3) |                                        ((Saturate(iY, -iG) >> 3) << 5) |                                        ((Saturate(iY, iU) >> 3) << 10));    }} // void myYUY2toRGB555(vm_byte *pucSrc,inlinevoid PutYUV2RGB32(vm_byte* pY,                  int iU,                  int iV,                  int iG,                  RGBQUAD* pRGB,                  vm_var32 uiLpos){    register int iY = pY[uiLpos] - 16;    iY = ((iY << 7) * 0x253f) >> 16;    pRGB[uiLpos].rgbRed = Saturate(iY, iU);    pRGB[uiLpos].rgbBlue = Saturate(iY, iV);    pRGB[uiLpos].rgbGreen = Saturate(iY, -iG);    pRGB[uiLpos].rgbReserved = 0;} // void PutYUV2RGB32(vm_byte* pY,void myYV12toRGB32(vm_byte* pucSrc,                   vm_byte* pucDst,                   vm_var32 uiWidth,                   vm_var32 uiHeight){    vm_byte* pY = pucSrc;    vm_byte* pU = pucSrc + uiWidth * uiHeight;    vm_byte* pV = pU + uiWidth * uiHeight / 4;    RGBQUAD* pRGB = (RGBQUAD*)pucDst;    for (vm_var32 y = 0; y < uiHeight / 2; y++)    {        vm_var32 uiLPos1 = 2 * y * uiWidth;        vm_var32 uiLPos2 = uiLPos1 + uiWidth;        for (vm_var32 x = 0; x < uiWidth / 2; x++)        {            vm_var32 uiCPos = y * uiWidth / 2 + x; // Chroma pos in buffer            register int iU;            register int iV;            register int iG;            CookUXV(pU[uiCPos], pV[uiCPos], iU, iV, iG);            PutYUV2RGB32(pY, iU, iV, iG, pRGB, uiLPos1++);            PutYUV2RGB32(pY, iU, iV, iG, pRGB, uiLPos1++);            PutYUV2RGB32(pY, iU, iV, iG, pRGB, uiLPos2++);            PutYUV2RGB32(pY, iU, iV, iG, pRGB, uiLPos2++);        }    }} // void myYV12toRGB32(vm_byte* pucSrc,inlinevoid PutYUV2RGB24(vm_byte* pY,                  int iU,                  int iV,                  int iG,                  RGB24T* pRGB,                  vm_var32 uiLpos){    register int iY = pY[uiLpos] - 16;    iY = ((iY << 7) * 0x253f) >> 16;    pRGB[uiLpos].rgbRed = Saturate(iY, iU);    pRGB[uiLpos].rgbBlue = Saturate(iY, iV);    pRGB[uiLpos].rgbGreen = Saturate(iY, -iG);} // void PutYUV2RGB24(vm_byte* pY,void myYV12toRGB24(vm_byte* pucSrc,                   vm_byte* pucDst,                   vm_var32 uiWidth,                   vm_var32 uiHeight){    vm_byte* pY = pucSrc;    vm_byte* pU = pucSrc + uiWidth * uiHeight;    vm_byte* pV = pU + uiWidth * uiHeight / 4;    RGB24T* pRGB = (RGB24T*)pucDst;    for (vm_var32 y = 0; y < uiHeight / 2; y++)    {        for (vm_var32 x = 0; x < uiWidth / 2; x++)        {            vm_var32 uiCPos = y * uiWidth / 2 + x; // Chroma pos in buffer            vm_var32 uiLpos = y * 2 * uiWidth + 2 * x; // Luma pos in buffer            register int iU;            register int iV;            register int iG;            CookUXV(pU[uiCPos], pV[uiCPos], iU, iV, iG);            PutYUV2RGB24(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos++;            PutYUV2RGB24(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos += uiWidth - 1;            PutYUV2RGB24(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos++;            PutYUV2RGB24(pY, iU, iV, iG, pRGB, uiLpos);        }    }} // void myYV12toRGB24(vm_byte* pucSrc,inlinevoid PutYUV2RGB555(vm_byte* pY,                   int iU,                   int iV,                   int iG,                   vm_var16* pRGB,                   vm_var32 uiLpos){    register int iY = pY[uiLpos] - 16;    iY = ((iY << 7) * 0x253f) >> 16;    pRGB[uiLpos] = static_cast<vm_var16>((Saturate(iY, iV) >> 3) |                                        ((Saturate(iY, -iG) >> 3) << 5) |                                        ((Saturate(iY, iU) >> 3) << 10));} // void PutYUV2RGB555(vm_byte* pY,void myYV12toRGB555(vm_byte* pucSrc,                    vm_byte* pucDst,                    vm_var32 uiWidth,                    vm_var32 uiHeight){    vm_byte* pY = pucSrc;    vm_byte* pU = pucSrc + uiWidth * uiHeight;    vm_byte* pV = pU + uiWidth * uiHeight / 4;    vm_var16* pRGB = (vm_var16*)pucDst;    for (vm_var32 y = 0; y < uiHeight / 2; y++)    {        for (vm_var32 x = 0; x < uiWidth / 2; x++)        {            vm_var32 uiCPos = y * uiWidth / 2 + x; // Chroma pos in buffer            vm_var32 uiLpos = y * 2 * uiWidth + 2 * x; // Luma pos in buffer            register int iU;            register int iV;            register int iG;            CookUXV(pU[uiCPos], pV[uiCPos], iU, iV, iG);            PutYUV2RGB555(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos++;            PutYUV2RGB555(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos += uiWidth - 1;            PutYUV2RGB555(pY, iU, iV, iG, pRGB, uiLpos);            uiLpos++;            PutYUV2RGB555(pY, iU, iV, iG, pRGB, uiLpos);        }    }} // void myYV12toRGB555(vm_byte* pucSrc,int GDIVideoRender::UnlockSurface(unsigned char **){    int iRes = 1;    if (m_iWriteIndex < 0)        iRes = 0;    if (1 == iRes)    {        //  Convert picture from the current RGB buffer        switch (m_InColorFormat)        {        case YV12:            switch (m_uiBytesPerDCPixel)            {            case 4:                myYV12toRGB32(m_pucYUVBuffer,                              (vm_byte*)m_Buffers[m_iWriteIndex].surface,                              m_SrcInfo.width, m_SrcInfo.height);                break;            case 3:                myYV12toRGB24(m_pucYUVBuffer,                              (vm_byte*)m_Buffers[m_iWriteIndex].surface,                              m_SrcInfo.width, m_SrcInfo.height);                break;            case 2:                myYV12toRGB555(m_pucYUVBuffer,                               (vm_byte*)m_Buffers[m_iWriteIndex].surface,                               m_SrcInfo.width, m_SrcInfo.height);                break;            default:                // unsupported output color representation                assert(false);            }            break;        case YUY2:            switch (m_uiBytesPerDCPixel)            {            case 4:                myYUY2toRGB32(m_pucYUVBuffer,                              (vm_byte*)m_Buffers[m_iWriteIndex].surface,                              m_SrcInfo.width, m_SrcInfo.height);                break;            case 3:                myYUY2toRGB24(m_pucYUVBuffer,                              (vm_byte*)m_Buffers[m_iWriteIndex].surface,                              m_SrcInfo.width, m_SrcInfo.height);                break;            case 2:                myYUY2toRGB555(m_pucYUVBuffer,                               (vm_byte*)m_Buffers[m_iWriteIndex].surface,                               m_SrcInfo.width, m_SrcInfo.height);                break;            default:                // unsupported output color representation                assert(false);            }            break;        case UYVY:            break;        case YUV420:            break;        default:            // unsupported input color representation            assert(false);        }    }    return iRes;} // int GDIVideoRender::UnlockSurface(unsigned char **)} // namespace UMC#endif // defined(UMC_ENABLE_GDI_VIDEO_RENDER)

⌨️ 快捷键说明

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