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.17 by schorsch, Sun Jul 27 22:12:03 2003 UTC vs.
Revision 3.33 by greg, Wed Sep 11 18:56:11 2024 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   */
8  
9   #include "platform.h"
10 + #include "paths.h"
11   #include "pcond.h"
12  
13  
14   #define LDMAX           100             /* default max. display luminance */
15 < #define LDDYN           32              /* default dynamic range */
15 > #define LDDYN           100             /* default dynamic range */
16  
17   int     what2do = 0;                    /* desired adjustments */
18  
# Line 42 | Line 43 | double bwavg;                          /* mean brightness */
43  
44   double  scalef = 0.;                    /* linear scaling factor */
45  
46 + static gethfunc headline;
47 + static void getahead(void);
48 + static void mapimage(void);
49 + static void getfovimg(void);
50 + static void check2do(void);
51  
52 < main(argc, argv)
53 < int     argc;
54 < char    *argv[];
52 >
53 >
54 > int
55 > main(
56 >        int     argc,
57 >        char    *argv[]
58 > )
59   {
60          static RGBPRIMS outprimS;
61          int     i;
62 < #define bool(flg)               switch (argv[i][2]) { \
62 > #define check_bool(flg)         switch (argv[i][2]) { \
63                                  case '\0': what2do ^= flg; break; \
64                                  case 'y': case 'Y': case 't': case 'T': \
65                                  case '+': case '1': what2do |= flg; break; \
# Line 62 | Line 72 | char   *argv[];
72          for (i = 1; i < argc && argv[i][0] == '-'; i++)
73                  switch (argv[i][1]) {
74                  case 'h':
75 <                        bool(DO_HUMAN);
75 >                        check_bool(DO_HUMAN);
76                          break;
77                  case 'a':
78 <                        bool(DO_ACUITY);
78 >                        check_bool(DO_ACUITY);
79                          break;
80                  case 'v':
81 <                        bool(DO_VEIL);
81 >                        check_bool(DO_VEIL);
82                          break;
83                  case 's':
84 <                        bool(DO_HSENS);
84 >                        check_bool(DO_HSENS);
85                          break;
86                  case 'c':
87 <                        bool(DO_COLOR);
87 >                        check_bool(DO_COLOR);
88                          break;
89                  case 'w':
90 <                        bool(DO_CWEIGHT);
90 >                        check_bool(DO_CWEIGHT);
91                          break;
92                  case 'i':
93                          if (i+1 >= argc) goto userr;
# Line 86 | Line 96 | char   *argv[];
96                          else what2do &= ~DO_FIXHIST;
97                          break;
98                  case 'I':
99 <                        bool(DO_PREHIST);
99 >                        check_bool(DO_PREHIST);
100                          break;
101                  case 'l':
102 <                        bool(DO_LINEAR);
102 >                        check_bool(DO_LINEAR);
103                          break;
104                  case 'p':
105                          if (i+8 >= argc) goto userr;
# Line 183 | Line 193 | userr:
193          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",
194                          progname);
195          exit(1);
196 < #undef bool
196 >        return 1; /* pro forma return */
197 > #undef check_bool
198   }
199  
200  
201 < syserror(s)                             /* report system error and exit */
202 < char    *s;
201 > void
202 > syserror(                               /* report system error and exit */
203 >        char    *s
204 > )
205   {
206          fprintf(stderr, "%s: ", progname);
207          perror(s);
# Line 196 | Line 209 | char   *s;
209   }
210  
211  
212 < headline(s)                             /* process header line */
213 < char    *s;
212 > static int
213 > headline(                               /* process header line */
214 >        char    *s,
215 >        void    *p
216 > )
217   {
218          static RGBPRIMS inprimS;
219 <        char    fmt[32];
219 >        char    fmt[MAXFMTLEN];
220  
221          if (formatval(fmt, s)) {        /* check if format string */
222 <                if (!strcmp(fmt,COLRFMT)) lumf = rgblum;
223 <                else if (!strcmp(fmt,CIEFMT)) lumf = cielum;
224 <                else lumf = NULL;
222 >                if (!strcmp(fmt,COLRFMT) || !strcmp(fmt,SPECFMT))
223 >                        lumf = rgblum;
224 >                else if (!strcmp(fmt,CIEFMT))
225 >                        lumf = cielum;
226 >                else
227 >                        lumf = NULL;
228                  return(0);              /* don't echo */
229          }
230 <        if (isprims(s)) {               /* get input primaries */
231 <                primsval(inprimS, s);
232 <                inprims= inprimS;
230 >        if (isncomp(s)) {
231 >                NCSAMP = ncompval(s);
232 >                return(0);
233 >        }
234 >        if (iswlsplit(s)) {
235 >                wlsplitval(WLPART, s);
236 >                return(0);
237 >        }
238 >                                        /* get input primaries */
239 >        if (isprims(s) && primsval(inprimS, s)) {
240 >                inprims = inprimS;
241                  return(0);              /* don't echo */
242          }
243          if (isexpos(s)) {               /* picture exposure */
# Line 225 | Line 252 | char   *s;
252   }
253  
254  
255 < getahead()                      /* load picture header */
255 > static void
256 > getahead(void)                  /* load picture header */
257   {
258          char    *err;
259  
# Line 242 | Line 270 | getahead()                     /* load picture header */
270                                  progname);
271                  exit(1);
272          }
273 <        if (!gotview || ourview.type == VT_PAR) {
273 >        if (!gotview || ourview.type == VT_PAR ||
274 >                        (ourview.horiz <= 5.) | (ourview.vert <= 5.)) {
275                  ourview = stdview;
276                  ourview.type = VT_PER;
277                  if (pixaspect*inpres.yr < inpres.xr) {
# Line 263 | Line 292 | getahead()                     /* load picture header */
292   }
293  
294  
295 < mapimage()                              /* map picture and send to stdout */
295 > static void
296 > mapimage(void)                          /* map picture and send to stdout */
297   {
298          COLOR   *scan;
299  
# Line 303 | Line 333 | mapimage()                             /* map picture and send to stdout */
333   }
334  
335  
336 < getfovimg()                     /* load foveal sampled image */
336 > static void
337 > getfovimg(void)                 /* load foveal sampled image */
338   {
339 <        extern FILE     *popen();
309 <        char    combuf[128];
339 >        char    combuf[PATH_MAX];
340          FILE    *fp;
341          int     x, y;
342                                                  /* compute image size */
# Line 321 | Line 351 | getfovimg()                    /* load foveal sampled image */
351          }
352          if ((fovimg = (COLOR *)malloc(fvxr*fvyr*sizeof(COLOR))) == NULL)
353                  syserror("malloc");
354 <        sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d %s", fvxr, fvyr, infn);
354 >        sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn);
355          if ((fp = popen(combuf, "r")) == NULL)
356                  syserror("popen");
357 +        SET_FILE_BINARY(fp);
358          getheader(fp, NULL, NULL);      /* skip header */
359          if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr))
360                  goto readerr;
361          for (y = 0; y < fvyr; y++)
362 <                if (freadscan(fovscan(y), fvxr, fp) < 0)
362 >                if (fread2scan(fovscan(y), fvxr, fp, NCSAMP, WLPART) < 0)
363                          goto readerr;
364          pclose(fp);
365          return;
# Line 339 | Line 370 | readerr:
370   }
371  
372  
373 < check2do()              /* check histogram to see what isn't worth doing */
373 > static void
374 > check2do(void)          /* check histogram to see what isn't worth doing */
375   {
376          double  sum;
377          double  b, l;
378 <        register int    i;
378 >        int     i;
379  
380                                          /* check for within display range */
381          if (bwmax - bwmin <= Bldmax - Bldmin)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines