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

Comparing ray/src/px/pcond2.c (file contents):
Revision 3.12 by schorsch, Sun Mar 28 20:33:14 2004 UTC vs.
Revision 3.18 by greg, Fri Aug 21 05:48:28 2015 UTC

# Line 38 | Line 38 | static void cwscan(COLOR *sl, int len, WARP3D *wp);
38   static void getmbcalfile(char *fn, struct mbc *mb);
39  
40  
41 < extern double
41 > double
42   rgblum(         /* compute (scotopic) luminance of RGB color */
43          COLOR   clr,
44          int     scotopic
# Line 53 | Line 53 | rgblum(                /* compute (scotopic) luminance of RGB color
53   }
54  
55  
56 < extern double
56 > double
57   cielum(         /* compute (scotopic) luminance of CIE color */
58          COLOR   xyz,
59          int     scotopic
# Line 67 | Line 67 | cielum(                /* compute (scotopic) luminance of CIE color
67   }
68  
69  
70 < extern COLOR *
70 > COLOR *
71   nextscan(void)                          /* read and condition next scanline */
72   {
73          if (nread >= numscans(&inpres)) {
# Line 102 | Line 102 | nextscan(void)                         /* read and condition next scanline
102   }
103  
104  
105 < extern COLOR *
105 > COLOR *
106   firstscan(void)                         /* return first processed scanline */
107   {
108          if (mbcalfile != NULL)          /* load macbethcal file */
# Line 127 | Line 127 | firstscan(void)                                /* return first processed scanline
127  
128   static void
129   sfscan(                 /* apply scalefactor to scanline */
130 <        register COLOR  *sl,
130 >        COLOR   *sl,
131          int     len,
132          double  sf
133   )
# Line 139 | Line 139 | sfscan(                        /* apply scalefactor to scanline */
139   }
140  
141  
142 + static double
143 + greypoint(                      /* compute gamut mapping grey target */
144 +        COLOR col
145 + )
146 + {
147 +        COLOR   gryc;
148 +        int     i;
149 +                                /* improves saturated color rendering */
150 +        copycolor(gryc, col);
151 +        for (i = 3; i--; )
152 +                if (gryc[i] > 1)
153 +                        gryc[i] = 1;
154 +                else if (gryc[i] < 0)
155 +                        gryc[i] = 0;
156 +        return(bright(gryc));
157 + }
158 +
159 +
160   static void
161   matscan(                        /* apply color matrix to scaline */
162 <        register COLOR  *sl,
162 >        COLOR   *sl,
163          int     len,
164          COLORMAT        mat
165   )
166   {
167          while (len--) {
168                  colortrans(sl[0], mat, sl[0]);
169 <                clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite);
169 >                clipgamut(sl[0], greypoint(sl[0]), CGAMUT, cblack, cwhite);
170                  sl++;
171          }
172   }
# Line 158 | Line 176 | static void
176   mbscan(                 /* apply macbethcal adj. to scaline */
177          COLOR   *sl,
178          int     len,
179 <        register struct mbc     *mb
179 >        struct mbc      *mb
180   )
181   {
182          double  d;
183 <        register int    i, j;
183 >        int     i, j;
184  
185          while (len--) {
186                  colortrans(sl[0], mb->cmat, sl[0]);
187 <                clipgamut(sl[0], bright(sl[0]), CGAMUT, mb->cmin, mb->cmax);
187 >                clipgamut(sl[0], greypoint(sl[0]), CGAMUT, mb->cmin, mb->cmax);
188                  for (i = 0; i < 3; i++) {
189                          d = colval(sl[0],i);
190                          for (j = 0; j < 4 && mb->xa[i][j+1] <= d; j++)
# Line 198 | Line 216 | cwscan(                        /* apply color space warp to scaline */
216                                          progname, cwarpfile);
217                          exit(1);
218                  }
219 <                clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite);
219 >                clipgamut(sl[0], greypoint(sl[0]), CGAMUT, cblack, cwhite);
220                  sl++;
221          }
222   }
# Line 207 | Line 225 | cwscan(                        /* apply color space warp to scaline */
225   static void
226   getmbcalfile(                   /* load macbethcal file */
227          char    *fn,
228 <        register struct mbc     *mb
228 >        struct mbc      *mb
229   )
230   {
231          char    buf[128];
232          FILE    *fp;
233          int     inpflags = 0;
234 <        register int    i;
234 >        int     i;
235  
236          if ((fp = fopen(fn, "r")) == NULL)
237                  syserror(fn);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines