|
100驿站币
目前 已有写法 CPU计算 比较浪费资源
int ConvertYUY2toRGB32(unsigned char* pOutputRgb, unsigned char* pInputBuffer, int tInputWidth, int tInputHeight)
{
unsigned char* yuyv = pInputBuffer;
int z = 0, i = 0, j = 0;
for (i = 0; i < tInputHeight; i++) {
for (j = 0; j < tInputWidth; j++) {
int r, g, b;
int y, u, v;
if (!z)
y = yuyv[0] << 8;
else
y = yuyv[2] << 8;
u = yuyv[1] - 128;
v = yuyv[3] - 128;
r = (y + (359 * v)) >> 8;
g = (y - (88 * u) - (183 * v)) >> 8;
b = (y + (454 * u)) >> 8;
r = (r > 255) ? 255 : ((r < 0) ? 0 : r);
g = (g > 255) ? 255 : ((g < 0) ? 0 : g);
b = (b > 255) ? 255 : ((b < 0) ? 0 : b);
*pOutputRgb++ = b;
*pOutputRgb++ = g;
*pOutputRgb++ = r;
*pOutputRgb++ = 255;
if (z++) {
z = 0;
yuyv += 4;
}
}
}
return 0;
}
求助 使用D3DCompile 等函数 和 hlsl 进行转换 ,包装的接口函数原型应(与上面保持一致) 如下
int ConvertYUY2toRGB32_GPU(unsigned char* pOutputRgb, unsigned char* pInputBuffer, int tInputWidth, int tInputHeight) ;
pOutputRgb为用户已分配的空白内存指针 大小为 tInputWidth * tInputHeight * 4
pInputBuffer为既有的YUY2帧数据, 大小为tInputWidth * tInputHeight * 2
d3d等创建释放全部写在这一个函数里就行 (之后我自己会提取分割函数)
|
上一篇: Color Picker for WTL with XP themes
|