9 |
|
*/ |
10 |
|
|
11 |
|
#include "glare.h" |
12 |
+ |
#include "resolu.h" |
13 |
|
/* maximum rtrace buffer size */ |
14 |
|
#define MAXPIX (4096/(6*sizeof(float))) |
15 |
|
|
41 |
|
static SCAN *freelist; /* scanline free list */ |
42 |
|
static SCAN *hashtab[HSIZE]; /* scanline hash table */ |
43 |
|
|
44 |
+ |
static long scanbufsiz; /* size of allocated scanline buffer */ |
45 |
+ |
|
46 |
|
static long ncall = 0L; /* number of calls to getpictscan */ |
47 |
|
static long nread = 0L; /* number of scanlines read */ |
48 |
|
static long nrecl = 0L; /* number of scanlines reclaimed */ |
156 |
|
FVECT vd; |
157 |
|
{ |
158 |
|
FVECT pp; |
159 |
< |
double vpx, vpy, vpz; |
159 |
> |
FVECT ip; |
160 |
|
COLOR res; |
161 |
|
|
162 |
|
if (pictfp == NULL) |
164 |
|
pp[0] = pictview.vp[0] + vd[0]; |
165 |
|
pp[1] = pictview.vp[1] + vd[1]; |
166 |
|
pp[2] = pictview.vp[2] + vd[2]; |
167 |
< |
viewpixel(&vpx, &vpy, &vpz, &pictview, pp); |
168 |
< |
if (vpz <= FTINY || vpx < 0. || vpx >= 1. || vpy < 0. || vpy >= 1.) |
167 |
> |
viewloc(ip, &pictview, pp); |
168 |
> |
if (ip[2] <= FTINY || ip[0] < 0. || ip[0] >= 1. || |
169 |
> |
ip[1] < 0. || ip[1] >= 1.) |
170 |
|
return(-1.0); |
171 |
< |
colr_color(res, getpictscan((int)(vpy*pysiz))[(int)(vpx*pxsiz)]); |
171 |
> |
colr_color(res, getpictscan((int)(ip[1]*pysiz))[(int)(ip[0]*pxsiz)]); |
172 |
|
return(luminance(res)/exposure); |
173 |
|
} |
174 |
|
|
297 |
|
} |
298 |
|
exposure = 1.0; |
299 |
|
getheader(pictfp, getexpos, NULL); |
300 |
< |
if (wrongformat || |
301 |
< |
fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) { |
298 |
< |
fprintf("%s: bad picture format\n", fn); |
300 |
> |
if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) { |
301 |
> |
fprintf(stderr, "%s: incompatible picture format\n", fn); |
302 |
|
exit(1); |
303 |
|
} |
304 |
|
initscans(); |
400 |
|
register SCAN *ptr; |
401 |
|
register int i; |
402 |
|
/* initialize positions */ |
403 |
< |
scanpos = (long *)malloc(pysiz*sizeof(long)); |
403 |
> |
scanpos = (long *)bmalloc(pysiz*sizeof(long)); |
404 |
|
if (scanpos == NULL) |
405 |
|
memerr("scanline positions"); |
406 |
|
for (i = pysiz-1; i >= 0; i--) |
417 |
|
i = MAXSBUF / scansize; /* compute number to allocate */ |
418 |
|
if (i > HSIZE) |
419 |
|
i = HSIZE; |
420 |
< |
scan_buf = malloc(i*scansize); /* get in one big chunk */ |
420 |
> |
scanbufsiz = i*scansize; |
421 |
> |
scan_buf = bmalloc(scanbufsiz); /* get in one big chunk */ |
422 |
|
if (scan_buf == NULL) |
423 |
|
memerr("scanline buffers"); |
424 |
|
ptr = (SCAN *)scan_buf; |
435 |
|
|
436 |
|
donescans() /* free up scanlines */ |
437 |
|
{ |
438 |
< |
free(scan_buf); |
439 |
< |
free((char *)scanpos); |
438 |
> |
bfree(scan_buf, scanbufsiz); |
439 |
> |
bfree((char *)scanpos, pysiz*sizeof(long)); |
440 |
|
} |