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.16 by greg, Thu Apr 18 14:35:21 1991 UTC vs.
Revision 2.7 by greg, Thu Nov 12 09:05:17 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     9/26/85
11   */
12  
13 < #include  <stdio.h>
13 > #include  "standard.h"
14  
15   #include  <signal.h>
16  
17   #include  "color.h"
18  
19 < extern char  *malloc();
19 > #include  "resolu.h"
20 >
21 > #include  "paths.h"
22 >
23   extern float  *matchlamp();
24  
25 < #define  FEQ(a,b)       ((a) >= .98*(b) && (a) <= 1.02*(b))
25 > #define  FEQ(a,b)       ((a) >= .98*(b) && (a) <= 1.02*(b))
26  
27 < #define  CHECKRAD       1.5     /* radius to check for filtering */
27 > #define  CHECKRAD       1.5     /* radius to check for filtering */
28  
29   COLOR  exposure = WHTCOLOR;     /* exposure for the frame */
30  
31 < double  rad = 0.0;              /* output pixel radius for filtering */
31 > double  rad = 0.0;              /* output pixel radius for filtering */
32  
33   int  nrows = 0;                 /* number of rows for output */
34   int  ncols = 0;                 /* number of columns for output */
35  
36 < double  x_c = 1.0;              /* ratio of output x size to input */
37 < double  y_r = 1.0;              /* ratio of output y size to input */
36 > double  x_c = 1.0;              /* ratio of output x size to input */
37 > double  y_r = 1.0;              /* ratio of output y size to input */
38  
39   int  singlepass = 0;            /* true means skip first pass */
40  
41   int  avghot = 0;                /* true means average in bright spots */
42  
43 < double  hotlvl = 1000.0;        /* level considered "hot" */
43 > double  hotlvl = 1000.0;        /* level considered "hot" */
44  
45   int  npts = 0;                  /* (half) number of points for stars */
46  
47 < double  spread = 1e-4;          /* spread for star points */
47 > double  spread = 1e-4;          /* spread for star points */
48  
46 #define  TEMPLATE       "/usr/tmp/pfXXXXXX"
47
49   char  *tfname = NULL;
50  
51   char  *lampdat = "lamp.tab";    /* lamp data file */
52  
53 + int  order;                     /* scanline ordering of input */
54   int  xres, yres;                /* resolution of input */
55 < double  inpaspect = 1.0;        /* pixel aspect ratio of input */
55 > double  inpaspect = 1.0;        /* pixel aspect ratio of input */
56   int  correctaspect = 0;         /* aspect ratio correction? */
57  
58   int  wrongformat = 0;
# Line 69 | Line 71 | main(argc, argv)
71   int  argc;
72   char  **argv;
73   {
72        extern char  *mktemp();
73        extern double  atof(), pow();
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;
82 <        int  i;
83 <
80 >        double  outaspect = 0.0;
81 >        double  d;
82 >        int  i, j;
83 > #ifdef MSDOS
84 >        extern int  _fmode;
85 >        _fmode = O_BINARY;
86 >        setmode(fileno(stdin), O_BINARY);
87 >        setmode(fileno(stdout), O_BINARY);
88 > #endif
89          if (signal(SIGINT, quit) == SIG_IGN)
90                  signal(SIGINT, SIG_IGN);
91          if (signal(SIGHUP, quit) == SIG_IGN)
92                  signal(SIGINT, SIG_IGN);
93          signal(SIGTERM, quit);
94          signal(SIGPIPE, quit);
95 < #ifdef  SIGXCPU
95 > #ifdef  SIGXCPU
96          signal(SIGXCPU, quit);
97          signal(SIGXFSZ, quit);
98   #endif
99  
100 <        progname = argv[0];
100 >        progname = argv[0] = fixargv0(argv[0]);
101  
102          for (i = 1; i < argc; i++)
103                  if (argv[i][0] == '-')
# Line 196 | Line 201 | char  **argv;
201                          fprintf(stderr, "%s: unknown lamp type\n", lamptype);
202                          quit(1);
203                  }
204 <                colval(exposure,RED) /= lampcolor[0];
205 <                colval(exposure,GRN) /= lampcolor[1];
206 <                colval(exposure,BLU) /= lampcolor[2];
204 >                for (i = 0; i < 3; i++)
205 >                        if (lampcolor[i] > 1e-4)
206 >                                colval(exposure,i) /= lampcolor[i];
207                  freelamps();
208          }
209                                          /* open input file */
# Line 238 | Line 243 | char  **argv;
243                                          /* add new header info. */
244          printargs(i, argv, stdout);
245                                          /* get picture size */
246 <        if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
246 >        if ((order = fgetresolu(&xres, &yres, fin)) < 0) {
247                  fprintf(stderr, "%s: bad picture size\n", progname);
248                  quit(1);
249          }
250 +        if (!(order & YMAJOR))
251 +                inpaspect = 1.0/inpaspect;
252                                          /* compute output resolution */
253          if (ncols <= 0)
254                  ncols = x_c*xres + .5;
# Line 322 | Line 329 | FILE  *in;
329          }
330          for (i = 0; i < yres; i++) {
331                  if (freadscan(scan, xres, in) < 0) {
332 <                        nrows = nrows * i / yres;       /* adjust frame */
332 >                        nrows = (long)nrows * i / yres; /* adjust frame */
333                          if (nrows <= 0) {
334                                  fprintf(stderr, "%s: empty frame\n", progname);
335                                  quit(1);
336                          }
337                          fprintf(stderr, "%s: warning - partial frame (%d%%)\n",
338 <                                        progname, 100*i/yres);
338 >                                        progname, (int)(100L*i/yres));
339                          yres = i;
340                          y_r = (double)nrows/yres;
341                          break;
# Line 345 | Line 352 | FILE  *in;
352          int  yread;
353          int  ycent, xcent;
354          int  r, c;
355 <        
355 >        
356          pass2init();
357          scan2init();
358          yread = 0;
# Line 388 | Line 395 | FILE  *in;
395   scan2init()                     /* prepare scanline arrays */
396   {
397          COLOR   ctmp;
398 <        double  d;
398 >        double  d;
399          register int  i;
400  
401          if (rad <= 0.0) {
# Line 403 | Line 410 | scan2init()                    /* prepare scanline arrays */
410  
411                  initmask();             /* initialize filter table */
412          }
413 <        barsize = 2 * yrad;
413 >        barsize = 2*yrad + 1;
414          scanin = (COLOR **)malloc(barsize*sizeof(COLOR *));
415          for (i = 0; i < barsize; i++) {
416                  scanin[i] = (COLOR *)malloc(xres*sizeof(COLOR));
# Line 419 | Line 426 | scan2init()                    /* prepare scanline arrays */
426          }
427                                          /* record pixel aspect ratio */
428          if (!correctaspect) {
429 <                d = x_c / y_r;
429 >                d = order & YMAJOR ? x_c/y_r : y_r/x_c ;
430                  if (!FEQ(d,1.0))
431                          fputaspect(d, stdout);
432          }
# Line 435 | Line 442 | scan2init()                    /* prepare scanline arrays */
442                  fputcolcor(ctmp, stdout);
443          printf("\n");
444                                          /* write out resolution */
445 <        fputresolu(YMAJOR|YDECR, ncols, nrows, stdout);
445 >        fputresolu(order, ncols, nrows, stdout);
446   }
447  
448  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines