-/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */
-/* We convert YCbCr to RGB here */
-static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel )
-{
- const GLushort *src0 = TEXEL_ADDR(GLushort, texImage, (i & ~1), j, k, 1); /* even */
- const GLushort *src1 = src0 + 1; /* odd */
- const GLubyte y0 = *src0 & 0xff; /* luminance */
- const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
- const GLubyte y1 = *src1 & 0xff; /* luminance */
- const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
- GLfloat r, g, b;
- if (i & 1) {
- /* odd pixel: use y1,cr,cb */
- r = (1.164 * (y1-16) + 1.596 * (cr-128));
- g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
- b = (1.164 * (y1-16) + 2.018 * (cb-128));
- }
- else {
- /* even pixel: use y0,cr,cb */
- r = (1.164 * (y0-16) + 1.596 * (cr-128));
- g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
- b = (1.164 * (y0-16) + 2.018 * (cb-128));
- }
- /* XXX remove / 255 here by tweaking arithmetic above */
- r /= 255.0;
- g /= 255.0;
- b /= 255.0;
- /* XXX should we really clamp??? */
- texel[RCOMP] = CLAMP(r, 0.0, 1.0);
- texel[GCOMP] = CLAMP(g, 0.0, 1.0);
- texel[BCOMP] = CLAMP(b, 0.0, 1.0);
- texel[ACOMP] = 1.0F;
-}
-