4 |
|
/* |
5 |
|
* ranimove2.c |
6 |
|
* |
7 |
< |
* Frame refinement routines for ranimate(1). |
7 |
> |
* Frame refinement routines for ranimove(1). |
8 |
|
* |
9 |
|
* Created by Gregory Ward on Wed Jan 08 2003. |
10 |
|
*/ |
26 |
|
static long refine_rays(long nrays); |
27 |
|
|
28 |
|
|
29 |
< |
extern int |
29 |
> |
int |
30 |
|
refine_first(void) /* initial refinement pass */ |
31 |
|
{ |
32 |
|
int *esamp = (int *)zprev; /* OK to reuse */ |
34 |
|
int nextra = 0; |
35 |
|
int x, y, xp, yp; |
36 |
|
int neigh; |
37 |
< |
register int n, np; |
37 |
> |
int n, np; |
38 |
|
|
39 |
|
if (sizeof(int) < sizeof(*zprev)) |
40 |
|
error(CONSISTENCY, "code error in refine_first"); |
128 |
|
|
129 |
|
static void |
130 |
|
clr_consp( /* initialize a conspicuity sum */ |
131 |
< |
register struct ConspSum *cs |
131 |
> |
struct ConspSum *cs |
132 |
|
) |
133 |
|
{ |
134 |
|
if (cs == NULL) |
143 |
|
|
144 |
|
static void |
145 |
|
sum_consp( /* sum in conspicuity result */ |
146 |
< |
register struct ConspSum *cdest, |
147 |
< |
register struct ConspSum *cs |
146 |
> |
struct ConspSum *cdest, |
147 |
> |
struct ConspSum *cs |
148 |
|
) |
149 |
|
{ |
150 |
|
if ((cdest == NULL) | (cs == NULL)) |
165 |
|
int y0, |
166 |
|
int x1, |
167 |
|
int y1, |
168 |
< |
register struct ConspSum *cs |
168 |
> |
struct ConspSum *cs |
169 |
|
) |
170 |
|
{ |
171 |
|
double rad2, mtn2, cpd, vm, vr, csf, eest; |
236 |
|
/* put into map */ |
237 |
|
for ( ; y0 < y1; y0++) { |
238 |
|
float *em0 = cerrmap + fndx(x0, y0); |
239 |
< |
register float *emp = em0 + (x1-x0); |
239 |
> |
float *emp = em0 + (x1-x0); |
240 |
|
while (emp-- > em0) |
241 |
|
if (eest > *emp) |
242 |
|
*emp = eest; |
263 |
|
|
264 |
|
if ((x0 == x1-1) & (y0 == y1-1)) { /* single pixel */ |
265 |
|
double hls; |
266 |
< |
register int n = fndx(x0, y0); |
266 |
> |
int n = fndx(x0, y0); |
267 |
|
if (sbuffer[n]) { |
268 |
|
copycolor(mysum.vsum, cbuffer[n]); |
269 |
|
copycolor(mysum.v2sum, val2map[n]); |
310 |
|
sum_consp(cs, &mysum); |
311 |
|
} |
312 |
|
|
313 |
< |
extern void |
313 |
> |
void |
314 |
|
conspicuity(void) /* compute conspicuous error map */ |
315 |
|
{ |
316 |
|
int fhres, fvres; |
375 |
|
|
376 |
|
static int |
377 |
|
ray_refine( /* refine the given pixel by tracing a ray */ |
378 |
< |
register int n |
378 |
> |
int n |
379 |
|
) |
380 |
|
{ |
381 |
|
RAY ir; |
382 |
< |
COLOR ctmp; |
382 |
> |
COLOR rcol, ctmp, csqr; |
383 |
|
int i; |
384 |
|
|
385 |
|
if (n < 0) { /* fetching stragglers */ |
396 |
|
return(-1); |
397 |
|
if (nprocs > 1) { |
398 |
|
int rval; |
399 |
< |
rayorigin(&ir, NULL, PRIMARY, 1.0); |
399 |
> |
rayorigin(&ir, PRIMARY, NULL, NULL); |
400 |
|
ir.rno = n; |
401 |
|
rval = ray_pqueue(&ir); |
402 |
|
if (!rval) |
407 |
|
} else |
408 |
|
ray_trace(&ir); |
409 |
|
} |
410 |
+ |
scolor_rgb(rcol, ir.rcol); |
411 |
|
if (abuffer[n] == ALOWQ && asump != NULL) { |
412 |
|
if (sbuffer[n] != 1) |
413 |
|
error(CONSISTENCY, "bad code in ray_refine"); |
417 |
|
(colval(ctmp,BLU) > 0.01)) { |
418 |
|
for (i = 0; i < 3; i++) |
419 |
|
asump->diffsum[i] += |
420 |
< |
(colval(ir.rcol,i) - colval(cbuffer[n],i)) |
420 |
> |
(colval(rcol,i) - colval(cbuffer[n],i)) |
421 |
|
/ colval(ctmp,i); |
422 |
|
asump->nsamps++; |
423 |
|
} |
424 |
|
sbuffer[n] = 0; |
425 |
|
} |
426 |
< |
setcolor(ctmp, |
427 |
< |
colval(ir.rcol,RED)*colval(ir.rcol,RED), |
427 |
< |
colval(ir.rcol,GRN)*colval(ir.rcol,GRN), |
428 |
< |
colval(ir.rcol,BLU)*colval(ir.rcol,BLU)); |
426 |
> |
copycolor(csqr, rcol); |
427 |
> |
multcolor(csqr, rcol); |
428 |
|
if (!sbuffer[n]) { /* first sample */ |
429 |
< |
copycolor(cbuffer[n], ir.rcol); |
430 |
< |
copycolor(val2map[n], ctmp); |
429 |
> |
copycolor(cbuffer[n], rcol); |
430 |
> |
copycolor(val2map[n], csqr); |
431 |
|
abuffer[n] = AHIGHQ; |
432 |
|
sbuffer[n] = 1; |
433 |
|
} else { /* else sum in sample */ |
434 |
< |
addcolor(cbuffer[n], ir.rcol); |
435 |
< |
addcolor(val2map[n], ctmp); |
434 |
> |
addcolor(cbuffer[n], rcol); |
435 |
> |
addcolor(val2map[n], csqr); |
436 |
|
sbuffer[n]++; |
437 |
|
} |
438 |
|
return(n); |
462 |
|
i = 0; |
463 |
|
/* trace rays in list */ |
464 |
|
for (rdone = 0; rdone < nrays; rdone++) { |
465 |
< |
if (ndtset && i >= 1000 && cerrmap[pord[i]] <= FTINY) |
465 |
> |
if (ndtset && (i >= 1000) & (i < ntodo) && |
466 |
> |
cerrmap[pord[i]] <= FTINY) |
467 |
|
ntodo = i; |
468 |
|
if (i >= ntodo) { /* redo conspicuity & priority */ |
469 |
|
while (ray_refine(-1) >= 0) |
486 |
|
} |
487 |
|
|
488 |
|
|
489 |
< |
extern int |
489 |
> |
int |
490 |
|
refine_frame( /* refine current frame */ |
491 |
|
int pass |
492 |
|
) |
499 |
|
double time_start, rtime_start, time_done; |
500 |
|
struct AmbSum myAmbSum; |
501 |
|
long rays_todo, nr; |
502 |
< |
register int n; |
502 |
> |
int n; |
503 |
|
/* IBR refinement? */ |
504 |
|
if ((pass == 0) & (fcur > fbeg)) |
505 |
|
return(refine_first()); |