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

Comparing ray/src/px/pcond.c (file contents):
Revision 3.16 by schorsch, Mon Jul 21 22:30:18 2003 UTC vs.
Revision 3.24 by schorsch, Wed Jun 7 17:52:04 2006 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   */
8  
9   #include "platform.h"
10 + #include "paths.h"
11 + #include "rtprocess.h"
12   #include "pcond.h"
13  
14  
# Line 42 | Line 44 | double bwavg;                          /* mean brightness */
44  
45   double  scalef = 0.;                    /* linear scaling factor */
46  
47 + static gethfunc headline;
48 + static void getahead(void);
49 + static void mapimage(void);
50 + static void getfovimg(void);
51 + static void check2do(void);
52  
53 < main(argc, argv)
54 < int     argc;
55 < char    *argv[];
53 >
54 >
55 > int
56 > main(
57 >        int     argc,
58 >        char    *argv[]
59 > )
60   {
61          static RGBPRIMS outprimS;
62          int     i;
# Line 106 | Line 117 | char   *argv[];
117                  case 'e':
118                          if (i+1 >= argc) goto userr;
119                          scalef = atof(argv[++i]);
120 <                        if (argv[i][0] == '+' | argv[i][0] == '-')
120 >                        if ((argv[i][0] == '+') | (argv[i][0] == '-'))
121                                  scalef = pow(2.0, scalef);
122                          what2do |= DO_LINEAR;
123                          break;
# Line 151 | Line 162 | char   *argv[];
162                                  progname);
163                  exit(1);
164          }
165 <        if (outprims == stdprims & inprims != stdprims)
165 >        if ((outprims == stdprims) & (inprims != stdprims))
166                  outprims = inprims;
167          Bldmin = Bl(ldmax/lddyn);
168          Bldmax = Bl(ldmax);
# Line 167 | Line 178 | char   *argv[];
178          SET_FILE_BINARY(stdout);
179          getahead();                     /* load input header */
180          printargs(argc, argv, stdout);  /* add to output header */
181 <        if (mbcalfile == NULL & outprims != stdprims)
181 >        if ((mbcalfile == NULL) & (outprims != stdprims))
182                  fputprims(outprims, stdout);
183          if ((what2do & (DO_PREHIST|DO_VEIL|DO_ACUITY)) != DO_PREHIST)
184                  getfovimg();            /* get foveal sample image? */
# Line 183 | Line 194 | userr:
194          fprintf(stderr, "Usage: %s [-{h|a|v|s|c|l|w}[+-]][-I|-i ffrac][-e ev][-p xr yr xg yg xb yb xw yw|-f mbf.cal|-m rgb.cwp][-u Ldmax][-d Lddyn][-x mapfile] inpic [outpic]\n",
195                          progname);
196          exit(1);
197 +        return 1; /* pro forma return */
198   #undef bool
199   }
200  
201  
202 < syserror(s)                             /* report system error and exit */
203 < char    *s;
202 > extern void
203 > syserror(                               /* report system error and exit */
204 >        char    *s
205 > )
206   {
207          fprintf(stderr, "%s: ", progname);
208          perror(s);
# Line 196 | Line 210 | char   *s;
210   }
211  
212  
213 < headline(s)                             /* process header line */
214 < char    *s;
213 > static int
214 > headline(                               /* process header line */
215 >        char    *s,
216 >        void    *p
217 > )
218   {
219          static RGBPRIMS inprimS;
220          char    fmt[32];
# Line 225 | Line 242 | char   *s;
242   }
243  
244  
245 < getahead()                      /* load picture header */
245 > static void
246 > getahead(void)                  /* load picture header */
247   {
248          char    *err;
249  
# Line 242 | Line 260 | getahead()                     /* load picture header */
260                                  progname);
261                  exit(1);
262          }
263 <        if (!gotview || ourview.type == VT_PAR) {
263 >        if (!gotview || ourview.type == VT_PAR ||
264 >                        (ourview.horiz <= 5.) | (ourview.vert <= 5.)) {
265                  ourview = stdview;
266                  ourview.type = VT_PER;
267                  if (pixaspect*inpres.yr < inpres.xr) {
# Line 263 | Line 282 | getahead()                     /* load picture header */
282   }
283  
284  
285 < mapimage()                              /* map picture and send to stdout */
285 > static void
286 > mapimage(void)                          /* map picture and send to stdout */
287   {
288          COLOR   *scan;
289  
# Line 303 | Line 323 | mapimage()                             /* map picture and send to stdout */
323   }
324  
325  
326 < getfovimg()                     /* load foveal sampled image */
326 > static void
327 > getfovimg(void)                 /* load foveal sampled image */
328   {
329 <        extern FILE     *popen();
309 <        char    combuf[128];
329 >        char    combuf[PATH_MAX];
330          FILE    *fp;
331          int     x, y;
332                                                  /* compute image size */
# Line 321 | Line 341 | getfovimg()                    /* load foveal sampled image */
341          }
342          if ((fovimg = (COLOR *)malloc(fvxr*fvyr*sizeof(COLOR))) == NULL)
343                  syserror("malloc");
344 <        sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d %s", fvxr, fvyr, infn);
344 >        sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn);
345          if ((fp = popen(combuf, "r")) == NULL)
346                  syserror("popen");
347          getheader(fp, NULL, NULL);      /* skip header */
348 <        if (fgetresolu(&x, &y, fp) < 0 || x != fvxr | y != fvyr)
348 >        if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr))
349                  goto readerr;
350          for (y = 0; y < fvyr; y++)
351                  if (freadscan(fovscan(y), fvxr, fp) < 0)
# Line 339 | Line 359 | readerr:
359   }
360  
361  
362 < check2do()              /* check histogram to see what isn't worth doing */
362 > static void
363 > check2do(void)          /* check histogram to see what isn't worth doing */
364   {
365          double  sum;
366          double  b, l;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines