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

Comparing ray/src/px/pfilt.c (file contents):
Revision 1.10 by greg, Thu Sep 13 09:46:00 1990 UTC vs.
Revision 1.17 by greg, Wed Jun 5 12:15:30 1991 UTC

# Line 17 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17   #include  "color.h"
18  
19   extern char  *malloc();
20 + extern float  *matchlamp();
21  
22 + #define  FEQ(a,b)       ((a) >= .98*(b) && (a) <= 1.02*(b))
23 +
24   #define  CHECKRAD       1.5     /* radius to check for filtering */
25  
26   COLOR  exposure = WHTCOLOR;     /* exposure for the frame */
# Line 44 | Line 47 | double  spread = 1e-4;         /* spread for star points */
47  
48   char  *tfname = NULL;
49  
50 + char  *lampdat = "lamp.tab";    /* lamp data file */
51 +
52   int  xres, yres;                /* resolution of input */
53   double  inpaspect = 1.0;        /* pixel aspect ratio of input */
54 + int  correctaspect = 0;         /* aspect ratio correction? */
55  
56 + int  wrongformat = 0;
57 +
58   int  xrad;                      /* x window size */
59   int  yrad;                      /* y window size */
60  
# Line 66 | Line 74 | char  **argv;
74          extern long  ftell();
75          extern int  quit(), headline();
76          FILE  *fin;
77 +        float  *lampcolor;
78 +        char  *lamptype = NULL;
79          long  fpos;
80          double  outaspect = 0.0;
81          double  d;
# Line 103 | Line 113 | char  **argv;
113                                  } else
114                                          nrows = atoi(argv[i]);
115                                  break;
116 +                        case 'c':
117 +                                correctaspect = !correctaspect;
118 +                                break;
119                          case 'p':
120                                  i++;
121                                  outaspect = atof(argv[i]);
# Line 112 | Line 125 | char  **argv;
125                                          d = pow(2.0, atof(argv[i+1]));
126                                  else
127                                          d = atof(argv[i+1]);
128 +                                if (d < 1e-20 || d > 1e20) {
129 +                                        fprintf(stderr,
130 +                                                "%s: exposure out of range\n",
131 +                                                        argv[0]);
132 +                                        exit(1);
133 +                                }
134                                  switch (argv[i][2]) {
135                                  case '\0':
136                                          scalecolor(exposure, d);
# Line 130 | Line 149 | char  **argv;
149                                  }
150                                  i++;
151                                  break;
152 +                        case 'f':
153 +                                lampdat = argv[++i];
154 +                                break;
155 +                        case 't':
156 +                                lamptype = argv[++i];
157 +                                break;
158                          case '1':
159                                  singlepass = 1;
160                                  break;
# Line 163 | Line 188 | char  **argv;
188                          }
189                  else
190                          break;
191 <                        
191 >                                        /* get lamp data (if necessary) */
192 >        if (lamptype != NULL) {
193 >                if (loadlamps(lampdat) < 0)
194 >                        quit(1);
195 >                if ((lampcolor = matchlamp(lamptype)) == NULL) {
196 >                        fprintf(stderr, "%s: unknown lamp type\n", lamptype);
197 >                        quit(1);
198 >                }
199 >                colval(exposure,RED) /= lampcolor[0];
200 >                colval(exposure,GRN) /= lampcolor[1];
201 >                colval(exposure,BLU) /= lampcolor[2];
202 >                freelamps();
203 >        }
204 >                                        /* open input file */
205          if (i == argc) {
206                  if (singlepass)
207                          fin = stdin;
# Line 191 | Line 229 | char  **argv;
229                  quit(1);
230          }
231                                          /* get header */
232 <        getheader(fin, headline);
232 >        getheader(fin, headline, NULL);
233 >        if (wrongformat) {
234 >                fprintf(stderr, "%s: input must be a Radiance picture\n",
235 >                                progname);
236 >                quit(1);
237 >        }
238                                          /* add new header info. */
239          printargs(i, argv, stdout);
240                                          /* get picture size */
# Line 237 | Line 280 | char  **argv;
280   headline(s)                             /* process line from header */
281   char  *s;
282   {
283 +        char  fmt[32];
284 +
285          fputs(s, stdout);               /* copy to output */
286          if (isaspect(s))                /* get aspect ratio */
287                  inpaspect *= aspectval(s);
288 +        else if (isformat(s)) {
289 +                formatval(fmt, s);
290 +                wrongformat = strcmp(fmt, COLRFMT);
291 +        }
292   }
293  
294  
# Line 281 | Line 330 | FILE  *in;
330                          fprintf(stderr, "%s: warning - partial frame (%d%%)\n",
331                                          progname, 100*i/yres);
332                          yres = i;
333 +                        y_r = (double)nrows/yres;
334                          break;
335                  }
336                  pass1scan(scan, i);
# Line 337 | Line 387 | FILE  *in;
387  
388   scan2init()                     /* prepare scanline arrays */
389   {
390 +        COLOR   ctmp;
391          double  d;
392          register int  i;
393  
# Line 352 | Line 403 | scan2init()                    /* prepare scanline arrays */
403  
404                  initmask();             /* initialize filter table */
405          }
406 <        barsize = 2 * yrad;
406 >        barsize = 2*yrad + 1;
407          scanin = (COLOR **)malloc(barsize*sizeof(COLOR *));
408          for (i = 0; i < barsize; i++) {
409                  scanin[i] = (COLOR *)malloc(xres*sizeof(COLOR));
# Line 366 | Line 417 | scan2init()                    /* prepare scanline arrays */
417                  fprintf(stderr, "%s: out of memory\n", progname);
418                  quit(1);
419          }
420 <                                        /* record pixel aspect and exposure */
421 <        d = x_c / y_r;
422 <        if (d < .99 || d > 1.01)
423 <                fputaspect(d, stdout);
420 >                                        /* record pixel aspect ratio */
421 >        if (!correctaspect) {
422 >                d = x_c / y_r;
423 >                if (!FEQ(d,1.0))
424 >                        fputaspect(d, stdout);
425 >        }
426 >                                        /* record exposure */
427          d = bright(exposure);
428 <        if (d < .995 || d > 1.005)
428 >        if (!FEQ(d,1.0))
429                  fputexpos(d, stdout);
430 +                                        /* record color correction */
431 +        copycolor(ctmp, exposure);
432 +        scalecolor(ctmp, 1.0/d);
433 +        if (!FEQ(colval(ctmp,RED),colval(ctmp,GRN)) ||
434 +                        !FEQ(colval(ctmp,GRN),colval(ctmp,BLU)))
435 +                fputcolcor(ctmp, stdout);
436          printf("\n");
437 <        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout); /* resolution */
437 >                                        /* write out resolution */
438 >        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout);
439   }
440  
441  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines