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.16 by schorsch, Sun Jul 27 22:12:03 2003 UTC vs.
Revision 2.17 by schorsch, Sun Mar 28 20:33:13 2004 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11  
12   #include "standard.h"
13   #include "color.h"
14 + #include "clrtab.h"
15  
16                                  /* histogram resolution */
17   #define NRED            36
# Line 29 | Line 30 | extern BYTE    clrtab[256][3];
30   static unsigned histo[NRED][NGRN][NBLU];
31   #define cndx(c)         histo[((c)[RED]*NRED)>>8][((c)[GRN]*NGRN)>>8][((c)[BLU]*NBLU)>>8]
32                                  /* initial color cube boundary */
33 < static int      CLRCUBE[3][2] = {0,NRED,0,NGRN,0,NBLU};
33 > static int      CLRCUBE[3][2] = {{0,NRED},{0,NGRN},{0,NBLU}};
34                                  /* maximum propagated error during dithering */
35   #define MAXERR          20
36                                  /* define CLOSEST to get closest colors */
# Line 41 | Line 42 | static int     CLRCUBE[3][2] = {0,NRED,0,NGRN,0,NBLU};
42   #endif
43   #endif
44  
44 static  cut(), mktabent(), closest(), addneigh(), setclosest();
45 static int      split();
46 static unsigned dist();
45  
46 + #ifdef CLOSEST
47 + static void closest(int n);
48 + static void setclosest(BYTE *nl[], int r, int g, int b);
49 + static void addneigh(BYTE *nl[], int i, int j);
50 + static unsigned int dist(BYTE col[3], int r, int g, int b);
51 + #endif
52 + static void cut(int box[3][2], int c0, int c1);
53 + static int split(int box[3][2]);
54 + static void mktabent(int p, int box[3][2]);
55  
56 < new_histo(n)            /* clear our histogram */
57 < int     n;
56 >
57 > extern int
58 > new_histo(              /* clear our histogram */
59 >        int     n
60 > )
61   {
62          memset((void *)histo, '\0', sizeof(histo));
63          return(0);
64   }
65  
66  
67 < cnt_pixel(col)          /* add pixel to our histogram */
68 < register BYTE   col[];
67 > extern void
68 > cnt_pixel(              /* add pixel to our histogram */
69 >        register BYTE   col[]
70 > )
71   {
72          cndx(col)++;
73   }
74  
75  
76 < cnt_colrs(cs, n)                /* add a scanline to our histogram */
77 < register COLR   *cs;
78 < register int    n;
76 > extern void
77 > cnt_colrs(              /* add a scanline to our histogram */
78 >        register COLR   *cs,
79 >        register int    n
80 > )
81   {
82          while (n-- > 0) {
83                  cndx(cs[0])++;
# Line 72 | Line 86 | register int   n;
86   }
87  
88  
89 < new_clrtab(ncolors)             /* make new color table using ncolors */
90 < int     ncolors;
89 > extern int
90 > new_clrtab(             /* make new color table using ncolors */
91 >        int     ncolors
92 > )
93   {
94          if (ncolors < 1)
95                  return(0);
# Line 91 | Line 107 | int    ncolors;
107   }
108  
109  
110 < int
111 < map_pixel(col)                  /* get pixel for color */
112 < register BYTE   col[];
110 > extern int
111 > map_pixel(                      /* get pixel for color */
112 >        register BYTE   col[]
113 > )
114   {
115      return(cndx(col));
116   }
117  
118  
119 < map_colrs(bs, cs, n)            /* convert a scanline to color index values */
120 < register BYTE   *bs;
121 < register COLR   *cs;
122 < register int    n;
119 > extern void
120 > map_colrs(              /* convert a scanline to color index values */
121 >        register BYTE   *bs,
122 >        register COLR   *cs,
123 >        register int    n
124 > )
125   {
126          while (n-- > 0) {
127                  *bs++ = cndx(cs[0]);
# Line 111 | Line 130 | register int   n;
130   }
131  
132  
133 < dith_colrs(bs, cs, n)           /* convert scanline to dithered index values */
134 < register BYTE   *bs;
135 < register COLR   *cs;
136 < int     n;
133 > extern void
134 > dith_colrs(             /* convert scanline to dithered index values */
135 >        register BYTE   *bs,
136 >        register COLR   *cs,
137 >        int     n
138 > )
139   {
140          static short    (*cerr)[3] = NULL;
141          static int      N = 0;
# Line 159 | Line 180 | int    n;
180   }
181  
182  
183 < static
184 < cut(box, c0, c1)                        /* partition color space */
185 < register int    box[3][2];
186 < int     c0, c1;
183 > static void
184 > cut(                    /* partition color space */
185 >        register int    box[3][2],
186 >        int     c0,
187 >        int     c1
188 > )
189   {
190          register int    branch;
191          int     kb[3][2];
# Line 185 | Line 208 | int    c0, c1;
208  
209  
210   static int
211 < split(box)                              /* find median cut for box */
212 < register int    box[3][2];
211 > split(                          /* find median cut for box */
212 >        register int    box[3][2]
213 > )
214   {
215   #define c0      r
216          register int    r, g, b;
# Line 242 | Line 266 | register int   box[3][2];
266   }
267  
268  
269 < static
270 < mktabent(p, box)        /* compute average color for box and assign */
271 < int     p;
272 < register int    box[3][2];
269 > static void
270 > mktabent(       /* compute average color for box and assign */
271 >        int     p,
272 >        register int    box[3][2]
273 > )
274   {
275          unsigned long   sum[3];
276          unsigned        r, g;
# Line 285 | Line 310 | register int   box[3][2];
310  
311   #ifdef CLOSEST
312   #define NBSIZ           32
313 < static
314 < closest(n)                      /* make sure we have the closest colors */
315 < int     n;
313 > static void
314 > closest(                        /* make sure we have the closest colors */
315 >        int     n
316 > )
317   {
318          BYTE    *neigh[256];
319          register int    r, g, b;
# Line 324 | Line 350 | int    n;
350   }
351  
352  
353 < static
354 < addneigh(nl, i, j)              /* i and j are neighbors; add them to list */
355 < register BYTE   *nl[];
356 < register int    i;
357 < int     j;
353 > static void
354 > addneigh(               /* i and j are neighbors; add them to list */
355 >        register BYTE   *nl[],
356 >        register int    i,
357 >        int     j
358 > )
359   {
360          int     nc;
361          char    *nnl;
# Line 354 | Line 381 | int    j;
381   }
382  
383  
384 < static unsigned
385 < dist(col, r, g, b)              /* find distance from clrtab entry to r,g,b */
386 < register BYTE   col[3];
387 < int     r, g, b;
384 > static unsigned int
385 > dist(           /* find distance from clrtab entry to r,g,b */
386 >        register BYTE   col[3],
387 >        int     r,
388 >        int     g,
389 >        int     b
390 > )
391   {
392          register int    tmp;
393          register unsigned       sum;
# Line 372 | Line 402 | int    r, g, b;
402   }
403  
404  
405 < static
406 < setclosest(nl, r, g, b)         /* find index closest to color and assign */
407 < BYTE    *nl[];
408 < int     r, g, b;
405 > static void
406 > setclosest(             /* find index closest to color and assign */
407 >        BYTE    *nl[],
408 >        int     r,
409 >        int     g,
410 >        int     b
411 > )
412   {
413          int     ident;
414          unsigned        min;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines