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

Comparing ray/src/px/closest.c (file contents):
Revision 2.3 by schorsch, Sun Jul 27 22:12:03 2003 UTC vs.
Revision 2.4 by schorsch, Sun Mar 28 20:33:13 2004 UTC

# Line 12 | Line 12 | About 6 times faster than exhaustive.
12   Paul Heckbert
13   */
14  
15 + #include <stdlib.h>
16 +
17   #include "ciq.h"
18  
19   #define inf 3*256*256
# Line 25 | Line 27 | static int nfill,tests,calls;
27   static char filled[512];                /* has bucket[key] been filled yet? */
28   static int sq[511];
29  
30 < initializeclosest() {                   /* reset the buckets */
30 > static int compare(const void *a, const void *b);
31 > static void fillbucket(int k);
32 >
33 >
34 > void
35 > initializeclosest(void) {                       /* reset the buckets */
36      int k;
37      nfill = tests = calls = 0;
38      for (k=0; k<512; k++) filled[k] = 0;
39      next = space;
40   }
41  
42 < closest(r,g,b)          /* find pv of colormap color closest to (r,g,b) */
43 < int r,g,b;
42 > int
43 > closest(                /* find pv of colormap color closest to (r,g,b) */
44 >        int r,
45 >        int g,
46 >        int b
47 > )
48   {
49      register struct thing *p;
50      register int *rsq,*gsq,*bsq,dist,min;
# Line 63 | Line 74 | int r,g,b;
74  
75   #define H 16    /* half-width of a bucket */
76  
77 < compare(a,b)
78 < register struct thing *a,*b;
77 > static int
78 > compare(
79 >        const void *a,
80 >        const void *b
81 > )
82   {
83 <    return a->mindist-b->mindist;
83 >    return ((struct thing*)a)->mindist - ((struct thing*)b)->mindist;
84   }
85  
86 < fillbucket(k)   /* make list of colormap colors which could be closest */
87 < int k;          /* matches for colors in bucket #k */
86 > static void
87 > fillbucket(     /* make list of colormap colors which could be closest */
88 >        int k           /* matches for colors in bucket #k */
89 > )
90   {
91      register int r,g,b,j,dist,*rsq,*gsq,*bsq,min,best;
92      struct thing *p,*q;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines