全部博文(668)
分类:
2009-08-06 15:46:27
The following coefficients are used in conversion process:
C = Y - 16 D = U - 128 E = V - 128
Using the previous coefficients and noting that clip()
denotes clipping a value to the range of 0 to 255, the following formulas provide the conversion from YUV to RGB:
R = clip(( 298 * C + 409 * E + 128) >> 8) G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8) B = clip(( 298 * C + 516 * D + 128) >> 8)
These formulas use some coefficients that require more than 8 bits of precision to produce each 8-bit result, and intermediate results require more than 16 bits of precision.
Note All units range from 0 (zero) to 1.0 (one). In DirectDraw, they range from 0 to 255. Overflow and underflow can (and does) occur, and the results must be saturated.
To convert 4:2:0 or 4:2:2 YUV to RGB, convert the YUV data to 4:4:4 YUV, and then convert from 4:4:4 YUV to RGB.