00001
00002 #ifndef oxp_yuv_to_rgb_h_
00003 #define oxp_yuv_to_rgb_h_
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 inline
00039 unsigned char oxp_yuv_to_rgb_byte_clamp(int x)
00040 {
00041 x = x / 1024;
00042 if (x < 0) return 0;
00043 if (x > 255) return 255;
00044 return (unsigned char) x;
00045 }
00046
00047 inline
00048 void oxp_yuv_to_rgb(unsigned char y, unsigned char u, unsigned char v, unsigned char* rgb)
00049 {
00050 const int c1164 = int(1.164 * 1024);
00051 const int c1596 = int(1.596 * 1024);
00052 const int c0813 = int(0.813 * 1024);
00053 const int c0391 = int(0.391 * 1024);
00054 const int c2018 = int(2.018 * 1024);
00055 rgb[0] = oxp_yuv_to_rgb_byte_clamp(c1164 * (y - 16) + c1596 * (v - 128));
00056 rgb[1] = oxp_yuv_to_rgb_byte_clamp(c1164 * (y - 16) - c0813 * (v - 128) - c0391 * (u - 128));
00057 rgb[2] = oxp_yuv_to_rgb_byte_clamp(c1164 * (y - 16) + c2018 * (u - 128));
00058 }
00059
00060 #endif // oxp_yuv_to_rgb_h_