| 10 |
|
#include "copyright.h" |
| 11 |
|
|
| 12 |
|
#include <ctype.h> |
| 13 |
+ |
#include <string.h> |
| 14 |
|
|
| 15 |
|
#include "standard.h" |
| 16 |
|
#include "rtprocess.h" /* Windows: must come before color.h */ |
| 27 |
|
#define averaging (ourweigh != NULL) |
| 28 |
|
#define blurring (ourbpict != NULL) |
| 29 |
|
#define usematrix (hasmatrix & !averaging) |
| 30 |
< |
#define zisnorm (!usematrix | ourview.type != VT_PER) |
| 30 |
> |
#define zisnorm ((!usematrix) | (ourview.type != VT_PER)) |
| 31 |
|
|
| 32 |
|
#define MAXWT 1000. /* maximum pixel weight (averaging) */ |
| 33 |
|
|
| 232 |
|
fillo &= ~F_BACK; |
| 233 |
|
if (doavg < 0) |
| 234 |
|
doavg = (argc-an) > 2; |
| 235 |
< |
if (expcomp != NULL) |
| 236 |
< |
if (expcomp[0] == '+' | expcomp[0] == '-') { |
| 235 |
> |
if (expcomp != NULL) { |
| 236 |
> |
if ((expcomp[0] == '+') | (expcomp[0] == '-')) { |
| 237 |
|
expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5); |
| 238 |
|
if (doavg | doblur) |
| 239 |
|
rexpadj = pow(2.0, atof(expcomp)); |
| 247 |
|
if (!(doavg | doblur)) |
| 248 |
|
rexpadj = pow(2.0, (double)expadj); |
| 249 |
|
} |
| 250 |
+ |
} |
| 251 |
|
/* set view */ |
| 252 |
|
if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) { |
| 253 |
|
fprintf(stderr, "%s: no view on standard input!\n", |
| 259 |
|
if (doavg) { |
| 260 |
|
ourspict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR)); |
| 261 |
|
ourweigh = (float *)bmalloc(hresolu*vresolu*sizeof(float)); |
| 262 |
< |
if (ourspict == NULL | ourweigh == NULL) |
| 262 |
> |
if ((ourspict == NULL) | (ourweigh == NULL)) |
| 263 |
|
syserror(progname); |
| 264 |
|
} else { |
| 265 |
|
ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR)); |
| 279 |
|
fputnow(stdout); |
| 280 |
|
/* run pictures */ |
| 281 |
|
do { |
| 282 |
< |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
| 282 |
> |
memset((char *)ourzbuf, '\0', hresolu*vresolu*sizeof(float)); |
| 283 |
|
for (i = an; i < argc; i += 2) |
| 284 |
|
addpicture(argv[i], argv[i+1]); |
| 285 |
|
if (fillo&F_BACK) /* fill in spaces */ |
| 299 |
|
fprintview(&avgview, stdout); |
| 300 |
|
putc('\n', stdout); |
| 301 |
|
} |
| 302 |
< |
if (pixaspect < .99 | pixaspect > 1.01) |
| 302 |
> |
if ((pixaspect < .99) | (pixaspect > 1.01)) |
| 303 |
|
fputaspect(pixaspect, stdout); |
| 304 |
|
if (ourexp > 0) |
| 305 |
|
ourexp *= rexpadj; |
| 306 |
|
else |
| 307 |
|
ourexp = rexpadj; |
| 308 |
< |
if (ourexp < .995 | ourexp > 1.005) |
| 308 |
> |
if ((ourexp < .995) | (ourexp > 1.005)) |
| 309 |
|
fputexpos(ourexp, stdout); |
| 310 |
|
if (strcmp(ourfmt, PICFMT)) /* print format if known */ |
| 311 |
|
fputformat(ourfmt, stdout); |
| 375 |
|
exit(1); |
| 376 |
|
} |
| 377 |
|
if (!nvavg) { /* first view */ |
| 378 |
< |
copystruct(&avgview, &ourview); |
| 378 |
> |
avgview = ourview; |
| 379 |
|
return(nvavg++); |
| 380 |
|
} |
| 381 |
|
/* add to average view */ |
| 414 |
|
avgview.vfore *= f; |
| 415 |
|
avgview.vaft *= f; |
| 416 |
|
if (setview(&avgview) != NULL) /* in case of emergency... */ |
| 417 |
< |
copystruct(&avgview, &ourview); |
| 417 |
> |
avgview = ourview; |
| 418 |
|
pixaspect = viewaspect(&avgview) * hresolu / vresolu; |
| 419 |
|
} |
| 420 |
|
|
| 435 |
|
syserror(pfile); |
| 436 |
|
/* get header with exposure and view */ |
| 437 |
|
theirexp = 1.0; |
| 438 |
< |
copystruct(&theirview, &stdview); |
| 438 |
> |
theirview = stdview; |
| 439 |
|
gotview = 0; |
| 440 |
|
if (nvavg < 2) |
| 441 |
|
printf("%s:\n", pfile); |
| 448 |
|
ourexp = theirexp; |
| 449 |
|
else if (ABS(theirexp-ourexp) > .01*ourexp) |
| 450 |
|
fprintf(stderr, "%s: different exposure (warning)\n", pfile); |
| 451 |
< |
if (err = setview(&theirview)) { |
| 451 |
> |
if ( (err = setview(&theirview)) ) { |
| 452 |
|
fprintf(stderr, "%s: %s\n", pfile, err); |
| 453 |
|
exit(1); |
| 454 |
|
} |
| 482 |
|
scanin = (COLR *)malloc(scanlen(&tresolu)*sizeof(COLR)); |
| 483 |
|
plast = (struct position *)calloc(scanlen(&tresolu), |
| 484 |
|
sizeof(struct position)); |
| 485 |
< |
if (scanin == NULL | plast == NULL) |
| 485 |
> |
if ((scanin == NULL) | (plast == NULL)) |
| 486 |
|
syserror(progname); |
| 487 |
|
/* skip to starting point */ |
| 488 |
|
for (y = 0; y < ylim.min; y++) |
| 522 |
|
{ |
| 523 |
|
double m4t[4][4]; |
| 524 |
|
|
| 525 |
< |
if (vw1->type != VT_PER & vw1->type != VT_PAR) |
| 525 |
> |
if ((vw1->type != VT_PER) & (vw1->type != VT_PAR)) |
| 526 |
|
return(0); |
| 527 |
< |
if (vw2->type != VT_PER & vw2->type != VT_PAR) |
| 527 |
> |
if ((vw2->type != VT_PER) & (vw2->type != VT_PAR)) |
| 528 |
|
return(0); |
| 529 |
|
setident4(xfmat); |
| 530 |
|
xfmat[0][0] = vw1->hvec[0]; |
| 608 |
|
s1x = p1->x - p0->x; |
| 609 |
|
s1y = p1->y - p0->y; |
| 610 |
|
l1 = ABS(s1x); |
| 611 |
< |
if (p1isy = (ABS(s1y) > l1)) |
| 611 |
> |
if ( (p1isy = (ABS(s1y) > l1)) ) |
| 612 |
|
l1 = ABS(s1y); |
| 613 |
|
else if (l1 < 1) |
| 614 |
|
l1 = 1; |
| 641 |
|
y1 = p0->y + c1*s1y/l1; |
| 642 |
|
for (c2 = l2; c2-- > 0; ) { |
| 643 |
|
x = x1 + c2*s2x/l2; |
| 644 |
< |
if (x < 0 | x >= hresolu) |
| 644 |
> |
if ((x < 0) | (x >= hresolu)) |
| 645 |
|
continue; |
| 646 |
|
y = y1 + c2*s2y/l2; |
| 647 |
< |
if (y < 0 | y >= vresolu) |
| 647 |
> |
if ((y < 0) | (y >= vresolu)) |
| 648 |
|
continue; |
| 649 |
|
if (averaging) { |
| 650 |
|
if (zscan(y)[x] <= 0 || zscan(y)[x]-z |
| 678 |
|
if (usematrix) { |
| 679 |
|
pos[0] += theirview.hoff - .5; |
| 680 |
|
pos[1] += theirview.voff - .5; |
| 681 |
< |
if (normdist & theirview.type == VT_PER) |
| 681 |
> |
if (normdist & (theirview.type == VT_PER)) |
| 682 |
|
d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
| 683 |
|
+ pos[1]*pos[1]*theirview.vn2); |
| 684 |
|
else |
| 702 |
|
} else { |
| 703 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
| 704 |
|
return(0); |
| 705 |
< |
if (!normdist & theirview.type == VT_PER) /* adjust */ |
| 705 |
> |
if ((!normdist) & (theirview.type == VT_PER)) /* adjust */ |
| 706 |
|
pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
| 707 |
|
+ pos[1]*pos[1]*theirview.vn2); |
| 708 |
|
pt[0] += tdir[0]*pos[2]; |
| 712 |
|
if (pos[2] <= 0) |
| 713 |
|
return(0); |
| 714 |
|
} |
| 715 |
< |
if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY) |
| 715 |
> |
if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | (pos[1] < 0) | (pos[1] >= 1-FTINY)) |
| 716 |
|
return(0); |
| 717 |
|
if (!averaging) |
| 718 |
|
return(1); |
| 804 |
|
xl[y-1].max = xl[y-step].max; |
| 805 |
|
} |
| 806 |
|
for (x = 2; x < step; x++) |
| 807 |
< |
copystruct(xl+y-x, xl+y-1); |
| 807 |
> |
*(xl+y-x) = *(xl+y-1); |
| 808 |
|
} |
| 809 |
|
if (yl->max >= numscans(&tresolu)) |
| 810 |
|
yl->max = numscans(&tresolu) - 1; |
| 811 |
|
y -= step; |
| 812 |
|
for (x = numscans(&tresolu) - 1; x > y; x--) /* fill bottom rows */ |
| 813 |
< |
copystruct(xl+x, xl+y); |
| 813 |
> |
*(xl+x) = *(xl+y); |
| 814 |
|
return(yl->max >= yl->min); |
| 815 |
|
} |
| 816 |
|
|
| 940 |
|
clipaft() /* perform aft clipping as indicated */ |
| 941 |
|
{ |
| 942 |
|
register int x, y; |
| 943 |
< |
int adjtest = ourview.type == VT_PER & zisnorm; |
| 943 |
> |
int adjtest = (ourview.type == VT_PER) & zisnorm; |
| 944 |
|
double tstdist; |
| 945 |
|
double yzn2, vx; |
| 946 |
|
|
| 963 |
|
continue; |
| 964 |
|
} |
| 965 |
|
if (averaging) |
| 966 |
< |
bzero(sscan(y)[x], sizeof(COLOR)); |
| 966 |
> |
memset(sscan(y)[x], '\0', sizeof(COLOR)); |
| 967 |
|
else |
| 968 |
< |
bzero(pscan(y)[x], sizeof(COLR)); |
| 968 |
> |
memset(pscan(y)[x], '\0', sizeof(COLR)); |
| 969 |
|
zscan(y)[x] = 0.0; |
| 970 |
|
} |
| 971 |
|
} |
| 1048 |
|
char *fname; |
| 1049 |
|
{ |
| 1050 |
|
int donorm = normdist & !zisnorm ? 1 : |
| 1051 |
< |
ourview.type == VT_PER & !normdist & zisnorm ? -1 : 0; |
| 1051 |
> |
(ourview.type == VT_PER) & !normdist & zisnorm ? -1 : 0; |
| 1052 |
|
int fd; |
| 1053 |
|
int y; |
| 1054 |
|
|
| 1169 |
|
*fbp++ = dir[0]; *fbp++ = dir[1]; *fbp++ = dir[2]; |
| 1170 |
|
} |
| 1171 |
|
/* mark end and get results */ |
| 1172 |
< |
bzero((char *)fbp, 6*sizeof(float)); |
| 1172 |
> |
memset((char *)fbp, '\0', 6*sizeof(float)); |
| 1173 |
|
if (process(&PDesc, (char *)fbuf, (char *)fbuf, |
| 1174 |
|
4*sizeof(float)*(queuesiz+1), |
| 1175 |
|
6*sizeof(float)*(queuesiz+1)) != |