1 |
– |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Radiance animation control program |
6 |
+ |
* |
7 |
+ |
* The main difference between this program and ranimove is that |
8 |
+ |
* we have many optimizations here for camera motion in static |
9 |
+ |
* environments, calling rpict and pinterp on multiple processors, |
10 |
+ |
* where ranimove puts its emphasis on object motion, and does |
11 |
+ |
* not use any external programs for image generation. |
12 |
+ |
* |
13 |
+ |
* See the ranimate(1) man page for further details. |
14 |
|
*/ |
15 |
|
|
16 |
< |
#include "standard.h" |
16 |
> |
#include "copyright.h" |
17 |
> |
|
18 |
|
#include <ctype.h> |
13 |
– |
#include <sys/types.h> |
19 |
|
#include <sys/stat.h> |
20 |
+ |
|
21 |
+ |
#include "standard.h" |
22 |
+ |
#include "paths.h" |
23 |
|
#include "view.h" |
24 |
|
#include "vars.h" |
25 |
|
#include "netproc.h" |
26 |
+ |
/* default blur samples */ |
27 |
+ |
#ifndef DEF_NBLUR |
28 |
+ |
#define DEF_NBLUR 5 |
29 |
+ |
#endif |
30 |
|
/* default remote shell */ |
19 |
– |
#ifdef _AUX_SOURCE |
20 |
– |
#define REMSH "remsh" |
21 |
– |
#else |
31 |
|
#define REMSH "rsh" |
32 |
< |
#endif |
33 |
< |
/* input variables */ |
34 |
< |
#define HOST 0 /* rendering host machine */ |
35 |
< |
#define RENDER 1 /* rendering options */ |
36 |
< |
#define PFILT 2 /* pfilt options */ |
37 |
< |
#define PINTERP 3 /* pinterp options */ |
38 |
< |
#define OCTREE 4 /* octree file name */ |
39 |
< |
#define DIRECTORY 5 /* working (sub)directory */ |
40 |
< |
#define BASENAME 6 /* output image base name */ |
41 |
< |
#define VIEWFILE 7 /* animation frame views */ |
42 |
< |
#define START 8 /* starting frame number */ |
43 |
< |
#define END 9 /* ending frame number */ |
44 |
< |
#define RIF 10 /* rad input file */ |
45 |
< |
#define NEXTANIM 11 /* next animation file */ |
46 |
< |
#define ANIMATE 12 /* animation command */ |
47 |
< |
#define TRANSFER 13 /* frame transfer command */ |
48 |
< |
#define ARCHIVE 14 /* archiving command */ |
49 |
< |
#define INTERP 15 /* # frames to interpolate */ |
50 |
< |
#define OVERSAMP 16 /* # times to oversample image */ |
51 |
< |
#define MBLUR 17 /* samples for motion blur */ |
52 |
< |
#define RTRACE 18 /* use rtrace with pinterp? */ |
53 |
< |
#define DISKSPACE 19 /* how much disk space to use */ |
54 |
< |
#define RESOLUTION 20 /* desired final resolution */ |
55 |
< |
#define EXPOSURE 21 /* how to compute exposure */ |
47 |
< |
#define RSH 22 /* remote shell script or program */ |
32 |
> |
/* input variables (alphabetical by name) */ |
33 |
> |
#define ANIMATE 0 /* animation command */ |
34 |
> |
#define ARCHIVE 1 /* archiving command */ |
35 |
> |
#define BASENAME 2 /* output image base name */ |
36 |
> |
#define DIRECTORY 3 /* working (sub)directory */ |
37 |
> |
#define DISKSPACE 4 /* how much disk space to use */ |
38 |
> |
#define END 5 /* ending frame number */ |
39 |
> |
#define EXPOSURE 6 /* how to compute exposure */ |
40 |
> |
#define HOST 7 /* rendering host machine */ |
41 |
> |
#define INTERP 8 /* # frames to interpolate */ |
42 |
> |
#define MBLUR 9 /* motion blur parameters */ |
43 |
> |
#define NEXTANIM 10 /* next animation file */ |
44 |
> |
#define OCTREE 11 /* octree file name */ |
45 |
> |
#define OVERSAMP 12 /* # times to oversample image */ |
46 |
> |
#define PFILT 13 /* pfilt options */ |
47 |
> |
#define PINTERP 14 /* pinterp options */ |
48 |
> |
#define RENDER 15 /* rendering options */ |
49 |
> |
#define RESOLUTION 16 /* desired final resolution */ |
50 |
> |
#define RIF 17 /* rad input file */ |
51 |
> |
#define RSH 18 /* remote shell script or program */ |
52 |
> |
#define RTRACE 19 /* use rtrace with pinterp? */ |
53 |
> |
#define START 20 /* starting frame number */ |
54 |
> |
#define TRANSFER 21 /* frame transfer command */ |
55 |
> |
#define VIEWFILE 22 /* animation frame views */ |
56 |
|
|
57 |
|
int NVARS = 23; /* total number of variables */ |
58 |
|
|
59 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
52 |
– |
{"host", 4, 0, NULL, NULL}, |
53 |
– |
{"render", 3, 0, NULL, catvalues}, |
54 |
– |
{"pfilt", 2, 0, NULL, catvalues}, |
55 |
– |
{"pinterp", 2, 0, NULL, catvalues}, |
56 |
– |
{"OCTREE", 3, 0, NULL, onevalue}, |
57 |
– |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
58 |
– |
{"BASENAME", 3, 0, NULL, onevalue}, |
59 |
– |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
60 |
– |
{"START", 2, 0, NULL, intvalue}, |
61 |
– |
{"END", 2, 0, NULL, intvalue}, |
62 |
– |
{"RIF", 3, 0, NULL, onevalue}, |
63 |
– |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
60 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
65 |
– |
{"TRANSFER", 2, 0, NULL, onevalue}, |
61 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
62 |
+ |
{"BASENAME", 3, 0, NULL, onevalue}, |
63 |
+ |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
64 |
+ |
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
65 |
+ |
{"END", 2, 0, NULL, intvalue}, |
66 |
+ |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
67 |
+ |
{"host", 4, 0, NULL, NULL}, |
68 |
|
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
68 |
– |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
69 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
70 |
< |
{"RTRACE", 2, 0, NULL, boolvalue}, |
71 |
< |
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
70 |
> |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
71 |
> |
{"OCTREE", 3, 0, NULL, onevalue}, |
72 |
> |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
73 |
> |
{"pfilt", 2, 0, NULL, catvalues}, |
74 |
> |
{"pinterp", 2, 0, NULL, catvalues}, |
75 |
> |
{"render", 3, 0, NULL, catvalues}, |
76 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
77 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
77 |
> |
{"RIF", 3, 0, NULL, onevalue}, |
78 |
|
{"RSH", 3, 0, NULL, onevalue}, |
79 |
+ |
{"RTRACE", 2, 0, NULL, boolvalue}, |
80 |
+ |
{"START", 2, 0, NULL, intvalue}, |
81 |
+ |
{"TRANSFER", 2, 0, NULL, onevalue}, |
82 |
+ |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
83 |
|
}; |
84 |
|
|
85 |
|
#define SFNAME "STATUS" /* status file name */ |
101 |
|
int noaction = 0; /* take no action? */ |
102 |
|
|
103 |
|
char *remsh; /* remote shell program/script */ |
104 |
< |
char rendopt[2048] = ""; /* rendering options */ |
104 |
> |
char rendopt[2048]; /* rendering options */ |
105 |
|
char rresopt[32]; /* rendering resolution options */ |
106 |
|
char fresopt[32]; /* filter resolution options */ |
107 |
|
int pfiltalways; /* always use pfilt? */ |
123 |
|
PSERVER *lastpserver; /* last process server with error */ |
124 |
|
|
125 |
|
VIEW *getview(); |
126 |
< |
char *getexp(); |
126 |
> |
char *getexp(), *dirfile(); |
127 |
> |
int getblur(); |
128 |
|
|
129 |
< |
extern time_t fdate(), time(); |
129 |
> |
extern time_t time(); |
130 |
|
|
131 |
|
|
132 |
|
main(argc, argv) |
159 |
|
cfname = argv[i]; |
160 |
|
/* load variables */ |
161 |
|
loadvars(cfname); |
162 |
+ |
/* check variables */ |
163 |
+ |
checkvalues(); |
164 |
|
/* did we get DIRECTORY? */ |
165 |
|
checkdir(); |
166 |
|
/* check status */ |
241 |
|
} |
242 |
|
/* assume it is dead */ |
243 |
|
} |
244 |
< |
if (strcmp(cfname, astat.cfname) && astat.tnext != 0) { /* other's */ |
244 |
> |
if (strcmp(cfname, astat.cfname) && astat.pid != 0) { /* other's */ |
245 |
|
fprintf(stderr, "%s: unfinished job \"%s\"\n", |
246 |
|
progname, astat.cfname); |
247 |
|
return(-1); |
311 |
|
setdefaults() /* set default values */ |
312 |
|
{ |
313 |
|
extern char *atos(); |
314 |
+ |
int decades; |
315 |
|
char buf[256]; |
316 |
|
|
317 |
|
if (vdef(ANIMATE)) { |
345 |
|
quit(1); |
346 |
|
} |
347 |
|
if (!vdef(BASENAME)) { |
348 |
< |
sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); |
348 |
> |
decades = (int)log10((double)vint(END)) + 1; |
349 |
> |
if (decades < 3) decades = 3; |
350 |
> |
sprintf(buf, "%s/frame%%0%dd", vval(DIRECTORY), decades); |
351 |
|
vval(BASENAME) = savqstr(buf); |
352 |
|
vdef(BASENAME)++; |
353 |
|
} |
459 |
|
char combuf[256]; |
460 |
|
register int i; |
461 |
|
register char *cp; |
462 |
+ |
char *pippt; |
463 |
|
/* create rad command */ |
464 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
465 |
|
sprintf(combuf, |
466 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
467 |
|
rfargs, rendopt+2); |
468 |
|
cp = combuf; |
469 |
< |
while (*cp) cp++; /* match unset variables */ |
469 |
> |
while (*cp) { |
470 |
> |
if (*cp == '|') pippt = cp; |
471 |
> |
cp++; |
472 |
> |
} /* match unset variables */ |
473 |
|
for (i = 0; mvar[i] >= 0; i++) |
474 |
|
if (!vdef(mvar[i])) { |
475 |
|
*cp++ = '|'; |
476 |
|
strcpy(cp, vnam(mvar[i])); |
477 |
|
while (*cp) cp++; |
478 |
+ |
pippt = NULL; |
479 |
|
} |
480 |
< |
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
481 |
< |
cp += 11; /* point to file name */ |
482 |
< |
if (system(combuf)) { |
483 |
< |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
484 |
< |
progname, combuf); |
466 |
< |
quit(1); |
480 |
> |
if (pippt != NULL) |
481 |
> |
strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */ |
482 |
> |
else { |
483 |
> |
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
484 |
> |
cp += 11; /* point to file name */ |
485 |
|
} |
486 |
< |
loadvars(cp); /* load variables and remove file */ |
487 |
< |
unlink(cp); |
486 |
> |
system(combuf); /* ignore exit code */ |
487 |
> |
if (pippt == NULL) { /* load variables and remove file */ |
488 |
> |
loadvars(cp); |
489 |
> |
unlink(cp); |
490 |
> |
} |
491 |
|
} |
492 |
|
|
493 |
|
|
521 |
|
progname, vnam(INTERP)); |
522 |
|
vval(INTERP) = "0"; |
523 |
|
} |
524 |
< |
if (atoi(vval(MBLUR))) { /* can't handle this yet */ |
524 |
> |
if (strcmp(vval(MBLUR),"0")) { /* can't handle this */ |
525 |
|
if (!nowarn) |
526 |
|
fprintf(stderr, |
527 |
|
"%s: resetting %s=0 for animation\n", |
531 |
|
} |
532 |
|
/* figure # frames per batch */ |
533 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
534 |
< |
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
534 |
> |
if ((i=vint(INTERP)) || getblur(NULL) > 1) |
535 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
536 |
|
d2 = xres*yres*4; /* space for final picture */ |
537 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
541 |
|
quit(1); |
542 |
|
} |
543 |
|
/* initialize archive argument list */ |
544 |
< |
i = 16; |
524 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
525 |
< |
i = strlen(vval(ARCHIVE)); |
544 |
> |
i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132; |
545 |
|
arcnext = arcfirst = arcargs + i; |
546 |
|
/* initialize status file */ |
547 |
|
if (astat.rnext == 0) |
627 |
|
if (astat.tnext < astat.fnext) /* other work to do first */ |
628 |
|
return; |
629 |
|
/* filter each view */ |
630 |
< |
for (i = astat.fnext; i < astat.rnext; i++) { |
631 |
< |
if ((vp = getview(i)) == NULL) { /* get view i */ |
632 |
< |
fprintf(stderr, |
614 |
< |
"%s: unexpected error reading view for frame %d\n", |
615 |
< |
progname, i); |
616 |
< |
quit(1); |
617 |
< |
} |
618 |
< |
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
619 |
< |
} |
630 |
> |
for (i = astat.fnext; i < astat.rnext; i++) |
631 |
> |
dofilt(i, 0); |
632 |
> |
|
633 |
|
bwait(0); /* wait for filter processes */ |
634 |
|
archive(); /* archive originals */ |
635 |
|
astat.fnext = i; /* update status */ |
639 |
|
|
640 |
|
transferframes() /* catch up with picture transfers */ |
641 |
|
{ |
642 |
< |
char combuf[10240]; |
642 |
> |
char combuf[10240], *fbase; |
643 |
|
register char *cp; |
644 |
|
register int i; |
645 |
|
|
650 |
|
putastat(); /* update status */ |
651 |
|
return; |
652 |
|
} |
653 |
< |
strcpy(combuf, vval(TRANSFER)); /* start transfer command */ |
654 |
< |
cp = combuf + strlen(combuf); |
653 |
> |
strcpy(combuf, "cd "); /* start transfer command */ |
654 |
> |
fbase = dirfile(cp = combuf+3, vval(BASENAME)); |
655 |
> |
if (*cp) { |
656 |
> |
while (*++cp) ; |
657 |
> |
*cp++ = ';'; *cp++ = ' '; |
658 |
> |
} else |
659 |
> |
cp = combuf; |
660 |
> |
strcpy(cp, vval(TRANSFER)); |
661 |
> |
while (*cp) cp++; |
662 |
|
/* make argument list */ |
663 |
|
for (i = astat.tnext; i < astat.fnext; i++) { |
664 |
|
*cp++ = ' '; |
665 |
< |
sprintf(cp, vval(BASENAME), i); |
665 |
> |
sprintf(cp, fbase, i); |
666 |
|
while (*cp) cp++; |
667 |
|
strcpy(cp, ".pic"); |
668 |
|
cp += 4; |
699 |
|
int first, last; |
700 |
|
char *vfn; |
701 |
|
{ |
702 |
+ |
double blurf; |
703 |
+ |
int nblur = getblur(&blurf); |
704 |
|
char combuf[2048]; |
705 |
< |
char *inspoint; |
705 |
> |
register char *inspoint; |
706 |
|
register int i; |
707 |
|
|
708 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
713 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
714 |
|
} |
715 |
|
/* create command */ |
716 |
< |
sprintf(combuf, "rpict%s -w0", rendopt); |
717 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) |
718 |
< |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
719 |
< |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
716 |
> |
sprintf(combuf, "rpict%s%s -w0", rendopt, |
717 |
> |
viewopt(getview(first>1 ? first-1 : 1))); |
718 |
> |
inspoint = combuf; |
719 |
> |
while (*inspoint) inspoint++; |
720 |
> |
if (nblur) { |
721 |
> |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
722 |
> |
while (*inspoint) inspoint++; |
723 |
> |
} |
724 |
> |
if (nblur > 1 || vint(INTERP)) { |
725 |
> |
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
726 |
> |
while (*inspoint) inspoint++; |
727 |
> |
} |
728 |
> |
sprintf(inspoint, " -o %s.unf %s -S %d", |
729 |
|
vval(BASENAME), rresopt, first); |
730 |
< |
inspoint = combuf + strlen(combuf); |
730 |
> |
while (*inspoint) inspoint++; |
731 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
732 |
|
/* run in parallel */ |
733 |
|
i = (last-first+1)/(vint(INTERP)+1); |
753 |
|
{ |
754 |
|
static int *rfrm; /* list of recovered frames */ |
755 |
|
static int nrfrms = 0; |
756 |
+ |
double blurf; |
757 |
+ |
int nblur = getblur(&blurf); |
758 |
|
char combuf[2048]; |
759 |
|
char fname[128]; |
760 |
|
register char *cp; |
770 |
|
vval(ANIMATE), frame, rendopt); |
771 |
|
else |
772 |
|
sprintf(combuf, "rpict%s -w0", rendopt); |
773 |
< |
cp = combuf + strlen(combuf); |
774 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) { |
773 |
> |
cp = combuf; |
774 |
> |
while (*cp) cp++; |
775 |
> |
if (nblur) { |
776 |
> |
sprintf(cp, " -pm %.3f", blurf/nblur); |
777 |
> |
while (*cp) cp++; |
778 |
> |
} |
779 |
> |
if (nblur > 1 || vint(INTERP)) { |
780 |
|
sprintf(cp, " -z %s.zbf", fname); |
781 |
|
while (*cp) cp++; |
782 |
|
} |
790 |
|
return(1); |
791 |
|
/* add frame to recovered list */ |
792 |
|
if (nrfrms) |
793 |
< |
rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); |
793 |
> |
rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); |
794 |
|
else |
795 |
|
rfrm = (int *)malloc(sizeof(int)); |
796 |
|
if (rfrm == NULL) { |
806 |
|
frecover(frame) /* recover filtered frame */ |
807 |
|
int frame; |
808 |
|
{ |
809 |
< |
VIEW *vp; |
772 |
< |
char *ex; |
773 |
< |
|
774 |
< |
vp = getview(frame); |
775 |
< |
ex = getexp(frame); |
776 |
< |
if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) |
809 |
> |
if (dofilt(frame, 2) && dofilt(frame, 1)) |
810 |
|
return(1); |
811 |
|
return(0); |
812 |
|
} |
816 |
|
{ |
817 |
|
#define RMCOML (sizeof(rmcom)-1) |
818 |
|
static char rmcom[] = "rm -f"; |
819 |
< |
register int i; |
819 |
> |
char basedir[128]; |
820 |
> |
int dlen, alen; |
821 |
> |
register int j; |
822 |
|
|
823 |
|
if (arcnext == arcfirst) |
824 |
|
return; /* nothing to do */ |
825 |
+ |
dirfile(basedir, vval(BASENAME)); |
826 |
+ |
dlen = strlen(basedir); |
827 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
828 |
< |
i = strlen(vval(ARCHIVE)); |
829 |
< |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
830 |
< |
if (runcom(arcfirst-i)) { |
828 |
> |
alen = strlen(vval(ARCHIVE)); |
829 |
> |
if (dlen) { |
830 |
> |
j = alen + dlen + 5; |
831 |
> |
strncpy(arcfirst-j, "cd ", 3); |
832 |
> |
strncpy(arcfirst-j+3, basedir, dlen); |
833 |
> |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
834 |
> |
} else |
835 |
> |
j = alen; |
836 |
> |
strncpy(arcfirst-alen, vval(ARCHIVE), alen); |
837 |
> |
if (runcom(arcfirst-j)) { |
838 |
|
fprintf(stderr, "%s: error running archive command\n", |
839 |
|
progname); |
840 |
|
quit(1); |
841 |
|
} |
842 |
|
} |
843 |
+ |
if (dlen) { |
844 |
+ |
j = RMCOML + dlen + 5; |
845 |
+ |
strncpy(arcfirst-j, "cd ", 3); |
846 |
+ |
strncpy(arcfirst-j+3, basedir, dlen); |
847 |
+ |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
848 |
+ |
} else |
849 |
+ |
j = RMCOML; |
850 |
|
/* run remove command */ |
851 |
|
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
852 |
< |
runcom(arcfirst-RMCOML); |
852 |
> |
runcom(arcfirst-j); |
853 |
|
arcnext = arcfirst; /* reset argument list */ |
854 |
|
#undef RMCOML |
855 |
|
} |
856 |
|
|
857 |
|
|
858 |
|
int |
859 |
< |
dofilt(frame, vp, ep, rvr) /* filter frame */ |
859 |
> |
dofilt(frame, rvr) /* filter frame */ |
860 |
|
int frame; |
810 |
– |
VIEW *vp; |
811 |
– |
char *ep; |
861 |
|
int rvr; |
862 |
|
{ |
863 |
|
extern int frecover(); |
864 |
|
static int iter = 0; |
865 |
< |
char fnbefore[128], fnafter[128]; |
865 |
> |
double blurf; |
866 |
> |
int nblur = getblur(&blurf); |
867 |
> |
VIEW *vp = getview(frame); |
868 |
> |
char *ep = getexp(frame); |
869 |
> |
char fnbefore[128], fnafter[128], *fbase; |
870 |
|
char combuf[1024], fname0[128], fname1[128]; |
871 |
|
int usepinterp, usepfilt, nora_rgbe; |
872 |
|
int frseq[2]; |
873 |
|
/* check what is needed */ |
874 |
< |
usepinterp = atoi(vval(MBLUR)); |
875 |
< |
usepfilt = pfiltalways | ep==NULL; |
874 |
> |
if (vp == NULL) { |
875 |
> |
fprintf(stderr, |
876 |
> |
"%s: unexpected error reading view for frame %d\n", |
877 |
> |
progname, frame); |
878 |
> |
quit(1); |
879 |
> |
} |
880 |
> |
if (ep == NULL) { |
881 |
> |
fprintf(stderr, |
882 |
> |
"%s: unexpected error reading exposure for frame %d\n", |
883 |
> |
progname, frame); |
884 |
> |
quit(1); |
885 |
> |
} |
886 |
> |
usepinterp = (nblur > 1); |
887 |
> |
usepfilt = pfiltalways | (ep==NULL); |
888 |
|
if (ep != NULL && !strcmp(ep, "1")) |
889 |
|
ep = "+0"; |
890 |
|
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
892 |
|
/* compute rendered views */ |
893 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
894 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
895 |
+ |
fbase = dirfile(NULL, vval(BASENAME)); |
896 |
|
if (frseq[1] > vint(END)) |
897 |
|
frseq[1] = vint(END); |
898 |
|
if (frseq[1] == frame) { /* pfilt only */ |
902 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
903 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
904 |
|
*arcnext++ = ' '; |
905 |
< |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
905 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
906 |
|
while (*arcnext) arcnext++; |
907 |
|
strcpy(arcnext, ".unf"); |
908 |
|
arcnext += 4; |
909 |
|
if (usepinterp || vint(INTERP)) { /* and Z-buf */ |
910 |
|
*arcnext++ = ' '; |
911 |
< |
sprintf(arcnext, vval(BASENAME), |
846 |
< |
frame-vint(INTERP)-1); |
911 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
912 |
|
while (*arcnext) arcnext++; |
913 |
|
strcpy(arcnext, ".zbf"); |
914 |
|
arcnext += 4; |
928 |
|
if (usepinterp) { /* using pinterp */ |
929 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
930 |
|
return(1); |
931 |
< |
if (atoi(vval(MBLUR))) { |
867 |
< |
FILE *fp; /* motion blurring */ |
931 |
> |
if (nblur > 1) { /* with pmblur */ |
932 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
933 |
|
'a'+(iter%26)); |
870 |
– |
if ((fp = fopen(fname0, "w")) == NULL) { |
871 |
– |
perror(fname0); quit(1); |
872 |
– |
} |
873 |
– |
fputs(VIEWSTR, fp); |
874 |
– |
fprintview(vp, fp); |
875 |
– |
putc('\n', fp); fclose(fp); |
876 |
– |
if ((vp = getview(frame+1)) == NULL) { |
877 |
– |
fprintf(stderr, |
878 |
– |
"%s: unexpected error reading view for frame %d\n", |
879 |
– |
progname, frame+1); |
880 |
– |
quit(1); |
881 |
– |
} |
934 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
935 |
|
'a'+(iter%26)); |
936 |
< |
if ((fp = fopen(fname1, "w")) == NULL) { |
937 |
< |
perror(fname1); quit(1); |
936 |
> |
if (!noaction) { |
937 |
> |
FILE *fp; /* motion blurring */ |
938 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
939 |
> |
perror(fname0); quit(1); |
940 |
> |
} |
941 |
> |
fputs(VIEWSTR, fp); |
942 |
> |
fprintview(vp, fp); |
943 |
> |
putc('\n', fp); fclose(fp); |
944 |
> |
if ((vp = getview(frame+1)) == NULL) { |
945 |
> |
fprintf(stderr, |
946 |
> |
"%s: unexpected error reading view for frame %d\n", |
947 |
> |
progname, frame+1); |
948 |
> |
quit(1); |
949 |
> |
} |
950 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
951 |
> |
perror(fname1); quit(1); |
952 |
> |
} |
953 |
> |
fputs(VIEWSTR, fp); |
954 |
> |
fprintview(vp, fp); |
955 |
> |
putc('\n', fp); fclose(fp); |
956 |
|
} |
887 |
– |
fputs(VIEWSTR, fp); |
888 |
– |
fprintview(vp, fp); |
889 |
– |
putc('\n', fp); fclose(fp); |
957 |
|
sprintf(combuf, |
958 |
< |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
959 |
< |
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
893 |
< |
atoi(vval(MBLUR)), |
958 |
> |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
959 |
> |
blurf, nblur, |
960 |
|
fname0, fname1, fname0, fname1); |
961 |
|
iter++; |
962 |
|
} else /* no blurring */ |
964 |
|
strcat(combuf, viewopt(vp)); |
965 |
|
if (vbool(RTRACE)) |
966 |
|
sprintf(combuf+strlen(combuf), " -ff -fr '%s -w0 %s'", |
967 |
< |
rendopt, vval(OCTREE)); |
967 |
> |
rendopt+1, vval(OCTREE)); |
968 |
|
if (vdef(PINTERP)) |
969 |
|
sprintf(combuf+strlen(combuf), " %s", vval(PINTERP)); |
970 |
|
if (usepfilt) |
971 |
|
sprintf(combuf+strlen(combuf), " %s", rresopt); |
972 |
|
else |
973 |
< |
sprintf(combuf+strlen(combuf), " %s -e %s", |
973 |
> |
sprintf(combuf+strlen(combuf), " -a %s -e %s", |
974 |
|
fresopt, ep); |
975 |
|
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", |
976 |
|
fnbefore, fnbefore); |
1031 |
|
fclose(viewfp); |
1032 |
|
viewfp = NULL; |
1033 |
|
viewnum = 0; |
1034 |
< |
copystruct(&curview, &stdview); |
1034 |
> |
curview = stdview; |
1035 |
|
} |
1036 |
|
return(NULL); |
1037 |
|
} |
1038 |
< |
if (viewfp == NULL) { /* open file */ |
1038 |
> |
if (viewfp == NULL) { /* open file */ |
1039 |
|
if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) { |
1040 |
|
perror(vval(VIEWFILE)); |
1041 |
|
quit(1); |
1042 |
|
} |
1043 |
< |
} else if (n < viewnum) { /* rewind file */ |
1043 |
> |
} else if (n > 0 && n < viewnum) { /* rewind file */ |
1044 |
|
if (viewnum == 1 && feof(viewfp)) |
1045 |
|
return(&curview); /* just one view */ |
1046 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
1047 |
|
perror(vval(VIEWFILE)); |
1048 |
|
quit(1); |
1049 |
|
} |
1050 |
< |
copystruct(&curview, &stdview); |
1050 |
> |
curview = stdview; |
1051 |
|
viewnum = 0; |
1052 |
|
} |
1053 |
+ |
if (n < 0) { /* get next view */ |
1054 |
+ |
register int c = getc(viewfp); |
1055 |
+ |
if (c == EOF) |
1056 |
+ |
return((VIEW *)NULL); /* that's it */ |
1057 |
+ |
ungetc(c, viewfp); |
1058 |
+ |
n = viewnum + 1; |
1059 |
+ |
} |
1060 |
|
while (n > viewnum) { /* scan to desired view */ |
1061 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
1062 |
|
return(viewnum==1 ? &curview : (VIEW *)NULL); |
1070 |
|
int |
1071 |
|
countviews() /* count views in view file */ |
1072 |
|
{ |
1073 |
< |
register int n = 0; |
1073 |
> |
int n; |
1074 |
|
|
1075 |
< |
while (getview(n+1) != NULL) |
1075 |
> |
if (getview(n=1) == NULL) |
1076 |
> |
return(0); |
1077 |
> |
while (getview(-1) != NULL) |
1078 |
|
n++; |
1079 |
|
return(n); |
1080 |
|
} |
1094 |
|
if (n == 0) { /* signal to close file */ |
1095 |
|
if (expfp != NULL) { |
1096 |
|
fclose(expfp); |
1097 |
< |
free((char *)exppos); |
1097 |
> |
free((void *)exppos); |
1098 |
|
expfp = NULL; |
1099 |
|
} |
1100 |
|
return(NULL); |
1299 |
|
strcpy(com1=buf, com); /* build -PP command */ |
1300 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1301 |
|
vval(DIRECTORY), phostname(ps)); |
1302 |
+ |
unlink(com1+(ppins-com)+5); |
1303 |
|
strcat(com1, ppins); |
1304 |
|
} else |
1305 |
|
com1 = com; |
1360 |
|
char *fn; |
1361 |
|
{ |
1362 |
|
if (!silent) |
1363 |
< |
#ifdef MSDOS |
1363 |
> |
#ifdef _WIN32 |
1364 |
|
printf("\tdel %s\n", fn); |
1365 |
|
#else |
1366 |
|
printf("\trm -f %s\n", fn); |
1377 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1378 |
|
progname, vnam(vc)); |
1379 |
|
quit(1); |
1380 |
+ |
} |
1381 |
+ |
|
1382 |
+ |
|
1383 |
+ |
char * |
1384 |
+ |
dirfile(df, path) /* separate path into directory and file */ |
1385 |
+ |
char *df; |
1386 |
+ |
register char *path; |
1387 |
+ |
{ |
1388 |
+ |
register int i; |
1389 |
+ |
int psep; |
1390 |
+ |
|
1391 |
+ |
for (i = 0, psep = -1; path[i]; i++) |
1392 |
+ |
if (path[i] == '/') |
1393 |
+ |
psep = i; |
1394 |
+ |
if (df != NULL) { |
1395 |
+ |
if (psep == 0) { |
1396 |
+ |
df[0] = '/'; |
1397 |
+ |
df[1] = '\0'; |
1398 |
+ |
} else if (psep > 0) { |
1399 |
+ |
strncpy(df, path, psep); |
1400 |
+ |
df[psep] = '\0'; |
1401 |
+ |
} else |
1402 |
+ |
df[0] = '\0'; |
1403 |
+ |
} |
1404 |
+ |
return(path+psep+1); |
1405 |
+ |
} |
1406 |
+ |
|
1407 |
+ |
|
1408 |
+ |
int |
1409 |
+ |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1410 |
+ |
{ |
1411 |
+ |
double blurf; |
1412 |
+ |
int nblur; |
1413 |
+ |
char *s; |
1414 |
+ |
|
1415 |
+ |
if (!vdef(MBLUR)) { |
1416 |
+ |
if (bf != NULL) |
1417 |
+ |
*bf = 0.0; |
1418 |
+ |
return(0); |
1419 |
+ |
} |
1420 |
+ |
blurf = atof(vval(MBLUR)); |
1421 |
+ |
if (blurf < 0.0) |
1422 |
+ |
blurf = 0.0; |
1423 |
+ |
if (bf != NULL) |
1424 |
+ |
*bf = blurf; |
1425 |
+ |
if (blurf <= FTINY) |
1426 |
+ |
return(0); |
1427 |
+ |
s = sskip(vval(MBLUR)); |
1428 |
+ |
if (!*s) |
1429 |
+ |
return(DEF_NBLUR); |
1430 |
+ |
nblur = atoi(s); |
1431 |
+ |
if (nblur <= 0) |
1432 |
+ |
return(1); |
1433 |
+ |
return(nblur); |
1434 |
|
} |