ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/clrtab.c
(Generate patch)

Comparing ray/src/px/clrtab.c (file contents):
Revision 2.18 by greg, Mon Sep 19 02:23:58 2005 UTC vs.
Revision 2.19 by greg, Fri May 20 02:06:39 2011 UTC

# Line 25 | Line 25 | static const char      RCSid[] = "$Id$";
25   #define part(cn)        ((cn)>>2)
26   #define prim(cn)        ((cn)&3)
27                                  /* our color table (global) */
28 < extern BYTE     clrtab[256][3];
28 > extern uby8     clrtab[256][3];
29                                  /* histogram of colors / color assignments */
30   static unsigned histo[NRED][NGRN][NBLU];
31   #define cndx(c)         histo[((c)[RED]*NRED)>>8][((c)[GRN]*NGRN)>>8][((c)[BLU]*NBLU)>>8]
# Line 41 | Line 41 | static int     CLRCUBE[3][2] = {{0,NRED},{0,NGRN},{0,NBLU}
41  
42   #ifdef CLOSEST
43   static void closest(int n);
44 < static void setclosest(BYTE *nl[], int r, int g, int b);
45 < static void addneigh(BYTE *nl[], int i, int j);
46 < static unsigned int dist(BYTE col[3], int r, int g, int b);
44 > static void setclosest(uby8 *nl[], int r, int g, int b);
45 > static void addneigh(uby8 *nl[], int i, int j);
46 > static unsigned int dist(uby8 col[3], int r, int g, int b);
47   #endif
48   static void cut(int box[3][2], int c0, int c1);
49   static int split(int box[3][2]);
# Line 62 | Line 62 | new_histo(             /* clear our histogram */
62  
63   extern void
64   cnt_pixel(              /* add pixel to our histogram */
65 <        register BYTE   col[]
65 >        register uby8   col[]
66   )
67   {
68          cndx(col)++;
# Line 97 | Line 97 | new_clrtab(            /* make new color table using ncolors */
97          closest(ncolors);       /* ensure colors picked are closest */
98   #endif
99                                  /* reset dithering function */
100 <        dith_colrs((BYTE *)NULL, (COLR *)NULL, 0);
100 >        dith_colrs((uby8 *)NULL, (COLR *)NULL, 0);
101                                  /* return new color table size */
102          return(ncolors);
103   }
# Line 105 | Line 105 | new_clrtab(            /* make new color table using ncolors */
105  
106   extern int
107   map_pixel(                      /* get pixel for color */
108 <        register BYTE   col[]
108 >        register uby8   col[]
109   )
110   {
111      return(cndx(col));
# Line 114 | Line 114 | map_pixel(                     /* get pixel for color */
114  
115   extern void
116   map_colrs(              /* convert a scanline to color index values */
117 <        register BYTE   *bs,
117 >        register uby8   *bs,
118          register COLR   *cs,
119          register int    n
120   )
# Line 128 | Line 128 | map_colrs(             /* convert a scanline to color index value
128  
129   extern void
130   dith_colrs(             /* convert scanline to dithered index values */
131 <        register BYTE   *bs,
131 >        register uby8   *bs,
132          register COLR   *cs,
133          int     n
134   )
# Line 311 | Line 311 | closest(                       /* make sure we have the closest colors */
311          int     n
312   )
313   {
314 <        BYTE    *neigh[256];
314 >        uby8    *neigh[256];
315          register int    r, g, b;
316   #define i r
317                                          /* get space for neighbor lists */
318          for (i = 0; i < n; i++) {
319 <                if ((neigh[i] = (BYTE *)malloc(NBSIZ)) == NULL) {
319 >                if ((neigh[i] = (uby8 *)malloc(NBSIZ)) == NULL) {
320                          while (i--)
321                                  free(neigh[i]);
322                          return;                 /* ENOMEM -- abandon effort */
# Line 348 | Line 348 | closest(                       /* make sure we have the closest colors */
348  
349   static void
350   addneigh(               /* i and j are neighbors; add them to list */
351 <        register BYTE   *nl[],
351 >        register uby8   *nl[],
352          register int    i,
353          int     j
354   )
# Line 368 | Line 368 | addneigh(              /* i and j are neighbors; add them to list
368                                                  t+NBSIZ)) == NULL)
369                                          t--;
370                                  else
371 <                                        nl[i] = (BYTE *)nnl;
371 >                                        nl[i] = (uby8 *)nnl;
372                          }
373                          nl[i][t] = i;           /* terminator */
374                  }
# Line 379 | Line 379 | addneigh(              /* i and j are neighbors; add them to list
379  
380   static unsigned int
381   dist(           /* find distance from clrtab entry to r,g,b */
382 <        register BYTE   col[3],
382 >        register uby8   col[3],
383          int     r,
384          int     g,
385          int     b
# Line 400 | Line 400 | dist(          /* find distance from clrtab entry to r,g,b */
400  
401   static void
402   setclosest(             /* find index closest to color and assign */
403 <        BYTE    *nl[],
403 >        uby8    *nl[],
404          int     r,
405          int     g,
406          int     b
# Line 409 | Line 409 | setclosest(            /* find index closest to color and assign
409          int     ident;
410          unsigned        min;
411          register unsigned       d;
412 <        register BYTE   *p;
412 >        register uby8   *p;
413                                          /* get starting value */
414          min = dist(clrtab[ident=histo[r][g][b]], r, g, b);
415                                          /* find minimum */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines