YUV 转 RGB 算法
void yuv422p_quto_rgb565(unsigned char *yuvBuffer_in, unsigned char *rgbBuffer_out, int width, int height) { u8 *yuvBuffer = (u8 *)yuvBuffer_in; u8 *rgb16Buff = (u8 *)rgbBuffer_out; int indexY = 0; int indexU = 0; int indexV = 0; u8 Y = 0; u8 U = 0; u8 V = 0; u8 R, G, B; u16 data = 0; int rdif, invgdif, bdif; int x, y; int br, bg, bb; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { indexY = y * width + x; indexU = width * height + y / 2 * width + x / 2 ; indexV = width * height + width * height / 2 + y / 2 * width + x / 2; Y = yuvBuffer[indexY]; U = yuvBuffer[indexU]; V = yuvBuffer[indexV]; rdif = Table_fv1[V]; invgdif = Table_fu1[U] + Table_fv2[V]; bdif = Table_fu2[U]; br = Y + rdif; bg = Y - invgdif; bb = Y + bdif; R = (br & 0x80000000) ? 0 : ((br & 0x7fffff00) ? 255 : br); //小于0 0 , 大于255 255 G = (bg & 0x80000000) ? 0 : ((bg & 0x7fffff00) ? 255 : bg); //小于0 0 , 大于255 255 B = (bb & 0x80000000) ? 0 : ((bb & 0x7fffff00) ? 255 : bb); //小于0 0 , 大于255 255 data = rgb_24_to_565((u8)R, (u8)G, (u8)B); #ifdef RGB16_BE *rgb16Buff++ = data & 0xff; *rgb16Buff++ = (data >> 8) & 0xff; #else *rgb16Buff++ = (data >> 8) & 0xff; *rgb16Buff++ = data & 0xff; #endif } } }