16 |
|
#include "platform.h" |
17 |
|
#include "ranimove.h" |
18 |
|
#include "otypes.h" |
19 |
+ |
#include "source.h" |
20 |
|
#include "random.h" |
21 |
|
|
22 |
|
double acctab[256]; /* accuracy value table */ |
47 |
|
double hlsmax; /* maximum high-level saliency this frame */ |
48 |
|
|
49 |
|
|
50 |
< |
void |
51 |
< |
write_map(mp, fn) /* write out float map (debugging) */ |
52 |
< |
float *mp; |
53 |
< |
char *fn; |
50 |
> |
static void next_frame(void); |
51 |
> |
static int sample_here(int x, int y); |
52 |
> |
static int offset_cmp(const void *p1, const void *p2); |
53 |
> |
static void setmotion(int n, FVECT wpos); |
54 |
> |
static void init_frame_sample(void); |
55 |
> |
|
56 |
> |
|
57 |
> |
extern void |
58 |
> |
write_map( /* write out float map (debugging) */ |
59 |
> |
float *mp, |
60 |
> |
char *fn |
61 |
> |
) |
62 |
|
{ |
63 |
|
FILE *fp = fopen(fn, "w"); |
64 |
|
COLOR scanbuf[2048]; |
82 |
|
|
83 |
|
|
84 |
|
static void |
85 |
< |
next_frame() /* prepare next frame buffer */ |
85 |
> |
next_frame(void) /* prepare next frame buffer */ |
86 |
|
{ |
87 |
|
VIEW *fv; |
88 |
|
char *err; |
164 |
|
|
165 |
|
|
166 |
|
static int |
167 |
< |
sample_here(x, y) /* 4x4 quincunx sample at this pixel? */ |
168 |
< |
register int x, y; |
167 |
> |
sample_here( /* 4x4 quincunx sample at this pixel? */ |
168 |
> |
register int x, |
169 |
> |
register int y |
170 |
> |
) |
171 |
|
{ |
172 |
|
if (y & 0x1) /* every other row has samples */ |
173 |
|
return(0); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
< |
void |
181 |
< |
sample_pos(hv, x, y, sn) /* compute jittered sample position */ |
182 |
< |
double hv[2]; |
183 |
< |
int x, y; |
184 |
< |
int sn; |
180 |
> |
extern void |
181 |
> |
sample_pos( /* compute jittered sample position */ |
182 |
> |
double hv[2], |
183 |
> |
int x, |
184 |
> |
int y, |
185 |
> |
int sn |
186 |
> |
) |
187 |
|
{ |
188 |
|
int hl[2]; |
189 |
|
|
194 |
|
} |
195 |
|
|
196 |
|
|
197 |
< |
double |
198 |
< |
sample_wt(xo, yo) /* compute interpolant sample weight */ |
199 |
< |
int xo, yo; |
197 |
> |
extern double |
198 |
> |
sample_wt( /* compute interpolant sample weight */ |
199 |
> |
int xo, |
200 |
> |
int yo |
201 |
> |
) |
202 |
|
{ |
203 |
|
static double etab[400]; |
204 |
|
/* we can't use the name rad2 here, for some reason Visual C |
219 |
|
|
220 |
|
|
221 |
|
static int |
222 |
< |
offset_cmp(p1, p2) /* compare offset distances */ |
223 |
< |
const void *p1, *p2; |
222 |
> |
offset_cmp( /* compare offset distances */ |
223 |
> |
const void *p1, |
224 |
> |
const void *p2 |
225 |
> |
) |
226 |
|
{ |
227 |
|
return(*(const int *)p1 - *(const int *)p2); |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
< |
int |
232 |
< |
getclosest(iarr, nc, x, y) /* get nc closest neighbors on same object */ |
233 |
< |
int *iarr; |
234 |
< |
int nc; |
235 |
< |
int x, y; |
231 |
> |
extern int |
232 |
> |
getclosest( /* get nc closest neighbors on same object */ |
233 |
> |
int *iarr, |
234 |
> |
int nc, |
235 |
> |
int x, |
236 |
> |
int y |
237 |
> |
) |
238 |
|
{ |
239 |
|
#define NSCHECK ((2*SAMPDIST+1)*(2*SAMPDIST+1)) |
240 |
|
static int hro, vro; |
304 |
|
|
305 |
|
|
306 |
|
static void |
307 |
< |
setmotion(n, wpos) /* compute motion vector for this pixel */ |
308 |
< |
register int n; |
309 |
< |
FVECT wpos; |
307 |
> |
setmotion( /* compute motion vector for this pixel */ |
308 |
> |
register int n, |
309 |
> |
FVECT wpos |
310 |
> |
) |
311 |
|
{ |
312 |
|
FVECT ovp; |
293 |
– |
MAT4 xfm; |
294 |
– |
double d; |
313 |
|
int moi; |
314 |
|
int xp, yp; |
315 |
|
/* ID object and update maximum HLS */ |
340 |
|
|
341 |
|
|
342 |
|
static void |
343 |
< |
init_frame_sample() /* sample our initial frame */ |
343 |
> |
init_frame_sample(void) /* sample our initial frame */ |
344 |
|
{ |
345 |
|
RAY ir; |
346 |
|
int x, y; |
367 |
|
continue; |
368 |
|
} |
369 |
|
if (!sample_here(x, y)) { /* just cast */ |
370 |
< |
rayorigin(&ir, NULL, PRIMARY, 1.0); |
370 |
> |
rayorigin(&ir, PRIMARY, NULL, NULL); |
371 |
|
if (!localhit(&ir, &thescene)) { |
372 |
|
if (ir.ro != &Aftplane) |
373 |
|
sourcehit(&ir); |
385 |
|
} |
386 |
|
if (nprocs > 1) { /* get sample */ |
387 |
|
int rval; |
388 |
< |
rayorigin(&ir, NULL, PRIMARY, 1.0); |
388 |
> |
rayorigin(&ir, PRIMARY, NULL, NULL); |
389 |
|
ir.rno = n; |
390 |
|
rval = ray_pqueue(&ir); |
391 |
|
if (!rval) |
442 |
|
} |
443 |
|
|
444 |
|
|
445 |
< |
int |
446 |
< |
getambcolor(clr, obj) /* get ambient color for object if we can */ |
447 |
< |
COLOR clr; |
448 |
< |
int obj; |
445 |
> |
extern int |
446 |
> |
getambcolor( /* get ambient color for object if we can */ |
447 |
> |
COLOR clr, |
448 |
> |
int obj |
449 |
> |
) |
450 |
|
{ |
451 |
|
register OBJREC *op; |
452 |
|
|
513 |
|
} |
514 |
|
|
515 |
|
|
516 |
< |
double |
517 |
< |
estimaterr(cs, cs2, ns, ns0) /* estimate relative error from samples */ |
518 |
< |
COLOR cs, cs2; |
519 |
< |
int ns; |
516 |
> |
extern double |
517 |
> |
estimaterr( /* estimate relative error from samples */ |
518 |
> |
COLOR cs, |
519 |
> |
COLOR cs2, |
520 |
> |
int ns, |
521 |
> |
int ns0 |
522 |
> |
) |
523 |
|
{ |
524 |
|
double d, d2, brt; |
525 |
|
|
539 |
|
} |
540 |
|
|
541 |
|
|
542 |
< |
double |
543 |
< |
comperr(neigh, nc, ns0) /* estimate relative error in neighborhood */ |
544 |
< |
int *neigh; |
545 |
< |
int nc; |
546 |
< |
int ns0; |
542 |
> |
extern double |
543 |
> |
comperr( /* estimate relative error in neighborhood */ |
544 |
> |
int *neigh, |
545 |
> |
int nc, |
546 |
> |
int ns0 |
547 |
> |
) |
548 |
|
{ |
549 |
|
COLOR csum, csum2; |
550 |
|
COLOR ctmp; |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
< |
void |
579 |
< |
comp_frame_error() /* initialize frame error values */ |
578 |
> |
extern void |
579 |
> |
comp_frame_error(void) /* initialize frame error values */ |
580 |
|
{ |
581 |
|
BYTE *edone = NULL; |
582 |
|
COLOR objamb; |
583 |
|
double eest; |
584 |
|
int neigh[NSAMPOK]; |
585 |
|
int nc; |
586 |
< |
int x, y, i, j; |
586 |
> |
int x, y, i; |
587 |
|
register int n; |
588 |
|
|
589 |
|
if (!silent) { |
654 |
|
} |
655 |
|
|
656 |
|
|
657 |
< |
void |
658 |
< |
init_frame() /* render base (low quality) frame */ |
657 |
> |
extern void |
658 |
> |
init_frame(void) /* render base (low quality) frame */ |
659 |
|
{ |
660 |
|
int restart; |
661 |
|
|
717 |
|
} |
718 |
|
|
719 |
|
|
720 |
< |
void |
721 |
< |
filter_frame() /* interpolation, motion-blur, and exposure */ |
720 |
> |
extern void |
721 |
> |
filter_frame(void) /* interpolation, motion-blur, and exposure */ |
722 |
|
{ |
723 |
|
double expval = expspec_val(getexp(fcur)); |
724 |
|
int x, y; |
729 |
|
register int n; |
730 |
|
|
731 |
|
#if 0 |
732 |
< |
/* XXX TEMPORARY!! */ |
733 |
< |
conspicuity(); |
734 |
< |
write_map(cerrmap, "outcmap.pic"); |
735 |
< |
{ |
736 |
< |
float *ebuf = (float *)malloc(sizeof(float)*hres*vres); |
737 |
< |
for (n = hres*vres; n--; ) |
738 |
< |
ebuf[n] = acctab[abuffer[n]]; |
739 |
< |
write_map(ebuf, "outerr.pic"); |
740 |
< |
free((void *)ebuf); |
741 |
< |
} |
732 |
> |
/* XXX TEMPORARY!! */ |
733 |
> |
conspicuity(); |
734 |
> |
write_map(cerrmap, "outcmap.pic"); |
735 |
> |
{ |
736 |
> |
float *ebuf = (float *)malloc(sizeof(float)*hres*vres); |
737 |
> |
for (n = hres*vres; n--; ) |
738 |
> |
ebuf[n] = acctab[abuffer[n]]; |
739 |
> |
write_map(ebuf, "outerr.pic"); |
740 |
> |
free((void *)ebuf); |
741 |
> |
} |
742 |
|
#endif |
743 |
|
|
744 |
|
if (!silent) { |
778 |
|
} |
779 |
|
/* motion blur if requested */ |
780 |
|
if (mblur > .02) { |
758 |
– |
int len; |
781 |
|
int xs, ys, xl, yl; |
782 |
|
int rise, run; |
783 |
|
long rise2, run2; |
815 |
|
while (cnt) |
816 |
|
if (rise2 >= run2) { |
817 |
|
if ((xl >= 0) & (xl < hres) & |
818 |
< |
(yl >= 0) & (yl < vres)) { |
818 |
> |
(yl >= 0) & (yl < vres)) { |
819 |
|
n2 = fndx(xl, yl); |
820 |
|
addcolor(outbuffer[n2], |
821 |
|
cval); |
836 |
|
while (cnt) |
837 |
|
if (run2 >= rise2) { |
838 |
|
if ((xl >= 0) & (xl < hres) & |
839 |
< |
(yl >= 0) & (yl < vres)) { |
839 |
> |
(yl >= 0) & (yl < vres)) { |
840 |
|
n2 = fndx(xl, yl); |
841 |
|
addcolor(outbuffer[n2], |
842 |
|
cval); |
863 |
|
} else |
864 |
|
for (n = hres*vres; n--; ) |
865 |
|
copycolor(outbuffer[n], cbuffer[n]); |
866 |
< |
/* |
867 |
< |
for (n = hres*vres; n--; ) |
868 |
< |
if (!sbuffer[n]) |
869 |
< |
setcolor(outbuffer[n], 0., 0., 0.); |
870 |
< |
*/ |
871 |
< |
/* adjust exposure */ |
866 |
> |
/* |
867 |
> |
for (n = hres*vres; n--; ) |
868 |
> |
if (!sbuffer[n]) |
869 |
> |
setcolor(outbuffer[n], 0., 0., 0.); |
870 |
> |
*/ |
871 |
> |
/* adjust exposure */ |
872 |
|
if ((expval < 0.99) | (expval > 1.01)) |
873 |
|
for (n = hres*vres; n--; ) |
874 |
|
scalecolor(outbuffer[n], expval); |
875 |
< |
return; |
876 |
< |
{ |
877 |
< |
float *sbuf = (float *)malloc(sizeof(float)*hres*vres); |
878 |
< |
char fnm[256]; |
879 |
< |
sprintf(fnm, vval(BASENAME), fcur); |
880 |
< |
strcat(fnm, "_outsamp.pic"); |
881 |
< |
for (n = hres*vres; n--; ) |
882 |
< |
sbuf[n] = (float)sbuffer[n]; |
883 |
< |
write_map(sbuf, fnm); |
884 |
< |
free((void *)sbuf); |
875 |
> |
#if 0 |
876 |
> |
{ |
877 |
> |
float *sbuf = (float *)malloc(sizeof(float)*hres*vres); |
878 |
> |
char fnm[256]; |
879 |
> |
sprintf(fnm, vval(BASENAME), fcur); |
880 |
> |
strcat(fnm, "_outsamp.pic"); |
881 |
> |
for (n = hres*vres; n--; ) |
882 |
> |
sbuf[n] = (float)sbuffer[n]; |
883 |
> |
write_map(sbuf, fnm); |
884 |
> |
free((void *)sbuf); |
885 |
> |
} |
886 |
> |
#endif |
887 |
|
} |
864 |
– |
} |
888 |
|
|
889 |
|
|
890 |
< |
void |
891 |
< |
send_frame() /* send frame to destination */ |
890 |
> |
extern void |
891 |
> |
send_frame(void) /* send frame to destination */ |
892 |
|
{ |
893 |
|
char pfname[1024]; |
894 |
|
double d; |
940 |
|
} |
941 |
|
|
942 |
|
|
943 |
< |
void |
944 |
< |
free_frame() /* free frame allocation */ |
943 |
> |
extern void |
944 |
> |
free_frame(void) /* free frame allocation */ |
945 |
|
{ |
946 |
|
if (cbuffer == NULL) |
947 |
|
return; |