| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
+ |
#include <stdlib.h> |
| 11 |
|
#include <string.h> |
| 12 |
|
|
| 13 |
+ |
#include "platform.h" |
| 14 |
|
#include "rtprocess.h" /* Windows: must come first because of conflicts */ |
| 15 |
|
#include "glare.h" |
| 16 |
|
|
| 53 |
|
|
| 54 |
|
static int wrongformat = 0; |
| 55 |
|
|
| 56 |
< |
SCAN *scanretire(); |
| 56 |
> |
static SCAN * claimscan(int y); |
| 57 |
> |
static COLR * getpictscan(int y); |
| 58 |
> |
static double pict_val(FVECT vd); |
| 59 |
> |
static void rt_compute(float *pb, int np); |
| 60 |
> |
static gethfunc getexpos; |
| 61 |
> |
static SCAN * scanretire(void); |
| 62 |
> |
static void initscans(void); |
| 63 |
> |
static void donescans(void); |
| 64 |
|
|
| 56 |
– |
extern long ftell(); |
| 65 |
|
|
| 66 |
< |
|
| 67 |
< |
SCAN * |
| 68 |
< |
claimscan(y) /* claim scanline from buffers */ |
| 69 |
< |
int y; |
| 66 |
> |
static SCAN * |
| 67 |
> |
claimscan( /* claim scanline from buffers */ |
| 68 |
> |
int y |
| 69 |
> |
) |
| 70 |
|
{ |
| 71 |
|
int hi = shash(y); |
| 72 |
|
SCAN *slast; |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
|
| 95 |
< |
COLR * |
| 96 |
< |
getpictscan(y) /* get picture scanline */ |
| 97 |
< |
int y; |
| 95 |
> |
static COLR * |
| 96 |
> |
getpictscan( /* get picture scanline */ |
| 97 |
> |
int y |
| 98 |
> |
) |
| 99 |
|
{ |
| 100 |
|
register SCAN *sl; |
| 101 |
|
register int i; |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
#ifdef DEBUG |
| 148 |
< |
pict_stats() /* print out picture read statistics */ |
| 148 |
> |
void |
| 149 |
> |
pict_stats(void) /* print out picture read statistics */ |
| 150 |
|
{ |
| 151 |
|
static long lastcall = 0L; /* ncall at last report */ |
| 152 |
|
static long lastread = 0L; /* nread at last report */ |
| 163 |
|
#endif |
| 164 |
|
|
| 165 |
|
|
| 166 |
< |
double |
| 167 |
< |
pict_val(vd) /* find picture value for view direction */ |
| 168 |
< |
FVECT vd; |
| 166 |
> |
static double |
| 167 |
> |
pict_val( /* find picture value for view direction */ |
| 168 |
> |
FVECT vd |
| 169 |
> |
) |
| 170 |
|
{ |
| 171 |
|
FVECT pp; |
| 172 |
|
FVECT ip; |
| 177 |
|
pp[0] = pictview.vp[0] + vd[0]; |
| 178 |
|
pp[1] = pictview.vp[1] + vd[1]; |
| 179 |
|
pp[2] = pictview.vp[2] + vd[2]; |
| 180 |
< |
viewloc(ip, &pictview, pp); |
| 170 |
< |
if (ip[2] <= FTINY || ip[0] < 0. || ip[0] >= 1. || |
| 171 |
< |
ip[1] < 0. || ip[1] >= 1.) |
| 180 |
> |
if (viewloc(ip, &pictview, pp) != 1) |
| 181 |
|
return(-1.0); |
| 182 |
|
colr_color(res, getpictscan((int)(ip[1]*pysiz))[(int)(ip[0]*pxsiz)]); |
| 183 |
|
return(luminance(res)/exposure); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
|
|
| 187 |
< |
double |
| 188 |
< |
getviewpix(vh, vv) /* compute single view pixel */ |
| 189 |
< |
int vh, vv; |
| 187 |
> |
extern double |
| 188 |
> |
getviewpix( /* compute single view pixel */ |
| 189 |
> |
int vh, |
| 190 |
> |
int vv |
| 191 |
> |
) |
| 192 |
|
{ |
| 193 |
|
FVECT dir; |
| 194 |
|
float rt_buf[12]; |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
|
| 217 |
< |
getviewspan(vv, vb) /* compute a span of view pixels */ |
| 218 |
< |
int vv; |
| 219 |
< |
float *vb; |
| 217 |
> |
extern void |
| 218 |
> |
getviewspan( /* compute a span of view pixels */ |
| 219 |
> |
int vv, |
| 220 |
> |
float *vb |
| 221 |
> |
) |
| 222 |
|
{ |
| 223 |
|
float rt_buf[6*MAXPIX]; /* rtrace send/receive buffer */ |
| 224 |
|
register int n; /* number of pixels in buffer */ |
| 247 |
|
/* send to rtrace */ |
| 248 |
|
if (n >= maxpix) { /* flush */ |
| 249 |
|
rt_compute(rt_buf, n); |
| 250 |
< |
while (n-- > 0) |
| 250 |
> |
while (n > 0) { |
| 251 |
> |
--n; |
| 252 |
|
vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n); |
| 253 |
+ |
} |
| 254 |
|
} |
| 255 |
|
rt_buf[6*n] = ourview.vp[0]; |
| 256 |
|
rt_buf[6*n+1] = ourview.vp[1]; |
| 272 |
|
} |
| 273 |
|
|
| 274 |
|
|
| 275 |
< |
rt_compute(pb, np) /* process buffer through rtrace */ |
| 276 |
< |
float *pb; |
| 277 |
< |
int np; |
| 275 |
> |
static void |
| 276 |
> |
rt_compute( /* process buffer through rtrace */ |
| 277 |
> |
float *pb, |
| 278 |
> |
int np |
| 279 |
> |
) |
| 280 |
|
{ |
| 281 |
|
#ifdef DEBUG |
| 282 |
|
if (verbose && np > 1) |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
|
| 296 |
< |
int |
| 297 |
< |
getexpos(s) /* get exposure from header line */ |
| 298 |
< |
char *s; |
| 296 |
> |
static int |
| 297 |
> |
getexpos( /* get exposure from header line */ |
| 298 |
> |
char *s, |
| 299 |
> |
void *p |
| 300 |
> |
) |
| 301 |
|
{ |
| 302 |
< |
char fmt[32]; |
| 302 |
> |
char fmt[MAXFMTLEN]; |
| 303 |
|
|
| 304 |
|
if (isexpos(s)) |
| 305 |
|
exposure *= exposval(s); |
| 311 |
|
} |
| 312 |
|
|
| 313 |
|
|
| 314 |
< |
open_pict(fn) /* open picture file */ |
| 315 |
< |
char *fn; |
| 314 |
> |
extern void |
| 315 |
> |
open_pict( /* open picture file */ |
| 316 |
> |
char *fn |
| 317 |
> |
) |
| 318 |
|
{ |
| 319 |
|
if ((pictfp = fopen(fn, "r")) == NULL) { |
| 320 |
|
fprintf(stderr, "%s: cannot open\n", fn); |
| 321 |
|
exit(1); |
| 322 |
|
} |
| 323 |
+ |
SET_FILE_BINARY(pictfp); |
| 324 |
|
exposure = 1.0; |
| 325 |
|
getheader(pictfp, getexpos, NULL); |
| 326 |
|
if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) { |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
|
| 334 |
< |
close_pict() /* done with picture */ |
| 334 |
> |
extern void |
| 335 |
> |
close_pict(void) /* done with picture */ |
| 336 |
|
{ |
| 337 |
|
if (pictfp == NULL) |
| 338 |
|
return; |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
|
| 345 |
< |
fork_rtrace(av) /* open pipe and start rtrace */ |
| 346 |
< |
char *av[]; |
| 345 |
> |
extern void |
| 346 |
> |
fork_rtrace( /* open pipe and start rtrace */ |
| 347 |
> |
char *av[] |
| 348 |
> |
) |
| 349 |
|
{ |
| 350 |
|
int rval; |
| 351 |
|
|
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
|
| 368 |
< |
done_rtrace() /* wait for rtrace to finish */ |
| 368 |
> |
extern void |
| 369 |
> |
done_rtrace(void) /* wait for rtrace to finish */ |
| 370 |
|
{ |
| 371 |
|
int status; |
| 372 |
|
|
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
|
| 383 |
< |
SCAN * |
| 384 |
< |
scanretire() /* retire old scanlines to free list */ |
| 383 |
> |
static SCAN * |
| 384 |
> |
scanretire(void) /* retire old scanlines to free list */ |
| 385 |
|
{ |
| 386 |
|
SCAN *sold[NRETIRE]; |
| 387 |
|
int n; |
| 424 |
|
static char *scan_buf; |
| 425 |
|
|
| 426 |
|
|
| 427 |
< |
initscans() /* initialize scanline buffers */ |
| 427 |
> |
static void |
| 428 |
> |
initscans(void) /* initialize scanline buffers */ |
| 429 |
|
{ |
| 430 |
|
int scansize; |
| 431 |
|
register SCAN *ptr; |
| 464 |
|
} |
| 465 |
|
|
| 466 |
|
|
| 467 |
< |
donescans() /* free up scanlines */ |
| 467 |
> |
static void |
| 468 |
> |
donescans(void) /* free up scanlines */ |
| 469 |
|
{ |
| 470 |
|
bfree(scan_buf, scanbufsiz); |
| 471 |
|
bfree((char *)scanpos, pysiz*sizeof(long)); |