1 |
|
#ifndef lint |
2 |
< |
static const char RCSid[] = "$Id$"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
|
* Radiance animation control program |
13 |
|
* See the ranimate(1) man page for further details. |
14 |
|
*/ |
15 |
|
|
16 |
< |
/* ==================================================================== |
17 |
< |
* The Radiance Software License, Version 1.0 |
18 |
< |
* |
19 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
20 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
21 |
< |
* |
22 |
< |
* Redistribution and use in source and binary forms, with or without |
23 |
< |
* modification, are permitted provided that the following conditions |
24 |
< |
* are met: |
25 |
< |
* |
26 |
< |
* 1. Redistributions of source code must retain the above copyright |
27 |
< |
* notice, this list of conditions and the following disclaimer. |
28 |
< |
* |
29 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
30 |
< |
* notice, this list of conditions and the following disclaimer in |
31 |
< |
* the documentation and/or other materials provided with the |
32 |
< |
* distribution. |
33 |
< |
* |
34 |
< |
* 3. The end-user documentation included with the redistribution, |
35 |
< |
* if any, must include the following acknowledgment: |
36 |
< |
* "This product includes Radiance software |
37 |
< |
* (http://radsite.lbl.gov/) |
38 |
< |
* developed by the Lawrence Berkeley National Laboratory |
39 |
< |
* (http://www.lbl.gov/)." |
40 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
41 |
< |
* if and wherever such third-party acknowledgments normally appear. |
42 |
< |
* |
43 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
44 |
< |
* and "The Regents of the University of California" must |
45 |
< |
* not be used to endorse or promote products derived from this |
46 |
< |
* software without prior written permission. For written |
47 |
< |
* permission, please contact [email protected]. |
48 |
< |
* |
49 |
< |
* 5. Products derived from this software may not be called "Radiance", |
50 |
< |
* nor may "Radiance" appear in their name, without prior written |
51 |
< |
* permission of Lawrence Berkeley National Laboratory. |
52 |
< |
* |
53 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
54 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
55 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
56 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
57 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
58 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
59 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
60 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
61 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
62 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
63 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
64 |
< |
* SUCH DAMAGE. |
65 |
< |
* ==================================================================== |
66 |
< |
* |
67 |
< |
* This software consists of voluntary contributions made by many |
68 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
69 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
70 |
< |
* <http://www.lbl.gov/>. |
71 |
< |
*/ |
16 |
> |
#include "copyright.h" |
17 |
|
|
18 |
< |
#include "standard.h" |
18 |
> |
#include <stdio.h> |
19 |
|
#include <ctype.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 "paths.h" |
27 |
+ |
#include "standard.h" |
28 |
|
#include "view.h" |
29 |
|
#include "vars.h" |
30 |
|
#include "netproc.h" |
33 |
|
#define DEF_NBLUR 5 |
34 |
|
#endif |
35 |
|
/* default remote shell */ |
36 |
< |
#ifdef _AUX_SOURCE |
37 |
< |
#define REMSH "remsh" |
86 |
< |
#else |
87 |
< |
#define REMSH "rsh" |
36 |
> |
#ifndef REMSH |
37 |
> |
#define REMSH "ssh" |
38 |
|
#endif |
39 |
|
/* input variables (alphabetical by name) */ |
40 |
|
#define ANIMATE 0 /* animation command */ |
41 |
|
#define ARCHIVE 1 /* archiving command */ |
42 |
|
#define BASENAME 2 /* output image base name */ |
43 |
< |
#define DIRECTORY 3 /* working (sub)directory */ |
44 |
< |
#define DISKSPACE 4 /* how much disk space to use */ |
45 |
< |
#define END 5 /* ending frame number */ |
46 |
< |
#define EXPOSURE 6 /* how to compute exposure */ |
47 |
< |
#define HOST 7 /* rendering host machine */ |
48 |
< |
#define INTERP 8 /* # frames to interpolate */ |
49 |
< |
#define MBLUR 9 /* motion blur parameters */ |
50 |
< |
#define NEXTANIM 10 /* next animation file */ |
51 |
< |
#define OCTREE 11 /* octree file name */ |
52 |
< |
#define OVERSAMP 12 /* # times to oversample image */ |
53 |
< |
#define PFILT 13 /* pfilt options */ |
54 |
< |
#define PINTERP 14 /* pinterp options */ |
55 |
< |
#define RENDER 15 /* rendering options */ |
56 |
< |
#define RESOLUTION 16 /* desired final resolution */ |
57 |
< |
#define RIF 17 /* rad input file */ |
58 |
< |
#define RSH 18 /* remote shell script or program */ |
59 |
< |
#define RTRACE 19 /* use rtrace with pinterp? */ |
60 |
< |
#define START 20 /* starting frame number */ |
61 |
< |
#define TRANSFER 21 /* frame transfer command */ |
62 |
< |
#define VIEWFILE 22 /* animation frame views */ |
43 |
> |
#define DBLUR 3 /* depth of field blur */ |
44 |
> |
#define DIRECTORY 4 /* working (sub)directory */ |
45 |
> |
#define DISKSPACE 5 /* how much disk space to use */ |
46 |
> |
#define END 6 /* ending frame number */ |
47 |
> |
#define EXPOSURE 7 /* how to compute exposure */ |
48 |
> |
#define HOST 8 /* rendering host machine */ |
49 |
> |
#define INTERP 9 /* # frames to interpolate */ |
50 |
> |
#define MBLUR 10 /* motion blur parameters */ |
51 |
> |
#define NEXTANIM 11 /* next animation file */ |
52 |
> |
#define OCTREE 12 /* octree file name */ |
53 |
> |
#define OVERSAMP 13 /* # times to oversample image */ |
54 |
> |
#define PFILT 14 /* pfilt options */ |
55 |
> |
#define PINTERP 15 /* pinterp options */ |
56 |
> |
#define RENDER 16 /* rendering options */ |
57 |
> |
#define RESOLUTION 17 /* desired final resolution */ |
58 |
> |
#define RIF 18 /* rad input file */ |
59 |
> |
#define RSH 19 /* remote shell script or program */ |
60 |
> |
#define RTRACE 20 /* use rtrace with pinterp? */ |
61 |
> |
#define START 21 /* starting frame number */ |
62 |
> |
#define TRANSFER 22 /* frame transfer command */ |
63 |
> |
#define VIEWFILE 23 /* animation frame views */ |
64 |
|
|
65 |
< |
int NVARS = 23; /* total number of variables */ |
65 |
> |
int NVARS = 24; /* total number of variables */ |
66 |
|
|
67 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
68 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
69 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
70 |
|
{"BASENAME", 3, 0, NULL, onevalue}, |
71 |
+ |
{"DBLUR", 2, 0, NULL, onevalue}, |
72 |
|
{"DIRECTORY", 3, 0, NULL, onevalue}, |
73 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
74 |
|
{"END", 2, 0, NULL, intvalue}, |
95 |
|
|
96 |
|
struct { |
97 |
|
char host[64]; /* control host name */ |
98 |
< |
int pid; /* control process id */ |
98 |
> |
RT_PID pid; /* control process id */ |
99 |
|
char cfname[128]; /* control file name */ |
100 |
|
int rnext; /* next frame to render */ |
101 |
|
int fnext; /* next frame to filter */ |
119 |
|
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
120 |
|
|
121 |
|
struct pslot { |
122 |
< |
int pid; /* process ID (0 if empty) */ |
122 |
> |
RT_PID pid; /* process ID (0 if empty) */ |
123 |
|
int fout; /* output frame number */ |
124 |
|
int (*rcvf)(); /* recover function */ |
125 |
|
} *pslot; /* process slots */ |
126 |
|
int npslots; /* number of process slots */ |
127 |
|
|
128 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
177 |
– |
|
178 |
– |
struct pslot *findpslot(); |
179 |
– |
|
129 |
|
PSERVER *lastpserver; /* last process server with error */ |
130 |
|
|
131 |
< |
VIEW *getview(); |
132 |
< |
char *getexp(), *dirfile(); |
133 |
< |
int getblur(); |
131 |
> |
static struct pslot * findpslot(RT_PID pid); |
132 |
> |
static void checkdir(void); |
133 |
> |
static VIEW * getview(int n); |
134 |
|
|
135 |
< |
extern time_t time(); |
135 |
> |
static char * dirfile(char *df, register char *path); |
136 |
> |
static char * getexp(int n); |
137 |
> |
static int getblur(double *mbf, double *dbf); |
138 |
> |
static int getastat(void); |
139 |
> |
static void getradfile(char *rfargs); |
140 |
> |
static void badvalue(int vc); |
141 |
> |
static int rmfile(char *fn); |
142 |
> |
static int runcom(char *cs); |
143 |
> |
static int pruncom(char *com, char *ppins, int maxcopies); |
144 |
> |
static void bwait(int ncoms); |
145 |
> |
static RT_PID bruncom(char *com, int fout, int (*rf)()); |
146 |
> |
static int serverdown(void); |
147 |
> |
static pscompfunc donecom; |
148 |
> |
static int countviews(void); |
149 |
> |
static int dofilt(int frame, int rvr); |
150 |
> |
static void archive(void); |
151 |
> |
static int frecover(int frame); |
152 |
> |
static int recover(int frame); |
153 |
> |
static void sethosts(void); |
154 |
> |
static void walkwait(int first, int last, char *vfn); |
155 |
> |
static void animrend(int frame, VIEW *vp); |
156 |
> |
static void transferframes(void); |
157 |
> |
static void filterframes(void); |
158 |
> |
static void renderframes(int nframes); |
159 |
> |
static void animate(void); |
160 |
> |
static void setdefaults(void); |
161 |
> |
static void putastat(void); |
162 |
|
|
163 |
|
|
164 |
< |
main(argc, argv) |
165 |
< |
int argc; |
166 |
< |
char *argv[]; |
164 |
> |
int |
165 |
> |
main( |
166 |
> |
int argc, |
167 |
> |
char *argv[] |
168 |
> |
) |
169 |
|
{ |
170 |
|
int explicate = 0; |
171 |
|
int i; |
218 |
|
animate(); |
219 |
|
/* all done */ |
220 |
|
if (vdef(NEXTANIM)) { |
221 |
+ |
char *fullp; |
222 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
223 |
|
if (!silent) |
224 |
|
printargs(argc, argv, stdout); |
225 |
< |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
226 |
< |
fprintf(stderr, "%s: command not found\n", progname); |
225 |
> |
fflush(stdout); |
226 |
> |
if ((fullp = getpath(argv[0],getenv("PATH"),X_OK)) == NULL) |
227 |
> |
fprintf(stderr, "%s: command not found\n", argv[0]); |
228 |
|
else |
229 |
< |
execv(progname, argv); |
229 |
> |
execv(fullp, argv); |
230 |
|
quit(1); |
231 |
|
} |
232 |
|
quit(0); |
233 |
+ |
return(0); /* pro forma return */ |
234 |
|
userr: |
235 |
|
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname); |
236 |
|
quit(1); |
237 |
+ |
return 1; /* pro forma return */ |
238 |
|
} |
239 |
|
|
240 |
|
|
241 |
< |
getastat() /* check/set animation status */ |
241 |
> |
static int |
242 |
> |
getastat(void) /* check/set animation status */ |
243 |
|
{ |
244 |
|
char sfname[256]; |
245 |
|
FILE *fp; |
303 |
|
} |
304 |
|
|
305 |
|
|
306 |
< |
putastat() /* put out current status */ |
306 |
> |
static void |
307 |
> |
putastat(void) /* put out current status */ |
308 |
|
{ |
309 |
|
char buf[256]; |
310 |
|
FILE *fp; |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
< |
checkdir() /* make sure we have our directory */ |
329 |
> |
static void |
330 |
> |
checkdir(void) /* make sure we have our directory */ |
331 |
|
{ |
332 |
|
struct stat stb; |
333 |
|
|
349 |
|
} |
350 |
|
|
351 |
|
|
352 |
< |
setdefaults() /* set default values */ |
352 |
> |
static void |
353 |
> |
setdefaults(void) /* set default values */ |
354 |
|
{ |
355 |
|
extern char *atos(); |
356 |
|
int decades; |
438 |
|
} |
439 |
|
|
440 |
|
|
441 |
< |
sethosts() /* set up process servers */ |
441 |
> |
static void |
442 |
> |
sethosts(void) /* set up process servers */ |
443 |
|
{ |
444 |
|
extern char *iskip(); |
445 |
|
char buf[256], *dir, *uname; |
494 |
|
} |
495 |
|
} |
496 |
|
|
497 |
< |
|
498 |
< |
getradfile(rfargs) /* run rad and get needed variables */ |
513 |
< |
char *rfargs; |
497 |
> |
static void |
498 |
> |
getradfile(char *rfargs) /* run rad and get needed variables */ |
499 |
|
{ |
500 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
501 |
|
char combuf[256]; |
502 |
|
register int i; |
503 |
|
register char *cp; |
504 |
< |
char *pippt; |
504 |
> |
char *pippt = NULL; |
505 |
|
/* create rad command */ |
506 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
507 |
|
sprintf(combuf, |
520 |
|
pippt = NULL; |
521 |
|
} |
522 |
|
if (pippt != NULL) |
523 |
< |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
523 |
> |
strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */ |
524 |
|
else { |
525 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
526 |
|
cp += 11; /* point to file name */ |
533 |
|
} |
534 |
|
|
535 |
|
|
536 |
< |
animate() /* run animation */ |
536 |
> |
static void |
537 |
> |
animate(void) /* run animation */ |
538 |
|
{ |
539 |
|
int xres, yres; |
540 |
|
float pa, mult; |
574 |
|
} |
575 |
|
/* figure # frames per batch */ |
576 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
577 |
< |
if ((i=vint(INTERP)) || getblur(NULL) > 1) |
577 |
> |
if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1) |
578 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
579 |
|
d2 = xres*yres*4; /* space for final picture */ |
580 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
605 |
|
} |
606 |
|
|
607 |
|
|
608 |
< |
renderframes(nframes) /* render next nframes frames */ |
609 |
< |
int nframes; |
608 |
> |
static void |
609 |
> |
renderframes(int nframes) /* render next nframes frames */ |
610 |
|
{ |
611 |
|
static char vendbuf[16]; |
612 |
|
VIEW *vp; |
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
< |
filterframes() /* catch up with filtering */ |
665 |
> |
static void |
666 |
> |
filterframes(void) /* catch up with filtering */ |
667 |
|
{ |
681 |
– |
VIEW *vp; |
668 |
|
register int i; |
669 |
|
|
670 |
|
if (astat.tnext < astat.fnext) /* other work to do first */ |
671 |
|
return; |
672 |
|
/* filter each view */ |
673 |
< |
for (i = astat.fnext; i < astat.rnext; i++) { |
674 |
< |
if ((vp = getview(i)) == NULL) { /* get view i */ |
675 |
< |
fprintf(stderr, |
690 |
< |
"%s: unexpected error reading view for frame %d\n", |
691 |
< |
progname, i); |
692 |
< |
quit(1); |
693 |
< |
} |
694 |
< |
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
695 |
< |
} |
673 |
> |
for (i = astat.fnext; i < astat.rnext; i++) |
674 |
> |
dofilt(i, 0); |
675 |
> |
|
676 |
|
bwait(0); /* wait for filter processes */ |
677 |
|
archive(); /* archive originals */ |
678 |
|
astat.fnext = i; /* update status */ |
680 |
|
} |
681 |
|
|
682 |
|
|
683 |
< |
transferframes() /* catch up with picture transfers */ |
683 |
> |
static void |
684 |
> |
transferframes(void) /* catch up with picture transfers */ |
685 |
|
{ |
686 |
|
char combuf[10240], *fbase; |
687 |
|
register char *cp; |
708 |
|
*cp++ = ' '; |
709 |
|
sprintf(cp, fbase, i); |
710 |
|
while (*cp) cp++; |
711 |
< |
strcpy(cp, ".pic"); |
711 |
> |
strcpy(cp, ".hdr"); |
712 |
|
cp += 4; |
713 |
|
} |
714 |
|
if (runcom(combuf)) { /* transfer frames */ |
721 |
|
} |
722 |
|
|
723 |
|
|
724 |
< |
animrend(frame, vp) /* start animation frame */ |
725 |
< |
int frame; |
726 |
< |
VIEW *vp; |
724 |
> |
static void |
725 |
> |
animrend( /* start animation frame */ |
726 |
> |
int frame, |
727 |
> |
VIEW *vp |
728 |
> |
) |
729 |
|
{ |
747 |
– |
extern int recover(); |
730 |
|
char combuf[2048]; |
731 |
|
char fname[128]; |
732 |
|
|
740 |
|
} |
741 |
|
|
742 |
|
|
743 |
< |
walkwait(first, last, vfn) /* walk-through frames */ |
744 |
< |
int first, last; |
745 |
< |
char *vfn; |
743 |
> |
static void |
744 |
> |
walkwait( /* walk-through frames */ |
745 |
> |
int first, |
746 |
> |
int last, |
747 |
> |
char *vfn |
748 |
> |
) |
749 |
|
{ |
750 |
< |
double blurf; |
751 |
< |
int nblur = getblur(&blurf); |
750 |
> |
double mblurf, dblurf; |
751 |
> |
int nblur = getblur(&mblurf, &dblurf); |
752 |
|
char combuf[2048]; |
753 |
|
register char *inspoint; |
754 |
|
register int i; |
766 |
|
inspoint = combuf; |
767 |
|
while (*inspoint) inspoint++; |
768 |
|
if (nblur) { |
769 |
< |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
769 |
> |
sprintf(inspoint, " -pm %.3f", mblurf/nblur); |
770 |
|
while (*inspoint) inspoint++; |
771 |
+ |
sprintf(inspoint, " -pd %.3f", dblurf/nblur); |
772 |
+ |
while (*inspoint) inspoint++; |
773 |
|
} |
774 |
|
if (nblur > 1 || vint(INTERP)) { |
775 |
|
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
797 |
|
} |
798 |
|
|
799 |
|
|
800 |
< |
int |
801 |
< |
recover(frame) /* recover the specified frame */ |
815 |
< |
int frame; |
800 |
> |
static int |
801 |
> |
recover(int frame) /* recover the specified frame */ |
802 |
|
{ |
803 |
|
static int *rfrm; /* list of recovered frames */ |
804 |
|
static int nrfrms = 0; |
805 |
< |
double blurf; |
806 |
< |
int nblur = getblur(&blurf); |
805 |
> |
double mblurf, dblurf; |
806 |
> |
int nblur = getblur(&mblurf, &dblurf); |
807 |
|
char combuf[2048]; |
808 |
|
char fname[128]; |
809 |
|
register char *cp; |
822 |
|
cp = combuf; |
823 |
|
while (*cp) cp++; |
824 |
|
if (nblur) { |
825 |
< |
sprintf(cp, " -pm %.3f", blurf/nblur); |
825 |
> |
sprintf(cp, " -pm %.3f", mblurf/nblur); |
826 |
|
while (*cp) cp++; |
827 |
+ |
sprintf(cp, " -pd %.3f", dblurf/nblur); |
828 |
+ |
while (*cp) cp++; |
829 |
|
} |
830 |
|
if (nblur > 1 || vint(INTERP)) { |
831 |
|
sprintf(cp, " -z %s.zbf", fname); |
841 |
|
return(1); |
842 |
|
/* add frame to recovered list */ |
843 |
|
if (nrfrms) |
844 |
< |
rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); |
844 |
> |
rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); |
845 |
|
else |
846 |
|
rfrm = (int *)malloc(sizeof(int)); |
847 |
|
if (rfrm == NULL) { |
853 |
|
} |
854 |
|
|
855 |
|
|
856 |
< |
int |
857 |
< |
frecover(frame) /* recover filtered frame */ |
870 |
< |
int frame; |
856 |
> |
static int |
857 |
> |
frecover(int frame) /* recover filtered frame */ |
858 |
|
{ |
859 |
< |
VIEW *vp; |
873 |
< |
char *ex; |
874 |
< |
|
875 |
< |
vp = getview(frame); |
876 |
< |
ex = getexp(frame); |
877 |
< |
if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) |
859 |
> |
if (dofilt(frame, 2) && dofilt(frame, 1)) |
860 |
|
return(1); |
861 |
|
return(0); |
862 |
|
} |
863 |
|
|
864 |
|
|
865 |
< |
archive() /* archive and remove renderings */ |
865 |
> |
static void |
866 |
> |
archive(void) /* archive and remove renderings */ |
867 |
|
{ |
868 |
|
#define RMCOML (sizeof(rmcom)-1) |
869 |
|
static char rmcom[] = "rm -f"; |
906 |
|
} |
907 |
|
|
908 |
|
|
909 |
< |
int |
910 |
< |
dofilt(frame, vp, ep, rvr) /* filter frame */ |
911 |
< |
int frame; |
912 |
< |
VIEW *vp; |
913 |
< |
char *ep; |
931 |
< |
int rvr; |
909 |
> |
static int |
910 |
> |
dofilt( /* filter frame */ |
911 |
> |
int frame, |
912 |
> |
int rvr |
913 |
> |
) |
914 |
|
{ |
933 |
– |
extern int frecover(); |
915 |
|
static int iter = 0; |
916 |
< |
double blurf; |
917 |
< |
int nblur = getblur(&blurf); |
916 |
> |
double mblurf, dblurf; |
917 |
> |
int nblur = getblur(&mblurf, &dblurf); |
918 |
> |
VIEW *vp = getview(frame); |
919 |
> |
char *ep = getexp(frame); |
920 |
|
char fnbefore[128], fnafter[128], *fbase; |
921 |
|
char combuf[1024], fname0[128], fname1[128]; |
922 |
|
int usepinterp, usepfilt, nora_rgbe; |
923 |
|
int frseq[2]; |
924 |
|
/* check what is needed */ |
925 |
+ |
if (vp == NULL) { |
926 |
+ |
fprintf(stderr, |
927 |
+ |
"%s: unexpected error reading view for frame %d\n", |
928 |
+ |
progname, frame); |
929 |
+ |
quit(1); |
930 |
+ |
} |
931 |
|
usepinterp = (nblur > 1); |
932 |
< |
usepfilt = pfiltalways | ep==NULL; |
932 |
> |
usepfilt = pfiltalways | (ep==NULL); |
933 |
|
if (ep != NULL && !strcmp(ep, "1")) |
934 |
|
ep = "+0"; |
935 |
|
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
946 |
|
usepfilt |= nora_rgbe; |
947 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
948 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
949 |
+ |
if (arcnext - arcargs + |
950 |
+ |
strlen(fbase) >= sizeof(arcargs)-8) { |
951 |
+ |
fprintf(stderr, |
952 |
+ |
"%s: too many filenames in archive command -- reduce %s variable\n", |
953 |
+ |
progname, vnam(DISKSPACE)); |
954 |
+ |
quit(1); |
955 |
+ |
} |
956 |
|
*arcnext++ = ' '; |
957 |
|
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
958 |
|
while (*arcnext) arcnext++; |
980 |
|
if (usepinterp) { /* using pinterp */ |
981 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
982 |
|
return(1); |
983 |
< |
if (nblur > 1) { /* with pmblur */ |
983 |
> |
if (nblur > 1) { /* with pdmblur */ |
984 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
985 |
|
'a'+(iter%26)); |
986 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
1007 |
|
putc('\n', fp); fclose(fp); |
1008 |
|
} |
1009 |
|
sprintf(combuf, |
1010 |
< |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B", |
1011 |
< |
blurf, nblur, |
1010 |
> |
"(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
1011 |
> |
mblurf, dblurf, nblur, |
1012 |
|
fname0, fname1, fname0, fname1); |
1013 |
|
iter++; |
1014 |
|
} else /* no blurring */ |
1022 |
|
if (usepfilt) |
1023 |
|
sprintf(combuf+strlen(combuf), " %s", rresopt); |
1024 |
|
else |
1025 |
< |
sprintf(combuf+strlen(combuf), " %s -e %s", |
1025 |
> |
sprintf(combuf+strlen(combuf), " -a %s -e %s", |
1026 |
|
fresopt, ep); |
1027 |
|
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", |
1028 |
|
fnbefore, fnbefore); |
1061 |
|
} |
1062 |
|
/* output file name */ |
1063 |
|
sprintf(fname0, vval(BASENAME), frame); |
1064 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
1064 |
> |
sprintf(combuf+strlen(combuf), " > %s.hdr", fname0); |
1065 |
|
if (rvr) /* in recovery */ |
1066 |
|
return(runcom(combuf)); |
1067 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
1069 |
|
} |
1070 |
|
|
1071 |
|
|
1072 |
< |
VIEW * |
1073 |
< |
getview(n) /* get view number n */ |
1078 |
< |
int n; |
1072 |
> |
static VIEW * |
1073 |
> |
getview(int n) /* get view number n */ |
1074 |
|
{ |
1075 |
|
static FILE *viewfp = NULL; /* view file pointer */ |
1076 |
|
static int viewnum = 0; /* current view number */ |
1082 |
|
fclose(viewfp); |
1083 |
|
viewfp = NULL; |
1084 |
|
viewnum = 0; |
1085 |
< |
copystruct(&curview, &stdview); |
1085 |
> |
curview = stdview; |
1086 |
|
} |
1087 |
|
return(NULL); |
1088 |
|
} |
1098 |
|
perror(vval(VIEWFILE)); |
1099 |
|
quit(1); |
1100 |
|
} |
1101 |
< |
copystruct(&curview, &stdview); |
1101 |
> |
curview = stdview; |
1102 |
|
viewnum = 0; |
1103 |
|
} |
1104 |
|
if (n < 0) { /* get next view */ |
1118 |
|
} |
1119 |
|
|
1120 |
|
|
1121 |
< |
int |
1122 |
< |
countviews() /* count views in view file */ |
1121 |
> |
static int |
1122 |
> |
countviews(void) /* count views in view file */ |
1123 |
|
{ |
1124 |
|
int n; |
1125 |
|
|
1131 |
|
} |
1132 |
|
|
1133 |
|
|
1134 |
< |
char * |
1135 |
< |
getexp(n) /* get exposure for nth frame */ |
1141 |
< |
int n; |
1134 |
> |
static char * |
1135 |
> |
getexp(int n) /* get exposure for nth frame */ |
1136 |
|
{ |
1143 |
– |
extern char *fskip(); |
1137 |
|
static char expval[32]; |
1138 |
|
static FILE *expfp = NULL; |
1139 |
|
static long *exppos; |
1200 |
|
} |
1201 |
|
|
1202 |
|
|
1203 |
< |
struct pslot * |
1204 |
< |
findpslot(pid) /* find or allocate a process slot */ |
1212 |
< |
int pid; |
1203 |
> |
static struct pslot * |
1204 |
> |
findpslot(RT_PID pid) /* find or allocate a process slot */ |
1205 |
|
{ |
1206 |
|
register struct pslot *psempty = NULL; |
1207 |
|
register int i; |
1216 |
|
} |
1217 |
|
|
1218 |
|
|
1219 |
< |
int |
1220 |
< |
donecom(ps, pn, status) /* clean up after finished process */ |
1221 |
< |
PSERVER *ps; |
1222 |
< |
int pn; |
1223 |
< |
int status; |
1219 |
> |
static int |
1220 |
> |
donecom( /* clean up after finished process */ |
1221 |
> |
PSERVER *ps, |
1222 |
> |
int pn, |
1223 |
> |
int status |
1224 |
> |
) |
1225 |
|
{ |
1226 |
< |
register PROC *pp; |
1226 |
> |
register NETPROC *pp; |
1227 |
|
register struct pslot *psl; |
1228 |
|
|
1229 |
|
pp = ps->proc + pn; |
1258 |
|
} |
1259 |
|
|
1260 |
|
|
1261 |
< |
int |
1262 |
< |
serverdown() /* check status of last process server */ |
1261 |
> |
static int |
1262 |
> |
serverdown(void) /* check status of last process server */ |
1263 |
|
{ |
1264 |
|
if (lastpserver == NULL || !lastpserver->hostname[0]) |
1265 |
|
return(0); |
1275 |
|
} |
1276 |
|
|
1277 |
|
|
1278 |
< |
int |
1279 |
< |
bruncom(com, fout, rf) /* run a command in the background */ |
1280 |
< |
char *com; |
1281 |
< |
int fout; |
1282 |
< |
int (*rf)(); |
1278 |
> |
static RT_PID |
1279 |
> |
bruncom( /* run a command in the background */ |
1280 |
> |
char *com, |
1281 |
> |
int fout, |
1282 |
> |
int (*rf)() |
1283 |
> |
) |
1284 |
|
{ |
1285 |
< |
int pid; |
1285 |
> |
RT_PID pid; |
1286 |
|
register struct pslot *psl; |
1287 |
|
|
1288 |
|
if (noaction) { |
1295 |
|
bwait(1); |
1296 |
|
if (!silent) { /* echo command */ |
1297 |
|
PSERVER *ps; |
1298 |
< |
int psn = pid; |
1298 |
> |
RT_PID psn = pid; |
1299 |
|
ps = findjob(&psn); |
1300 |
|
printf("\t%s\n", com); |
1301 |
|
printf("\tProcess started on %s\n", phostname(ps)); |
1309 |
|
} |
1310 |
|
|
1311 |
|
|
1312 |
< |
bwait(ncoms) /* wait for batch job(s) to finish */ |
1313 |
< |
int ncoms; |
1312 |
> |
static void |
1313 |
> |
bwait(int ncoms) /* wait for batch job(s) to finish */ |
1314 |
|
{ |
1315 |
|
int status; |
1316 |
|
|
1324 |
|
} |
1325 |
|
|
1326 |
|
|
1327 |
< |
int |
1328 |
< |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1329 |
< |
char *com, *ppins; |
1330 |
< |
int maxcopies; |
1327 |
> |
static int |
1328 |
> |
pruncom( /* run a command in parallel over network */ |
1329 |
> |
char *com, |
1330 |
> |
char *ppins, |
1331 |
> |
int maxcopies |
1332 |
> |
) |
1333 |
|
{ |
1334 |
|
int retstatus = 0; |
1335 |
|
int hostcopies; |
1351 |
|
strcpy(com1=buf, com); /* build -PP command */ |
1352 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1353 |
|
vval(DIRECTORY), phostname(ps)); |
1354 |
+ |
unlink(com1+(ppins-com)+5); |
1355 |
|
strcat(com1, ppins); |
1356 |
|
} else |
1357 |
|
com1 = com; |
1396 |
|
} |
1397 |
|
|
1398 |
|
|
1399 |
< |
runcom(cs) /* run a command locally and wait for it */ |
1400 |
< |
char *cs; |
1399 |
> |
static int |
1400 |
> |
runcom(char *cs) /* run a command locally and wait for it */ |
1401 |
|
{ |
1402 |
|
if (!silent) /* echo it */ |
1403 |
|
printf("\t%s\n", cs); |
1408 |
|
} |
1409 |
|
|
1410 |
|
|
1411 |
< |
rmfile(fn) /* remove a file */ |
1412 |
< |
char *fn; |
1411 |
> |
static int |
1412 |
> |
rmfile(char *fn) /* remove a file */ |
1413 |
|
{ |
1414 |
|
if (!silent) |
1415 |
< |
#ifdef MSDOS |
1415 |
> |
#ifdef _WIN32 |
1416 |
|
printf("\tdel %s\n", fn); |
1417 |
|
#else |
1418 |
|
printf("\trm -f %s\n", fn); |
1423 |
|
} |
1424 |
|
|
1425 |
|
|
1426 |
< |
badvalue(vc) /* report bad variable value and exit */ |
1427 |
< |
int vc; |
1426 |
> |
static void |
1427 |
> |
badvalue(int vc) /* report bad variable value and exit */ |
1428 |
|
{ |
1429 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1430 |
|
progname, vnam(vc)); |
1432 |
|
} |
1433 |
|
|
1434 |
|
|
1435 |
< |
char * |
1436 |
< |
dirfile(df, path) /* separate path into directory and file */ |
1437 |
< |
char *df; |
1438 |
< |
register char *path; |
1435 |
> |
static char * |
1436 |
> |
dirfile( /* separate path into directory and file */ |
1437 |
> |
char *df, |
1438 |
> |
register char *path |
1439 |
> |
) |
1440 |
|
{ |
1441 |
|
register int i; |
1442 |
|
int psep; |
1444 |
|
for (i = 0, psep = -1; path[i]; i++) |
1445 |
|
if (path[i] == '/') |
1446 |
|
psep = i; |
1447 |
< |
if (df != NULL) |
1447 |
> |
if (df != NULL) { |
1448 |
|
if (psep == 0) { |
1449 |
|
df[0] = '/'; |
1450 |
|
df[1] = '\0'; |
1453 |
|
df[psep] = '\0'; |
1454 |
|
} else |
1455 |
|
df[0] = '\0'; |
1456 |
+ |
} |
1457 |
|
return(path+psep+1); |
1458 |
|
} |
1459 |
|
|
1460 |
|
|
1461 |
< |
int |
1462 |
< |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1461 |
> |
static int |
1462 |
> |
getblur(double *mbf, double *dbf) /* get # blur samples (and fraction) */ |
1463 |
|
{ |
1464 |
< |
double blurf; |
1465 |
< |
int nblur; |
1464 |
> |
double mblurf, dblurf; |
1465 |
> |
int nmblur, ndblur; |
1466 |
|
char *s; |
1467 |
< |
|
1468 |
< |
if (!vdef(MBLUR)) { |
1469 |
< |
if (bf != NULL) |
1470 |
< |
*bf = 0.0; |
1471 |
< |
return(0); |
1472 |
< |
} |
1473 |
< |
blurf = atof(vval(MBLUR)); |
1474 |
< |
if (blurf < 0.0) |
1475 |
< |
blurf = 0.0; |
1476 |
< |
if (bf != NULL) |
1477 |
< |
*bf = blurf; |
1478 |
< |
if (blurf <= FTINY) |
1479 |
< |
return(0); |
1480 |
< |
s = sskip(vval(MBLUR)); |
1481 |
< |
if (!*s) |
1482 |
< |
return(DEF_NBLUR); |
1483 |
< |
nblur = atoi(s); |
1484 |
< |
if (nblur <= 0) |
1467 |
> |
/* get motion blur */ |
1468 |
> |
if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0) |
1469 |
> |
mblurf = 0.0; |
1470 |
> |
if (mbf != NULL) |
1471 |
> |
*mbf = mblurf; |
1472 |
> |
if (mblurf <= FTINY) |
1473 |
> |
nmblur = 0; |
1474 |
> |
else if (!*(s = sskip(vval(MBLUR)))) |
1475 |
> |
nmblur = DEF_NBLUR; |
1476 |
> |
else if ((nmblur = atoi(s)) <= 0) |
1477 |
> |
nmblur = 1; |
1478 |
> |
/* get depth-of-field blur */ |
1479 |
> |
if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0) |
1480 |
> |
dblurf = 0.0; |
1481 |
> |
if (dbf != NULL) |
1482 |
> |
*dbf = dblurf; |
1483 |
> |
if (dblurf <= FTINY) |
1484 |
> |
ndblur = 0; |
1485 |
> |
else if (!*(s = sskip(vval(DBLUR)))) |
1486 |
> |
ndblur = DEF_NBLUR; |
1487 |
> |
else if ((ndblur = atoi(s)) <= 0) |
1488 |
> |
ndblur = 1; |
1489 |
> |
if ((nmblur == 1) & (ndblur == 1)) |
1490 |
|
return(1); |
1491 |
< |
return(nblur); |
1491 |
> |
/* return combined samples */ |
1492 |
> |
return(nmblur + ndblur); |
1493 |
|
} |