89 |
|
char fresopt[32]; /* filter resolution options */ |
90 |
|
int pfiltalways; /* always use pfilt? */ |
91 |
|
|
92 |
+ |
char arcargs[10240]; /* files to archive */ |
93 |
+ |
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
94 |
+ |
|
95 |
|
struct pslot { |
96 |
|
int pid; /* process ID (0 if empty) */ |
97 |
|
int fout; /* output frame number */ |
409 |
|
} |
410 |
|
|
411 |
|
|
412 |
< |
getradfile(rfname) /* run rad and get needed variables */ |
413 |
< |
char *rfname; |
412 |
> |
getradfile(rfargs) /* run rad and get needed variables */ |
413 |
> |
char *rfargs; |
414 |
|
{ |
415 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
416 |
|
char combuf[256]; |
420 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
421 |
|
sprintf(combuf, |
422 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
423 |
< |
rfname, rendopt+2); |
423 |
> |
rfargs, rendopt+2); |
424 |
|
cp = combuf; |
425 |
|
while (*cp) cp++; /* match unset variables */ |
426 |
|
for (i = 0; mvar[i] >= 0; i++) |
432 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
433 |
|
cp += 11; /* point to file name */ |
434 |
|
if (system(combuf)) { |
435 |
< |
fprintf(stderr, "%s: bad rad input file \"%s\"\n", |
436 |
< |
progname, rfname); |
435 |
> |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
436 |
> |
progname, combuf); |
437 |
|
quit(1); |
438 |
|
} |
439 |
|
loadvars(cp); /* load variables and remove file */ |
490 |
|
progname); |
491 |
|
quit(1); |
492 |
|
} |
493 |
+ |
/* initialize archive argument list */ |
494 |
+ |
i = 16; |
495 |
+ |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
496 |
+ |
i = strlen(vval(ARCHIVE)); |
497 |
+ |
arcnext = arcfirst = arcargs + i; |
498 |
|
/* initialize status file */ |
499 |
|
if (astat.rnext == 0) |
500 |
|
astat.rnext = astat.fnext = astat.tnext = vint(START); |
589 |
|
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
590 |
|
} |
591 |
|
bwait(0); /* wait for filter processes */ |
592 |
< |
archive(astat.fnext, i-1); /* archive originals */ |
592 |
> |
archive(); /* archive originals */ |
593 |
|
astat.fnext = i; /* update status */ |
594 |
|
putastat(); |
595 |
|
} |
670 |
|
inspoint = combuf + strlen(combuf); |
671 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
672 |
|
/* run in parallel */ |
673 |
< |
if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) { |
673 |
> |
i = (last-first+1)/(vint(INTERP)+1); |
674 |
> |
if (i < 1) i = 1; |
675 |
> |
if (pruncom(combuf, inspoint, i)) { |
676 |
|
fprintf(stderr, "%s: error rendering frames %d through %d\n", |
677 |
|
progname, first, last); |
678 |
|
quit(1); |
750 |
|
} |
751 |
|
|
752 |
|
|
753 |
< |
archive(first, last) /* archive and remove renderings */ |
744 |
< |
int first, last; |
753 |
> |
archive() /* archive and remove renderings */ |
754 |
|
{ |
755 |
|
#define RMCOML (sizeof(rmcom)-1) |
756 |
|
static char rmcom[] = "rm -f"; |
748 |
– |
int offset = RMCOML; |
749 |
– |
char combuf[10240]; |
750 |
– |
struct stat stb; |
751 |
– |
register char *cp; |
757 |
|
register int i; |
758 |
|
|
759 |
< |
if (noaction) |
760 |
< |
return; |
756 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset) |
757 |
< |
offset = strlen(vval(ARCHIVE)); |
758 |
< |
cp = combuf + offset; |
759 |
< |
*cp++ = ' '; /* make argument list */ |
760 |
< |
for (i = first; i <= last; i++) { |
761 |
< |
sprintf(cp, vval(BASENAME), i); |
762 |
< |
strcat(cp, ".unf"); |
763 |
< |
if (stat(cp, &stb) == 0 && stb.st_size > 0) { /* non-zero? */ |
764 |
< |
while (*cp) cp++; |
765 |
< |
*cp++ = ' '; |
766 |
< |
sprintf(cp, vval(BASENAME), i); |
767 |
< |
strcat(cp, ".zbf"); |
768 |
< |
if (access(cp, F_OK) == 0) { /* exists? */ |
769 |
< |
while (*cp) cp++; |
770 |
< |
*cp++ = ' '; |
771 |
< |
} |
772 |
< |
} |
773 |
< |
} |
774 |
< |
*--cp = '\0'; |
775 |
< |
if (cp <= combuf + offset) /* no files? */ |
776 |
< |
return; |
759 |
> |
if (arcnext == arcfirst) |
760 |
> |
return; /* nothing to do */ |
761 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
762 |
|
i = strlen(vval(ARCHIVE)); |
763 |
< |
strncpy(combuf+offset-i, vval(ARCHIVE), i); |
764 |
< |
if (runcom(combuf+offset-i)) { |
765 |
< |
fprintf(stderr, |
766 |
< |
"%s: error running archive command on frames %d through %d\n", |
783 |
< |
progname, first, last); |
763 |
> |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
764 |
> |
if (runcom(arcfirst-i)) { |
765 |
> |
fprintf(stderr, "%s: error running archive command\n", |
766 |
> |
progname); |
767 |
|
quit(1); |
768 |
|
} |
769 |
|
} |
770 |
|
/* run remove command */ |
771 |
< |
strncpy(combuf+offset-RMCOML, rmcom, RMCOML); |
772 |
< |
runcom(combuf+offset-RMCOML); |
771 |
> |
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
772 |
> |
runcom(arcfirst-RMCOML); |
773 |
> |
arcnext = arcfirst; /* reset argument list */ |
774 |
|
#undef RMCOML |
775 |
|
} |
776 |
|
|
786 |
|
static int iter = 0; |
787 |
|
char fnbefore[128], fnafter[128]; |
788 |
|
char combuf[1024], fname0[128], fname1[128]; |
789 |
< |
int usepinterp, usepfilt; |
789 |
> |
int usepinterp, usepfilt, nora_rgbe; |
790 |
|
int frseq[2]; |
791 |
|
/* check what is needed */ |
792 |
|
usepinterp = atoi(vval(MBLUR)); |
793 |
|
usepfilt = pfiltalways | ep==NULL; |
794 |
+ |
if (ep != NULL && !strcmp(ep, "1")) |
795 |
+ |
ep = "+0"; |
796 |
+ |
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
797 |
+ |
*ep != '+' || *ep != '-' || !isint(ep); |
798 |
|
/* compute rendered views */ |
799 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
800 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
803 |
|
if (frseq[1] == frame) { /* pfilt only */ |
804 |
|
frseq[0] = frseq[1]; |
805 |
|
usepinterp = 0; /* update what's needed */ |
806 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
807 |
< |
} else if (frseq[0] == frame) { /* no interpolation */ |
808 |
< |
/* update what's needed */ |
809 |
< |
if (!usepinterp) |
810 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
806 |
> |
usepfilt |= nora_rgbe; |
807 |
> |
} else if (frseq[0] == frame) { /* no interpolation needed */ |
808 |
> |
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
809 |
> |
*arcnext++ = ' '; |
810 |
> |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
811 |
> |
while (*arcnext) arcnext++; |
812 |
> |
strcpy(arcnext, ".unf"); |
813 |
> |
arcnext += 4; |
814 |
> |
if (usepinterp || vint(INTERP)) { /* and z-buf */ |
815 |
> |
*arcnext++ = ' '; |
816 |
> |
sprintf(arcnext, vval(BASENAME), |
817 |
> |
frame-vint(INTERP)-1); |
818 |
> |
while (*arcnext) arcnext++; |
819 |
> |
strcpy(arcnext, ".zbf"); |
820 |
> |
arcnext += 4; |
821 |
> |
} |
822 |
> |
} |
823 |
> |
if (!usepinterp) /* update what's needed */ |
824 |
> |
usepfilt |= nora_rgbe; |
825 |
|
} else /* interpolation needed */ |
826 |
|
usepinterp++; |
827 |
|
if (frseq[1] >= astat.rnext) /* next batch unavailable */ |
910 |
|
} else { /* else just check it */ |
911 |
|
if (rvr == 2) |
912 |
|
return(1); |
913 |
< |
sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore); |
913 |
> |
sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore); |
914 |
|
} |
915 |
|
/* output file name */ |
916 |
|
sprintf(fname0, vval(BASENAME), frame); |
946 |
|
quit(1); |
947 |
|
} |
948 |
|
} else if (n < viewnum) { /* rewind file */ |
949 |
+ |
if (viewnum == 1 && feof(viewfp)) |
950 |
+ |
return(&curview); /* just one view */ |
951 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
952 |
|
perror(vval(VIEWFILE)); |
953 |
|
quit(1); |
957 |
|
} |
958 |
|
while (n > viewnum) { /* scan to desired view */ |
959 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
960 |
< |
return(NULL); |
960 |
> |
return(viewnum==1 ? &curview : NULL); |
961 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
962 |
|
viewnum++; |
963 |
|
} |