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

Comparing ray/src/px/pcomb.c (file contents):
Revision 2.43 by greg, Mon Nov 10 19:08:19 2008 UTC vs.
Revision 2.53 by greg, Fri Mar 18 18:31:47 2022 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include "platform.h"
11   #include "standard.h"
12 < #include "rtprocess.h"
12 > #include "paths.h"
13   #include "color.h"
14   #include "calcomp.h"
15   #include "view.h"
16  
17 < #define MAXINP          512             /* maximum number of input files */
18 < #define WINSIZ          64              /* scanline window size */
17 > #define MAXINP          1024            /* maximum number of input files */
18 > #define WINSIZ          127             /* scanline window size */
19   #define MIDSCN          ((WINSIZ-1)/2+1)
20  
21   struct {
# Line 31 | Line 31 | struct {
31  
32   int     nfiles;                         /* number of input files */
33  
34 + VIEW    *commvp = NULL;                 /* common view parameters */
35 +
36   char    ourfmt[LPICFMT+1] = PICFMT;     /* input picture format */
37  
38   char    StandardInput[] = "<stdin>";
# Line 74 | Line 76 | int    gotview;
76  
77  
78   static gethfunc headline;
79 < static void checkfile(void);
79 > static void checkfile(int orig);
80   static double rgb_bright(COLOR  clr);
81   static double xyz_bright(COLOR  clr);
82   static void init(void);
# Line 96 | Line 98 | main(
98          int     original;
99          double  f;
100          int     a;
101 +
102          SET_DEFAULT_BINARY();
103          SET_FILE_BINARY(stdin);
104          SET_FILE_BINARY(stdout);
105          progname = argv[0];
106 +        esupport |= E_VARIABLE|E_FUNCTION|E_RCONST;
107 +        esupport &= ~(E_OUTCHAN|E_INCHAN);
108                                                  /* scan options */
109          for (a = 1; a < argc; a++) {
110                  if (argv[a][0] == '-')
# Line 172 | Line 177 | main(
177                                  quit(1);
178                          }
179                  }
180 <                checkfile();
176 <                if (original) {
177 <                        colval(input[nfiles].coef,RED) /=
178 <                                        colval(input[nfiles].expos,RED);
179 <                        colval(input[nfiles].coef,GRN) /=
180 <                                        colval(input[nfiles].expos,GRN);
181 <                        colval(input[nfiles].coef,BLU) /=
182 <                                        colval(input[nfiles].expos,BLU);
183 <                        setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
184 <                }
180 >                checkfile(original);
181                  nfiles++;
182                  original = 0;
183          }
184          init();                         /* set constants */
185                                          /* go back and get expressions */
186          for (a = 1; a < argc; a++) {
187 +                char    *fpath;
188                  if (argv[a][0] == '-')
189                          switch (argv[a][1]) {
190                          case 'x':
# Line 201 | Line 198 | main(
198                          case 'h':
199                                  continue;
200                          case 'f':
201 <                                fcompile(argv[++a]);
201 >                                fpath = getpath(argv[++a], getrlibpath(), 0);
202 >                                if (fpath == NULL) {
203 >                                        eputs(argv[0]);
204 >                                        eputs(": cannot find file '");
205 >                                        eputs(argv[a]);
206 >                                        eputs("'\n");
207 >                                        quit(1);
208 >                                }
209 >                                fcompile(fpath);
210                                  continue;
211                          case 'e':
212                                  scompile(argv[++a], NULL, 0);
# Line 209 | Line 214 | main(
214                          }
215                  break;
216          }
217 <                                                /* set/get output resolution */
213 <        if (!vardefined(vxres))
214 <                varset(vxres, ':', (double)xmax);
215 <        if (!vardefined(vyres))
216 <                varset(vyres, ':', (double)ymax);
217 >                                                /* get output resolution */
218          xres = varvalue(vxres) + .5;
219          yres = varvalue(vyres) + .5;
220          if (xres <= 0 || yres <= 0) {
# Line 223 | Line 224 | main(
224          }
225                                                  /* complete header */
226          printargs(argc, argv, stdout);
227 +        if (commvp != NULL) {
228 +                fputs(VIEWSTR, stdout);
229 +                fprintview(commvp, stdout);
230 +                fputc('\n', stdout);
231 +        }
232          if (strcmp(ourfmt, PICFMT))
233                  fputformat(ourfmt, stdout);     /* print format if known */
234          putchar('\n');
# Line 246 | Line 252 | headline(                      /* check header line & echo if requested *
252          void    *p
253   )
254   {
255 <        char    fmt[32];
255 >        int     orig = *(int *)p;
256 >        char    fmt[MAXFMTLEN];
257          double  d;
258          COLOR   ctmp;
259  
# Line 260 | Line 267 | headline(                      /* check header line & echo if requested *
267                          wrongformat = globmatch(PICFMT, fmt) ? 1 : -1;
268                  return(0);      /* don't echo */
269          }
270 <        if (isexpos(s)) {                       /* exposure */
270 >        if (orig) {                             /* undo exposure? */
271 >                if (isexpos(s)) {
272 >                        d = 1./exposval(s);
273 >                        scalecolor(input[nfiles].coef, d);
274 >                        return(0);      /* don't echo */
275 >                }
276 >                if (iscolcor(s)) {
277 >                        int     i;
278 >                        colcorval(ctmp, s);
279 >                        for (i = 3; i--; )
280 >                                colval(input[nfiles].coef,i) /= colval(ctmp,i);
281 >                        return(0);      /* don't echo */
282 >                }
283 >        } else if (isexpos(s)) {                /* record exposure? */
284                  d = exposval(s);
285                  scalecolor(input[nfiles].expos, d);
286 <        } else if (iscolcor(s)) {               /* color correction */
286 >        } else if (iscolcor(s)) {
287                  colcorval(ctmp, s);
288                  multcolor(input[nfiles].expos, ctmp);
289          } else if (isaspect(s))
# Line 280 | Line 300 | headline(                      /* check header line & echo if requested *
300  
301  
302   static void
303 < checkfile(void)                 /* ready a file */
303 > checkfile(int orig)                     /* ready a file */
304   {
305 <        register int    i;
305 >        int     i;
306                                          /* process header */
307          gotview = 0;
308          if (echoheader) {
309                  fputs(input[nfiles].name, stdout);
310                  fputs(":\n", stdout);
311          }
312 <        getheader(input[nfiles].fp, headline, NULL);
312 >        getheader(input[nfiles].fp, headline, &orig);
313          if (wrongformat < 0) {
314                  eputs(input[nfiles].name);
315                  eputs(": not a Radiance picture\n");
# Line 301 | Line 321 | checkfile(void)                        /* ready a file */
321          }
322          if (!gotview || setview(&input[nfiles].vw) != NULL)
323                  input[nfiles].vw.type = 0;
324 +        else if (commvp == NULL)
325 +                commvp = &input[nfiles].vw;
326          if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) {
327                  eputs(input[nfiles].name);
328                  eputs(": bad picture size\n");
# Line 345 | Line 367 | double (*ourbright)() = rgb_bright;
367   static void
368   init(void)                                      /* perform final setup */
369   {
370 <        register int    i;
370 >        int     i;
371                                                  /* define constants */
372          varset("PI", ':', PI);
373          varset(vnfiles, ':', (double)nfiles);
# Line 368 | Line 390 | init(void)                                     /* perform final setup */
390                  ourbright = xyz_bright;
391          } else
392                  varset(vwhteff, ':', WHTEFFICACY);
393 +                                                /* these may be overridden */
394 +        varset(vxres, ':', (double)xmax);
395 +        varset(vyres, ':', (double)ymax);
396   }
397  
398  
# Line 377 | Line 402 | combine(void)                  /* combine pictures */
402          EPNODE  *coldef[3], *brtdef;
403          COLOR   *scanout;
404          double  d;
405 <        register int    i, j;
405 >        int     i, j;
406                                                  /* check defined variables */
407          for (j = 0; j < 3; j++) {
408                  if (vardefined(vcolout[j]))
# Line 434 | Line 459 | static void
459   advance(void)                   /* read in data for next scanline */
460   {
461          int     ytarget;
462 <        register COLOR  *st;
463 <        register int    i, j;
462 >        COLOR   *st;
463 >        int     i, j;
464  
465          for (ytarget = (ypos+.5)*ymax/yres; yscan > ytarget; yscan--)
466                  for (i = 0; i < nfiles; i++) {
# Line 504 | Line 529 | l_pixaspect(char *nm)          /* return pixel aspect ratio */
529  
530   static double
531   l_colin(                        /* return color value for picture */
532 <        register char   *nam
532 >        char    *nam
533   )
534   {
535          int     fn;
536 <        register int    n, xoff, yoff;
536 >        int     n, xoff, yoff;
537          double  d;
538  
539          d = argument(1);
# Line 563 | Line 588 | l_colin(                       /* return color value for picture */
588  
589   static double
590   l_ray(          /* return ray origin or direction */
591 <        register char   *nam
591 >        char    *nam
592   )
593   {
594          static unsigned long    ltick[MAXINP];
# Line 572 | Line 597 | l_ray(         /* return ray origin or direction */
597          RREAL   loc[2];
598          double  d;
599          int     fn;
600 <        register int    i;
600 >        int     i;
601  
602          d = argument(1);
603          if (d <= -0.5 || d >= nfiles+0.5) {
# Line 615 | Line 640 | l_psize(char *nm)              /* compute pixel size in steradians
640          RREAL   locx[2], locy[2];
641          double  d;
642          int     fn;
643 <        register int    i;
643 >        int     i;
644  
645          d = argument(1);
646          if (d <= -0.5 || d >= nfiles+0.5) {
# Line 672 | Line 697 | eputs(char *msg)
697   extern void
698   quit(int code)          /* exit gracefully */
699   {
700 <        register int  i;
700 >        int  i;
701                                  /* close input files */
702          for (i = 0; i < nfiles; i++)
703                  if (input[i].name == Command)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines