Changeset 6653 for trunk/src/opengl/glide/sst1/texus
- Timestamp:
- Sep 5, 2001, 4:31:14 PM (24 years ago)
- Location:
- trunk/src/opengl/glide/sst1/texus
- Files:
-
- 14 edited
-
3df.c (modified) (6 diffs)
-
clamp.c (modified) (7 diffs)
-
dequant.c (modified) (10 diffs)
-
diffuse.c (modified) (17 diffs)
-
gldutil.c (modified) (5 diffs)
-
mipmap.c (modified) (3 diffs)
-
ncc.c (modified) (9 diffs)
-
nccnnet.c (modified) (21 diffs)
-
pal256.c (modified) (19 diffs)
-
ppm.c (modified) (5 diffs)
-
quantize.c (modified) (23 diffs)
-
read.c (modified) (10 diffs)
-
resample.c (modified) (9 diffs)
-
rgt.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/glide/sst1/texus/3df.c
r2885 r6653 1 /* $Id: 3df.c,v 1.2 2001-09-05 14:31:07 bird Exp $ */ 1 2 /* 2 3 * THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 4 * PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 5 * TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 * INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 * DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 * THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 6 * INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 * DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 * THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 9 * EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 * FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 * FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 11 * 11 12 * USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO … … 25 26 /*************************************** 3df files ****************************/ 26 27 /* Read word, msb first */ 27 static FxBool 28 static FxBool 28 29 _txRead16 (FILE *stream, FxU16* data) 29 30 { … … 36 37 37 38 /* Read long word, msb first */ 38 static FxBool 39 static FxBool 39 40 _txRead32 (FILE *stream, FxU32* data) 40 41 { … … 53 54 54 55 /* Read NCC table */ 55 static FxBool 56 static FxBool 56 57 _txRead3DFNCCTable (FILE* stream, FxI32* ncc_table) 57 58 { … … 87 88 } 88 89 89 static FxBool 90 static FxBool 90 91 _txRead3DFPalTable (FILE* stream, FxI32* pal) 91 92 { … … 114 115 if (fscanf (stream, "f v%6s", version) != 1) return FXFALSE; 115 116 116 /* 117 /* 117 118 * skip comments 118 119 */ -
trunk/src/opengl/glide/sst1/texus/clamp.c
r2885 r6653 1 /* $Id: clamp.c,v 1.2 2001-09-05 14:31:08 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:36$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:08 $ 23 24 */ 24 25 … … 37 38 if( txVerbose ) 38 39 { 39 printf( "clamping from %dx%d to %dx%d\n", 40 printf( "clamping from %dx%d to %dx%d\n", 40 41 ix, iy, ox, oy ); 41 42 } … … 76 77 if ((srcMip->data[0] == NULL) || (dstMip->data[0] == NULL)) 77 78 txPanic("txImageClamp: Null buffer\n"); 78 79 79 80 sw = srcMip->width; 80 81 sh = srcMip->height; … … 82 83 dh = dstMip->height; 83 84 84 for( i = 0; i < srcMip->depth; i++ ) 85 for( i = 0; i < srcMip->depth; i++ ) 85 86 { 86 87 if( !dstMip->data[i] ) … … 103 104 } 104 105 } 105 106 -
trunk/src/opengl/glide/sst1/texus/dequant.c
r2885 r6653 1 /* $Id: dequant.c,v 1.2 2001-09-05 14:31:08 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:37$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:08 $ 23 24 */ 24 25 … … 30 31 #include "texusint.h" 31 32 32 /* 33 /* 33 34 * Pn_8 = convert n bits (n <= 6) to 8 bits by replicating the msb's of input 34 35 * into the lsb's of the output. … … 94 95 95 96 /* 16 bit pixels */ 96 static FxU32 97 static FxU32 97 98 _txPixArgb8332to8888(FxU16 c8332) 98 99 { 99 100 FxU32 a, r, g, b; 100 a = (c8332 >> 8); 101 a = (c8332 >> 8); 101 102 r = P3_8[(c8332 >> 5) & 0x7]; 102 103 g = P3_8[(c8332 >> 2) & 0x7]; … … 233 234 in += n; 234 235 while (n--) { 235 in--; 236 in--; 236 237 *--out = (pal[(*in) & 0xff] & 0x00ffffff) | ((*in & 0xFF00) << 16); 237 238 } … … 302 303 in += n; 303 304 304 while (n--) *--out = *--in; 305 while (n--) *--out = *--in; 305 306 } 306 307 … … 314 315 for( i = 0; i < n; i++ ) 315 316 { 316 out[i] = 317 ( ( ( FxU32 )0xff ) << 24 ) | 317 out[i] = 318 ( ( ( FxU32 )0xff ) << 24 ) | 318 319 ( ( ( FxU32 )in[i*3] )<< 16 ) | 319 320 ( ( ( FxU32 )in[i*3+1] )<< 8 ) | … … 322 323 } 323 324 324 void 325 void 325 326 txMipDequantize(TxMip *txMip, TxMip *pxMip) 326 327 { … … 344 345 printf(" %dx%d", w, h); fflush(stdout); 345 346 } 346 347 347 348 switch(pxMip->format) { 348 case GR_TEXFMT_RGB_332: _txImgDequantizeRGB332(dst, src, w, h); 349 break; 350 case GR_TEXFMT_YIQ_422: _txImgDequantizeYIQ422(dst, src, w, h, 349 case GR_TEXFMT_RGB_332: _txImgDequantizeRGB332(dst, src, w, h); 350 break; 351 case GR_TEXFMT_YIQ_422: _txImgDequantizeYIQ422(dst, src, w, h, 351 352 (long *)pxMip->pal); break; 352 case GR_TEXFMT_A_8: _txImgDequantizeA8(dst, src, w, h); 353 break; 354 case GR_TEXFMT_I_8: _txImgDequantizeI8(dst, src, w, h); 355 break; 356 case GR_TEXFMT_AI_44: _txImgDequantizeAI44(dst, src, w, h); 357 break; 358 case GR_TEXFMT_P_8: _txImgDequantizeP8(dst, src, w, h, 353 case GR_TEXFMT_A_8: _txImgDequantizeA8(dst, src, w, h); 354 break; 355 case GR_TEXFMT_I_8: _txImgDequantizeI8(dst, src, w, h); 356 break; 357 case GR_TEXFMT_AI_44: _txImgDequantizeAI44(dst, src, w, h); 358 break; 359 case GR_TEXFMT_P_8: _txImgDequantizeP8(dst, src, w, h, 359 360 pxMip->pal); break; 360 361 361 case GR_TEXFMT_ARGB_8332: _txImgDequantizeARGB8332(dst, src, w, h); 362 break; 363 case GR_TEXFMT_AYIQ_8422: _txImgDequantizeAYIQ8422(dst, src, w, h, 362 case GR_TEXFMT_ARGB_8332: _txImgDequantizeARGB8332(dst, src, w, h); 363 break; 364 case GR_TEXFMT_AYIQ_8422: _txImgDequantizeAYIQ8422(dst, src, w, h, 364 365 (long *)pxMip->pal); break; 365 case GR_TEXFMT_RGB_565: _txImgDequantizeRGB565(dst, src, w, h); 366 break; 367 case GR_TEXFMT_ARGB_1555: _txImgDequantizeARGB1555(dst, src, w, h); 368 break; 369 case GR_TEXFMT_ARGB_4444: _txImgDequantizeARGB4444(dst, src, w, h); 370 break; 371 case GR_TEXFMT_AI_88: _txImgDequantizeAI88(dst, src, w, h); 372 break; 373 case GR_TEXFMT_AP_88: _txImgDequantizeAP88(dst, src, w, h, 366 case GR_TEXFMT_RGB_565: _txImgDequantizeRGB565(dst, src, w, h); 367 break; 368 case GR_TEXFMT_ARGB_1555: _txImgDequantizeARGB1555(dst, src, w, h); 369 break; 370 case GR_TEXFMT_ARGB_4444: _txImgDequantizeARGB4444(dst, src, w, h); 371 break; 372 case GR_TEXFMT_AI_88: _txImgDequantizeAI88(dst, src, w, h); 373 break; 374 case GR_TEXFMT_AP_88: _txImgDequantizeAP88(dst, src, w, h, 374 375 pxMip->pal); break; 375 case GR_TEXFMT_ARGB_8888: _txImgDequantizeARGB8888(dst, src, w, h); 376 break; 377 case GR_TEXFMT_RGB_888: _txImgDequantizeRGB888(dst, src, w, h); 378 break; 379 380 default: 376 case GR_TEXFMT_ARGB_8888: _txImgDequantizeARGB8888(dst, src, w, h); 377 break; 378 case GR_TEXFMT_RGB_888: _txImgDequantizeRGB888(dst, src, w, h); 379 break; 380 381 default: 381 382 break; 382 383 } -
trunk/src/opengl/glide/sst1/texus/diffuse.c
r2885 r6653 1 /* $Id: diffuse.c,v 1.2 2001-09-05 14:31:09 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:37$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:09 $ 23 24 */ 24 25 … … 39 40 FxU8 bestR[256], bestG[256], bestB[256]; 40 41 41 static int 42 static int 42 43 _txAscendingR(const void *a, const void *b) 43 44 { … … 46 47 47 48 48 static int 49 static int 49 50 _txAscendingG(const void *a, const void *b) 50 51 { … … 53 54 54 55 55 static int 56 static int 56 57 _txAscendingB(const void *a, const void *b) 57 58 { … … 78 79 79 80 #if 0 80 for (i=0; i<ncolors; i++) 81 printf("[%3d] = R%.08x G%.08x B%.08x\n", 81 for (i=0; i<ncolors; i++) 82 printf("[%3d] = R%.08x G%.08x B%.08x\n", 82 83 i, sortR[i], sortG[i], sortB[i]); 83 84 #endif 84 85 85 86 86 87 for (i=0; i<256; i++) { 87 88 … … 129 130 persist = 0; 130 131 for (i=bestR[r]; i>=0; i--) { 131 d = DISTANCE(r, g, b, 132 d = DISTANCE(r, g, b, 132 133 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 133 134 if (d < mindist) { mindist = d; minpos = (pal[i] >> 24) & 0xff; } … … 138 139 persist = 0; 139 140 for (i=bestR[r]+1; i < nsorted; i++) { 140 d = DISTANCE(r, g, b, 141 d = DISTANCE(r, g, b, 141 142 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 142 143 if (d < mindist) { mindist = d; minpos = (pal[i] >> 24) & 0xff; } … … 149 150 persist = 0; 150 151 for (i=bestG[g]; i>=0; i--) { 151 d = DISTANCE(r, g, b, 152 d = DISTANCE(r, g, b, 152 153 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 153 154 if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; } … … 158 159 persist = 0; 159 160 for (i=bestG[g]+1; i < nsorted; i++) { 160 d = DISTANCE(r, g, b, 161 d = DISTANCE(r, g, b, 161 162 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 162 163 if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; } … … 168 169 persist = 0; 169 170 for (i=bestB[b]; i>=0; i--) { 170 d = DISTANCE(r, g, b, 171 d = DISTANCE(r, g, b, 171 172 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 172 173 if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; } … … 177 178 persist = 0; 178 179 for (i=bestB[b]+1; i < nsorted; i++) { 179 d = DISTANCE(r, g, b, 180 d = DISTANCE(r, g, b, 180 181 ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff)); 181 182 if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; } … … 221 222 ib += qb + ErrB[x]; 222 223 223 qr = ir; // quantized pixel values. 224 qr = ir; // quantized pixel values. 224 225 qg = ig; // qR is error from pixel to left, errR is 225 226 qb = ib; // error from pixel to the top & top left. … … 245 246 qb = ib - qb; 246 247 247 // 3/8 (=0.375) to the EAST, 3/8 to the SOUTH, 248 // 3/8 (=0.375) to the EAST, 3/8 to the SOUTH, 248 249 // 1/4 (0.25) to the SOUTH-EAST. 249 250 ErrR[x] = ((x == 0) ? 0 : ErrR[x]) + ((int) (qr * 0.375f)); … … 279 280 printf("EDiffusion:..."); fflush(stdout); 280 281 } 281 282 282 283 #if FAST_DIFFUSION 283 284 _txMakeRange(palette, ncolors); … … 289 290 290 291 for (i=0; i<txMip->depth; i++) { 291 _txToDiffuseIndex(pxMip->data[i], pixsize, palette, ncolors, 292 _txToDiffuseIndex(pxMip->data[i], pixsize, palette, ncolors, 292 293 txMip->data[i], w, h); 293 294 if (w > 1) w >>= 1; -
trunk/src/opengl/glide/sst1/texus/gldutil.c
r2885 r6653 1 /* $Id: gldutil.c,v 1.2 2001-09-05 14:31:10 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:37$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:10 $ 23 24 */ 24 25 … … 35 36 /* 36 37 * Allocate memory via Glide for a texture. 37 * Assumes that the passed image is already quantized to 38 * Assumes that the passed image is already quantized to 38 39 * the format that you want to download. 39 40 */ … … 325 326 ncc_table.yRGB[i] = ( FxU8 )texture->pal[i]; 326 327 } 327 328 328 329 for( i = 0; i < 4; i++ ) 329 330 { -
trunk/src/opengl/glide/sst1/texus/mipmap.c
r2885 r6653 1 /* $Id: mipmap.c,v 1.2 2001-09-05 14:31:10 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:37$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:10 $ 23 24 */ 24 25 -
trunk/src/opengl/glide/sst1/texus/ncc.c
r2885 r6653 1 /* $Id: ncc.c,v 1.2 2001-09-05 14:31:11 bird Exp $ */ 1 2 /* 2 3 ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 4 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 5 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 9 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 ** 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 12 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 12 13 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 14 15 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 15 16 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 16 ** THE UNITED STATES. 17 ** 17 ** THE UNITED STATES. 18 ** 18 19 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 19 20 ** 20 ** $Revision: 1. 1$21 ** $Date: 200 0-02-25 00:31:37$21 ** $Revision: 1.2 $ 22 ** $Date: 2001-09-05 14:31:11 $ 22 23 */ 23 24 … … 29 30 #include "texusint.h" 30 31 31 static int 32 dithmat[4][4] = { 0, 8, 2, 10, 33 12, 4, 14, 6, 34 3, 11, 1, 9, 32 static int 33 dithmat[4][4] = { 0, 8, 2, 10, 34 12, 4, 14, 6, 35 3, 11, 1, 9, 35 36 15, 7, 13, 5 }; 36 37 … … 45 46 _txPixQuantize_YIQ422 (unsigned long argb, int x, int y, int w) 46 47 { 47 int r, g, b; 48 int r, g, b; 48 49 int iy, ii, iq; 49 50 … … 125 126 126 127 static void 127 _txImgNcc(char *odata, unsigned long *idata, int w, int h, int format, 128 _txImgNcc(char *odata, unsigned long *idata, int w, int h, int format, 128 129 int dither) 129 130 { … … 153 154 154 155 RGB values can be converted to YIQ using the equation: 155 156 156 157 Y = 0.30F * R + 0.59F * G + 0.11F * B; 157 158 I = 0.60F * R - 0.28F * G - 0.32F * B; 158 159 Q = 0.21F * R - 0.52F * G + 0.31F * B; 159 160 160 Assuming that each of the RGB components are in the range 0..255, 161 Assuming that each of the RGB components are in the range 0..255, 161 162 Y ranges from (0 .. 255) 162 163 I ranges from (-0.60 * 255 .. 0.60 * 255) i.e, (-153 to 153) … … 166 167 167 168 168 static void 169 static void 169 170 _txMipNccStatTable(TxMip *txMip) 170 171 { 171 172 int i, w, h; 172 173 173 for (i=0; i<256; i++) 174 for (i=0; i<256; i++) 174 175 ncc.yhist[i] = ncc.ihist[i] = ncc.qhist[i] = 0; 175 176 ncc.npixels = 0; … … 250 251 251 252 252 void 253 void 253 254 txMipNcc(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression) 254 255 { … … 256 257 257 258 switch (compression & TX_COMPRESSION_MASK) { 258 case TX_COMPRESSION_HEURISTIC: 259 case TX_COMPRESSION_HEURISTIC: 259 260 _txMipNccStatTable(txMip); 260 261 for (i=0; i< 16; i++) pxMip->pal[ 0 + i] = ncc.y[i]; -
trunk/src/opengl/glide/sst1/texus/nccnnet.c
r2885 r6653 1 /* $Id: nccnnet.c,v 1.2 2001-09-05 14:31:11 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:38$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:11 $ 23 24 */ 24 25 #include <stdio.h> … … 33 34 * ARGB8888 format and produces an optimal YAB table, and an 8 bit image 34 35 * in YAB format that best represents the original image. A very detailed 35 * explanation of the algorithm is available in 36 * explanation of the algorithm is available in 36 37 * /tdfx/engr/devel/sst1/docs/yab.doc. The summary follows. 37 38 * 38 * Neural net algorithms first determine a "representative sample" of the 39 * Neural net algorithms first determine a "representative sample" of the 39 40 * input image. This representative sample is repeatedly run through the net 40 41 * during the network learning stage, and the neural net "learns" which colors 41 42 * are important and which ones are not. It's quite possible to feed every 42 43 * pixel in the original image repeatedly into the neural net 43 * to make it learn; however, this can be extremely time consuming. 44 * to make it learn; however, this can be extremely time consuming. 44 45 * 45 46 * So, we prefer to make a representative sample of colors for the input image. … … 48 49 * colors (just like for the 8-bit palettized case) works quite well, and 49 50 * so we first quantize to 8 bit palette, and use the palette as the sample 50 * colors to feed the neural network. This also makes using 256-palette 51 * colors to feed the neural network. This also makes using 256-palette 51 52 * textures very easy. 52 53 * 53 54 * After the "representative colors" are determined, we train the neural net, 54 * and obtain the optimal YAB table. Each sample color in the palette, 55 * which was originally in ARGB8888 format is now replaced with IRGB8888, 56 * where the RGB is the same as before, but the alpha channel is replaced 57 * with an 8 bit number I which is the YAB index corresponding to this 58 * representative color. 55 * and obtain the optimal YAB table. Each sample color in the palette, 56 * which was originally in ARGB8888 format is now replaced with IRGB8888, 57 * where the RGB is the same as before, but the alpha channel is replaced 58 * with an 8 bit number I which is the YAB index corresponding to this 59 * representative color. 59 60 * 60 61 * So now it's possible to translate the original image into an 8 bit image … … 65 66 * In the process of converting the original image to the YAB format, we could 66 67 * optionally dither the image. Ordered dithering doesn't quite work, so we 67 * use error-diffusion dithering. 68 * use error-diffusion dithering. 68 69 * 69 70 * I've found that there are three speed bottlenecks to overcome. The first 70 71 * time consuming operation is the computation of representative image colors. 71 * 256 color quantization is used for this part. The second bottleneck is the 72 * training of the neural net algorithm itself, and I've optimized this as 72 * 256 color quantization is used for this part. The second bottleneck is the 73 * training of the neural net algorithm itself, and I've optimized this as 73 74 * much as possible. The third bottleneck is the translation of the original 74 75 * image into the 8 bit YAB indexed image; this still needs work, especially … … 79 80 80 81 /****************************************************************************** 81 * 82 * 82 83 * The hardcore neural net stuff begins here. 83 84 * … … 117 118 _nn_modifyNeurons(long ir, long ig, long ib) 118 119 { 119 int i; 120 int i; 120 121 int d0, d1; // closest & next closest distance to input 121 122 int p0, p1; // index into the 256 color table. … … 138 139 139 140 d = DISTANCE(n->r, n->g, n->b, ir, ig, ib); 140 if (d < d0) { 141 if (d < d0) { 141 142 d1 = d0; d0 = d; 142 143 p1 = p0; p0 = i; … … 145 146 d1 = d; 146 147 p1 = i; 147 } 148 } 148 149 } 149 150 … … 183 184 pb = N[p0].pb; 184 185 py->r += (dr >> 2) + (dg >> 1) + (db >> 2); CLAMP_PLUS(py->r); 185 pa->r += (dr >> 2) ; CLAMP_BOTH(pa->r); 186 pa->r += (dr >> 2) ; CLAMP_BOTH(pa->r); 186 187 pa->g += (dg >> 2) ; CLAMP_BOTH(pa->g); 187 188 pa->b += (db >> 2) ; CLAMP_BOTH(pa->b); … … 258 259 259 260 static int order[256]; 260 static int 261 static int 261 262 _nn_randomOrder(const void *a, const void *b) 262 263 { … … 275 276 276 277 _nn_initTables(); 277 /* 278 /* 278 279 * Select a number which is relatively prime to nsamples. 279 280 */ … … 295 296 FxU32 *pRGB; 296 297 297 // We present the samples randomly to the network. 298 // We present the samples randomly to the network. 298 299 // _nn_modify_neurons() makes the neurons learn 299 300 // errR, errG, errB, errMax are computed in _nn_modifyNeurons(), as … … 308 309 309 310 if (errMax < bstMax) { 310 /* 311 /* 311 312 * A lower total error than before, take a Snapshot 312 313 * … … 344 345 bstB = errB; 345 346 #if 0 346 printf("%8d%, dry=%8d, eMax=%8x eMax=%3d%3d%3d eAvg=%3d%3d%3d\n", 347 iterations, drySpells, errMax, 348 errG, errR, errB, 347 printf("%8d%, dry=%8d, eMax=%8x eMax=%3d%3d%3d eAvg=%3d%3d%3d\n", 348 iterations, drySpells, errMax, 349 errG, errR, errB, 349 350 totG/nsamples, totR/nsamples, totB/nsamples 350 351 ); … … 356 357 } 357 358 358 if (errMax == 0) { 359 // printf("******Exact Solution in %d iterations\n", iterations); 360 // _nn_Dump(); 359 if (errMax == 0) { 360 // printf("******Exact Solution in %d iterations\n", iterations); 361 // _nn_Dump(); 361 362 break; 362 363 } 363 364 } 364 365 365 /* 366 /* 366 367 * At this point YAB has the YAB table, samples has input palette, 367 368 * Replace MSB of samples with index to be used with YAB table. … … 393 394 394 395 395 /* 396 * Get a 256 color palette, to be used as samples 396 /* 397 * Get a 256 color palette, to be used as samples 397 398 * Incidentally, convert src 32 bit image to dst 8 bit indexed image, 398 399 * with indices referring to the 256 color palette. … … 403 404 printf("NCC Neural nets..."); fflush(stdout); 404 405 } 405 pxMip->format = (format == GR_TEXFMT_YIQ_422) ? GR_TEXFMT_P_8 : 406 pxMip->format = (format == GR_TEXFMT_YIQ_422) ? GR_TEXFMT_P_8 : 406 407 GR_TEXFMT_AP_88; 407 408 ncolors = txMipPal256(pxMip, txMip, pxMip->format, 0, 0); … … 413 414 if( txVerbose ) 414 415 { 415 printf("eMax=(%3d%3d%3d)...eAvg=(%3d%3d%3d)\n", 416 errG, errR, errB, 416 printf("eMax=(%3d%3d%3d)...eAvg=(%3d%3d%3d)\n", 417 errG, errR, errB, 417 418 totG/ncolors, totR/ncolors, totB/ncolors 418 419 ); … … 423 424 /* 424 425 * At this point, we can lose the 256 color palette, and replace it with 425 * the 256 color palette generated from the YAB table. This will be 426 * the 256 color palette generated from the YAB table. This will be 426 427 * useful for error diffusion dithering. 427 428 */ 428 429 txYABtoPal256((long *)pxMip->pal, (long *)yabTable); 429 430 txDiffuseIndex(pxMip, txMip, pixsize, pxMip->pal, 256); 430 } 431 } 431 432 else { 432 433 -
trunk/src/opengl/glide/sst1/texus/pal256.c
r2885 r6653 1 /* $Id: pal256.c,v 1.2 2001-09-05 14:31:12 bird Exp $ */ 1 2 /* 2 3 * This software is copyrighted as noted below. It may be freely copied, 3 * modified, and redistributed, provided that the copyright notice is 4 * modified, and redistributed, provided that the copyright notice is 4 5 * preserved on all copies. 5 * 6 * 6 7 * There is no warranty or other guarantee of fitness for this software, 7 8 * it is provided solely "as is". Bug reports or fixes may be sent … … 9 10 * 10 11 * You may not include this software in a program or other software product 11 * without supplying the source, or without informing the end-user that the 12 * without supplying the source, or without informing the end-user that the 12 13 * source is available for no extra charge. 13 14 * … … 72 73 * Readability constants. 73 74 */ 74 #define REDI 0 75 #define REDI 0 75 76 #define GREENI 1 76 #define BLUEI 2 77 #define BLUEI 2 77 78 #define TRUE 1 78 79 #define FALSE 0 … … 111 112 * Perform variance-based color quantization on a 24-bit image. 112 113 */ 113 int 114 int 114 115 txMipPal256(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression) 115 116 { … … 117 118 int i; /* Counter */ 118 119 int OutColors; /* # of entries computed */ 119 int Colormax; /* quantized full-intensity */ 120 int Colormax; /* quantized full-intensity */ 120 121 float Cfactor; /* Conversion factor */ 121 122 #if 0 … … 131 132 Cfactor = (float)FULLINTENSITY / Colormax; 132 133 133 Boxes = _Boxes; 134 Boxes = _Boxes; 134 135 #if 0 135 136 Histogram = (ulong *) txMalloc(ColormaxI*ColormaxI*ColormaxI * sizeof(long)); … … 157 158 158 159 OutColors = CutBoxes(Boxes, MAXCOLORS); 159 160 160 161 /* 161 162 * We now know the set of representative colors. We now … … 180 181 pxMip->pal[i] = (r<<16) | (g << 8) | b; 181 182 } 182 ComputeRGBMap(Boxes, OutColors, rgbmap); 183 ComputeRGBMap(Boxes, OutColors, rgbmap); 183 184 184 185 /* … … 218 219 *dst++ = rgbmap[index]; 219 220 } else { 220 *(FxU16 *)dst = (rgbmap[index]) | 221 *(FxU16 *)dst = (rgbmap[index]) | 221 222 ((argb >> 16) & 0xFF00); 222 223 dst+= 2; … … 253 254 * We compute both the histogram and the proj. frequencies of 254 255 * the first box at the same time to save a pass through the 255 * entire image. 256 * entire image. 256 257 */ 257 258 258 259 for (i = 0; i < npixels; i++) { 259 260 rr = (uchar) (((*pixels >> 16) & 0xff) >> (8-NBITS)); … … 266 267 Histogram[(((rr<<NBITS)|gg)<<NBITS)|bb]++; 267 268 } 268 269 269 270 } 270 271 … … 273 274 */ 274 275 static int 275 CutBoxes(Box *boxes, int colors) 276 CutBoxes(Box *boxes, int colors) 276 277 { 277 278 int curbox; … … 363 364 * Find 'optimal' cutpoint along each of the red, green and blue 364 365 * axes. Sum the variances of the two boxes which would result 365 * by making each cut and store the resultant boxes for 366 * by making each cut and store the resultant boxes for 366 367 * (possible) later use. 367 368 */ … … 461 462 bzero(box1->freq[0], ColormaxI * sizeof(ulong)); 462 463 bzero(box1->freq[1], ColormaxI * sizeof(ulong)); 463 bzero(box1->freq[2], ColormaxI * sizeof(ulong)); 464 bzero(box1->freq[2], ColormaxI * sizeof(ulong)); 464 465 465 466 for (r = box1->low[0]; r < box1->high[0]; r++) { … … 507 508 { 508 509 int r, g, b; 509 510 510 511 for (r = box->low[REDI]; r < box->high[REDI]; r++) { 511 512 for (g = box->low[GREENI]; g < box->high[GREENI]; g++) { 512 513 for (b = box->low[BLUEI]; b < box->high[BLUEI]; b++) { 513 514 int index; 514 515 515 516 index = (((r<<NBITS)|g)<<NBITS)|b; 516 517 rgbmap[index]=(char)boxnum; … … 528 529 int min_index; 529 530 long r, g, b; 530 531 531 532 min_dist = 256 * 256 + 256 * 256 + 256 * 256; 532 533 min_index = -1; … … 573 574 unsigned long index; 574 575 unsigned long r_index, g_index, b_index; 575 576 576 577 r_index = ( ( ( unsigned long )src[i*4+2] ) >> ( 8 - INVERSE_PAL_R_BITS ) ); 577 578 g_index = ( ( ( unsigned long )src[i*4+1] ) >> ( 8 - INVERSE_PAL_G_BITS ) ); 578 579 b_index = ( ( ( unsigned long )src[i*4+0] ) >> ( 8 - INVERSE_PAL_B_BITS ) ); 579 index = 580 index = 580 581 ( r_index << ( INVERSE_PAL_G_BITS + INVERSE_PAL_B_BITS ) ) | 581 582 ( g_index << INVERSE_PAL_B_BITS ) | … … 618 619 static FxU32 last_pal[256]; 619 620 static FxBool been_here = FXFALSE; 620 621 621 622 w = outputMip->width; 622 623 h = outputMip->height; … … 632 633 } 633 634 634 for( i = 0; i < trueColorMip->depth; i++ ) 635 for( i = 0; i < trueColorMip->depth; i++ ) 635 636 { 636 637 _txImgTrueToFixedPal( outputMip->data[i], trueColorMip->data[i], pal, -
trunk/src/opengl/glide/sst1/texus/ppm.c
r2885 r6653 1 /* $Id: ppm.c,v 1.2 2001-09-05 14:31:12 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:38$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:12 $ 23 24 ** 24 25 */ … … 32 33 33 34 34 FxBool 35 FxBool 35 36 _txReadPPMHeader( FILE *stream, FxU32 cookie, TxMip *info) 36 { 37 { 37 38 char buffer[256]; 38 39 FxU32 state = 1; 39 40 FxBool done = FXFALSE; 40 41 41 42 if ( stream == NULL ) { 42 txPanic("PPM file: Bad file handle.");43 return FXFALSE;43 txPanic("PPM file: Bad file handle."); 44 return FXFALSE; 44 45 } 45 46 46 47 while( !done && fgets( buffer, 256, stream ) ) { 47 char *token; 48 49 if ( buffer[0] == '#' ) continue; 50 for (token = strtok( buffer, " \t\n\r" ); token != NULL; 51 token = strtok( NULL, " \t\n\r" )) { 52 switch( state ) { 53 case 1: // Width 54 info->width = atoi( token ); 55 state++; 56 break; 48 char *token; 57 49 58 case 2: // height 59 info->height = atoi( token ); 60 state++; 61 break; 50 if ( buffer[0] == '#' ) continue; 51 for (token = strtok( buffer, " \t\n\r" ); token != NULL; 52 token = strtok( NULL, " \t\n\r" )) { 53 switch( state ) { 54 case 1: // Width 55 info->width = atoi( token ); 56 state++; 57 break; 62 58 63 case 3: // Color Depth 64 info->format = atoi( token ); 65 if ( info->format != 255 ) { 66 txPanic("Unsupported PPM format: max != 255\n"); 67 return FXFALSE; 68 } 69 state++; 70 done = FXTRUE; 71 break; 59 case 2: // height 60 info->height = atoi( token ); 61 state++; 62 break; 72 63 73 default: 74 txPanic("PPM file: parse error\n"); 75 return FXFALSE; 76 break; 77 } 78 } 64 case 3: // Color Depth 65 info->format = atoi( token ); 66 if ( info->format != 255 ) { 67 txPanic("Unsupported PPM format: max != 255\n"); 68 return FXFALSE; 69 } 70 state++; 71 done = FXTRUE; 72 break; 73 74 default: 75 txPanic("PPM file: parse error\n"); 76 return FXFALSE; 77 break; 78 } 79 79 } 80 80 } 81 81 82 if ( state < 4 ) { 82 txPanic("PPM file: Read error before end of header.");83 return FXFALSE;83 txPanic("PPM file: Read error before end of header."); 84 return FXFALSE; 84 85 } 85 86 info->depth = 1; … … 89 90 } 90 91 91 FxBool 92 _txReadPPMData( FILE *stream, TxMip *info) 93 { 92 FxBool 93 _txReadPPMData( FILE *stream, TxMip *info) 94 { 94 95 FxU32 numPixels; 95 96 FxU32 *data32 = info->data[0]; 96 97 97 98 numPixels = info->width * info->height; 98 99 99 100 if ( stream == NULL ) { 100 txPanic("PPM file: Bad file handle.");101 return FXFALSE;101 txPanic("PPM file: Bad file handle."); 102 return FXFALSE; 102 103 } 103 104 104 105 // Read in image data 105 106 while (numPixels--) { 106 int r, g, b;107 int r, g, b; 107 108 108 r = getc( stream );109 g = getc( stream );110 b = getc( stream );111 if ( b == EOF ) {112 txPanic("PPM file: Unexpected End of File.");113 return FXFALSE;114 }115 *data32++ = (0xFF << 24) | (r << 16) | (g << 8) | b;109 r = getc( stream ); 110 g = getc( stream ); 111 b = getc( stream ); 112 if ( b == EOF ) { 113 txPanic("PPM file: Unexpected End of File."); 114 return FXFALSE; 115 } 116 *data32++ = (0xFF << 24) | (r << 16) | (g << 8) | b; 116 117 } 117 118 return FXTRUE; -
trunk/src/opengl/glide/sst1/texus/quantize.c
r2885 r6653 1 /* $Id: quantize.c,v 1.2 2001-09-05 14:31:12 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:38$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:12 $ 23 24 */ 24 25 … … 30 31 #include "texusint.h" 31 32 32 static int 33 dithmat[4][4] = { 0, 8, 2, 10, 34 12, 4, 14, 6, 35 3, 11, 1, 9, 33 static int 34 dithmat[4][4] = { 0, 8, 2, 10, 35 12, 4, 14, 6, 36 3, 11, 1, 9, 36 37 15, 7, 13, 5 }; 37 38 38 39 // for error diffusion. 39 static int errR[MAX_TEXWIDTH], errG[MAX_TEXWIDTH], errB[MAX_TEXWIDTH]; 40 static int errR[MAX_TEXWIDTH], errG[MAX_TEXWIDTH], errB[MAX_TEXWIDTH]; 40 41 41 42 static int … … 54 55 int n, t; 55 56 56 n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 57 n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 57 58 t = (n>>4)<<5; 58 n = (int) (((argb >> 8) & 0xFF) * 0x70/255.0f + 0.5f) + d; 59 n = (int) (((argb >> 8) & 0xFF) * 0x70/255.0f + 0.5f) + d; 59 60 t |= (n>>4)<<2; 60 n = (int) (((argb ) & 0xFF) * 0x30/255.0f + 0.5f) + d; 61 n = (int) (((argb ) & 0xFF) * 0x30/255.0f + 0.5f) + d; 61 62 t |= (n>>4)<<0; 62 63 return t & 0xFF; … … 82 83 ib += errB[x] + qb; 83 84 84 qr = ir; // quantized pixel values. 85 qr = ir; // quantized pixel values. 85 86 qg = ig; // qR is error from pixel to left, errR is 86 87 qb = ib; // error from pixel to the top & top left. … … 157 158 158 159 159 n = (int) (n * 0xF0/255.0f + 0.5f) + d; 160 n = (int) (n * 0xF0/255.0f + 0.5f) + d; 160 161 t = (n>>4); 161 162 t |= (int) ((argb>>24) & 0xF0); … … 215 216 int n, t; 216 217 217 n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 218 n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 218 219 t = (n>>4)<<5; 219 n = (int) (((argb >> 8) & 0xFF) * 0x70/255.0f + 0.5f) + d; 220 n = (int) (((argb >> 8) & 0xFF) * 0x70/255.0f + 0.5f) + d; 220 221 t |= (n>>4)<<2; 221 n = (int) (((argb ) & 0xFF) * 0x30/255.0f + 0.5f) + d; 222 n = (int) (((argb ) & 0xFF) * 0x30/255.0f + 0.5f) + d; 222 223 t |= (n>>4)<<0; 223 224 t |= ((argb >> 16) & 0xFF00); … … 252 253 int n, t; 253 254 254 n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 255 n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 255 256 t = (n>>4)<<11; 256 n = (int) (((argb >> 8) & 0xFF) * 0x3F0/255.0f + 0.5f) + d; 257 n = (int) (((argb >> 8) & 0xFF) * 0x3F0/255.0f + 0.5f) + d; 257 258 t |= (n>>4)<<5; 258 n = (int) (((argb ) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 259 n = (int) (((argb ) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 259 260 t |= (n>>4)<<0; 260 261 return t & 0xFFFF; … … 279 280 ib += errB[x] + qb; 280 281 281 qr = ir; // quantized pixel values. 282 qr = ir; // quantized pixel values. 282 283 qg = ig; // qR is error from pixel to left, errR is 283 284 qb = ib; // error from pixel to the top & top left. … … 324 325 ((argb >> 9) & 0x7C00) | 325 326 ((argb >> 6) & 0x03E0) | 326 ((argb >> 3) & 0x001F) | 327 ((argb >> 3) & 0x001F) | 327 328 ((argb >> 24) ? 0x8000 : 0) ); 328 329 } … … 334 335 int n, t; 335 336 336 n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 337 n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 337 338 t = (n>>4)<<10; 338 n = (int) (((argb >> 8) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 339 n = (int) (((argb >> 8) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 339 340 t |= (n>>4)<<5; 340 n = (int) (((argb ) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 341 n = (int) (((argb ) & 0xFF) * 0x1F0/255.0f + 0.5f) + d; 341 342 t |= (n>>4)<<0; 342 343 t |= ((argb >> 24) ? 0x8000 : 0); … … 361 362 ib += errB[x] + qb; 362 363 363 qr = ir; // quantized pixel values. 364 qr = ir; // quantized pixel values. 364 365 qg = ig; // qR is error from pixel to left, errR is 365 366 qb = ib; // error from pixel to the top & top left. … … 407 408 ((argb >> 12) & 0x0F00) | 408 409 ((argb >> 8) & 0x00F0) | 409 ((argb >> 4) & 0x000F) | 410 ((argb >> 4) & 0x000F) | 410 411 ((argb >> 16) & 0xF000) ); 411 412 } … … 417 418 int n, t; 418 419 419 n = (int) (((argb >> 16) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 420 n = (int) (((argb >> 16) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 420 421 t = (n>>4)<<8; 421 n = (int) (((argb >> 8) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 422 n = (int) (((argb >> 8) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 422 423 t |= (n>>4)<<4; 423 n = (int) (((argb ) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 424 n = (int) (((argb ) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 424 425 t |= (n>>4)<<0; 425 426 t |= (argb >> 16) & 0xF000; … … 444 445 ib += errB[x] + qb; 445 446 446 qr = ir; // quantized pixel values. 447 qr = ir; // quantized pixel values. 447 448 qg = ig; // qR is error from pixel to left, errR is 448 449 qb = ib; // error from pixel to the top & top left. … … 511 512 512 513 switch(format) { 513 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332_DErr; 514 break; 515 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 514 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332_DErr; 515 break; 516 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 516 517 break; 517 518 case GR_TEXFMT_I_8: quantizer = _txPixQuantize_I8; … … 521 522 case GR_TEXFMT_ARGB_8332: quantizer = _txPixQuantize_ARGB8332_DErr; 522 523 break; 523 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565_DErr; 524 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565_DErr; 524 525 break; 525 526 case GR_TEXFMT_ARGB_1555: quantizer = _txPixQuantize_ARGB1555_DErr; … … 535 536 536 537 switch(format) { 537 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332_D4x4; 538 break; 539 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 540 break; 541 case GR_TEXFMT_I_8: quantizer = _txPixQuantize_I8; 542 break; 543 case GR_TEXFMT_AI_44: quantizer = _txPixQuantize_AI44_D4x4; 544 break; 545 546 case GR_TEXFMT_ARGB_8332: quantizer = _txPixQuantize_ARGB8332_D4x4; 547 break; 548 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565_D4x4; 549 break; 550 case GR_TEXFMT_ARGB_1555: quantizer = _txPixQuantize_ARGB1555_D4x4; 551 break; 552 case GR_TEXFMT_ARGB_4444: quantizer = _txPixQuantize_ARGB4444_D4x4; 553 break; 554 case GR_TEXFMT_AI_88: quantizer = _txPixQuantize_AI88; 555 break; 556 557 default: txPanic("Bad case in txQuantize()\n"); 538 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332_D4x4; 539 break; 540 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 541 break; 542 case GR_TEXFMT_I_8: quantizer = _txPixQuantize_I8; 543 break; 544 case GR_TEXFMT_AI_44: quantizer = _txPixQuantize_AI44_D4x4; 545 break; 546 547 case GR_TEXFMT_ARGB_8332: quantizer = _txPixQuantize_ARGB8332_D4x4; 548 break; 549 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565_D4x4; 550 break; 551 case GR_TEXFMT_ARGB_1555: quantizer = _txPixQuantize_ARGB1555_D4x4; 552 break; 553 case GR_TEXFMT_ARGB_4444: quantizer = _txPixQuantize_ARGB4444_D4x4; 554 break; 555 case GR_TEXFMT_AI_88: quantizer = _txPixQuantize_AI88; 556 break; 557 558 default: txPanic("Bad case in txQuantize()\n"); 558 559 break; 559 560 } … … 561 562 562 563 switch(format) { 563 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332; 564 break; 565 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 566 break; 567 case GR_TEXFMT_I_8: quantizer = _txPixQuantize_I8; 568 break; 569 case GR_TEXFMT_AI_44: quantizer = _txPixQuantize_AI44; 570 break; 571 572 case GR_TEXFMT_ARGB_8332: quantizer = _txPixQuantize_ARGB8332; 573 break; 574 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565; 575 break; 576 case GR_TEXFMT_ARGB_1555: quantizer = _txPixQuantize_ARGB1555; 577 break; 578 case GR_TEXFMT_ARGB_4444: quantizer = _txPixQuantize_ARGB4444; 579 break; 580 case GR_TEXFMT_AI_88: quantizer = _txPixQuantize_AI88; 581 break; 582 583 default: txPanic("Bad case in txQuantize()\n"); 564 case GR_TEXFMT_RGB_332: quantizer = _txPixQuantize_RGB332; 565 break; 566 case GR_TEXFMT_A_8: quantizer = _txPixQuantize_A8; 567 break; 568 case GR_TEXFMT_I_8: quantizer = _txPixQuantize_I8; 569 break; 570 case GR_TEXFMT_AI_44: quantizer = _txPixQuantize_AI44; 571 break; 572 573 case GR_TEXFMT_ARGB_8332: quantizer = _txPixQuantize_ARGB8332; 574 break; 575 case GR_TEXFMT_RGB_565: quantizer = _txPixQuantize_RGB565; 576 break; 577 case GR_TEXFMT_ARGB_1555: quantizer = _txPixQuantize_ARGB1555; 578 break; 579 case GR_TEXFMT_ARGB_4444: quantizer = _txPixQuantize_ARGB4444; 580 break; 581 case GR_TEXFMT_AI_88: quantizer = _txPixQuantize_AI88; 582 break; 583 584 default: txPanic("Bad case in txQuantize()\n"); 584 585 break; 585 586 } … … 614 615 * quality levels in each of the compression cases. 615 616 */ 616 void 617 void 617 618 txMipQuantize(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression) 618 619 { … … 636 637 return; 637 638 638 case GR_TEXFMT_ARGB_8888: 639 case GR_TEXFMT_ARGB_8888: 639 640 // Copy source to destination, and be done. 640 641 if( txVerbose ) … … 651 652 652 653 // Normal cases 653 case GR_TEXFMT_A_8: 654 case GR_TEXFMT_I_8: 655 case GR_TEXFMT_AI_44: 654 case GR_TEXFMT_A_8: 655 case GR_TEXFMT_I_8: 656 case GR_TEXFMT_AI_44: 656 657 case GR_TEXFMT_RGB_332: 657 case GR_TEXFMT_RGB_565: 658 case GR_TEXFMT_ARGB_8332: 659 case GR_TEXFMT_ARGB_1555: 658 case GR_TEXFMT_RGB_565: 659 case GR_TEXFMT_ARGB_8332: 660 case GR_TEXFMT_ARGB_1555: 660 661 case GR_TEXFMT_ARGB_4444: 661 662 case GR_TEXFMT_AI_88: -
trunk/src/opengl/glide/sst1/texus/read.c
r2885 r6653 1 /* $Id: read.c,v 1.2 2001-09-05 14:31:13 bird Exp $ */ 1 2 /* 2 3 ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 4 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 5 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 9 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 ** 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 12 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 12 13 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 14 15 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 15 16 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 16 ** THE UNITED STATES. 17 ** 17 ** THE UNITED STATES. 18 ** 18 19 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 19 20 ** 20 ** $Revision: 1. 1$21 ** $Date: 200 0-02-25 00:31:38$21 ** $Revision: 1.2 $ 22 ** $Date: 2001-09-05 14:31:13 $ 22 23 */ 23 24 … … 38 39 #define TX_UNK 0x200 // TGA is unknown from cookie signature. 39 40 40 int 41 int 41 42 _txReadHeader( FILE *stream, TxMip *info ) 42 43 { … … 86 87 } 87 88 88 static FxBool 89 static FxBool 89 90 _txReadData( FILE *stream, int fformat, TxMip *info ) 90 91 { … … 109 110 110 111 file = fopen(filename, "rb"); 111 if( file == NULL ) 112 if( file == NULL ) 112 113 { 113 114 fprintf( stderr,"Error: can't open input file %s\n", filename ); 114 115 exit(2); 115 116 } 116 117 117 118 retval = txMipReadFromFP( txMip, filename, file, prefFormat ); 118 119 fclose(file); … … 128 129 129 130 if ((prefFormat != GR_TEXFMT_ARGB_8888) && 130 (prefFormat != GR_TEXFMT_ANY)) 131 (prefFormat != GR_TEXFMT_ANY)) 131 132 { 132 133 txPanic("txMipRead: bad preferred format."); … … 143 144 fprintf(stderr,"Loading image file "); 144 145 145 fprintf (stderr,"%s (%dw x %dh x %d Bpp x %d mips) .. ", debug_filename, 146 fprintf (stderr,"%s (%dw x %dh x %d Bpp x %d mips) .. ", debug_filename, 146 147 txMip->width,txMip->height, GR_TEXFMT_SIZE(txMip->format), txMip->depth); 147 148 } 148 149 149 150 /* 150 * Allocate memory requested in data[0]; 151 * Allocate memory requested in data[0]; 151 152 */ 152 153 … … 159 160 continue; 160 161 } 161 txMip->data[i] = (FxU8*)txMip->data[i-1] + 162 txMip->data[i] = (FxU8*)txMip->data[i-1] + 162 163 w * h * GR_TEXFMT_SIZE(txMip->format); 163 164 if (w > 1) w >>= 1; … … 166 167 167 168 if( txVerbose ) { 168 fprintf( stderr, "mip-> format: %d width: %d height: %d depth: %d size: %d\n",169 txMip->format, txMip->width, txMip->height, txMip->depth,170 txMip->size );171 fflush( stderr );169 fprintf( stderr, "mip-> format: %d width: %d height: %d depth: %d size: %d\n", 170 txMip->format, txMip->width, txMip->height, txMip->depth, 171 txMip->size ); 172 fflush( stderr ); 172 173 } 173 174 … … 195 196 if( txVerbose ) 196 197 { 197 fprintf(stderr, "Dequantizing Input from %s to argb8888.\n", 198 fprintf(stderr, "Dequantizing Input from %s to argb8888.\n", 198 199 Format_Name[txMip->format]); 199 200 } -
trunk/src/opengl/glide/sst1/texus/resample.c
r2885 r6653 1 /* $Id: resample.c,v 1.2 2001-09-05 14:31:13 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:39$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:13 $ 23 24 */ 24 25 … … 38 39 * total of ox * ix fragments, same as before. 39 40 * Initialize an accumulator to 0. Add the first input pixel, multiplied by ox 40 * the number of fragments per input pixel. Keep track of the number of 41 * the number of fragments per input pixel. Keep track of the number of 41 42 * fragments in the accumulator; when this is >= ix, (the number of fragments 42 * it takes to make an output pixel), multiply the accumulator by 43 * it takes to make an output pixel), multiply the accumulator by 43 44 */ 44 45 … … 65 66 int oa, or, og, ob; 66 67 67 // Yes, we have (possibly more than) enough to generate an output 68 // pixel. Of the nf new fragments, use up enough to generate an 68 // Yes, we have (possibly more than) enough to generate an output 69 // pixel. Of the nf new fragments, use up enough to generate an 69 70 // output pixel. 70 71 71 72 ef = ix - accf; // the excessive # of fragments. 72 73 73 // printf("New: accf = %3d, nf = %3d, ef = %3d, ix = %3d, ox = %3d\n", 74 // printf("New: accf = %3d, nf = %3d, ef = %3d, ix = %3d, ox = %3d\n", 74 75 // accf, nf, ef, ix, ox); 75 76 … … 94 95 95 96 *out++ = (oa << 24) | (or << 16) | (og << 8) | ob; 96 // printf("Output pixel %4d: %.02x %.02x %.02x %.02x\n", 97 // printf("Output pixel %4d: %.02x %.02x %.02x %.02x\n", 97 98 // o, oa, or, og, ob); 98 99 o++; … … 124 125 125 126 static void 126 _txImgResample(FxU32 *out, int ox, int oy, 127 _txImgResample(FxU32 *out, int ox, int oy, 127 128 const FxU32 *in, int ix, int iy) 128 129 { … … 147 148 int ef; 148 149 149 // Yes, we have (possibly more than) enough to generate an output 150 // pixel. Of the nf new fragments, use up enough to generate an 150 // Yes, we have (possibly more than) enough to generate an output 151 // pixel. Of the nf new fragments, use up enough to generate an 151 152 // output pixel. 152 153 … … 243 244 printf("Resampling to %dx%d: ", destMip->width, destMip->height); 244 245 245 246 246 247 sw = srcMip->width; 247 248 sh = srcMip->height; -
trunk/src/opengl/glide/sst1/texus/rgt.c
r2885 r6653 1 /* $Id: rgt.c,v 1.2 2001-09-05 14:31:14 bird Exp $ */ 1 2 2 3 /* … … 4 5 ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 5 6 ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 6 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 7 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 8 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 7 ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 8 ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 9 ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 9 10 ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 10 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 11 ** 11 ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 12 ** 12 13 ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 13 14 ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN … … 15 16 ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 16 17 ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 17 ** THE UNITED STATES. 18 ** 18 ** THE UNITED STATES. 19 ** 19 20 ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 20 21 ** 21 ** $Revision: 1. 1$22 ** $Date: 200 0-02-25 00:31:39$22 ** $Revision: 1.2 $ 23 ** $Date: 2001-09-05 14:31:14 $ 23 24 ** 24 25 */ … … 36 37 const FxU16 ITYPE_BGR = 0x04; 37 38 const FxU16 ITYPE_RGT = 0x08; 38 39 39 40 typedef struct _rgtHeader{ 40 41 FxU16 magic; … … 67 68 while (length--) { 68 69 s = *array; 69 *array++ = (s << 24) | ((s >> 8)&0xFF00) | 70 *array++ = (s << 24) | ((s >> 8)&0xFF00) | 70 71 ((s&0xFF00) << 8) | (s>>24); 71 72 } … … 83 84 84 85 85 FxBool 86 FxBool 86 87 _txReadRGTHeader( FILE *stream, FxU32 cookie, TxMip *info) 87 88 { … … 93 94 return FXFALSE; 94 95 } 95 96 96 97 if ( fread( &(rgtHeader->typeLo), 1, sizeof(RgtHeader)-2, stream ) != 10 ) { 97 98 txPanic("RGT file: Unexpected end of file."); … … 104 105 105 106 106 info->format = GR_TEXFMT_ARGB_8888; 107 info->format = GR_TEXFMT_ARGB_8888; 107 108 info->width = rgtHeader->sizeXHi << 8 | rgtHeader->sizeXLo; 108 109 info->height = rgtHeader->sizeYHi << 8 | rgtHeader->sizeYLo; … … 111 112 if( txVerbose ) 112 113 { 113 printf("Magic: %.04x w = %d, h = %d, z = %d, typehi = %d, typelo = %d, swap=%d\n", rgtHeader->magic, 114 printf("Magic: %.04x w = %d, h = %d, z = %d, typehi = %d, typelo = %d, swap=%d\n", rgtHeader->magic, 114 115 info->width, info->height, rgtHeader->sizeZLo, rgtHeader->typeHi, rgtHeader->typeLo, rgtHeader->magic == IMAGIC); 115 116 } … … 119 120 // RGT is RGBA in memory (low byte to high byte), or ABGR in a register 120 121 121 FxBool 122 FxBool 122 123 _txReadRGTData( FILE *stream, TxMip *info) 123 124 { 124 125 RgtHeader *rgtHeader = (RgtHeader *) info->pal; 125 126 FxU16 type = (rgtHeader->typeHi); 126 FxU16 swap = (rgtHeader->magic == IMAGIC); 127 FxU16 swap = (rgtHeader->magic == IMAGIC); 127 128 int x, y; 128 129 129 130 if ( stream == NULL ) { 130 131 txPanic("RGT file: Bad file handle."); … … 139 140 return FXFALSE; 140 141 } 141 142 142 143 // load rgt, rgt's are bottom up 143 144 for ( y = 0; y < info->height; y++ ) {
Note:
See TracChangeset
for help on using the changeset viewer.
