Ignore:
Timestamp:
Sep 5, 2001, 4:31:14 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

Location:
trunk/src/opengl/glide/sst1/texus
Files:
14 edited

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 $ */
    12/*
    23 * THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
    34 * PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    45 * 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
    89 * 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.
    1011 *
    1112 * USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
     
    2526/*************************************** 3df files ****************************/
    2627/* Read word, msb first */
    27 static FxBool 
     28static FxBool
    2829_txRead16 (FILE *stream, FxU16* data)
    2930{
     
    3637
    3738/* Read long word, msb first */
    38 static FxBool 
     39static FxBool
    3940_txRead32 (FILE *stream, FxU32* data)
    4041{
     
    5354
    5455/* Read NCC table */
    55 static FxBool 
     56static FxBool
    5657_txRead3DFNCCTable (FILE* stream, FxI32* ncc_table)
    5758{
     
    8788}
    8889
    89 static FxBool 
     90static FxBool
    9091_txRead3DFPalTable (FILE* stream, FxI32* pal)
    9192{
     
    114115    if (fscanf (stream, "f v%6s", version) != 1) return FXFALSE;
    115116
    116     /* 
     117    /*
    117118     * skip comments
    118119     */
  • 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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:36 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:08 $
    2324*/
    2425
     
    3738  if( txVerbose )
    3839    {
    39       printf( "clamping from %dx%d to %dx%d\n", 
     40      printf( "clamping from %dx%d to %dx%d\n",
    4041              ix, iy, ox, oy );
    4142    }
     
    7677  if ((srcMip->data[0] == NULL) || (dstMip->data[0] == NULL))
    7778    txPanic("txImageClamp: Null buffer\n");
    78  
     79
    7980  sw = srcMip->width;
    8081  sh = srcMip->height;
     
    8283  dh = dstMip->height;
    8384
    84   for( i = 0; i < srcMip->depth; i++ ) 
     85  for( i = 0; i < srcMip->depth; i++ )
    8586    {
    8687      if( !dstMip->data[i] )
     
    103104    }
    104105}
    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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:37 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:08 $
    2324*/
    2425
     
    3031#include "texusint.h"
    3132
    32 /* 
     33/*
    3334 * Pn_8 = convert n bits (n <= 6) to 8 bits by replicating the msb's of input
    3435 * into the lsb's of the output.
     
    9495
    9596/* 16 bit pixels */
    96 static FxU32 
     97static FxU32
    9798_txPixArgb8332to8888(FxU16 c8332)
    9899{
    99100    FxU32       a, r, g, b;
    100     a =      (c8332 >>  8);     
     101    a =      (c8332 >>  8);
    101102    r = P3_8[(c8332 >>  5) & 0x7];
    102103    g = P3_8[(c8332 >>  2) & 0x7];
     
    233234    in  += n;
    234235    while (n--) {
    235         in--; 
     236        in--;
    236237        *--out = (pal[(*in) & 0xff] & 0x00ffffff) | ((*in & 0xFF00) << 16);
    237238    }
     
    302303    in  += n;
    303304
    304     while (n--) *--out = *--in; 
     305    while (n--) *--out = *--in;
    305306}
    306307
     
    314315    for( i = 0; i < n; i++ )
    315316      {
    316         out[i] = 
    317           ( ( ( FxU32 )0xff ) << 24 ) | 
     317        out[i] =
     318          ( ( ( FxU32 )0xff ) << 24 ) |
    318319          ( ( ( FxU32 )in[i*3] )<< 16 ) |
    319320          ( ( ( FxU32 )in[i*3+1] )<< 8 ) |
     
    322323}
    323324
    324 void   
     325void
    325326txMipDequantize(TxMip *txMip, TxMip *pxMip)
    326327{
     
    344345            printf(" %dx%d", w, h); fflush(stdout);
    345346          }
    346            
     347
    347348        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,
    351352                                                                        (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,
    359360                                                                        pxMip->pal); break;
    360361
    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,
    364365                                                                        (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,
    374375                                                                        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:
    381382                                                                break;
    382383        }
  • 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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:37 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:09 $
    2324*/
    2425
     
    3940FxU8    bestR[256], bestG[256], bestB[256];
    4041
    41 static int 
     42static int
    4243_txAscendingR(const void *a, const void *b)
    4344{
     
    4647
    4748
    48 static int 
     49static int
    4950_txAscendingG(const void *a, const void *b)
    5051{
     
    5354
    5455
    55 static int 
     56static int
    5657_txAscendingB(const void *a, const void *b)
    5758{
     
    7879
    7980#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",
    8283            i, sortR[i], sortG[i], sortB[i]);
    8384#endif
    8485
    85  
     86
    8687    for (i=0; i<256; i++) {
    8788
     
    129130    persist = 0;
    130131    for (i=bestR[r]; i>=0; i--) {
    131         d = DISTANCE(r, g, b, 
     132        d = DISTANCE(r, g, b,
    132133            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    133134        if (d < mindist) { mindist = d; minpos = (pal[i] >> 24) & 0xff; }
     
    138139    persist = 0;
    139140    for (i=bestR[r]+1; i < nsorted; i++) {
    140         d = DISTANCE(r, g, b, 
     141        d = DISTANCE(r, g, b,
    141142            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    142143        if (d < mindist) { mindist = d; minpos = (pal[i] >> 24) & 0xff; }
     
    149150    persist = 0;
    150151    for (i=bestG[g]; i>=0; i--) {
    151         d = DISTANCE(r, g, b, 
     152        d = DISTANCE(r, g, b,
    152153            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    153154        if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; }
     
    158159    persist = 0;
    159160    for (i=bestG[g]+1; i < nsorted; i++) {
    160         d = DISTANCE(r, g, b, 
     161        d = DISTANCE(r, g, b,
    161162            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    162163        if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; }
     
    168169    persist = 0;
    169170    for (i=bestB[b]; i>=0; i--) {
    170         d = DISTANCE(r, g, b, 
     171        d = DISTANCE(r, g, b,
    171172            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    172173        if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; }
     
    177178    persist = 0;
    178179    for (i=bestB[b]+1; i < nsorted; i++) {
    179         d = DISTANCE(r, g, b, 
     180        d = DISTANCE(r, g, b,
    180181            ((pal[i] >> 16) & 0xff), ((pal[i] >> 8) & 0xff), ((pal[i]) & 0xff));
    181182        if (d < mindist) { mindist = d; minpos = (pal[i]>>24) & 0xff; }
     
    221222            ib += qb + ErrB[x];
    222223
    223             qr = ir;    // quantized pixel values. 
     224            qr = ir;    // quantized pixel values.
    224225            qg = ig;    // qR is error from pixel to left, errR is
    225226            qb = ib;    // error from pixel to the top & top left.
     
    245246            qb = ib - qb;
    246247
    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,
    248249            // 1/4 (0.25) to the SOUTH-EAST.
    249250            ErrR[x]  = ((x == 0) ? 0 : ErrR[x]) + ((int) (qr * 0.375f));
     
    279280        printf("EDiffusion:..."); fflush(stdout);
    280281      }
    281        
     282
    282283#if     FAST_DIFFUSION
    283284    _txMakeRange(palette, ncolors);
     
    289290
    290291    for (i=0; i<txMip->depth; i++) {
    291         _txToDiffuseIndex(pxMip->data[i], pixsize, palette, ncolors, 
     292        _txToDiffuseIndex(pxMip->data[i], pixsize, palette, ncolors,
    292293            txMip->data[i], w, h);
    293294            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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:37 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:10 $
    2324*/
    2425
     
    3536/*
    3637 * 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
    3839 * the format that you want to download.
    3940 */
     
    325326          ncc_table.yRGB[i] = ( FxU8 )texture->pal[i];
    326327        }
    327      
     328
    328329      for( i = 0; i < 4; i++ )
    329330        {
  • 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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:37 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:10 $
    2324*/
    2425
  • 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 $ */
    12/*
    23** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
    34** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    45** 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
    89** 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**
    1112** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1213** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1415** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1516** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    16 ** THE UNITED STATES. 
    17 ** 
     17** THE UNITED STATES.
     18**
    1819** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    1920**
    20 ** $Revision: 1.1 $
    21 ** $Date: 2000-02-25 00:31:37 $
     21** $Revision: 1.2 $
     22** $Date: 2001-09-05 14:31:11 $
    2223*/
    2324
     
    2930#include "texusint.h"
    3031
    31 static int 
    32 dithmat[4][4] = {       0,  8,  2, 10, 
    33                            12,  4, 14,  6, 
    34                             3, 11,  1,  9, 
     32static int
     33dithmat[4][4] = {       0,  8,  2, 10,
     34                           12,  4, 14,  6,
     35                            3, 11,  1,  9,
    3536                           15,  7, 13,  5 };
    3637
     
    4546_txPixQuantize_YIQ422 (unsigned long argb, int x, int y, int w)
    4647{
    47     int         r, g, b; 
     48    int         r, g, b;
    4849    int         iy, ii, iq;
    4950
     
    125126
    126127static 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,
    128129    int dither)
    129130{
     
    153154
    154155   RGB values can be converted to YIQ using the equation:
    155  
     156
    156157   Y = 0.30F * R + 0.59F * G + 0.11F * B;
    157158   I = 0.60F * R - 0.28F * G - 0.32F * B;
    158159   Q = 0.21F * R - 0.52F * G + 0.31F * B;
    159160
    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,
    161162   Y ranges from (0 .. 255)
    162163   I ranges from (-0.60 * 255 .. 0.60 * 255) i.e, (-153 to 153)
     
    166167
    167168
    168 static void     
     169static void
    169170_txMipNccStatTable(TxMip *txMip)
    170171{
    171172    int i, w, h;
    172173
    173     for (i=0; i<256; i++) 
     174    for (i=0; i<256; i++)
    174175        ncc.yhist[i] = ncc.ihist[i] = ncc.qhist[i] = 0;
    175176    ncc.npixels = 0;
     
    250251
    251252
    252 void   
     253void
    253254txMipNcc(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression)
    254255{
     
    256257
    257258    switch (compression & TX_COMPRESSION_MASK) {
    258     case        TX_COMPRESSION_HEURISTIC:                               
     259    case        TX_COMPRESSION_HEURISTIC:
    259260                _txMipNccStatTable(txMip);
    260261                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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:38 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:11 $
    2324*/
    2425#include <stdio.h>
     
    3334 * ARGB8888 format and produces an optimal YAB table, and an 8 bit image
    3435 * 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
    3637 * /tdfx/engr/devel/sst1/docs/yab.doc. The summary follows.
    3738 *
    38  * Neural net algorithms first determine a "representative sample" of the 
     39 * Neural net algorithms first determine a "representative sample" of the
    3940 * input image. This representative sample is repeatedly run through the net
    4041 * during the network learning stage, and the neural net "learns" which colors
    4142 * are important and which ones are not. It's quite possible to feed every
    4243 * 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.
    4445 *
    4546 * So, we prefer to make a representative sample of colors for the input image.
     
    4849 * colors (just like for the 8-bit palettized case) works quite well, and
    4950 * 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
    5152 * textures very easy.
    5253 *
    5354 * 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.
    5960 *
    6061 * So now it's possible to translate the original image into an 8 bit image
     
    6566 * In the process of converting the original image to the YAB format, we could
    6667 * optionally dither the image. Ordered dithering doesn't quite work, so we
    67  * use error-diffusion dithering. 
     68 * use error-diffusion dithering.
    6869 *
    6970 * I've found that there are three speed bottlenecks to overcome. The first
    7071 * 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
    7374 * much as possible. The third bottleneck is the translation of the original
    7475 * image into the 8 bit YAB indexed image; this still needs work, especially
     
    7980
    8081/******************************************************************************
    81  * 
     82 *
    8283 * The hardcore neural net stuff begins here.
    8384 *
     
    117118_nn_modifyNeurons(long ir, long ig, long ib)
    118119{
    119     int         i; 
     120    int         i;
    120121    int         d0, d1;                         // closest & next closest distance to input
    121122    int         p0, p1;                         // index into the 256 color table.
     
    138139
    139140        d = DISTANCE(n->r, n->g, n->b, ir, ig, ib);
    140         if (d < d0) { 
     141        if (d < d0) {
    141142                d1 = d0; d0 = d;
    142143                p1 = p0; p0 = i;
     
    145146                d1 = d;
    146147                p1 = i;
    147         } 
     148        }
    148149    }
    149150
     
    183184    pb = N[p0].pb;
    184185    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);
    186187    pa->g += (dg >> 2) ; CLAMP_BOTH(pa->g);
    187188    pa->b += (db >> 2) ; CLAMP_BOTH(pa->b);
     
    258259
    259260static  int order[256];
    260 static int 
     261static int
    261262_nn_randomOrder(const void *a, const void *b)
    262263{
     
    275276
    276277    _nn_initTables();
    277     /* 
     278    /*
    278279     * Select a number which is relatively prime to nsamples.
    279280     */
     
    295296                FxU32   *pRGB;
    296297
    297                 // We present the samples randomly to the network. 
     298                // We present the samples randomly to the network.
    298299                // _nn_modify_neurons() makes the neurons learn
    299300                // errR, errG, errB, errMax are computed in _nn_modifyNeurons(), as
     
    308309
    309310        if (errMax < bstMax) {
    310                 /* 
     311                /*
    311312                 * A lower total error than before, take a Snapshot
    312313                 *
     
    344345                bstB   = errB;
    345346#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,
    349350                   totG/nsamples, totR/nsamples, totB/nsamples
    350351                );
     
    356357        }
    357358
    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();
    361362                break;
    362363        }
    363364    }
    364365
    365     /* 
     366    /*
    366367     * At this point YAB has the YAB table, samples has input palette,
    367368     * Replace MSB of samples with index to be used with YAB table.
     
    393394
    394395
    395     /* 
    396      * Get a 256 color palette, to be used as samples 
     396    /*
     397     * Get a 256 color palette, to be used as samples
    397398     * Incidentally, convert src 32 bit image to dst 8 bit indexed image,
    398399     * with indices referring to the 256 color palette.
     
    403404        printf("NCC Neural nets..."); fflush(stdout);
    404405      }
    405     pxMip->format = (format == GR_TEXFMT_YIQ_422) ? GR_TEXFMT_P_8 : 
     406    pxMip->format = (format == GR_TEXFMT_YIQ_422) ? GR_TEXFMT_P_8 :
    406407        GR_TEXFMT_AP_88;
    407408    ncolors = txMipPal256(pxMip, txMip, pxMip->format, 0, 0);
     
    413414    if( txVerbose )
    414415      {
    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,
    417418               totG/ncolors, totR/ncolors, totB/ncolors
    418419               );
     
    423424        /*
    424425         * 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
    426427         * useful for error diffusion dithering.
    427428         */
    428429        txYABtoPal256((long *)pxMip->pal, (long *)yabTable);
    429430        txDiffuseIndex(pxMip, txMip, pixsize, pxMip->pal, 256);
    430     } 
     431    }
    431432    else {
    432433
  • 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 $ */
    12/*
    23 * 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
    45 * preserved on all copies.
    5  * 
     6 *
    67 * There is no warranty or other guarantee of fitness for this software,
    78 * it is provided solely "as is".  Bug reports or fixes may be sent
     
    910 *
    1011 * 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
    1213 * source is available for no extra charge.
    1314 *
     
    7273 * Readability constants.
    7374 */
    74 #define REDI            0       
     75#define REDI            0
    7576#define GREENI          1
    76 #define BLUEI           2       
     77#define BLUEI           2
    7778#define TRUE            1
    7879#define FALSE           0
     
    111112 * Perform variance-based color quantization on a 24-bit image.
    112113 */
    113 int     
     114int
    114115txMipPal256(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression)
    115116{
     
    117118    int         i;                              /* Counter */
    118119    int         OutColors;              /* # of entries computed */
    119     int         Colormax;               /* quantized full-intensity */ 
     120    int         Colormax;               /* quantized full-intensity */
    120121    float       Cfactor;                /* Conversion factor */
    121122#if 0
     
    131132    Cfactor = (float)FULLINTENSITY / Colormax;
    132133
    133     Boxes = _Boxes;     
     134    Boxes = _Boxes;
    134135#if 0
    135136    Histogram = (ulong *) txMalloc(ColormaxI*ColormaxI*ColormaxI * sizeof(long));
     
    157158
    158159    OutColors = CutBoxes(Boxes, MAXCOLORS);
    159    
     160
    160161    /*
    161162     * We now know the set of representative colors.  We now
     
    180181        pxMip->pal[i] = (r<<16) | (g << 8) | b;
    181182    }
    182     ComputeRGBMap(Boxes, OutColors, rgbmap); 
     183    ComputeRGBMap(Boxes, OutColors, rgbmap);
    183184
    184185    /*
     
    218219                                *dst++ = rgbmap[index];
    219220                        } else {
    220                                 *(FxU16 *)dst = (rgbmap[index]) | 
     221                                *(FxU16 *)dst = (rgbmap[index]) |
    221222                                                ((argb >> 16) & 0xFF00);
    222223                                dst+= 2;
     
    253254     * We compute both the histogram and the proj. frequencies of
    254255     * the first box at the same time to save a pass through the
    255      * entire image. 
     256     * entire image.
    256257     */
    257    
     258
    258259    for (i = 0; i < npixels; i++) {
    259260        rr = (uchar) (((*pixels >> 16) & 0xff) >> (8-NBITS));
     
    266267        Histogram[(((rr<<NBITS)|gg)<<NBITS)|bb]++;
    267268    }
    268        
     269
    269270}
    270271
     
    273274 */
    274275static int
    275 CutBoxes(Box *boxes, int colors) 
     276CutBoxes(Box *boxes, int colors)
    276277{
    277278    int curbox;
     
    363364     * Find 'optimal' cutpoint along each of the red, green and blue
    364365     * 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
    366367     * (possible) later use.
    367368     */
     
    461462    bzero(box1->freq[0], ColormaxI * sizeof(ulong));
    462463    bzero(box1->freq[1], ColormaxI * sizeof(ulong));
    463     bzero(box1->freq[2], ColormaxI * sizeof(ulong)); 
     464    bzero(box1->freq[2], ColormaxI * sizeof(ulong));
    464465
    465466    for (r = box1->low[0]; r < box1->high[0]; r++) {
     
    507508{
    508509    int r, g, b;
    509    
     510
    510511    for (r = box->low[REDI]; r < box->high[REDI]; r++) {
    511512        for (g = box->low[GREENI]; g < box->high[GREENI]; g++) {
    512513                for (b = box->low[BLUEI]; b < box->high[BLUEI]; b++) {
    513514                        int     index;
    514                        
     515
    515516                        index = (((r<<NBITS)|g)<<NBITS)|b;
    516517                        rgbmap[index]=(char)boxnum;
     
    528529  int min_index;
    529530  long r, g, b;
    530  
     531
    531532  min_dist = 256 * 256 + 256 * 256 + 256 * 256;
    532533  min_index = -1;
     
    573574          unsigned long index;
    574575          unsigned long r_index, g_index, b_index;
    575          
     576
    576577          r_index = ( ( ( unsigned long )src[i*4+2] ) >> ( 8 - INVERSE_PAL_R_BITS ) );
    577578          g_index = ( ( ( unsigned long )src[i*4+1] ) >> ( 8 - INVERSE_PAL_G_BITS ) );
    578579          b_index = ( ( ( unsigned long )src[i*4+0] ) >> ( 8 - INVERSE_PAL_B_BITS ) );
    579           index = 
     580          index =
    580581            ( r_index << ( INVERSE_PAL_G_BITS + INVERSE_PAL_B_BITS ) ) |
    581582            ( g_index << INVERSE_PAL_B_BITS ) |
     
    618619  static          FxU32 last_pal[256];
    619620  static          FxBool been_here = FXFALSE;
    620  
     621
    621622  w = outputMip->width;
    622623  h = outputMip->height;
     
    632633    }
    633634
    634   for( i = 0; i < trueColorMip->depth; i++ ) 
     635  for( i = 0; i < trueColorMip->depth; i++ )
    635636    {
    636637      _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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:38 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:12 $
    2324**
    2425*/
     
    3233
    3334
    34 FxBool 
     35FxBool
    3536_txReadPPMHeader( FILE *stream, FxU32 cookie, TxMip *info)
    36 { 
     37{
    3738    char buffer[256];
    3839    FxU32 state = 1;
    3940    FxBool done = FXFALSE;
    40    
     41
    4142    if ( stream == NULL ) {
    42         txPanic("PPM file: Bad file handle.");
    43         return FXFALSE;
     43    txPanic("PPM file: Bad file handle.");
     44    return FXFALSE;
    4445    }
    45    
     46
    4647    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;
    5749
    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;
    6258
    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;
    7263
    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        }
    7979    }
    80    
     80    }
     81
    8182    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;
    8485    }
    8586    info->depth = 1;
     
    8990}
    9091
    91 FxBool 
    92 _txReadPPMData( FILE *stream, TxMip *info) 
    93 { 
     92FxBool
     93_txReadPPMData( FILE *stream, TxMip *info)
     94{
    9495    FxU32 numPixels;
    9596    FxU32 *data32 = info->data[0];
    96    
     97
    9798    numPixels = info->width * info->height;
    9899
    99100    if ( stream == NULL ) {
    100         txPanic("PPM file: Bad file handle.");
    101         return FXFALSE;
     101    txPanic("PPM file: Bad file handle.");
     102    return FXFALSE;
    102103    }
    103    
     104
    104105    // Read in image data
    105106    while (numPixels--) {
    106         int r, g, b;
     107    int r, g, b;
    107108
    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;
    116117    }
    117118    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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:38 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:12 $
    2324*/
    2425
     
    3031#include "texusint.h"
    3132
    32 static int 
    33 dithmat[4][4] = {       0,  8,  2, 10, 
    34                            12,  4, 14,  6, 
    35                             3, 11,  1,  9, 
     33static int
     34dithmat[4][4] = {       0,  8,  2, 10,
     35                           12,  4, 14,  6,
     36                            3, 11,  1,  9,
    3637                           15,  7, 13,  5 };
    3738
    3839// for error diffusion.
    39 static int      errR[MAX_TEXWIDTH], errG[MAX_TEXWIDTH], errB[MAX_TEXWIDTH];     
     40static int      errR[MAX_TEXWIDTH], errG[MAX_TEXWIDTH], errB[MAX_TEXWIDTH];
    4041
    4142static int
     
    5455    int n, t;
    5556
    56     n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 
     57    n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d;
    5758    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;
    5960    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;
    6162    t |= (n>>4)<<0;
    6263    return t & 0xFF;
     
    8283    ib += errB[x] + qb;
    8384
    84     qr = ir;            // quantized pixel values. 
     85    qr = ir;            // quantized pixel values.
    8586    qg = ig;            // qR is error from pixel to left, errR is
    8687    qb = ib;            // error from pixel to the top & top left.
     
    157158
    158159
    159     n = (int) (n * 0xF0/255.0f + 0.5f) + d;     
     160    n = (int) (n * 0xF0/255.0f + 0.5f) + d;
    160161    t = (n>>4);
    161162    t |= (int)  ((argb>>24) & 0xF0);
     
    215216    int n, t;
    216217
    217     n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d; 
     218    n = (int) (((argb >> 16) & 0xFF) * 0x70/255.0f + 0.5f) + d;
    218219    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;
    220221    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;
    222223    t |= (n>>4)<<0;
    223224    t |= ((argb >> 16) & 0xFF00);
     
    252253    int n, t;
    253254
    254     n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d;       
     255    n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d;
    255256    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;
    257258    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;
    259260    t |= (n>>4)<<0;
    260261    return t & 0xFFFF;
     
    279280    ib += errB[x] + qb;
    280281
    281     qr = ir;            // quantized pixel values. 
     282    qr = ir;            // quantized pixel values.
    282283    qg = ig;            // qR is error from pixel to left, errR is
    283284    qb = ib;            // error from pixel to the top & top left.
     
    324325                    ((argb >> 9) & 0x7C00) |
    325326                        ((argb >> 6) & 0x03E0) |
    326                         ((argb >> 3) & 0x001F) |       
     327                        ((argb >> 3) & 0x001F) |
    327328                        ((argb >> 24) ? 0x8000 : 0)     );
    328329}
     
    334335    int n, t;
    335336
    336     n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d;       
     337    n = (int) (((argb >> 16) & 0xFF) * 0x1F0/255.0f + 0.5f) + d;
    337338    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;
    339340    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;
    341342    t |= (n>>4)<<0;
    342343    t |= ((argb >> 24) ? 0x8000 : 0);
     
    361362    ib += errB[x] + qb;
    362363
    363     qr = ir;            // quantized pixel values. 
     364    qr = ir;            // quantized pixel values.
    364365    qg = ig;            // qR is error from pixel to left, errR is
    365366    qb = ib;            // error from pixel to the top & top left.
     
    407408                    ((argb >> 12) & 0x0F00) |
    408409                        ((argb >>  8) & 0x00F0) |
    409                         ((argb >>  4) & 0x000F) |       
     410                        ((argb >>  4) & 0x000F) |
    410411                        ((argb >> 16) & 0xF000) );
    411412}
     
    417418    int n, t;
    418419
    419     n = (int) (((argb >> 16) & 0xFF) * 0xF0/255.0f + 0.5f) + d; 
     420    n = (int) (((argb >> 16) & 0xFF) * 0xF0/255.0f + 0.5f) + d;
    420421    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;
    422423    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;
    424425    t |= (n>>4)<<0;
    425426    t |= (argb >> 16) & 0xF000;
     
    444445    ib += errB[x] + qb;
    445446
    446     qr = ir;            // quantized pixel values. 
     447    qr = ir;            // quantized pixel values.
    447448    qg = ig;            // qR is error from pixel to left, errR is
    448449    qb = ib;            // error from pixel to the top & top left.
     
    511512
    512513        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;
    516517                                                                break;
    517518        case GR_TEXFMT_I_8:                     quantizer = _txPixQuantize_I8;
     
    521522        case GR_TEXFMT_ARGB_8332:       quantizer = _txPixQuantize_ARGB8332_DErr;
    522523                                                                break;
    523         case GR_TEXFMT_RGB_565:         quantizer = _txPixQuantize_RGB565_DErr; 
     524        case GR_TEXFMT_RGB_565:         quantizer = _txPixQuantize_RGB565_DErr;
    524525                                                                break;
    525526        case GR_TEXFMT_ARGB_1555:       quantizer =     _txPixQuantize_ARGB1555_DErr;
     
    535536
    536537        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");
    558559                                                                break;
    559560        }
     
    561562
    562563        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");
    584585                                                                break;
    585586        }
     
    614615 * quality levels in each of the compression cases.
    615616 */
    616 void   
     617void
    617618txMipQuantize(TxMip *pxMip, TxMip *txMip, int format, FxU32 dither, FxU32 compression)
    618619{
     
    636637                return;
    637638
    638     case GR_TEXFMT_ARGB_8888: 
     639    case GR_TEXFMT_ARGB_8888:
    639640                // Copy source to destination, and be done.
    640641                if( txVerbose )
     
    651652
    652653    // 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:
    656657    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:
    660661    case GR_TEXFMT_ARGB_4444:
    661662    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 $ */
    12/*
    23** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
    34** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    45** 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
    89** 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**
    1112** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1213** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1415** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1516** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    16 ** THE UNITED STATES. 
    17 ** 
     17** THE UNITED STATES.
     18**
    1819** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    1920**
    20 ** $Revision: 1.1 $
    21 ** $Date: 2000-02-25 00:31:38 $
     21** $Revision: 1.2 $
     22** $Date: 2001-09-05 14:31:13 $
    2223*/
    2324
     
    3839#define TX_UNK  0x200   // TGA is unknown from cookie signature.
    3940
    40 int 
     41int
    4142_txReadHeader( FILE *stream, TxMip *info )
    4243{
     
    8687}
    8788
    88 static FxBool 
     89static FxBool
    8990_txReadData( FILE *stream, int fformat, TxMip *info )
    9091{
     
    109110
    110111  file = fopen(filename, "rb");
    111   if( file == NULL ) 
     112  if( file == NULL )
    112113    {
    113114      fprintf( stderr,"Error: can't open input file %s\n", filename );
    114115      exit(2);
    115116    }
    116  
     117
    117118  retval = txMipReadFromFP( txMip, filename, file, prefFormat );
    118119  fclose(file);
     
    128129
    129130        if ((prefFormat != GR_TEXFMT_ARGB_8888) &&
    130             (prefFormat != GR_TEXFMT_ANY)) 
     131            (prefFormat != GR_TEXFMT_ANY))
    131132          {
    132133            txPanic("txMipRead: bad preferred format.");
     
    143144            fprintf(stderr,"Loading image file ");
    144145
    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,
    146147                     txMip->width,txMip->height, GR_TEXFMT_SIZE(txMip->format), txMip->depth);
    147148          }
    148149
    149150        /*
    150          * Allocate memory requested in data[0]; 
     151         * Allocate memory requested in data[0];
    151152         */
    152153
     
    159160                        continue;
    160161                }
    161                 txMip->data[i] = (FxU8*)txMip->data[i-1] + 
     162                txMip->data[i] = (FxU8*)txMip->data[i-1] +
    162163                        w * h * GR_TEXFMT_SIZE(txMip->format);
    163164                if (w > 1) w >>= 1;
     
    166167
    167168        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 );
    172173        }
    173174
     
    195196        if( txVerbose )
    196197          {
    197             fprintf(stderr, "Dequantizing Input from %s to argb8888.\n", 
     198            fprintf(stderr, "Dequantizing Input from %s to argb8888.\n",
    198199                   Format_Name[txMip->format]);
    199200          }
  • 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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:39 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:13 $
    2324*/
    2425
     
    3839 * total of ox * ix fragments, same as before.
    3940 * 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
    4142 * 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
    4344 */
    4445
     
    6566        int    oa, or, og, ob;
    6667
    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
    6970        // output pixel.
    7071
    7172        ef = ix - accf;         // the excessive # of fragments.
    7273
    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",
    7475    //  accf, nf, ef, ix, ox);
    7576
     
    9495
    9596        *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",
    9798           //  o, oa, or, og, ob);
    9899        o++;
     
    124125
    125126static void
    126 _txImgResample(FxU32 *out, int ox, int oy, 
     127_txImgResample(FxU32 *out, int ox, int oy,
    127128               const FxU32 *in, int ix, int iy)
    128129{
     
    147148        int          ef;
    148149
    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
    151152        // output pixel.
    152153
     
    243244          printf("Resampling to %dx%d: ", destMip->width, destMip->height);
    244245
    245        
     246
    246247        sw = srcMip->width;
    247248        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 $ */
    12
    23/*
     
    45** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
    56** 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
    910** 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**
    1213** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
    1314** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
     
    1516** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
    1617** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
    17 ** THE UNITED STATES. 
    18 ** 
     18** THE UNITED STATES.
     19**
    1920** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
    2021**
    21 ** $Revision: 1.1 $
    22 ** $Date: 2000-02-25 00:31:39 $
     22** $Revision: 1.2 $
     23** $Date: 2001-09-05 14:31:14 $
    2324**
    2425*/
     
    3637const FxU16 ITYPE_BGR      = 0x04;
    3738const FxU16 ITYPE_RGT      = 0x08;
    38    
     39
    3940typedef struct _rgtHeader{
    4041    FxU16 magic;
     
    6768    while (length--) {
    6869        s = *array;
    69         *array++ = (s << 24) | ((s >> 8)&0xFF00) | 
     70        *array++ = (s << 24) | ((s >> 8)&0xFF00) |
    7071                        ((s&0xFF00) << 8) | (s>>24);
    7172    }
     
    8384
    8485
    85 FxBool 
     86FxBool
    8687_txReadRGTHeader( FILE *stream, FxU32 cookie, TxMip *info)
    8788{
     
    9394        return FXFALSE;
    9495    }
    95    
     96
    9697    if ( fread( &(rgtHeader->typeLo), 1, sizeof(RgtHeader)-2, stream ) != 10 ) {
    9798        txPanic("RGT file: Unexpected end of file.");
     
    104105
    105106
    106     info->format = GR_TEXFMT_ARGB_8888; 
     107    info->format = GR_TEXFMT_ARGB_8888;
    107108    info->width = rgtHeader->sizeXHi << 8 | rgtHeader->sizeXLo;
    108109    info->height = rgtHeader->sizeYHi << 8 | rgtHeader->sizeYLo;
     
    111112    if( txVerbose )
    112113      {
    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,
    114115               info->width, info->height, rgtHeader->sizeZLo, rgtHeader->typeHi, rgtHeader->typeLo, rgtHeader->magic == IMAGIC);
    115116      }
     
    119120// RGT is RGBA in memory (low byte to high byte), or ABGR in a register
    120121
    121 FxBool 
     122FxBool
    122123_txReadRGTData( FILE *stream, TxMip *info)
    123124{
    124125    RgtHeader   *rgtHeader = (RgtHeader *) info->pal;
    125126    FxU16 type = (rgtHeader->typeHi);
    126     FxU16 swap = (rgtHeader->magic == IMAGIC); 
     127    FxU16 swap = (rgtHeader->magic == IMAGIC);
    127128    int   x, y;
    128    
     129
    129130    if ( stream == NULL ) {
    130131        txPanic("RGT file: Bad file handle.");
     
    139140        return FXFALSE;
    140141    }
    141    
     142
    142143    // load rgt, rgt's are bottom up
    143144    for ( y = 0; y < info->height; y++ ) {
Note: See TracChangeset for help on using the changeset viewer.