In an existing Visual Studio 2015 C++ 32-bit Windows project I have a function for converting a video frame from NV12 to YUY2, which is basically just shuffling bytes around. Here it is:
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();
}
If has always worked OK in the 32 bit project, but now I'm porting it to 64 bit, and it fails to compile due to these identifiers not found:
_m_punpcklbw
_m_punpckhbw
_m_empty
I think this is something to do with mmx intrinsics not being supported by the Microsoft 64 bit compiler, but to be honest I know very little about mmx.
Are there equivalent replacement functions that would do the same in 64 bit ?