| 9 |
|
|
| 10 |
|
#include "platform.h" |
| 11 |
|
#include "standard.h" |
| 12 |
< |
#include "rtprocess.h" |
| 12 |
> |
#include "paths.h" |
| 13 |
|
#include "color.h" |
| 14 |
|
#include "calcomp.h" |
| 15 |
|
#include "view.h" |
| 16 |
|
|
| 17 |
< |
#define MAXINP 512 /* maximum number of input files */ |
| 18 |
< |
#define WINSIZ 64 /* scanline window size */ |
| 17 |
> |
#define MAXINP 1024 /* maximum number of input files */ |
| 18 |
> |
#define WINSIZ 127 /* scanline window size */ |
| 19 |
|
#define MIDSCN ((WINSIZ-1)/2+1) |
| 20 |
|
|
| 21 |
|
struct { |
| 31 |
|
|
| 32 |
|
int nfiles; /* number of input files */ |
| 33 |
|
|
| 34 |
+ |
VIEW commvw; /* common view parameters */ |
| 35 |
+ |
|
| 36 |
|
char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ |
| 37 |
|
|
| 38 |
|
char StandardInput[] = "<stdin>"; |
| 98 |
|
int original; |
| 99 |
|
double f; |
| 100 |
|
int a; |
| 101 |
+ |
|
| 102 |
|
SET_DEFAULT_BINARY(); |
| 103 |
|
SET_FILE_BINARY(stdin); |
| 104 |
|
SET_FILE_BINARY(stdout); |
| 105 |
|
progname = argv[0]; |
| 106 |
+ |
esupport |= E_VARIABLE|E_FUNCTION|E_RCONST; |
| 107 |
+ |
esupport &= ~(E_OUTCHAN|E_INCHAN); |
| 108 |
|
/* scan options */ |
| 109 |
|
for (a = 1; a < argc; a++) { |
| 110 |
|
if (argv[a][0] == '-') |
| 193 |
|
init(); /* set constants */ |
| 194 |
|
/* go back and get expressions */ |
| 195 |
|
for (a = 1; a < argc; a++) { |
| 196 |
+ |
char *fpath; |
| 197 |
|
if (argv[a][0] == '-') |
| 198 |
|
switch (argv[a][1]) { |
| 199 |
|
case 'x': |
| 207 |
|
case 'h': |
| 208 |
|
continue; |
| 209 |
|
case 'f': |
| 210 |
< |
fcompile(argv[++a]); |
| 210 |
> |
fpath = getpath(argv[++a], getrlibpath(), 0); |
| 211 |
> |
if (fpath == NULL) { |
| 212 |
> |
eputs(argv[0]); |
| 213 |
> |
eputs(": cannot find file '"); |
| 214 |
> |
eputs(argv[a]); |
| 215 |
> |
eputs("'\n"); |
| 216 |
> |
quit(1); |
| 217 |
> |
} |
| 218 |
> |
fcompile(fpath); |
| 219 |
|
continue; |
| 220 |
|
case 'e': |
| 221 |
|
scompile(argv[++a], NULL, 0); |
| 223 |
|
} |
| 224 |
|
break; |
| 225 |
|
} |
| 226 |
< |
/* set/get output resolution */ |
| 213 |
< |
if (!vardefined(vxres)) |
| 214 |
< |
varset(vxres, ':', (double)xmax); |
| 215 |
< |
if (!vardefined(vyres)) |
| 216 |
< |
varset(vyres, ':', (double)ymax); |
| 226 |
> |
/* get output resolution */ |
| 227 |
|
xres = varvalue(vxres) + .5; |
| 228 |
|
yres = varvalue(vyres) + .5; |
| 229 |
|
if (xres <= 0 || yres <= 0) { |
| 233 |
|
} |
| 234 |
|
/* complete header */ |
| 235 |
|
printargs(argc, argv, stdout); |
| 236 |
+ |
if (commvw.type) { |
| 237 |
+ |
fputs(VIEWSTR, stdout); |
| 238 |
+ |
fprintview(&commvw, stdout); |
| 239 |
+ |
fputc('\n', stdout); |
| 240 |
+ |
} |
| 241 |
|
if (strcmp(ourfmt, PICFMT)) |
| 242 |
|
fputformat(ourfmt, stdout); /* print format if known */ |
| 243 |
|
putchar('\n'); |
| 249 |
|
eputs("Usage: "); |
| 250 |
|
eputs(argv[0]); |
| 251 |
|
eputs( |
| 252 |
< |
" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
| 252 |
> |
" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] hdr ..]\n"); |
| 253 |
|
quit(1); |
| 254 |
|
return 1; /* pro forma return */ |
| 255 |
|
} |
| 261 |
|
void *p |
| 262 |
|
) |
| 263 |
|
{ |
| 264 |
< |
char fmt[32]; |
| 264 |
> |
char fmt[MAXFMTLEN]; |
| 265 |
|
double d; |
| 266 |
|
COLOR ctmp; |
| 267 |
|
|
| 297 |
|
static void |
| 298 |
|
checkfile(void) /* ready a file */ |
| 299 |
|
{ |
| 300 |
< |
register int i; |
| 300 |
> |
int i; |
| 301 |
|
/* process header */ |
| 302 |
|
gotview = 0; |
| 303 |
|
if (echoheader) { |
| 316 |
|
} |
| 317 |
|
if (!gotview || setview(&input[nfiles].vw) != NULL) |
| 318 |
|
input[nfiles].vw.type = 0; |
| 319 |
+ |
else if (!commvw.type) |
| 320 |
+ |
commvw = input[nfiles].vw; |
| 321 |
|
if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
| 322 |
|
eputs(input[nfiles].name); |
| 323 |
|
eputs(": bad picture size\n"); |
| 362 |
|
static void |
| 363 |
|
init(void) /* perform final setup */ |
| 364 |
|
{ |
| 365 |
< |
register int i; |
| 365 |
> |
int i; |
| 366 |
|
/* define constants */ |
| 367 |
|
varset("PI", ':', PI); |
| 368 |
|
varset(vnfiles, ':', (double)nfiles); |
| 385 |
|
ourbright = xyz_bright; |
| 386 |
|
} else |
| 387 |
|
varset(vwhteff, ':', WHTEFFICACY); |
| 388 |
+ |
/* these may be overridden */ |
| 389 |
+ |
varset(vxres, ':', (double)xmax); |
| 390 |
+ |
varset(vyres, ':', (double)ymax); |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
|
| 397 |
|
EPNODE *coldef[3], *brtdef; |
| 398 |
|
COLOR *scanout; |
| 399 |
|
double d; |
| 400 |
< |
register int i, j; |
| 400 |
> |
int i, j; |
| 401 |
|
/* check defined variables */ |
| 402 |
|
for (j = 0; j < 3; j++) { |
| 403 |
|
if (vardefined(vcolout[j])) |
| 418 |
|
advance(); |
| 419 |
|
varset(vypos, '=', (double)ypos); |
| 420 |
|
for (xpos = 0; xpos < xres; xpos++) { |
| 421 |
< |
xscan = (long)xpos*xmax/xres; |
| 421 |
> |
xscan = (xpos+.5)*xmax/xres; |
| 422 |
|
varset(vxpos, '=', (double)xpos); |
| 423 |
|
eclock++; |
| 424 |
|
if (brtdef != NULL) { |
| 454 |
|
advance(void) /* read in data for next scanline */ |
| 455 |
|
{ |
| 456 |
|
int ytarget; |
| 457 |
< |
register COLOR *st; |
| 458 |
< |
register int i, j; |
| 457 |
> |
COLOR *st; |
| 458 |
> |
int i, j; |
| 459 |
|
|
| 460 |
< |
for (ytarget = (long)ypos*ymax/yres; yscan > ytarget; yscan--) |
| 460 |
> |
for (ytarget = (ypos+.5)*ymax/yres; yscan > ytarget; yscan--) |
| 461 |
|
for (i = 0; i < nfiles; i++) { |
| 462 |
|
st = input[i].scan[WINSIZ-1]; |
| 463 |
|
for (j = WINSIZ-1; j > 0; j--) /* rotate window */ |
| 478 |
|
|
| 479 |
|
static double |
| 480 |
|
l_expos( /* return picture exposure */ |
| 481 |
< |
register char *nam |
| 481 |
> |
char *nam |
| 482 |
|
) |
| 483 |
|
{ |
| 484 |
< |
register int fn, n; |
| 484 |
> |
int fn, n; |
| 485 |
> |
double d; |
| 486 |
|
|
| 487 |
< |
fn = argument(1) - .5; |
| 488 |
< |
if (fn < 0 || fn >= nfiles) |
| 489 |
< |
return(1.0); |
| 487 |
> |
d = argument(1); |
| 488 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 489 |
> |
errno = EDOM; |
| 490 |
> |
return(0.0); |
| 491 |
> |
} |
| 492 |
> |
if (d < 0.5) |
| 493 |
> |
return((double)nfiles); |
| 494 |
> |
fn = d - 0.5; |
| 495 |
|
if (nam == vbrtexp) |
| 496 |
|
return((*ourbright)(input[fn].expos)); |
| 497 |
|
n = 3; |
| 507 |
|
static double |
| 508 |
|
l_pixaspect(char *nm) /* return pixel aspect ratio */ |
| 509 |
|
{ |
| 510 |
< |
register int fn; |
| 510 |
> |
int fn; |
| 511 |
> |
double d; |
| 512 |
|
|
| 513 |
< |
fn = argument(1) - .5; |
| 514 |
< |
if (fn < 0 || fn >= nfiles) |
| 515 |
< |
return(1.0); |
| 513 |
> |
d = argument(1); |
| 514 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 515 |
> |
errno = EDOM; |
| 516 |
> |
return(0.0); |
| 517 |
> |
} |
| 518 |
> |
if (d < 0.5) |
| 519 |
> |
return((double)nfiles); |
| 520 |
> |
fn = d - 0.5; |
| 521 |
|
return(input[fn].pa); |
| 522 |
|
} |
| 523 |
|
|
| 524 |
|
|
| 525 |
|
static double |
| 526 |
|
l_colin( /* return color value for picture */ |
| 527 |
< |
register char *nam |
| 527 |
> |
char *nam |
| 528 |
|
) |
| 529 |
|
{ |
| 530 |
|
int fn; |
| 531 |
< |
register int n, xoff, yoff; |
| 531 |
> |
int n, xoff, yoff; |
| 532 |
|
double d; |
| 533 |
|
|
| 534 |
< |
fn = argument(1) - .5; |
| 535 |
< |
if (fn < 0 || fn >= nfiles) { |
| 534 |
> |
d = argument(1); |
| 535 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 536 |
|
errno = EDOM; |
| 537 |
|
return(0.0); |
| 538 |
|
} |
| 539 |
+ |
if (d < 0.5) |
| 540 |
+ |
return((double)nfiles); |
| 541 |
+ |
fn = d - 0.5; |
| 542 |
|
xoff = yoff = 0; |
| 543 |
|
n = nargum(); |
| 544 |
|
if (n >= 2) { |
| 583 |
|
|
| 584 |
|
static double |
| 585 |
|
l_ray( /* return ray origin or direction */ |
| 586 |
< |
register char *nam |
| 586 |
> |
char *nam |
| 587 |
|
) |
| 588 |
|
{ |
| 589 |
|
static unsigned long ltick[MAXINP]; |
| 590 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
| 591 |
|
static double ldist[MAXINP]; |
| 592 |
|
RREAL loc[2]; |
| 593 |
+ |
double d; |
| 594 |
|
int fn; |
| 595 |
< |
register int i; |
| 595 |
> |
int i; |
| 596 |
|
|
| 597 |
< |
fn = argument(1) - .5; |
| 598 |
< |
if (fn < 0 || fn >= nfiles) { |
| 597 |
> |
d = argument(1); |
| 598 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 599 |
|
errno = EDOM; |
| 600 |
|
return(0.0); |
| 601 |
|
} |
| 602 |
+ |
if (d < 0.5) |
| 603 |
+ |
return((double)nfiles); |
| 604 |
+ |
fn = d - 0.5; |
| 605 |
|
if (ltick[fn] != eclock) { /* need to compute? */ |
| 606 |
|
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
| 607 |
|
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
| 635 |
|
RREAL locx[2], locy[2]; |
| 636 |
|
double d; |
| 637 |
|
int fn; |
| 638 |
< |
register int i; |
| 638 |
> |
int i; |
| 639 |
|
|
| 640 |
|
d = argument(1); |
| 641 |
< |
if (d < .5 || d >= nfiles+.5) { |
| 641 |
> |
if (d <= -0.5 || d >= nfiles+0.5) { |
| 642 |
|
errno = EDOM; |
| 643 |
|
return(0.0); |
| 644 |
|
} |
| 645 |
< |
fn = d - .5; |
| 645 |
> |
if (d < 0.5) |
| 646 |
> |
return((double)nfiles); |
| 647 |
> |
fn = d - 0.5; |
| 648 |
|
if (ltick[fn] != eclock) { /* need to compute? */ |
| 649 |
|
psize[fn] = 0.0; |
| 650 |
|
if (input[fn].vw.type == 0) |
| 692 |
|
extern void |
| 693 |
|
quit(int code) /* exit gracefully */ |
| 694 |
|
{ |
| 695 |
< |
register int i; |
| 695 |
> |
int i; |
| 696 |
|
/* close input files */ |
| 697 |
|
for (i = 0; i < nfiles; i++) |
| 698 |
|
if (input[i].name == Command) |