summaryrefslogtreecommitdiff
path: root/progs/tests/yuvrect.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2003-05-20 09:54:58 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2003-05-20 09:54:58 +0000
commit27358a24a0113a62492923abe35e8660ed7335ef (patch)
tree474f45986d53e0829312ac99db7dc78634d4a84d /progs/tests/yuvrect.c
parenteea72ff722975d91bc2293a403bb43d69e5858d0 (diff)
move LoadYUVImage into readtex.c
Diffstat (limited to 'progs/tests/yuvrect.c')
-rw-r--r--progs/tests/yuvrect.c43
1 files changed, 2 insertions, 41 deletions
diff --git a/progs/tests/yuvrect.c b/progs/tests/yuvrect.c
index 22ee91cae97..509c0433b91 100644
--- a/progs/tests/yuvrect.c
+++ b/progs/tests/yuvrect.c
@@ -19,7 +19,6 @@
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLint ImgWidth, ImgHeight;
static GLenum ImgFormat;
-static GLubyte *Image = NULL;
static GLushort *ImageYUV = NULL;
@@ -107,42 +106,6 @@ static void SpecialKey( int key, int x, int y )
}
-#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
-
-static void ConvertRGBtoYUV(GLint w, GLint h, const GLubyte *src,
- GLushort *dest)
-{
- GLint i, j;
-
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
- const GLfloat r = (*src++) / 255.0;
- const GLfloat g = (*src++) / 255.0;
- const GLfloat b = (*src++) / 255.0;
- GLfloat y, cr, cb;
- GLint iy, icr, icb;
-
- y = r * 65.481 + g * 128.553 + b * 24.966 + 16;
- cb = r * -37.797 + g * -74.203 + b * 112.0 + 128;
- cr = r * 112.0 + g * -93.786 + b * -18.214 + 128;
- /*printf("%f %f %f -> %f %f %f\n", r, g, b, y, cb, cr);*/
- iy = (GLint) CLAMP(y, 0, 254);
- icb = (GLint) CLAMP(cb, 0, 254);
- icr = (GLint) CLAMP(cr, 0, 254);
-
- if (j & 1) {
- /* odd */
- *dest = (iy << 8) | icr;
- }
- else {
- /* even */
- *dest = (iy << 8) | icb;
- }
- dest++;
- }
- }
-}
-
static void Init( int argc, char *argv[] )
{
@@ -176,16 +139,14 @@ static void Init( int argc, char *argv[] )
else
file = TEXTURE_FILE;
- Image = LoadRGBImage(file, &ImgWidth, &ImgHeight, &ImgFormat);
- if (!Image) {
+ ImageYUV = LoadYUVImage(file, &ImgWidth, &ImgHeight);
+ if (!ImageYUV) {
printf("Couldn't read %s\n", TEXTURE_FILE);
exit(0);
}
printf("Image: %dx%d\n", ImgWidth, ImgHeight);
- ImageYUV = (GLushort *) malloc(ImgWidth * ImgHeight * sizeof(GLushort));
- ConvertRGBtoYUV(ImgWidth, ImgHeight, Image, ImageYUV);
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0,
GL_YCBCR_MESA, ImgWidth, ImgHeight, 0,
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, ImageYUV);