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; |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
< |
double |
190 |
< |
getviewpix(vh, vv) /* compute single view pixel */ |
191 |
< |
int vh, vv; |
189 |
> |
extern double |
190 |
> |
getviewpix( /* compute single view pixel */ |
191 |
> |
int vh, |
192 |
> |
int vv |
193 |
> |
) |
194 |
|
{ |
195 |
|
FVECT dir; |
196 |
|
float rt_buf[12]; |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
< |
getviewspan(vv, vb) /* compute a span of view pixels */ |
220 |
< |
int vv; |
221 |
< |
float *vb; |
219 |
> |
extern void |
220 |
> |
getviewspan( /* compute a span of view pixels */ |
221 |
> |
int vv, |
222 |
> |
float *vb |
223 |
> |
) |
224 |
|
{ |
225 |
|
float rt_buf[6*MAXPIX]; /* rtrace send/receive buffer */ |
226 |
|
register int n; /* number of pixels in buffer */ |
249 |
|
/* send to rtrace */ |
250 |
|
if (n >= maxpix) { /* flush */ |
251 |
|
rt_compute(rt_buf, n); |
252 |
< |
while (n-- > 0) |
252 |
> |
while (n > 0) { |
253 |
> |
--n; |
254 |
|
vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n); |
255 |
+ |
} |
256 |
|
} |
257 |
|
rt_buf[6*n] = ourview.vp[0]; |
258 |
|
rt_buf[6*n+1] = ourview.vp[1]; |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
< |
rt_compute(pb, np) /* process buffer through rtrace */ |
278 |
< |
float *pb; |
279 |
< |
int np; |
277 |
> |
static void |
278 |
> |
rt_compute( /* process buffer through rtrace */ |
279 |
> |
float *pb, |
280 |
> |
int np |
281 |
> |
) |
282 |
|
{ |
283 |
|
#ifdef DEBUG |
284 |
|
if (verbose && np > 1) |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
< |
int |
299 |
< |
getexpos(s) /* get exposure from header line */ |
300 |
< |
char *s; |
298 |
> |
static int |
299 |
> |
getexpos( /* get exposure from header line */ |
300 |
> |
char *s, |
301 |
> |
void *p |
302 |
> |
) |
303 |
|
{ |
304 |
|
char fmt[32]; |
305 |
|
|
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
< |
open_pict(fn) /* open picture file */ |
317 |
< |
char *fn; |
316 |
> |
extern void |
317 |
> |
open_pict( /* open picture file */ |
318 |
> |
char *fn |
319 |
> |
) |
320 |
|
{ |
321 |
|
if ((pictfp = fopen(fn, "r")) == NULL) { |
322 |
|
fprintf(stderr, "%s: cannot open\n", fn); |
323 |
|
exit(1); |
324 |
|
} |
325 |
+ |
SET_FILE_BINARY(pictfp); |
326 |
|
exposure = 1.0; |
327 |
|
getheader(pictfp, getexpos, NULL); |
328 |
|
if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) { |
333 |
|
} |
334 |
|
|
335 |
|
|
336 |
< |
close_pict() /* done with picture */ |
336 |
> |
extern void |
337 |
> |
close_pict(void) /* done with picture */ |
338 |
|
{ |
339 |
|
if (pictfp == NULL) |
340 |
|
return; |
344 |
|
} |
345 |
|
|
346 |
|
|
347 |
< |
fork_rtrace(av) /* open pipe and start rtrace */ |
348 |
< |
char *av[]; |
347 |
> |
extern void |
348 |
> |
fork_rtrace( /* open pipe and start rtrace */ |
349 |
> |
char *av[] |
350 |
> |
) |
351 |
|
{ |
352 |
|
int rval; |
353 |
|
|
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
< |
done_rtrace() /* wait for rtrace to finish */ |
370 |
> |
extern void |
371 |
> |
done_rtrace(void) /* wait for rtrace to finish */ |
372 |
|
{ |
373 |
|
int status; |
374 |
|
|
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
< |
SCAN * |
386 |
< |
scanretire() /* retire old scanlines to free list */ |
385 |
> |
static SCAN * |
386 |
> |
scanretire(void) /* retire old scanlines to free list */ |
387 |
|
{ |
388 |
|
SCAN *sold[NRETIRE]; |
389 |
|
int n; |
426 |
|
static char *scan_buf; |
427 |
|
|
428 |
|
|
429 |
< |
initscans() /* initialize scanline buffers */ |
429 |
> |
static void |
430 |
> |
initscans(void) /* initialize scanline buffers */ |
431 |
|
{ |
432 |
|
int scansize; |
433 |
|
register SCAN *ptr; |
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
< |
donescans() /* free up scanlines */ |
469 |
> |
static void |
470 |
> |
donescans(void) /* free up scanlines */ |
471 |
|
{ |
472 |
|
bfree(scan_buf, scanbufsiz); |
473 |
|
bfree((char *)scanpos, pysiz*sizeof(long)); |