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.22 by greg, Sun Nov 14 16:57:18 2004 UTC vs.
Revision 3.34 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
8  
9   #include "platform.h"
10   #include "paths.h"
11 #include "rtprocess.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 21 | Line 20 | double ldmax = LDMAX;                  /* maximum output luminance */
20   double  lddyn = LDDYN;                  /* display dynamic range */
21   double  Bldmin, Bldmax;                 /* Bl(ldmax/lddyn) and Bl(ldmax) */
22  
24 char    *progname;                      /* global argv[0] */
25
23   char    *infn;                          /* input file name */
24   FILE    *infp;                          /* input stream */
25   FILE    *mapfp = NULL;                  /* tone-mapping function stream */
# Line 60 | Line 57 | main(
57   {
58          static RGBPRIMS outprimS;
59          int     i;
60 < #define bool(flg)               switch (argv[i][2]) { \
60 > #define check_bool(flg)         switch (argv[i][2]) { \
61                                  case '\0': what2do ^= flg; break; \
62                                  case 'y': case 'Y': case 't': case 'T': \
63                                  case '+': case '1': what2do |= flg; break; \
# Line 68 | Line 65 | main(
65                                  case '-': case '0': what2do &= ~(flg); break; \
66                                  default: goto userr; }
67  
68 <        progname = argv[0];
68 >        fixargv0(argv[0]);              /* sets global progname */
69  
70          for (i = 1; i < argc && argv[i][0] == '-'; i++)
71                  switch (argv[i][1]) {
72                  case 'h':
73 <                        bool(DO_HUMAN);
73 >                        check_bool(DO_HUMAN);
74                          break;
75                  case 'a':
76 <                        bool(DO_ACUITY);
76 >                        check_bool(DO_ACUITY);
77                          break;
78                  case 'v':
79 <                        bool(DO_VEIL);
79 >                        check_bool(DO_VEIL);
80                          break;
81                  case 's':
82 <                        bool(DO_HSENS);
82 >                        check_bool(DO_HSENS);
83                          break;
84                  case 'c':
85 <                        bool(DO_COLOR);
85 >                        check_bool(DO_COLOR);
86                          break;
87                  case 'w':
88 <                        bool(DO_CWEIGHT);
88 >                        check_bool(DO_CWEIGHT);
89                          break;
90                  case 'i':
91                          if (i+1 >= argc) goto userr;
# Line 97 | Line 94 | main(
94                          else what2do &= ~DO_FIXHIST;
95                          break;
96                  case 'I':
97 <                        bool(DO_PREHIST);
97 >                        check_bool(DO_PREHIST);
98                          break;
99                  case 'l':
100 <                        bool(DO_LINEAR);
100 >                        check_bool(DO_LINEAR);
101                          break;
102                  case 'p':
103                          if (i+8 >= argc) goto userr;
# Line 195 | Line 192 | userr:
192                          progname);
193          exit(1);
194          return 1; /* pro forma return */
195 < #undef bool
195 > #undef check_bool
196   }
197  
198  
199 < extern void
199 > void
200   syserror(                               /* report system error and exit */
201          char    *s
202   )
# Line 217 | Line 214 | headline(                              /* process header line */
214   )
215   {
216          static RGBPRIMS inprimS;
217 <        char    fmt[32];
217 >        char    fmt[MAXFMTLEN];
218  
219          if (formatval(fmt, s)) {        /* check if format string */
220 <                if (!strcmp(fmt,COLRFMT)) lumf = rgblum;
221 <                else if (!strcmp(fmt,CIEFMT)) lumf = cielum;
222 <                else lumf = NULL;
220 >                if (!strcmp(fmt,COLRFMT) || !strcmp(fmt,SPECFMT))
221 >                        lumf = rgblum;
222 >                else if (!strcmp(fmt,CIEFMT))
223 >                        lumf = cielum;
224 >                else
225 >                        lumf = NULL;
226                  return(0);              /* don't echo */
227          }
228 <        if (isprims(s)) {               /* get input primaries */
229 <                primsval(inprimS, s);
230 <                inprims= inprimS;
228 >        if (isncomp(s)) {
229 >                NCSAMP = ncompval(s);
230 >                return(0);
231 >        }
232 >        if (iswlsplit(s)) {
233 >                wlsplitval(WLPART, s);
234 >                return(0);
235 >        }
236 >                                        /* get input primaries */
237 >        if (isprims(s) && primsval(inprimS, s)) {
238 >                inprims = inprimS;
239                  return(0);              /* don't echo */
240          }
241          if (isexpos(s)) {               /* picture exposure */
# Line 261 | Line 269 | getahead(void)                 /* load picture header */
269                  exit(1);
270          }
271          if (!gotview || ourview.type == VT_PAR ||
272 <                        ourview.horiz <= 3. | ourview.vert <= 3.) {
272 >                        (ourview.horiz <= 5.) | (ourview.vert <= 5.)) {
273                  ourview = stdview;
274                  ourview.type = VT_PER;
275                  if (pixaspect*inpres.yr < inpres.xr) {
# Line 344 | Line 352 | getfovimg(void)                        /* load foveal sampled image */
352          sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn);
353          if ((fp = popen(combuf, "r")) == NULL)
354                  syserror("popen");
355 +        SET_FILE_BINARY(fp);
356          getheader(fp, NULL, NULL);      /* skip header */
357          if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr))
358                  goto readerr;
359          for (y = 0; y < fvyr; y++)
360 <                if (freadscan(fovscan(y), fvxr, fp) < 0)
360 >                if (fread2scan(fovscan(y), fvxr, fp, NCSAMP, WLPART) < 0)
361                          goto readerr;
362          pclose(fp);
363          return;
# Line 364 | Line 373 | check2do(void)         /* check histogram to see what isn't w
373   {
374          double  sum;
375          double  b, l;
376 <        register int    i;
376 >        int     i;
377  
378                                          /* check for within display range */
379          if (bwmax - bwmin <= Bldmax - Bldmin)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines