--- ray/src/util/glareval.c 1991/04/05 14:41:55 1.10 +++ ray/src/util/glareval.c 1991/04/19 17:41:06 1.14 @@ -20,7 +20,7 @@ static char SCCSid[] = "$SunId$ LBL"; #define vfork fork #endif -#define MAXSBUF 1023980 /* maximum total size of scanline buffer */ +#define MAXSBUF 524268 /* maximum total size of scanline buffer */ #define HSIZE 317 /* size of scanline hash table */ #define NRETIRE 16 /* number of scanlines to retire at once */ @@ -50,6 +50,8 @@ static SCAN *hashtab[HSIZE]; /* scanline hash table */ static long ncall = 0L; /* number of calls to getpictscan */ static long nread = 0L; /* number of scanlines read */ +static int wrongformat = 0; + SCAN *scanretire(); extern long ftell(); @@ -75,6 +77,12 @@ int y; if (sl->y == y) { /* reclaim */ sl->next = hashtab[hi]; hashtab[hi] = sl; +#ifdef DEBUG + if (verbose) + fprintf(stderr, + "%s: scanline %d reclaimed\n", + progname, y); +#endif } return(sl); } @@ -215,7 +223,7 @@ float *vb; #endif n = 0; for (vh = -hsize; vh <= hsize; vh++) { - if (compdir(dir, vh, vv) < 0) { /* off viewable region */ + if (compdir(dir, vh, vv) < 0) { /* not in view */ vb[vh+hsize] = -1.0; continue; } @@ -281,24 +289,29 @@ int np; getexpos(s) /* get exposure from header line */ char *s; { + char fmt[32]; + if (isexpos(s)) exposure *= exposval(s); + else if (isformat(s)) { + formatval(fmt, s); + wrongformat = strcmp(fmt, COLRFMT); + } } open_pict(fn) /* open picture file */ char *fn; { - register int i; - if ((pictfp = fopen(fn, "r")) == NULL) { fprintf("%s: cannot open\n", fn); exit(1); } exposure = 1.0; - getheader(pictfp, getexpos); - if (fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) { - fprintf("%s: bad picture resolution\n", fn); + getheader(pictfp, getexpos, NULL); + if (wrongformat || + fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) { + fprintf("%s: bad picture format\n", fn); exit(1); } initscans(); @@ -307,8 +320,6 @@ char *fn; close_pict() /* done with picture */ { - register int i; - if (pictfp == NULL) return; fclose(pictfp);