I copy/past the code i use. clip8 trunc the value at 0 or 255.
YUV444toRGB888_true are the value find inside the fourcc website and a microsoft web site. YUV444toRGB888 are the one i use because the array of possible value are not the same. I find this because on some image appear big array of white or blue. I juste change Y value ( 298 -> 266) because i did not find an easy way to have the max and the min for the uv part of the image. /* Real formule for yuv -> rgb conversion "the defined range for Y is [16,235] (220 steps) and the valid ranges for Cr and Cb are [16,239] (235 steps) These are normalized ranges and when the data is used, 16 is added to Y and 128 is added from Cr and Cb to de-normalize them. The reason for this is that control and colorburst information is stored in the components along with the luminence and chromiance data which is why the full range of [0,255] is not used. There is no "rumor" about this being correct. It is a defined standard for YCrCb video. I wouldn't be surprised if certain PC programs are using a variant where the entire range of [0,255] is used but technically it is not YCrCb." http://www.fourcc.org/fccyvrgb.php Y [16,235] for [0.0:1.0] U&V [16,239] for [-0.5;+0.5] */ inline unsigned char * video_t::YUV444toRGB888_true(unsigned int Y, unsigned int U, unsigned int V, unsigned char ret[3]) { int C, D, E; C = Y - 16; D = U - 128; E = V - 128; ret[0] = clip8(( 298 * C + 409 * E + 128) >> 8); ret[1] = clip8(( 298 * C - 100 * D - 208 * E + 128) >> 8); ret[2] = clip8(( 298 * C + 516 * D + 128) >> 8); return ret; } /* but webcam use Y[0;244] */ inline unsigned char * video_t::YUV444toRGB888(unsigned int Y, unsigned int U, unsigned int V, unsigned char ret[3]) { int C, D, E; C = Y; D = U - 128; E = V - 128; ret[0] = clip8(( 266 * C + 409 * E + 128) >> 8); ret[1] = clip8(( 266 * C - 100 * D - 208 * E + 128) >> 8); ret[2] = clip8(( 266 * C + 516 * D + 128) >> 8); return ret; } 2007/1/19, Timothy Miller <[EMAIL PROTECTED]>:
On 1/19/07, Nicolas Boulay <[EMAIL PROTECTED]> wrote: > So we can't take a fixe transformation matrix for it. I think someone here said that the various transform matrices aren't really different enough for it to make much of a visible difference. If there are a handful of different ones that are really different, we will have to decide whether it's better to have multiple fixed functions versus one generalized one. Some of the subterms may be shared between different sets of coefficients. -- Timothy Miller http://www.cse.ohio-state.edu/~millerti
_______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
