57 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
58 |
|
{"TRANSFER", 2, 0, NULL, onevalue}, |
59 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
60 |
< |
{"INTERP", 3, 0, NULL, intvalue}, |
61 |
< |
{"OVERSAMP", 2, 0, NULL, fltvalue}, |
60 |
> |
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
61 |
> |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
62 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
63 |
|
{"RTRACE", 2, 0, NULL, boolvalue}, |
64 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
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 */ |
102 |
|
int lastpid; /* ID of last completed background process */ |
103 |
|
PSERVER *lastpserver; /* last process server used */ |
104 |
|
|
105 |
+ |
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
106 |
+ |
|
107 |
|
struct pslot *findpslot(); |
108 |
|
|
109 |
|
VIEW *getview(); |
204 |
|
goto fmterr; |
205 |
|
fclose(fp); |
206 |
|
if (astat.pid != 0) { /* thinks it's still running */ |
207 |
< |
gethostname(buf, sizeof(buf)); |
203 |
< |
if (strcmp(buf, astat.host)) { |
207 |
> |
if (strcmp(myhostname(), astat.host)) { |
208 |
|
fprintf(stderr, |
209 |
|
"%s: process %d may still be running on host %s\n", |
210 |
|
progname, astat.pid, astat.host); |
223 |
|
return(-1); |
224 |
|
} |
225 |
|
setours: /* set our values */ |
226 |
< |
gethostname(astat.host, sizeof(astat.host)); |
226 |
> |
strcpy(astat.host, myhostname()); |
227 |
|
astat.pid = getpid(); |
228 |
|
strcpy(astat.cfname, cfname); |
229 |
|
return(0); |
304 |
|
vdef(START)++; |
305 |
|
} |
306 |
|
if (!vdef(END)) { |
307 |
< |
sprintf(buf, "%d", countviews()); |
307 |
> |
sprintf(buf, "%d", countviews()+vint(START)-1); |
308 |
|
vval(END) = savqstr(buf); |
309 |
|
vdef(END)++; |
310 |
|
} |
311 |
+ |
if (vint(END) < vint(START)) { |
312 |
+ |
fprintf(stderr, "%s: ending frame less than starting frame\n", |
313 |
+ |
progname); |
314 |
+ |
quit(1); |
315 |
+ |
} |
316 |
|
if (!vdef(BASENAME)) { |
317 |
|
sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); |
318 |
|
vval(BASENAME) = savqstr(buf); |
408 |
|
} |
409 |
|
|
410 |
|
|
411 |
< |
getradfile(rfname) /* run rad and get needed variables */ |
412 |
< |
char *rfname; |
411 |
> |
getradfile(rfargs) /* run rad and get needed variables */ |
412 |
> |
char *rfargs; |
413 |
|
{ |
414 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
415 |
|
char combuf[256]; |
419 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
420 |
|
sprintf(combuf, |
421 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
422 |
< |
rfname, rendopt+2); |
422 |
> |
rfargs, rendopt+2); |
423 |
|
cp = combuf; |
424 |
|
while (*cp) cp++; /* match unset variables */ |
425 |
|
for (i = 0; mvar[i] >= 0; i++) |
431 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
432 |
|
cp += 11; /* point to file name */ |
433 |
|
if (system(combuf)) { |
434 |
< |
fprintf(stderr, "%s: bad rad input file \"%s\"\n", |
435 |
< |
progname, rfname); |
434 |
> |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
435 |
> |
progname, combuf); |
436 |
|
quit(1); |
437 |
|
} |
438 |
|
loadvars(cp); /* load variables and remove file */ |
489 |
|
progname); |
490 |
|
quit(1); |
491 |
|
} |
492 |
+ |
/* initialize archive argument list */ |
493 |
+ |
i = 16; |
494 |
+ |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
495 |
+ |
i = strlen(vval(ARCHIVE)); |
496 |
+ |
arcnext = arcfirst = arcargs + i; |
497 |
|
/* initialize status file */ |
498 |
|
if (astat.rnext == 0) |
499 |
|
astat.rnext = astat.fnext = astat.tnext = vint(START); |
588 |
|
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
589 |
|
} |
590 |
|
bwait(0); /* wait for filter processes */ |
591 |
< |
archive(astat.fnext, i-1); /* archive originals */ |
591 |
> |
archive(); /* archive originals */ |
592 |
|
astat.fnext = i; /* update status */ |
593 |
|
putastat(); |
594 |
|
} |
650 |
|
char *vfn; |
651 |
|
{ |
652 |
|
char combuf[2048]; |
653 |
+ |
char *inspoint; |
654 |
|
register int i; |
655 |
|
|
656 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
661 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
662 |
|
} |
663 |
|
/* create command */ |
664 |
< |
sprintf(combuf, "rpict%s -w0 ", rendopt); |
664 |
> |
sprintf(combuf, "rpict%s -w0", rendopt); |
665 |
|
if (vint(INTERP) || atoi(vval(MBLUR))) |
666 |
< |
sprintf(combuf+strlen(combuf), "-z %s.zbf ", vval(BASENAME)); |
667 |
< |
sprintf(combuf+strlen(combuf), "-o %s.unf %s -S %d %s < %s", |
668 |
< |
vval(BASENAME), rresopt, first, vval(OCTREE), vfn); |
666 |
> |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
667 |
> |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
668 |
> |
vval(BASENAME), rresopt, first); |
669 |
> |
inspoint = combuf + strlen(combuf); |
670 |
> |
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
671 |
|
/* run in parallel */ |
672 |
< |
if (pruncom(combuf, (last-first+1)/(vint(INTERP)+1))) { |
672 |
> |
i = (last-first+1)/(vint(INTERP)+1); |
673 |
> |
if (i < 1) i = 1; |
674 |
> |
if (pruncom(combuf, inspoint, i)) { |
675 |
|
fprintf(stderr, "%s: error rendering frames %d through %d\n", |
676 |
|
progname, first, last); |
677 |
|
quit(1); |
749 |
|
} |
750 |
|
|
751 |
|
|
752 |
< |
archive(first, last) /* archive and remove renderings */ |
734 |
< |
int first, last; |
752 |
> |
archive() /* archive and remove renderings */ |
753 |
|
{ |
754 |
|
#define RMCOML (sizeof(rmcom)-1) |
755 |
|
static char rmcom[] = "rm -f"; |
738 |
– |
int offset = RMCOML; |
739 |
– |
char combuf[10240]; |
740 |
– |
struct stat stb; |
741 |
– |
register char *cp; |
756 |
|
register int i; |
757 |
|
|
758 |
< |
if (noaction) |
759 |
< |
return; |
746 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset) |
747 |
< |
offset = strlen(vval(ARCHIVE)); |
748 |
< |
cp = combuf + offset; |
749 |
< |
*cp++ = ' '; /* make argument list */ |
750 |
< |
for (i = first; i <= last; i++) { |
751 |
< |
sprintf(cp, vval(BASENAME), i); |
752 |
< |
strcat(cp, ".unf"); |
753 |
< |
if (stat(cp, &stb) == 0 && stb.st_size > 0) { /* non-zero? */ |
754 |
< |
while (*cp) cp++; |
755 |
< |
*cp++ = ' '; |
756 |
< |
sprintf(cp, vval(BASENAME), i); |
757 |
< |
strcat(cp, ".zbf"); |
758 |
< |
if (access(cp, F_OK) == 0) { /* exists? */ |
759 |
< |
while (*cp) cp++; |
760 |
< |
*cp++ = ' '; |
761 |
< |
} |
762 |
< |
} |
763 |
< |
} |
764 |
< |
*--cp = '\0'; |
765 |
< |
if (cp <= combuf + offset) /* no files? */ |
766 |
< |
return; |
758 |
> |
if (arcnext == arcfirst) |
759 |
> |
return; /* nothing to do */ |
760 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
761 |
|
i = strlen(vval(ARCHIVE)); |
762 |
< |
strncpy(combuf+offset-i, vval(ARCHIVE), i); |
763 |
< |
if (runcom(combuf+offset-i)) { |
764 |
< |
fprintf(stderr, |
765 |
< |
"%s: error running archive command on frames %d through %d\n", |
773 |
< |
progname, first, last); |
762 |
> |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
763 |
> |
if (runcom(arcfirst-i)) { |
764 |
> |
fprintf(stderr, "%s: error running archive command\n", |
765 |
> |
progname); |
766 |
|
quit(1); |
767 |
|
} |
768 |
|
} |
769 |
|
/* run remove command */ |
770 |
< |
strncpy(combuf+offset-RMCOML, rmcom, RMCOML); |
771 |
< |
runcom(combuf+offset-RMCOML); |
770 |
> |
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
771 |
> |
runcom(arcfirst-RMCOML); |
772 |
> |
arcnext = arcfirst; /* reset argument list */ |
773 |
|
#undef RMCOML |
774 |
|
} |
775 |
|
|
782 |
|
int rvr; |
783 |
|
{ |
784 |
|
extern int frecover(); |
785 |
+ |
static int iter = 0; |
786 |
|
char fnbefore[128], fnafter[128]; |
787 |
< |
char combuf[1024], fname[128]; |
788 |
< |
int usepinterp, usepfilt; |
787 |
> |
char combuf[1024], fname0[128], fname1[128]; |
788 |
> |
int usepinterp, usepfilt, nora_rgbe; |
789 |
|
int frseq[2]; |
790 |
|
/* check what is needed */ |
791 |
|
usepinterp = atoi(vval(MBLUR)); |
792 |
|
usepfilt = pfiltalways | ep==NULL; |
793 |
+ |
if (ep != NULL && !strcmp(ep, "1")) |
794 |
+ |
ep = "+0"; |
795 |
+ |
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
796 |
+ |
*ep != '+' || *ep != '-' || !isint(ep); |
797 |
|
/* compute rendered views */ |
798 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
799 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
802 |
|
if (frseq[1] == frame) { /* pfilt only */ |
803 |
|
frseq[0] = frseq[1]; |
804 |
|
usepinterp = 0; /* update what's needed */ |
805 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
806 |
< |
} else if (frseq[0] == frame) { /* no interpolation */ |
807 |
< |
/* update what's needed */ |
808 |
< |
if (!usepinterp) |
809 |
< |
usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1"); |
805 |
> |
usepfilt |= nora_rgbe; |
806 |
> |
} else if (frseq[0] == frame) { /* no interpolation needed */ |
807 |
> |
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
808 |
> |
*arcnext++ = ' '; |
809 |
> |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
810 |
> |
while (*arcnext) arcnext++; |
811 |
> |
strcpy(arcnext, ".unf"); |
812 |
> |
arcnext += 4; |
813 |
> |
if (usepinterp || vint(INTERP)) { /* and z-buf */ |
814 |
> |
*arcnext++ = ' '; |
815 |
> |
sprintf(arcnext, vval(BASENAME), |
816 |
> |
frame-vint(INTERP)-1); |
817 |
> |
while (*arcnext) arcnext++; |
818 |
> |
strcpy(arcnext, ".zbf"); |
819 |
> |
arcnext += 4; |
820 |
> |
} |
821 |
> |
} |
822 |
> |
if (!usepinterp) /* update what's needed */ |
823 |
> |
usepfilt |= nora_rgbe; |
824 |
|
} else /* interpolation needed */ |
825 |
|
usepinterp++; |
826 |
|
if (frseq[1] >= astat.rnext) /* next batch unavailable */ |
835 |
|
return(1); |
836 |
|
if (atoi(vval(MBLUR))) { |
837 |
|
FILE *fp; /* motion blurring */ |
838 |
< |
sprintf(fname, "%s/vw0", vval(DIRECTORY)); |
839 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
840 |
< |
perror(fname); quit(1); |
838 |
> |
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
839 |
> |
'a'+(iter%26)); |
840 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
841 |
> |
perror(fname0); quit(1); |
842 |
|
} |
843 |
|
fputs(VIEWSTR, fp); |
844 |
|
fprintview(vp, fp); |
849 |
|
progname, frame+1); |
850 |
|
quit(1); |
851 |
|
} |
852 |
< |
sprintf(fname, "%s/vw1", vval(DIRECTORY)); |
853 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
854 |
< |
perror(fname); quit(1); |
852 |
> |
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
853 |
> |
'a'+(iter%26)); |
854 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
855 |
> |
perror(fname1); quit(1); |
856 |
|
} |
857 |
|
fputs(VIEWSTR, fp); |
858 |
|
fprintview(vp, fp); |
859 |
|
putc('\n', fp); fclose(fp); |
860 |
|
sprintf(combuf, |
861 |
< |
"(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B", |
861 |
> |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
862 |
|
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
863 |
< |
atoi(vval(MBLUR)), vval(DIRECTORY), |
864 |
< |
vval(DIRECTORY), vval(DIRECTORY), |
865 |
< |
vval(DIRECTORY), vval(DIRECTORY)); |
863 |
> |
atoi(vval(MBLUR)), |
864 |
> |
fname0, fname1, fname0, fname1); |
865 |
> |
iter++; |
866 |
|
} else /* no blurring */ |
867 |
|
strcpy(combuf, "pinterp"); |
868 |
|
strcat(combuf, viewopt(vp)); |
909 |
|
} else { /* else just check it */ |
910 |
|
if (rvr == 2) |
911 |
|
return(1); |
912 |
< |
sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore); |
912 |
> |
sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore); |
913 |
|
} |
914 |
|
/* output file name */ |
915 |
< |
sprintf(fname, vval(BASENAME), frame); |
916 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname); |
915 |
> |
sprintf(fname0, vval(BASENAME), frame); |
916 |
> |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
917 |
|
if (rvr) /* in recovery */ |
918 |
|
return(runcom(combuf)); |
919 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
945 |
|
quit(1); |
946 |
|
} |
947 |
|
} else if (n < viewnum) { /* rewind file */ |
948 |
+ |
if (viewnum == 1 && feof(viewfp)) |
949 |
+ |
return(&curview); /* just one view */ |
950 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
951 |
|
perror(vval(VIEWFILE)); |
952 |
|
quit(1); |
956 |
|
} |
957 |
|
while (n > viewnum) { /* scan to desired view */ |
958 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
959 |
< |
return(NULL); |
959 |
> |
return(viewnum==1 ? &curview : NULL); |
960 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
961 |
|
viewnum++; |
962 |
|
} |
1108 |
|
int pid; |
1109 |
|
register struct pslot *psl; |
1110 |
|
|
1111 |
< |
if (!silent) |
1112 |
< |
printf("\t%s &\n", com); /* echo command */ |
1113 |
< |
if (noaction) |
1111 |
> |
if (noaction) { |
1112 |
> |
if (!silent) |
1113 |
> |
printf("\t%s\n", com); /* echo command */ |
1114 |
|
return(0); |
1115 |
< |
fflush(stdout); |
1115 |
> |
} |
1116 |
|
/* else start it when we can */ |
1117 |
|
while ((pid = startjob(NULL, savestr(com), donecom)) == -1) |
1118 |
|
bwait(1); |
1119 |
< |
if (!silent) { |
1119 |
> |
if (!silent) { /* echo command */ |
1120 |
|
PSERVER *ps; |
1121 |
|
int psn = pid; |
1122 |
< |
ps = findpjob(&psn); |
1123 |
< |
printf("\tProcess started on %s\n", |
1124 |
< |
ps->hostname[0] ? ps->hostname : LHOSTNAME); |
1122 |
> |
ps = findjob(&psn); |
1123 |
> |
printf("\t%s\n", com); |
1124 |
> |
printf("\tProcess started on %s\n", phostname(ps)); |
1125 |
|
fflush(stdout); |
1126 |
|
} |
1127 |
|
psl = findpslot(pid); /* record info. in appropriate slot */ |
1159 |
|
|
1160 |
|
|
1161 |
|
int |
1162 |
< |
pruncom(com, maxcopies) /* run a command in parallel over network */ |
1163 |
< |
char *com; |
1162 |
> |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1163 |
> |
char *com, *ppins; |
1164 |
|
int maxcopies; |
1165 |
|
{ |
1166 |
|
int retstatus = 0; |
1167 |
|
int hostcopies; |
1168 |
+ |
char com1buf[10240], *com1, *endcom1; |
1169 |
|
int status; |
1170 |
|
register PSERVER *ps; |
1171 |
|
|
1172 |
|
if (!silent) |
1173 |
< |
printf("\t%s &\n", com); /* echo command */ |
1173 |
> |
printf("\t%s\n", com); /* echo command */ |
1174 |
|
if (noaction) |
1175 |
|
return(0); |
1176 |
|
fflush(stdout); |
1177 |
|
/* start jobs on each server */ |
1178 |
|
for (ps = pslist; ps != NULL; ps = ps->next) { |
1179 |
|
hostcopies = 0; |
1180 |
+ |
if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { |
1181 |
+ |
strcpy(com1=com1buf, com); /* build -PP command */ |
1182 |
+ |
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1183 |
+ |
vval(DIRECTORY), phostname(ps)); |
1184 |
+ |
strcat(com1, ppins); |
1185 |
+ |
endcom1 = com1 + strlen(com1); |
1186 |
+ |
sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", |
1187 |
+ |
vval(DIRECTORY), phostname(ps)); |
1188 |
+ |
} else { |
1189 |
+ |
com1 = com; |
1190 |
+ |
endcom1 = NULL; |
1191 |
+ |
} |
1192 |
|
while (maxcopies > 0 && |
1193 |
< |
startjob(ps, savestr(com), donecom) != -1) { |
1193 |
> |
startjob(ps, savestr(com1), donecom) != -1) { |
1194 |
|
sleep(10); |
1195 |
|
hostcopies++; |
1196 |
|
maxcopies--; |
1197 |
+ |
if (endcom1 != NULL) |
1198 |
+ |
*endcom1 = '\0'; |
1199 |
|
} |
1200 |
|
if (!silent && hostcopies) { |
1201 |
|
if (hostcopies > 1) |
1202 |
|
printf("\t%d duplicate processes", hostcopies); |
1203 |
|
else |
1204 |
|
printf("\tProcess"); |
1205 |
< |
printf(" started on %s\n", |
1175 |
< |
ps->hostname[0] ? ps->hostname : LHOSTNAME); |
1205 |
> |
printf(" started on %s\n", phostname(ps)); |
1206 |
|
fflush(stdout); |
1207 |
|
} |
1208 |
|
} |