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.19 by schorsch, Mon Nov 10 11:54:23 2003 UTC vs.
Revision 3.35 by greg, Sat Jun 7 05:09:46 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   */
8  
9   #include "platform.h"
10 #include "paths.h"
11 #include "rtprocess.h"
10   #include "pcond.h"
11  
12  
13   #define LDMAX           100             /* default max. display luminance */
14 < #define LDDYN           32              /* default dynamic range */
14 > #define LDDYN           100             /* default dynamic range */
15  
16   int     what2do = 0;                    /* desired adjustments */
17  
# Line 21 | Line 19 | double ldmax = LDMAX;                  /* maximum output luminance */
19   double  lddyn = LDDYN;                  /* display dynamic range */
20   double  Bldmin, Bldmax;                 /* Bl(ldmax/lddyn) and Bl(ldmax) */
21  
24 char    *progname;                      /* global argv[0] */
25
22   char    *infn;                          /* input file name */
23   FILE    *infp;                          /* input stream */
24   FILE    *mapfp = NULL;                  /* tone-mapping function stream */
# Line 44 | Line 40 | double bwavg;                          /* mean brightness */
40  
41   double  scalef = 0.;                    /* linear scaling factor */
42  
43 + static gethfunc headline;
44 + static void getahead(void);
45 + static void mapimage(void);
46 + static void getfovimg(void);
47 + static void check2do(void);
48  
49 < main(argc, argv)
50 < int     argc;
51 < char    *argv[];
49 >
50 >
51 > int
52 > main(
53 >        int     argc,
54 >        char    *argv[]
55 > )
56   {
57          static RGBPRIMS outprimS;
58          int     i;
59 < #define bool(flg)               switch (argv[i][2]) { \
59 > #define check_bool(flg)         switch (argv[i][2]) { \
60                                  case '\0': what2do ^= flg; break; \
61                                  case 'y': case 'Y': case 't': case 'T': \
62                                  case '+': case '1': what2do |= flg; break; \
# Line 59 | Line 64 | char   *argv[];
64                                  case '-': case '0': what2do &= ~(flg); break; \
65                                  default: goto userr; }
66  
67 <        progname = argv[0];
67 >        fixargv0(argv[0]);              /* sets global progname */
68  
69          for (i = 1; i < argc && argv[i][0] == '-'; i++)
70                  switch (argv[i][1]) {
71                  case 'h':
72 <                        bool(DO_HUMAN);
72 >                        check_bool(DO_HUMAN);
73                          break;
74                  case 'a':
75 <                        bool(DO_ACUITY);
75 >                        check_bool(DO_ACUITY);
76                          break;
77                  case 'v':
78 <                        bool(DO_VEIL);
78 >                        check_bool(DO_VEIL);
79                          break;
80                  case 's':
81 <                        bool(DO_HSENS);
81 >                        check_bool(DO_HSENS);
82                          break;
83                  case 'c':
84 <                        bool(DO_COLOR);
84 >                        check_bool(DO_COLOR);
85                          break;
86                  case 'w':
87 <                        bool(DO_CWEIGHT);
87 >                        check_bool(DO_CWEIGHT);
88                          break;
89                  case 'i':
90                          if (i+1 >= argc) goto userr;
# Line 88 | Line 93 | char   *argv[];
93                          else what2do &= ~DO_FIXHIST;
94                          break;
95                  case 'I':
96 <                        bool(DO_PREHIST);
96 >                        check_bool(DO_PREHIST);
97                          break;
98                  case 'l':
99 <                        bool(DO_LINEAR);
99 >                        check_bool(DO_LINEAR);
100                          break;
101                  case 'p':
102                          if (i+8 >= argc) goto userr;
# Line 185 | Line 190 | userr:
190          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",
191                          progname);
192          exit(1);
193 < #undef bool
193 >        return 1; /* pro forma return */
194 > #undef check_bool
195   }
196  
197  
198 < syserror(s)                             /* report system error and exit */
199 < char    *s;
198 > void
199 > syserror(                               /* report system error and exit */
200 >        char    *s
201 > )
202   {
203          fprintf(stderr, "%s: ", progname);
204          perror(s);
# Line 198 | Line 206 | char   *s;
206   }
207  
208  
209 < headline(s)                             /* process header line */
210 < char    *s;
209 > static int
210 > headline(                               /* process header line */
211 >        char    *s,
212 >        void    *p
213 > )
214   {
215          static RGBPRIMS inprimS;
216 <        char    fmt[32];
216 >        char    fmt[MAXFMTLEN];
217  
218          if (formatval(fmt, s)) {        /* check if format string */
219 <                if (!strcmp(fmt,COLRFMT)) lumf = rgblum;
220 <                else if (!strcmp(fmt,CIEFMT)) lumf = cielum;
221 <                else lumf = NULL;
219 >                if (!strcmp(fmt,COLRFMT) || !strcmp(fmt,SPECFMT))
220 >                        lumf = rgblum;
221 >                else if (!strcmp(fmt,CIEFMT))
222 >                        lumf = cielum;
223 >                else
224 >                        lumf = NULL;
225                  return(0);              /* don't echo */
226          }
227 <        if (isprims(s)) {               /* get input primaries */
228 <                primsval(inprimS, s);
229 <                inprims= inprimS;
227 >        if (isncomp(s)) {
228 >                NCSAMP = ncompval(s);
229 >                return(0);
230 >        }
231 >        if (iswlsplit(s)) {
232 >                wlsplitval(WLPART, s);
233 >                return(0);
234 >        }
235 >                                        /* get input primaries */
236 >        if (isprims(s) && primsval(inprimS, s)) {
237 >                inprims = inprimS;
238                  return(0);              /* don't echo */
239          }
240          if (isexpos(s)) {               /* picture exposure */
# Line 227 | Line 249 | char   *s;
249   }
250  
251  
252 < getahead()                      /* load picture header */
252 > static void
253 > getahead(void)                  /* load picture header */
254   {
255          char    *err;
256  
# Line 244 | Line 267 | getahead()                     /* load picture header */
267                                  progname);
268                  exit(1);
269          }
270 <        if (!gotview || ourview.type == VT_PAR) {
270 >        if (!gotview || ourview.type == VT_PAR ||
271 >                        (ourview.horiz <= 5.) | (ourview.vert <= 5.)) {
272                  ourview = stdview;
273                  ourview.type = VT_PER;
274                  if (pixaspect*inpres.yr < inpres.xr) {
# Line 265 | Line 289 | getahead()                     /* load picture header */
289   }
290  
291  
292 < mapimage()                              /* map picture and send to stdout */
292 > static void
293 > mapimage(void)                          /* map picture and send to stdout */
294   {
295          COLOR   *scan;
296  
# Line 305 | Line 330 | mapimage()                             /* map picture and send to stdout */
330   }
331  
332  
333 < getfovimg()                     /* load foveal sampled image */
333 > static void
334 > getfovimg(void)                 /* load foveal sampled image */
335   {
336          char    combuf[PATH_MAX];
337          FILE    *fp;
# Line 325 | Line 351 | getfovimg()                    /* load foveal sampled image */
351          sprintf(combuf, "pfilt -1 -b -pa 0 -x %d -y %d \"%s\"", fvxr, fvyr, infn);
352          if ((fp = popen(combuf, "r")) == NULL)
353                  syserror("popen");
354 +        SET_FILE_BINARY(fp);
355          getheader(fp, NULL, NULL);      /* skip header */
356          if (fgetresolu(&x, &y, fp) < 0 || (x != fvxr) | (y != fvyr))
357                  goto readerr;
358          for (y = 0; y < fvyr; y++)
359 <                if (freadscan(fovscan(y), fvxr, fp) < 0)
359 >                if (fread2scan(fovscan(y), fvxr, fp, NCSAMP, WLPART) < 0)
360                          goto readerr;
361          pclose(fp);
362          return;
# Line 340 | Line 367 | readerr:
367   }
368  
369  
370 < check2do()              /* check histogram to see what isn't worth doing */
370 > static void
371 > check2do(void)          /* check histogram to see what isn't worth doing */
372   {
373          double  sum;
374          double  b, l;
375 <        register int    i;
375 >        int     i;
376  
377                                          /* check for within display range */
378          if (bwmax - bwmin <= Bldmax - Bldmin)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines