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 <stdio.h> |
19 |
|
#include <ctype.h> |
13 |
– |
#include <sys/types.h> |
20 |
|
#include <sys/stat.h> |
21 |
+ |
#include <time.h> |
22 |
+ |
#include <signal.h> |
23 |
+ |
|
24 |
+ |
#include "platform.h" |
25 |
+ |
#include "rtprocess.h" |
26 |
+ |
#include "standard.h" |
27 |
|
#include "view.h" |
28 |
|
#include "vars.h" |
29 |
|
#include "netproc.h" |
30 |
+ |
/* default blur samples */ |
31 |
+ |
#ifndef DEF_NBLUR |
32 |
+ |
#define DEF_NBLUR 5 |
33 |
+ |
#endif |
34 |
|
/* default remote shell */ |
35 |
< |
#ifdef _AUX_SOURCE |
36 |
< |
#define REMSH "remsh" |
21 |
< |
#else |
22 |
< |
#define REMSH "rsh" |
35 |
> |
#ifndef REMSH |
36 |
> |
#define REMSH "ssh" |
37 |
|
#endif |
38 |
|
/* input variables (alphabetical by name) */ |
39 |
|
#define ANIMATE 0 /* animation command */ |
40 |
|
#define ARCHIVE 1 /* archiving command */ |
41 |
|
#define BASENAME 2 /* output image base name */ |
42 |
< |
#define DIRECTORY 3 /* working (sub)directory */ |
43 |
< |
#define DISKSPACE 4 /* how much disk space to use */ |
44 |
< |
#define END 5 /* ending frame number */ |
45 |
< |
#define EXPOSURE 6 /* how to compute exposure */ |
46 |
< |
#define HOST 7 /* rendering host machine */ |
47 |
< |
#define INTERP 8 /* # frames to interpolate */ |
48 |
< |
#define MBLUR 9 /* samples for motion blur */ |
49 |
< |
#define NEXTANIM 10 /* next animation file */ |
50 |
< |
#define OCTREE 11 /* octree file name */ |
51 |
< |
#define OVERSAMP 12 /* # times to oversample image */ |
52 |
< |
#define PFILT 13 /* pfilt options */ |
53 |
< |
#define PINTERP 14 /* pinterp options */ |
54 |
< |
#define RENDER 15 /* rendering options */ |
55 |
< |
#define RESOLUTION 16 /* desired final resolution */ |
56 |
< |
#define RIF 17 /* rad input file */ |
57 |
< |
#define RSH 18 /* remote shell script or program */ |
58 |
< |
#define RTRACE 19 /* use rtrace with pinterp? */ |
59 |
< |
#define START 20 /* starting frame number */ |
60 |
< |
#define TRANSFER 21 /* frame transfer command */ |
61 |
< |
#define VIEWFILE 22 /* animation frame views */ |
42 |
> |
#define DBLUR 3 /* depth of field blur */ |
43 |
> |
#define DIRECTORY 4 /* working (sub)directory */ |
44 |
> |
#define DISKSPACE 5 /* how much disk space to use */ |
45 |
> |
#define END 6 /* ending frame number */ |
46 |
> |
#define EXPOSURE 7 /* how to compute exposure */ |
47 |
> |
#define HOST 8 /* rendering host machine */ |
48 |
> |
#define INTERP 9 /* # frames to interpolate */ |
49 |
> |
#define MBLUR 10 /* motion blur parameters */ |
50 |
> |
#define NEXTANIM 11 /* next animation file */ |
51 |
> |
#define OCTREE 12 /* octree file name */ |
52 |
> |
#define OVERSAMP 13 /* # times to oversample image */ |
53 |
> |
#define PFILT 14 /* pfilt options */ |
54 |
> |
#define PINTERP 15 /* pinterp options */ |
55 |
> |
#define RENDER 16 /* rendering options */ |
56 |
> |
#define RESOLUTION 17 /* desired final resolution */ |
57 |
> |
#define RIF 18 /* rad input file */ |
58 |
> |
#define RSH 19 /* remote shell script or program */ |
59 |
> |
#define RTRACE 20 /* use rtrace with pinterp? */ |
60 |
> |
#define START 21 /* starting frame number */ |
61 |
> |
#define TRANSFER 22 /* frame transfer command */ |
62 |
> |
#define VIEWFILE 23 /* animation frame views */ |
63 |
|
|
64 |
< |
int NVARS = 23; /* total number of variables */ |
64 |
> |
int NVARS = 24; /* total number of variables */ |
65 |
|
|
66 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
67 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
68 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
69 |
< |
{"BASENAME", 3, 0, NULL, onevalue}, |
70 |
< |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
69 |
> |
{"BASENAME", 3, 0, NULL, strvalue}, |
70 |
> |
{"DBLUR", 2, 0, NULL, onevalue}, |
71 |
> |
{"DIRECTORY", 3, 0, NULL, strvalue}, |
72 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
73 |
|
{"END", 2, 0, NULL, intvalue}, |
74 |
|
{"EXPOSURE", 3, 0, NULL, onevalue}, |
75 |
|
{"host", 4, 0, NULL, NULL}, |
76 |
|
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
77 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
78 |
< |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
79 |
< |
{"OCTREE", 3, 0, NULL, onevalue}, |
78 |
> |
{"NEXTANIM", 3, 0, NULL, strvalue}, |
79 |
> |
{"OCTREE", 3, 0, NULL, strvalue}, |
80 |
|
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
81 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
82 |
|
{"pinterp", 2, 0, NULL, catvalues}, |
83 |
|
{"render", 3, 0, NULL, catvalues}, |
84 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
85 |
< |
{"RIF", 3, 0, NULL, onevalue}, |
85 |
> |
{"RIF", 3, 0, NULL, strvalue}, |
86 |
|
{"RSH", 3, 0, NULL, onevalue}, |
87 |
|
{"RTRACE", 2, 0, NULL, boolvalue}, |
88 |
|
{"START", 2, 0, NULL, intvalue}, |
89 |
|
{"TRANSFER", 2, 0, NULL, onevalue}, |
90 |
< |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
90 |
> |
{"VIEWFILE", 2, 0, NULL, strvalue}, |
91 |
|
}; |
92 |
|
|
93 |
|
#define SFNAME "STATUS" /* status file name */ |
94 |
|
|
95 |
|
struct { |
96 |
|
char host[64]; /* control host name */ |
97 |
< |
int pid; /* control process id */ |
97 |
> |
RT_PID pid; /* control process id */ |
98 |
|
char cfname[128]; /* control file name */ |
99 |
|
int rnext; /* next frame to render */ |
100 |
|
int fnext; /* next frame to filter */ |
101 |
|
int tnext; /* next frame to transfer */ |
102 |
|
} astat; /* animation status */ |
103 |
|
|
88 |
– |
char *progname; /* our program name */ |
104 |
|
char *cfname; /* our control file name */ |
105 |
|
|
106 |
|
int nowarn = 0; /* turn warnings off? */ |
117 |
|
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
118 |
|
|
119 |
|
struct pslot { |
120 |
< |
int pid; /* process ID (0 if empty) */ |
120 |
> |
RT_PID pid; /* process ID (0 if empty) */ |
121 |
|
int fout; /* output frame number */ |
122 |
|
int (*rcvf)(); /* recover function */ |
123 |
|
} *pslot; /* process slots */ |
124 |
|
int npslots; /* number of process slots */ |
125 |
|
|
126 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
112 |
– |
|
113 |
– |
struct pslot *findpslot(); |
114 |
– |
|
127 |
|
PSERVER *lastpserver; /* last process server with error */ |
128 |
|
|
129 |
< |
VIEW *getview(); |
130 |
< |
char *getexp(), *dirfile(); |
129 |
> |
static struct pslot * findpslot(RT_PID pid); |
130 |
> |
static void checkdir(void); |
131 |
> |
static VIEW * getview(int n); |
132 |
|
|
133 |
< |
extern time_t fdate(), time(); |
133 |
> |
static char * dirfile(char *df, register char *path); |
134 |
> |
static char * getexp(int n); |
135 |
> |
static int getblur(double *mbf, double *dbf); |
136 |
> |
static int getastat(void); |
137 |
> |
static void getradfile(char *rfargs); |
138 |
> |
static void badvalue(int vc); |
139 |
> |
static int rmfile(char *fn); |
140 |
> |
static int runcom(char *cs); |
141 |
> |
static int pruncom(char *com, char *ppins, int maxcopies); |
142 |
> |
static void bwait(int ncoms); |
143 |
> |
static RT_PID bruncom(char *com, int fout, int (*rf)()); |
144 |
> |
static int serverdown(void); |
145 |
> |
static pscompfunc donecom; |
146 |
> |
static int countviews(void); |
147 |
> |
static int dofilt(int frame, int rvr); |
148 |
> |
static void archive(void); |
149 |
> |
static int frecover(int frame); |
150 |
> |
static int recover(int frame); |
151 |
> |
static void sethosts(void); |
152 |
> |
static void walkwait(int first, int last, char *vfn); |
153 |
> |
static void animrend(int frame, VIEW *vp); |
154 |
> |
static void transferframes(void); |
155 |
> |
static void filterframes(void); |
156 |
> |
static void renderframes(int nframes); |
157 |
> |
static void animate(void); |
158 |
> |
static void setdefaults(void); |
159 |
> |
static void putastat(void); |
160 |
|
|
161 |
|
|
162 |
< |
main(argc, argv) |
163 |
< |
int argc; |
164 |
< |
char *argv[]; |
162 |
> |
int |
163 |
> |
main( |
164 |
> |
int argc, |
165 |
> |
char *argv[] |
166 |
> |
) |
167 |
|
{ |
168 |
|
int explicate = 0; |
169 |
|
int i; |
170 |
< |
|
171 |
< |
progname = argv[0]; /* get arguments */ |
170 |
> |
/* set global progname */ |
171 |
> |
fixargv0(argv[0]); |
172 |
> |
/* get arguments */ |
173 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
174 |
|
switch (argv[i][1]) { |
175 |
|
case 'e': /* print variables */ |
217 |
|
animate(); |
218 |
|
/* all done */ |
219 |
|
if (vdef(NEXTANIM)) { |
220 |
+ |
char *fullp; |
221 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
222 |
|
if (!silent) |
223 |
|
printargs(argc, argv, stdout); |
224 |
< |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
225 |
< |
fprintf(stderr, "%s: command not found\n", progname); |
224 |
> |
fflush(stdout); |
225 |
> |
if ((fullp = getpath(argv[0],getenv("PATH"),X_OK)) == NULL) |
226 |
> |
fprintf(stderr, "%s: command not found\n", argv[0]); |
227 |
|
else |
228 |
< |
execv(progname, argv); |
228 |
> |
execv(fullp, argv); |
229 |
|
quit(1); |
230 |
|
} |
231 |
|
quit(0); |
232 |
+ |
return(0); /* pro forma return */ |
233 |
|
userr: |
234 |
|
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname); |
235 |
|
quit(1); |
236 |
+ |
return 1; /* pro forma return */ |
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
< |
getastat() /* check/set animation status */ |
240 |
> |
static int |
241 |
> |
getastat(void) /* check/set animation status */ |
242 |
|
{ |
243 |
|
char sfname[256]; |
244 |
|
FILE *fp; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
< |
putastat() /* put out current status */ |
305 |
> |
static void |
306 |
> |
putastat(void) /* put out current status */ |
307 |
|
{ |
308 |
|
char buf[256]; |
309 |
|
FILE *fp; |
325 |
|
} |
326 |
|
|
327 |
|
|
328 |
< |
checkdir() /* make sure we have our directory */ |
328 |
> |
static void |
329 |
> |
checkdir(void) /* make sure we have our directory */ |
330 |
|
{ |
331 |
|
struct stat stb; |
332 |
|
|
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
< |
setdefaults() /* set default values */ |
351 |
> |
static void |
352 |
> |
setdefaults(void) /* set default values */ |
353 |
|
{ |
354 |
|
extern char *atos(); |
355 |
|
int decades; |
415 |
|
if (!vdef(DISKSPACE)) { |
416 |
|
if (!nowarn) |
417 |
|
fprintf(stderr, |
418 |
< |
"%s: warning - no %s setting, assuming 100 Mbytes available\n", |
418 |
> |
"%s: warning - no %s setting, assuming 1000 Mbytes available\n", |
419 |
|
progname, vnam(DISKSPACE)); |
420 |
< |
vval(DISKSPACE) = "100"; |
420 |
> |
vval(DISKSPACE) = "1000"; |
421 |
|
vdef(DISKSPACE)++; |
422 |
|
} |
423 |
|
if (!vdef(RSH)) { |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
< |
sethosts() /* set up process servers */ |
440 |
> |
static void |
441 |
> |
sethosts(void) /* set up process servers */ |
442 |
|
{ |
443 |
|
extern char *iskip(); |
444 |
|
char buf[256], *dir, *uname; |
493 |
|
} |
494 |
|
} |
495 |
|
|
496 |
< |
|
497 |
< |
getradfile(rfargs) /* run rad and get needed variables */ |
447 |
< |
char *rfargs; |
496 |
> |
static void |
497 |
> |
getradfile(char *rfargs) /* run rad and get needed variables */ |
498 |
|
{ |
499 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
500 |
|
char combuf[256]; |
501 |
|
register int i; |
502 |
|
register char *cp; |
503 |
< |
char *pippt; |
503 |
> |
char *pippt = NULL; |
504 |
|
/* create rad command */ |
505 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
506 |
|
sprintf(combuf, |
519 |
|
pippt = NULL; |
520 |
|
} |
521 |
|
if (pippt != NULL) |
522 |
< |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
522 |
> |
strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */ |
523 |
|
else { |
524 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
525 |
|
cp += 11; /* point to file name */ |
526 |
|
} |
527 |
< |
if (system(combuf)) { |
478 |
< |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
479 |
< |
progname, combuf); |
480 |
< |
quit(1); |
481 |
< |
} |
527 |
> |
system(combuf); /* ignore exit code */ |
528 |
|
if (pippt == NULL) { /* load variables and remove file */ |
529 |
|
loadvars(cp); |
530 |
|
unlink(cp); |
532 |
|
} |
533 |
|
|
534 |
|
|
535 |
< |
animate() /* run animation */ |
535 |
> |
static void |
536 |
> |
animate(void) /* run animation */ |
537 |
|
{ |
538 |
|
int xres, yres; |
539 |
|
float pa, mult; |
563 |
|
progname, vnam(INTERP)); |
564 |
|
vval(INTERP) = "0"; |
565 |
|
} |
566 |
< |
if (atoi(vval(MBLUR))) { /* can't handle this yet */ |
566 |
> |
if (strcmp(vval(MBLUR),"0")) { /* can't handle this */ |
567 |
|
if (!nowarn) |
568 |
|
fprintf(stderr, |
569 |
|
"%s: resetting %s=0 for animation\n", |
573 |
|
} |
574 |
|
/* figure # frames per batch */ |
575 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
576 |
< |
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
576 |
> |
if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1) |
577 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
578 |
|
d2 = xres*yres*4; /* space for final picture */ |
579 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
604 |
|
} |
605 |
|
|
606 |
|
|
607 |
< |
renderframes(nframes) /* render next nframes frames */ |
608 |
< |
int nframes; |
607 |
> |
static void |
608 |
> |
renderframes(int nframes) /* render next nframes frames */ |
609 |
|
{ |
610 |
|
static char vendbuf[16]; |
611 |
|
VIEW *vp; |
661 |
|
} |
662 |
|
|
663 |
|
|
664 |
< |
filterframes() /* catch up with filtering */ |
664 |
> |
static void |
665 |
> |
filterframes(void) /* catch up with filtering */ |
666 |
|
{ |
619 |
– |
VIEW *vp; |
667 |
|
register int i; |
668 |
|
|
669 |
|
if (astat.tnext < astat.fnext) /* other work to do first */ |
670 |
|
return; |
671 |
|
/* filter each view */ |
672 |
< |
for (i = astat.fnext; i < astat.rnext; i++) { |
673 |
< |
if ((vp = getview(i)) == NULL) { /* get view i */ |
674 |
< |
fprintf(stderr, |
628 |
< |
"%s: unexpected error reading view for frame %d\n", |
629 |
< |
progname, i); |
630 |
< |
quit(1); |
631 |
< |
} |
632 |
< |
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
633 |
< |
} |
672 |
> |
for (i = astat.fnext; i < astat.rnext; i++) |
673 |
> |
dofilt(i, 0); |
674 |
> |
|
675 |
|
bwait(0); /* wait for filter processes */ |
676 |
|
archive(); /* archive originals */ |
677 |
|
astat.fnext = i; /* update status */ |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
< |
transferframes() /* catch up with picture transfers */ |
682 |
> |
static void |
683 |
> |
transferframes(void) /* catch up with picture transfers */ |
684 |
|
{ |
685 |
|
char combuf[10240], *fbase; |
686 |
|
register char *cp; |
707 |
|
*cp++ = ' '; |
708 |
|
sprintf(cp, fbase, i); |
709 |
|
while (*cp) cp++; |
710 |
< |
strcpy(cp, ".pic"); |
710 |
> |
strcpy(cp, ".hdr"); |
711 |
|
cp += 4; |
712 |
|
} |
713 |
|
if (runcom(combuf)) { /* transfer frames */ |
720 |
|
} |
721 |
|
|
722 |
|
|
723 |
< |
animrend(frame, vp) /* start animation frame */ |
724 |
< |
int frame; |
725 |
< |
VIEW *vp; |
723 |
> |
static void |
724 |
> |
animrend( /* start animation frame */ |
725 |
> |
int frame, |
726 |
> |
VIEW *vp |
727 |
> |
) |
728 |
|
{ |
685 |
– |
extern int recover(); |
729 |
|
char combuf[2048]; |
730 |
|
char fname[128]; |
731 |
|
|
739 |
|
} |
740 |
|
|
741 |
|
|
742 |
< |
walkwait(first, last, vfn) /* walk-through frames */ |
743 |
< |
int first, last; |
744 |
< |
char *vfn; |
742 |
> |
static void |
743 |
> |
walkwait( /* walk-through frames */ |
744 |
> |
int first, |
745 |
> |
int last, |
746 |
> |
char *vfn |
747 |
> |
) |
748 |
|
{ |
749 |
+ |
double mblurf, dblurf; |
750 |
+ |
int nblur = getblur(&mblurf, &dblurf); |
751 |
|
char combuf[2048]; |
752 |
< |
char *inspoint; |
752 |
> |
register char *inspoint; |
753 |
|
register int i; |
754 |
|
|
755 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
762 |
|
/* create command */ |
763 |
|
sprintf(combuf, "rpict%s%s -w0", rendopt, |
764 |
|
viewopt(getview(first>1 ? first-1 : 1))); |
765 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) |
766 |
< |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
767 |
< |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
765 |
> |
inspoint = combuf; |
766 |
> |
while (*inspoint) inspoint++; |
767 |
> |
if (nblur) { |
768 |
> |
sprintf(inspoint, " -pm %.3f", mblurf/nblur); |
769 |
> |
while (*inspoint) inspoint++; |
770 |
> |
sprintf(inspoint, " -pd %.3f", dblurf/nblur); |
771 |
> |
while (*inspoint) inspoint++; |
772 |
> |
} |
773 |
> |
if (nblur > 1 || vint(INTERP)) { |
774 |
> |
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
775 |
> |
while (*inspoint) inspoint++; |
776 |
> |
} |
777 |
> |
sprintf(inspoint, " -o %s.unf %s -S %d", |
778 |
|
vval(BASENAME), rresopt, first); |
779 |
< |
inspoint = combuf + strlen(combuf); |
779 |
> |
while (*inspoint) inspoint++; |
780 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
781 |
|
/* run in parallel */ |
782 |
|
i = (last-first+1)/(vint(INTERP)+1); |
796 |
|
} |
797 |
|
|
798 |
|
|
799 |
< |
int |
800 |
< |
recover(frame) /* recover the specified frame */ |
743 |
< |
int frame; |
799 |
> |
static int |
800 |
> |
recover(int frame) /* recover the specified frame */ |
801 |
|
{ |
802 |
|
static int *rfrm; /* list of recovered frames */ |
803 |
|
static int nrfrms = 0; |
804 |
+ |
double mblurf, dblurf; |
805 |
+ |
int nblur = getblur(&mblurf, &dblurf); |
806 |
|
char combuf[2048]; |
807 |
|
char fname[128]; |
808 |
|
register char *cp; |
818 |
|
vval(ANIMATE), frame, rendopt); |
819 |
|
else |
820 |
|
sprintf(combuf, "rpict%s -w0", rendopt); |
821 |
< |
cp = combuf + strlen(combuf); |
822 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) { |
821 |
> |
cp = combuf; |
822 |
> |
while (*cp) cp++; |
823 |
> |
if (nblur) { |
824 |
> |
sprintf(cp, " -pm %.3f", mblurf/nblur); |
825 |
> |
while (*cp) cp++; |
826 |
> |
sprintf(cp, " -pd %.3f", dblurf/nblur); |
827 |
> |
while (*cp) cp++; |
828 |
> |
} |
829 |
> |
if (nblur > 1 || vint(INTERP)) { |
830 |
|
sprintf(cp, " -z %s.zbf", fname); |
831 |
|
while (*cp) cp++; |
832 |
|
} |
840 |
|
return(1); |
841 |
|
/* add frame to recovered list */ |
842 |
|
if (nrfrms) |
843 |
< |
rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); |
843 |
> |
rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); |
844 |
|
else |
845 |
|
rfrm = (int *)malloc(sizeof(int)); |
846 |
|
if (rfrm == NULL) { |
852 |
|
} |
853 |
|
|
854 |
|
|
855 |
< |
int |
856 |
< |
frecover(frame) /* recover filtered frame */ |
791 |
< |
int frame; |
855 |
> |
static int |
856 |
> |
frecover(int frame) /* recover filtered frame */ |
857 |
|
{ |
858 |
< |
VIEW *vp; |
794 |
< |
char *ex; |
795 |
< |
|
796 |
< |
vp = getview(frame); |
797 |
< |
ex = getexp(frame); |
798 |
< |
if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) |
858 |
> |
if (dofilt(frame, 2) && dofilt(frame, 1)) |
859 |
|
return(1); |
860 |
|
return(0); |
861 |
|
} |
862 |
|
|
863 |
|
|
864 |
< |
archive() /* archive and remove renderings */ |
864 |
> |
static void |
865 |
> |
archive(void) /* archive and remove renderings */ |
866 |
|
{ |
867 |
|
#define RMCOML (sizeof(rmcom)-1) |
868 |
|
static char rmcom[] = "rm -f"; |
905 |
|
} |
906 |
|
|
907 |
|
|
908 |
< |
int |
909 |
< |
dofilt(frame, vp, ep, rvr) /* filter frame */ |
910 |
< |
int frame; |
911 |
< |
VIEW *vp; |
912 |
< |
char *ep; |
852 |
< |
int rvr; |
908 |
> |
static int |
909 |
> |
dofilt( /* filter frame */ |
910 |
> |
int frame, |
911 |
> |
int rvr |
912 |
> |
) |
913 |
|
{ |
854 |
– |
extern int frecover(); |
914 |
|
static int iter = 0; |
915 |
+ |
double mblurf, dblurf; |
916 |
+ |
int nblur = getblur(&mblurf, &dblurf); |
917 |
+ |
VIEW *vp = getview(frame); |
918 |
+ |
char *ep = getexp(frame); |
919 |
|
char fnbefore[128], fnafter[128], *fbase; |
920 |
|
char combuf[1024], fname0[128], fname1[128]; |
921 |
|
int usepinterp, usepfilt, nora_rgbe; |
922 |
|
int frseq[2]; |
923 |
|
/* check what is needed */ |
924 |
< |
usepinterp = atoi(vval(MBLUR)); |
925 |
< |
usepfilt = pfiltalways | ep==NULL; |
924 |
> |
if (vp == NULL) { |
925 |
> |
fprintf(stderr, |
926 |
> |
"%s: unexpected error reading view for frame %d\n", |
927 |
> |
progname, frame); |
928 |
> |
quit(1); |
929 |
> |
} |
930 |
> |
usepinterp = (nblur > 1); |
931 |
> |
usepfilt = pfiltalways | (ep==NULL); |
932 |
|
if (ep != NULL && !strcmp(ep, "1")) |
933 |
|
ep = "+0"; |
934 |
|
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
945 |
|
usepfilt |= nora_rgbe; |
946 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
947 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
948 |
+ |
if (arcnext - arcargs + |
949 |
+ |
strlen(fbase) >= sizeof(arcargs)-8) { |
950 |
+ |
fprintf(stderr, |
951 |
+ |
"%s: too many filenames in archive command -- reduce %s variable\n", |
952 |
+ |
progname, vnam(DISKSPACE)); |
953 |
+ |
quit(1); |
954 |
+ |
} |
955 |
|
*arcnext++ = ' '; |
956 |
|
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
957 |
|
while (*arcnext) arcnext++; |
979 |
|
if (usepinterp) { /* using pinterp */ |
980 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
981 |
|
return(1); |
982 |
< |
if (atoi(vval(MBLUR))) { |
982 |
> |
if (nblur > 1) { /* with pdmblur */ |
983 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
984 |
|
'a'+(iter%26)); |
985 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
1006 |
|
putc('\n', fp); fclose(fp); |
1007 |
|
} |
1008 |
|
sprintf(combuf, |
1009 |
< |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
1010 |
< |
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
935 |
< |
atoi(vval(MBLUR)), |
1009 |
> |
"(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
1010 |
> |
mblurf, dblurf, nblur, |
1011 |
|
fname0, fname1, fname0, fname1); |
1012 |
|
iter++; |
1013 |
|
} else /* no blurring */ |
1021 |
|
if (usepfilt) |
1022 |
|
sprintf(combuf+strlen(combuf), " %s", rresopt); |
1023 |
|
else |
1024 |
< |
sprintf(combuf+strlen(combuf), " %s -e %s", |
1024 |
> |
sprintf(combuf+strlen(combuf), " -a %s -e %s", |
1025 |
|
fresopt, ep); |
1026 |
|
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", |
1027 |
|
fnbefore, fnbefore); |
1060 |
|
} |
1061 |
|
/* output file name */ |
1062 |
|
sprintf(fname0, vval(BASENAME), frame); |
1063 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
1063 |
> |
sprintf(combuf+strlen(combuf), " > %s.hdr", fname0); |
1064 |
|
if (rvr) /* in recovery */ |
1065 |
|
return(runcom(combuf)); |
1066 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
1068 |
|
} |
1069 |
|
|
1070 |
|
|
1071 |
< |
VIEW * |
1072 |
< |
getview(n) /* get view number n */ |
998 |
< |
int n; |
1071 |
> |
static VIEW * |
1072 |
> |
getview(int n) /* get view number n */ |
1073 |
|
{ |
1074 |
|
static FILE *viewfp = NULL; /* view file pointer */ |
1075 |
|
static int viewnum = 0; /* current view number */ |
1081 |
|
fclose(viewfp); |
1082 |
|
viewfp = NULL; |
1083 |
|
viewnum = 0; |
1084 |
< |
copystruct(&curview, &stdview); |
1084 |
> |
curview = stdview; |
1085 |
|
} |
1086 |
|
return(NULL); |
1087 |
|
} |
1097 |
|
perror(vval(VIEWFILE)); |
1098 |
|
quit(1); |
1099 |
|
} |
1100 |
< |
copystruct(&curview, &stdview); |
1100 |
> |
curview = stdview; |
1101 |
|
viewnum = 0; |
1102 |
|
} |
1103 |
|
if (n < 0) { /* get next view */ |
1117 |
|
} |
1118 |
|
|
1119 |
|
|
1120 |
< |
int |
1121 |
< |
countviews() /* count views in view file */ |
1120 |
> |
static int |
1121 |
> |
countviews(void) /* count views in view file */ |
1122 |
|
{ |
1123 |
|
int n; |
1124 |
|
|
1130 |
|
} |
1131 |
|
|
1132 |
|
|
1133 |
< |
char * |
1134 |
< |
getexp(n) /* get exposure for nth frame */ |
1061 |
< |
int n; |
1133 |
> |
static char * |
1134 |
> |
getexp(int n) /* get exposure for nth frame */ |
1135 |
|
{ |
1063 |
– |
extern char *fskip(); |
1136 |
|
static char expval[32]; |
1137 |
|
static FILE *expfp = NULL; |
1138 |
|
static long *exppos; |
1142 |
|
if (n == 0) { /* signal to close file */ |
1143 |
|
if (expfp != NULL) { |
1144 |
|
fclose(expfp); |
1145 |
< |
free((char *)exppos); |
1145 |
> |
free((void *)exppos); |
1146 |
|
expfp = NULL; |
1147 |
|
} |
1148 |
|
return(NULL); |
1199 |
|
} |
1200 |
|
|
1201 |
|
|
1202 |
< |
struct pslot * |
1203 |
< |
findpslot(pid) /* find or allocate a process slot */ |
1132 |
< |
int pid; |
1202 |
> |
static struct pslot * |
1203 |
> |
findpslot(RT_PID pid) /* find or allocate a process slot */ |
1204 |
|
{ |
1205 |
|
register struct pslot *psempty = NULL; |
1206 |
|
register int i; |
1215 |
|
} |
1216 |
|
|
1217 |
|
|
1218 |
< |
int |
1219 |
< |
donecom(ps, pn, status) /* clean up after finished process */ |
1220 |
< |
PSERVER *ps; |
1221 |
< |
int pn; |
1222 |
< |
int status; |
1218 |
> |
static int |
1219 |
> |
donecom( /* clean up after finished process */ |
1220 |
> |
PSERVER *ps, |
1221 |
> |
int pn, |
1222 |
> |
int status |
1223 |
> |
) |
1224 |
|
{ |
1225 |
< |
register PROC *pp; |
1225 |
> |
register NETPROC *pp; |
1226 |
|
register struct pslot *psl; |
1227 |
|
|
1228 |
|
pp = ps->proc + pn; |
1257 |
|
} |
1258 |
|
|
1259 |
|
|
1260 |
< |
int |
1261 |
< |
serverdown() /* check status of last process server */ |
1260 |
> |
static int |
1261 |
> |
serverdown(void) /* check status of last process server */ |
1262 |
|
{ |
1263 |
|
if (lastpserver == NULL || !lastpserver->hostname[0]) |
1264 |
|
return(0); |
1274 |
|
} |
1275 |
|
|
1276 |
|
|
1277 |
< |
int |
1278 |
< |
bruncom(com, fout, rf) /* run a command in the background */ |
1279 |
< |
char *com; |
1280 |
< |
int fout; |
1281 |
< |
int (*rf)(); |
1277 |
> |
static RT_PID |
1278 |
> |
bruncom( /* run a command in the background */ |
1279 |
> |
char *com, |
1280 |
> |
int fout, |
1281 |
> |
int (*rf)() |
1282 |
> |
) |
1283 |
|
{ |
1284 |
< |
int pid; |
1284 |
> |
RT_PID pid; |
1285 |
|
register struct pslot *psl; |
1286 |
|
|
1287 |
|
if (noaction) { |
1294 |
|
bwait(1); |
1295 |
|
if (!silent) { /* echo command */ |
1296 |
|
PSERVER *ps; |
1297 |
< |
int psn = pid; |
1297 |
> |
RT_PID psn = pid; |
1298 |
|
ps = findjob(&psn); |
1299 |
|
printf("\t%s\n", com); |
1300 |
|
printf("\tProcess started on %s\n", phostname(ps)); |
1308 |
|
} |
1309 |
|
|
1310 |
|
|
1311 |
< |
bwait(ncoms) /* wait for batch job(s) to finish */ |
1312 |
< |
int ncoms; |
1311 |
> |
static void |
1312 |
> |
bwait(int ncoms) /* wait for batch job(s) to finish */ |
1313 |
|
{ |
1314 |
|
int status; |
1315 |
|
|
1323 |
|
} |
1324 |
|
|
1325 |
|
|
1326 |
< |
int |
1327 |
< |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1328 |
< |
char *com, *ppins; |
1329 |
< |
int maxcopies; |
1326 |
> |
static int |
1327 |
> |
pruncom( /* run a command in parallel over network */ |
1328 |
> |
char *com, |
1329 |
> |
char *ppins, |
1330 |
> |
int maxcopies |
1331 |
> |
) |
1332 |
|
{ |
1333 |
|
int retstatus = 0; |
1334 |
|
int hostcopies; |
1350 |
|
strcpy(com1=buf, com); /* build -PP command */ |
1351 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1352 |
|
vval(DIRECTORY), phostname(ps)); |
1353 |
+ |
unlink(com1+(ppins-com)+5); |
1354 |
|
strcat(com1, ppins); |
1355 |
|
} else |
1356 |
|
com1 = com; |
1395 |
|
} |
1396 |
|
|
1397 |
|
|
1398 |
< |
runcom(cs) /* run a command locally and wait for it */ |
1399 |
< |
char *cs; |
1398 |
> |
static int |
1399 |
> |
runcom(char *cs) /* run a command locally and wait for it */ |
1400 |
|
{ |
1401 |
|
if (!silent) /* echo it */ |
1402 |
|
printf("\t%s\n", cs); |
1407 |
|
} |
1408 |
|
|
1409 |
|
|
1410 |
< |
rmfile(fn) /* remove a file */ |
1411 |
< |
char *fn; |
1410 |
> |
static int |
1411 |
> |
rmfile(char *fn) /* remove a file */ |
1412 |
|
{ |
1413 |
|
if (!silent) |
1414 |
< |
#ifdef MSDOS |
1414 |
> |
#if defined(_WIN32) || defined(_WIN64) |
1415 |
|
printf("\tdel %s\n", fn); |
1416 |
|
#else |
1417 |
|
printf("\trm -f %s\n", fn); |
1422 |
|
} |
1423 |
|
|
1424 |
|
|
1425 |
< |
badvalue(vc) /* report bad variable value and exit */ |
1426 |
< |
int vc; |
1425 |
> |
static void |
1426 |
> |
badvalue(int vc) /* report bad variable value and exit */ |
1427 |
|
{ |
1428 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1429 |
|
progname, vnam(vc)); |
1431 |
|
} |
1432 |
|
|
1433 |
|
|
1434 |
< |
char * |
1435 |
< |
dirfile(df, path) /* separate path into directory and file */ |
1436 |
< |
char *df; |
1437 |
< |
register char *path; |
1434 |
> |
static char * |
1435 |
> |
dirfile( /* separate path into directory and file */ |
1436 |
> |
char *df, |
1437 |
> |
register char *path |
1438 |
> |
) |
1439 |
|
{ |
1440 |
|
register int i; |
1441 |
|
int psep; |
1443 |
|
for (i = 0, psep = -1; path[i]; i++) |
1444 |
|
if (path[i] == '/') |
1445 |
|
psep = i; |
1446 |
< |
if (df != NULL) |
1446 |
> |
if (df != NULL) { |
1447 |
|
if (psep == 0) { |
1448 |
|
df[0] = '/'; |
1449 |
|
df[1] = '\0'; |
1452 |
|
df[psep] = '\0'; |
1453 |
|
} else |
1454 |
|
df[0] = '\0'; |
1455 |
+ |
} |
1456 |
|
return(path+psep+1); |
1457 |
+ |
} |
1458 |
+ |
|
1459 |
+ |
|
1460 |
+ |
static int |
1461 |
+ |
getblur(double *mbf, double *dbf) /* get # blur samples (and fraction) */ |
1462 |
+ |
{ |
1463 |
+ |
double mblurf, dblurf; |
1464 |
+ |
int nmblur, ndblur; |
1465 |
+ |
char *s; |
1466 |
+ |
/* get motion blur */ |
1467 |
+ |
if (vdef(ANIMATE) || !vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0) |
1468 |
+ |
mblurf = 0.0; |
1469 |
+ |
if (mbf != NULL) |
1470 |
+ |
*mbf = mblurf; |
1471 |
+ |
if (mblurf <= FTINY) |
1472 |
+ |
nmblur = 0; |
1473 |
+ |
else if (!*(s = sskip(vval(MBLUR)))) |
1474 |
+ |
nmblur = DEF_NBLUR; |
1475 |
+ |
else if ((nmblur = atoi(s)) <= 0) |
1476 |
+ |
nmblur = 1; |
1477 |
+ |
/* get depth-of-field blur */ |
1478 |
+ |
if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0) |
1479 |
+ |
dblurf = 0.0; |
1480 |
+ |
if (dbf != NULL) |
1481 |
+ |
*dbf = dblurf; |
1482 |
+ |
if (dblurf <= FTINY) |
1483 |
+ |
ndblur = 0; |
1484 |
+ |
else if (!*(s = sskip(vval(DBLUR)))) |
1485 |
+ |
ndblur = DEF_NBLUR; |
1486 |
+ |
else if ((ndblur = atoi(s)) <= 0) |
1487 |
+ |
ndblur = 1; |
1488 |
+ |
if ((nmblur == 1) & (ndblur == 1)) |
1489 |
+ |
return(1); |
1490 |
+ |
/* return combined samples */ |
1491 |
+ |
return(nmblur + ndblur); |
1492 |
|
} |