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.7 by greg, Fri Jan 31 15:56:20 1997 UTC vs.
Revision 3.10 by greg, Sat Feb 22 02:07:27 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Input and output conditioning routines for pcond.
6 + *  Added white-balance adjustment 10/01 (GW).
7   */
8  
9   #include "pcond.h"
10 + #include "warp3d.h"
11  
12  
13   RGBPRIMP        inprims = stdprims;     /* input primaries */
# Line 19 | Line 18 | double (*lumf)() = rgblum;             /* input luminance functio
18   double  inpexp = 1.0;                   /* input exposure value */
19  
20   char    *mbcalfile = NULL;              /* macbethcal mapping file */
21 + char    *cwarpfile = NULL;              /* color space warping file */
22  
23   static struct mbc {
24          COLORMAT        cmat;
# Line 26 | Line 26 | static struct mbc {
26          COLOR   cmin, cmax;
27   }       mbcond;                         /* macbethcal conditioning struct */
28  
29 + static WARP3D   *cwarp;                 /* color warping structure */
30 +
31   static COLOR    *scanbuf;               /* scanline processing buffer */
32   static int      nread;                  /* number of scanlines processed */
33  
# Line 61 | Line 63 | COLOR *
63   nextscan()                              /* read and condition next scanline */
64   {
65          if (nread >= numscans(&inpres)) {
66 <                free((char *)scanbuf);
66 >                if (cwarpfile != NULL)
67 >                        free3dw(cwarp);
68 >                free((void *)scanbuf);
69                  return(scanbuf = NULL);
70          }
71          if (what2do&DO_ACUITY)
# Line 81 | Line 85 | nextscan()                             /* read and condition next scanline */
85                  mapscan(scanbuf, scanlen(&inpres));
86          if (mbcalfile != NULL)                  /* device color correction */
87                  mbscan(scanbuf, scanlen(&inpres), &mbcond);
88 +        else if (cwarpfile != NULL)             /* device color space warp */
89 +                cwscan(scanbuf, scanlen(&inpres), cwarp);
90          else if (lumf == cielum | inprims != outprims)
91                  matscan(scanbuf, scanlen(&inpres), mbcond.cmat);
92          nread++;
# Line 93 | Line 99 | firstscan()                            /* return first processed scanline */
99   {
100          if (mbcalfile != NULL)          /* load macbethcal file */
101                  getmbcalfile(mbcalfile, &mbcond);
102 <        else
102 >        else if (cwarpfile != NULL) {
103 >                if ((cwarp = load3dw(cwarpfile, NULL)) == NULL)
104 >                        syserror(cwarpfile);
105 >        } else
106                  if (lumf == rgblum)
107 <                        comprgb2rgbmat(mbcond.cmat, inprims, outprims);
107 >                        comprgb2rgbWBmat(mbcond.cmat, inprims, outprims);
108                  else
109 <                        compxyz2rgbmat(mbcond.cmat, outprims);
109 >                        compxyz2rgbWBmat(mbcond.cmat, outprims);
110          if (what2do&DO_ACUITY)
111                  initacuity();
112          scanbuf = (COLOR *)malloc(scanlen(&inpres)*sizeof(COLOR));
# Line 157 | Line 166 | register struct mbc    *mb;
166   }
167  
168  
169 + cwscan(sl, len, wp)                     /* apply color space warp to scaline */
170 + COLOR   *sl;
171 + int     len;
172 + WARP3D  *wp;
173 + {
174 +        int     rval;
175 +
176 +        while (len--) {
177 +                rval = warp3d(sl[0], sl[0], wp);
178 +                if (rval & W3ERROR)
179 +                        syserror("warp3d");
180 +                if (rval & W3BADMAP) {
181 +                        fprintf(stderr, "%s: %s: bad color space map\n",
182 +                                        progname, cwarpfile);
183 +                        exit(1);
184 +                }
185 +                clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite);
186 +                sl++;
187 +        }
188 + }
189 +
190 +
191   getmbcalfile(fn, mb)                    /* load macbethcal file */
192   char    *fn;
193   register struct mbc     *mb;
# Line 220 | Line 251 | register struct mbc    *mb;
251                          inpflags |= 040;
252                  else if (!(inpflags & 0100) &&
253                                  sscanf(buf,
254 <                                "r = %f*r1 + %f*g1 + %f*b1",
254 >                                "ro = %f*rn + %f*gn + %f*bn",
255                                  &mb->cmat[0][0], &mb->cmat[0][1],
256                                  &mb->cmat[0][2]) == 3)
257                          inpflags |= 0100;
258                  else if (!(inpflags & 0200) &&
259                                  sscanf(buf,
260 <                                "g = %f*r1 + %f*g1 + %f*b1",
260 >                                "go = %f*rn + %f*gn + %f*bn",
261                                  &mb->cmat[1][0], &mb->cmat[1][1],
262                                  &mb->cmat[1][2]) == 3)
263                          inpflags |= 0200;
264                  else if (!(inpflags & 0400) &&
265                                  sscanf(buf,
266 <                                "b = %f*r1 + %f*g1 + %f*b1",
266 >                                "bo = %f*rn + %f*gn + %f*bn",
267                                  &mb->cmat[2][0], &mb->cmat[2][1],
268                                  &mb->cmat[2][2]) == 3)
269                          inpflags |= 0400;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines