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

Comparing ray/src/util/glareval.c (file contents):
Revision 1.10 by greg, Fri Apr 5 14:41:55 1991 UTC vs.
Revision 1.18 by greg, Wed Jun 26 13:35:16 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #define vfork           fork
21   #endif
22  
23 < #define MAXSBUF         1023980 /* maximum total size of scanline buffer */
23 > #define MAXSBUF         786432  /* maximum total size of scanline buffer */
24   #define HSIZE           317     /* size of scanline hash table */
25   #define NRETIRE         16      /* number of scanlines to retire at once */
26  
# Line 49 | Line 49 | static SCAN    *hashtab[HSIZE];        /* scanline hash table */
49  
50   static long     ncall = 0L;     /* number of calls to getpictscan */
51   static long     nread = 0L;     /* number of scanlines read */
52 + static long     nrecl = 0L;     /* number of scanlines reclaimed */
53  
54 + static int      wrongformat = 0;
55 +
56   SCAN    *scanretire();
57  
58   extern long     ftell();
# Line 75 | Line 78 | int    y;
78                          if (sl->y == y) {               /* reclaim */
79                                  sl->next = hashtab[hi];
80                                  hashtab[hi] = sl;
81 +                                nrecl++;
82                          }
83                          return(sl);
84                  }
# Line 138 | Line 142 | pict_stats()                   /* print out picture read statistics */
142   {
143          static long     lastcall = 0L;  /* ncall at last report */
144          static long     lastread = 0L;  /* nread at last report */
145 +        static long     lastrecl = 0L;  /* nrecl at last report */
146  
147          if (ncall == lastcall)
148                  return;
149 <        fprintf(stderr, "%s: %ld scanlines read in %ld calls\n",
150 <                        progname, nread-lastread, ncall-lastcall);
149 >        fprintf(stderr, "%s: %ld scanlines read (%ld reclaimed) in %ld calls\n",
150 >                progname, nread-lastread, nrecl-lastrecl, ncall-lastcall);
151          lastcall = ncall;
152          lastread = nread;
153 +        lastrecl = nrecl;
154   }
155   #endif
156  
# Line 215 | Line 221 | float  *vb;
221   #endif
222          n = 0;
223          for (vh = -hsize; vh <= hsize; vh++) {
224 <                if (compdir(dir, vh, vv) < 0) { /* off viewable region */
224 >                if (compdir(dir, vh, vv) < 0) {         /* not in view */
225                          vb[vh+hsize] = -1.0;
226                          continue;
227                  }
# Line 281 | Line 287 | int    np;
287   getexpos(s)                     /* get exposure from header line */
288   char    *s;
289   {
290 +        char    fmt[32];
291 +
292          if (isexpos(s))
293                  exposure *= exposval(s);
294 +        else if (isformat(s)) {
295 +                formatval(fmt, s);
296 +                wrongformat = strcmp(fmt, COLRFMT);
297 +        }
298   }
299  
300  
301   open_pict(fn)                   /* open picture file */
302   char    *fn;
303   {
292        register int    i;
293
304          if ((pictfp = fopen(fn, "r")) == NULL) {
305                  fprintf("%s: cannot open\n", fn);
306                  exit(1);
307          }
308          exposure = 1.0;
309 <        getheader(pictfp, getexpos);
310 <        if (fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) {
311 <                fprintf("%s: bad picture resolution\n", fn);
309 >        getheader(pictfp, getexpos, NULL);
310 >        if (wrongformat ||
311 >                        fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) {
312 >                fprintf("%s: bad picture format\n", fn);
313                  exit(1);
314          }
315          initscans();
# Line 307 | Line 318 | char   *fn;
318  
319   close_pict()                    /* done with picture */
320   {
310        register int    i;
311
321          if (pictfp == NULL)
322                  return;
323          fclose(pictfp);
# Line 333 | Line 342 | char   *av[];
342                          dup2(p0[0], 0);
343                          close(p0[0]);
344                  }
345 <                if (p1[1] != 0) {       /* connect p1 to stdout */
345 >                if (p1[1] != 1) {       /* connect p1 to stdout */
346                          dup2(p1[1], 1);
347                          close(p1[1]);
348                  }
# Line 468 | Line 477 | initscans()                            /* initialize scanline buffers */
477                                          /* allocate scanline buffers */
478          scansize = sizeof(SCAN) + pxsiz*sizeof(COLR);
479   #ifdef ALIGN
480 <        scansize = scansize+(sizeof(ALIGN)-1)) & ~(sizeof(ALIGN)-1);
480 >        scansize = scansize+(sizeof(ALIGN)-1) & ~(sizeof(ALIGN)-1);
481   #endif
482          i = MAXSBUF / scansize;         /* compute number to allocate */
483          if (i > HSIZE)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines