将NV12转换为YUY2

时间:2017-06-27 13:43:47

标签: c++ 64-bit intel video-processing mmx

在现有的Visual Studio 2015 C ++ 32位Windows项目中,我有一个将视频帧从NV12转换为YUY2的功能,这基本上只是改组字节。这是:

void ConvertNV12toYUY2(int nInputHeight,
                       LPBITMAPINFOHEADER lpbiOutput,
                       void * _src, void * _dst,
                       bool bInterlaced)
{
    const unsigned char* py8 = (const unsigned char*)_src;
    unsigned char* pyuy2_8 = (unsigned char*)_dst;
    int pitch = lpbiOutput->biWidth;
    int width = pitch;
    int nOutputHeight = abs((int)lpbiOutput->biHeight);
    const unsigned char *puv8 = py8 + (nInputHeight * pitch);

    int w = (width+7) >> 3;
    const __m64 *py = (const __m64 *)py8;
    __m64 *pyuy2 = (__m64 *)pyuy2_8;

    for (int y = 0; y < nOutputHeight; y++)
    {
        const __m64 *puv;

        if (bInterlaced)
            puv = (const __m64 *)(puv8+(((y/2)&~1)+(y&1))*pitch);
        else
            puv = (const __m64 *)(puv8+(y/2)*pitch);
        for (int x = 0; x < w; x++)
        {
            __m64 r0 = py[x];       // yyyy
            __m64 r1 = puv[x];      // uvuv
            __m64 r2 = r0;          // yyyy
            r0 = _m_punpcklbw(r0, r1);  // yuyv
            r2 = _m_punpckhbw(r2, r1);  // yuyv
            pyuy2[x*2] = r0;
            pyuy2[x*2+1] = r2;
        }
        py += pitch/sizeof(__m64);
        pyuy2 += (width*2)/sizeof(__m64);
    }
    _m_empty();
}

如果在32位项目中一直工作正常,但现在我将其移植到 64位,并且由于找不到这些标识符而无法编译:

_m_punpcklbw
_m_punpckhbw
_m_empty

认为这与微软64位编译器不支持的mmx内在函数有关,但老实说我对mmx知之甚少。

是否有相同的替换函数可以在64位中执行相同的操作?

0 个答案:

没有答案