我有以下 C 代码将隔行扫描网络摄像头 YUYV 转换为灰色:
void convert_yuyv_to_y(const void *src, char *dest) {
int x, y;
char *Y, *gray;
//get only Y component for grayscale from (Y1)(U1,2)(Y2)(V1,2)
for (y = 0; y < CAM_HEIGHT; y++) {
Y = src + (CAM_WIDTH * 2 * y);
gray = dest + (CAM_WIDTH * y);
for (x=0; x < CAM_WIDTH; x += 2) {
gray[x] = *Y;
Y += 2;
gray[x + 1] = *Y;
Y += 2;
}
}
}
有没有办法通过一些霓虹灯指令来优化这种功能?