ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ranimate.c
(Generate patch)

Comparing ray/src/util/ranimate.c (file contents):
Revision 2.42 by schorsch, Tue Oct 21 19:19:29 2003 UTC vs.
Revision 2.47 by greg, Tue Jun 8 19:48:31 2004 UTC

# Line 15 | Line 15 | static const char RCSid[] = "$Id$";
15  
16   #include "copyright.h"
17  
18 + #include <stdio.h>
19   #include <ctype.h>
20   #include <sys/stat.h>
21 + #include <time.h>
22 + #include <signal.h>
23  
24 < #include "standard.h"
24 > #include "platform.h"
25   #include "paths.h"
26 + #include "standard.h"
27   #include "view.h"
28   #include "vars.h"
29   #include "netproc.h"
# Line 117 | Line 121 | struct pslot {
121   int     npslots;                /* number of process slots */
122  
123   #define phostname(ps)   ((ps)->hostname[0] ? (ps)->hostname : astat.host)
120
121 struct pslot    *findpslot();
122
124   PSERVER *lastpserver;           /* last process server with error */
125  
126 < VIEW    *getview();
127 < char    *getexp(), *dirfile();
128 < int     getblur();
126 > static struct pslot * findpslot(int pid);
127 > static void checkdir(void);
128 > static VIEW * getview(int n);
129  
130 < extern time_t   time();
130 > static char * dirfile(char *df, register char *path);
131 > static char * getexp(int n);
132 > static int getblur(double *bf);
133 > static int getastat(void);
134 > static void getradfile(char *rfargs);
135 > static void badvalue(int vc);
136 > static int rmfile(char *fn);
137 > static int runcom(char *cs);
138 > static int pruncom(char *com, char *ppins, int maxcopies);
139 > static void bwait(int ncoms);
140 > static int bruncom(char *com, int fout, int (*rf)());
141 > static int serverdown(void);
142 > static pscompfunc donecom;
143 > static int countviews(void);
144 > static int dofilt(int frame, int rvr);
145 > static void archive(void);
146 > static int frecover(int frame);
147 > static int recover(int frame);
148 > static void sethosts(void);
149 > static void walkwait(int first, int last, char *vfn);
150 > static void animrend(int frame, VIEW *vp);
151 > static void transferframes(void);
152 > static void filterframes(void);
153 > static void renderframes(int nframes);
154 > static void animate(void);
155 > static void setdefaults(void);
156 > static void putastat(void);
157  
158  
159 < main(argc, argv)
160 < int     argc;
161 < char    *argv[];
159 > int
160 > main(
161 >        int     argc,
162 >        char    *argv[]
163 > )
164   {
165          int     explicate = 0;
166          int     i;
# Line 194 | Line 223 | char   *argv[];
223                  quit(1);
224          }
225          quit(0);
226 +        return 0; /* pro forma return */
227   userr:
228          fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname);
229          quit(1);
230 +        return 1; /* pro forma return */
231   }
232  
233  
234 < getastat()                      /* check/set animation status */
234 > static int
235 > getastat(void)                  /* check/set animation status */
236   {
237          char    sfname[256];
238          FILE    *fp;
# Line 264 | Line 296 | fmterr:
296   }
297  
298  
299 < putastat()                      /* put out current status */
299 > static void
300 > putastat(void)                  /* put out current status */
301   {
302          char    buf[256];
303          FILE    *fp;
# Line 286 | Line 319 | putastat()                     /* put out current status */
319   }
320  
321  
322 < checkdir()                      /* make sure we have our directory */
322 > static void
323 > checkdir(void)                  /* make sure we have our directory */
324   {
325          struct stat     stb;
326  
# Line 308 | Line 342 | checkdir()                     /* make sure we have our directory */
342   }
343  
344  
345 < setdefaults()                   /* set default values */
345 > static void
346 > setdefaults(void)                       /* set default values */
347   {
348          extern char     *atos();
349          int     decades;
# Line 396 | Line 431 | setdefaults()                  /* set default values */
431   }
432  
433  
434 < sethosts()                      /* set up process servers */
434 > static void
435 > sethosts(void)                  /* set up process servers */
436   {
437          extern char     *iskip();
438          char    buf[256], *dir, *uname;
# Line 451 | Line 487 | sethosts()                     /* set up process servers */
487          }
488   }
489  
490 <
491 < getradfile(rfargs)              /* run rad and get needed variables */
456 < char    *rfargs;
490 > static void
491 > getradfile(char *rfargs)                /* run rad and get needed variables */
492   {
493          static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
494          char    combuf[256];
495          register int    i;
496          register char   *cp;
497 <        char    *pippt;
497 >        char    *pippt = NULL;
498                                          /* create rad command */
499          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
500          sprintf(combuf,
# Line 491 | Line 526 | char   *rfargs;
526   }
527  
528  
529 < animate()                       /* run animation */
529 > static void
530 > animate(void)                   /* run animation */
531   {
532          int     xres, yres;
533          float   pa, mult;
# Line 562 | Line 598 | animate()                      /* run animation */
598   }
599  
600  
601 < renderframes(nframes)           /* render next nframes frames */
602 < int     nframes;
601 > static void
602 > renderframes(int nframes)               /* render next nframes frames */
603   {
604          static char     vendbuf[16];
605          VIEW    *vp;
# Line 619 | Line 655 | int    nframes;
655   }
656  
657  
658 < filterframes()                          /* catch up with filtering */
658 > static void
659 > filterframes(void)                              /* catch up with filtering */
660   {
624        VIEW    *vp;
661          register int    i;
662  
663          if (astat.tnext < astat.fnext)  /* other work to do first */
# Line 637 | Line 673 | filterframes()                         /* catch up with filtering */
673   }
674  
675  
676 < transferframes()                        /* catch up with picture transfers */
676 > static void
677 > transferframes(void)                    /* catch up with picture transfers */
678   {
679          char    combuf[10240], *fbase;
680          register char   *cp;
# Line 677 | Line 714 | transferframes()                       /* catch up with picture transfers
714   }
715  
716  
717 < animrend(frame, vp)                     /* start animation frame */
718 < int     frame;
719 < VIEW    *vp;
717 > static void
718 > animrend(                       /* start animation frame */
719 > int     frame,
720 > VIEW    *vp
721 > )
722   {
684        extern int      recover();
723          char    combuf[2048];
724          char    fname[128];
725  
# Line 695 | Line 733 | VIEW   *vp;
733   }
734  
735  
736 < walkwait(first, last, vfn)              /* walk-through frames */
737 < int     first, last;
738 < char    *vfn;
736 > static void
737 > walkwait(               /* walk-through frames */
738 > int     first,
739 > int last,
740 > char    *vfn
741 > )
742   {
743          double  blurf;
744          int     nblur = getblur(&blurf);
# Line 747 | Line 788 | char   *vfn;
788   }
789  
790  
791 < int
792 < recover(frame)                          /* recover the specified frame */
752 < int     frame;
791 > static int
792 > recover(int frame)                      /* recover the specified frame */
793   {
794          static int      *rfrm;          /* list of recovered frames */
795          static int      nrfrms = 0;
# Line 802 | Line 842 | int    frame;
842   }
843  
844  
845 < int
846 < frecover(frame)                         /* recover filtered frame */
807 < int     frame;
845 > static int
846 > frecover(int frame)                             /* recover filtered frame */
847   {
848          if (dofilt(frame, 2) && dofilt(frame, 1))
849                  return(1);
# Line 812 | Line 851 | int    frame;
851   }
852  
853  
854 < archive()                       /* archive and remove renderings */
854 > static void
855 > archive(void)                   /* archive and remove renderings */
856   {
857   #define RMCOML  (sizeof(rmcom)-1)
858          static char     rmcom[] = "rm -f";
# Line 855 | Line 895 | archive()                      /* archive and remove renderings */
895   }
896  
897  
898 < int
899 < dofilt(frame, rvr)                              /* filter frame */
900 < int     frame;
901 < int     rvr;
898 > static int
899 > dofilt(                         /* filter frame */
900 > int     frame,
901 > int     rvr
902 > )
903   {
863        extern int      frecover();
904          static int      iter = 0;
905          double  blurf;
906          int     nblur = getblur(&blurf);
# Line 877 | Line 917 | int    rvr;
917                                            progname, frame);
918                  quit(1);
919          }
880        if (ep == NULL) {
881                 fprintf(stderr,
882                        "%s: unexpected error reading exposure for frame %d\n",
883                                          progname, frame);
884                quit(1);
885        }
920          usepinterp = (nblur > 1);
921          usepfilt = pfiltalways | (ep==NULL);
922          if (ep != NULL && !strcmp(ep, "1"))
# Line 1017 | Line 1051 | int    rvr;
1051   }
1052  
1053  
1054 < VIEW *
1055 < getview(n)                      /* get view number n */
1022 < int     n;
1054 > static VIEW *
1055 > getview(int n)                  /* get view number n */
1056   {
1057          static FILE     *viewfp = NULL;         /* view file pointer */
1058          static int      viewnum = 0;            /* current view number */
# Line 1067 | Line 1100 | int    n;
1100   }
1101  
1102  
1103 < int
1104 < countviews()                    /* count views in view file */
1103 > static int
1104 > countviews(void)                        /* count views in view file */
1105   {
1106          int     n;
1107  
# Line 1080 | Line 1113 | countviews()                   /* count views in view file */
1113   }
1114  
1115  
1116 < char *
1117 < getexp(n)                       /* get exposure for nth frame */
1085 < int     n;
1116 > static char *
1117 > getexp(int n)                   /* get exposure for nth frame */
1118   {
1119          extern char     *fskip();
1120          static char     expval[32];
# Line 1151 | Line 1183 | int    n;
1183   }
1184  
1185  
1186 < struct pslot *
1187 < findpslot(pid)                  /* find or allocate a process slot */
1156 < int     pid;
1186 > static struct pslot *
1187 > findpslot(int pid)                      /* find or allocate a process slot */
1188   {
1189          register struct pslot   *psempty = NULL;
1190          register int    i;
# Line 1168 | Line 1199 | int    pid;
1199   }
1200  
1201  
1202 < int
1203 < donecom(ps, pn, status)         /* clean up after finished process */
1204 < PSERVER *ps;
1205 < int     pn;
1206 < int     status;
1202 > static int
1203 > donecom(                /* clean up after finished process */
1204 >        PSERVER *ps,
1205 >        int     pn,
1206 >        int     status
1207 > )
1208   {
1209 <        register PROC   *pp;
1209 >        register NETPROC        *pp;
1210          register struct pslot   *psl;
1211  
1212          pp = ps->proc + pn;
# Line 1209 | Line 1241 | int    status;
1241   }
1242  
1243  
1244 < int
1245 < serverdown()                    /* check status of last process server */
1244 > static int
1245 > serverdown(void)                        /* check status of last process server */
1246   {
1247          if (lastpserver == NULL || !lastpserver->hostname[0])
1248                  return(0);
# Line 1226 | Line 1258 | serverdown()                   /* check status of last process server
1258   }
1259  
1260  
1261 < int
1262 < bruncom(com, fout, rf)          /* run a command in the background */
1263 < char    *com;
1264 < int     fout;
1265 < int     (*rf)();
1261 > static int
1262 > bruncom(                /* run a command in the background */
1263 > char    *com,
1264 > int     fout,
1265 > int     (*rf)()
1266 > )
1267   {
1268          int     pid;
1269          register struct pslot   *psl;
# Line 1259 | Line 1292 | int    (*rf)();
1292   }
1293  
1294  
1295 < bwait(ncoms)                            /* wait for batch job(s) to finish */
1296 < int     ncoms;
1295 > static void
1296 > bwait(int ncoms)                                /* wait for batch job(s) to finish */
1297   {
1298          int     status;
1299  
# Line 1274 | Line 1307 | int    ncoms;
1307   }
1308  
1309  
1310 < int
1311 < pruncom(com, ppins, maxcopies)  /* run a command in parallel over network */
1312 < char    *com, *ppins;
1313 < int     maxcopies;
1310 > static int
1311 > pruncom(        /* run a command in parallel over network */
1312 > char    *com,
1313 > char    *ppins,
1314 > int     maxcopies
1315 > )
1316   {
1317          int     retstatus = 0;
1318          int     hostcopies;
# Line 1344 | Line 1379 | int    maxcopies;
1379   }
1380  
1381  
1382 < runcom(cs)                      /* run a command locally and wait for it */
1383 < char    *cs;
1382 > static int
1383 > runcom(char *cs)                        /* run a command locally and wait for it */
1384   {
1385          if (!silent)            /* echo it */
1386                  printf("\t%s\n", cs);
# Line 1356 | Line 1391 | char   *cs;
1391   }
1392  
1393  
1394 < rmfile(fn)                      /* remove a file */
1395 < char    *fn;
1394 > static int
1395 > rmfile(char *fn)                        /* remove a file */
1396   {
1397          if (!silent)
1398   #ifdef _WIN32
# Line 1371 | Line 1406 | char   *fn;
1406   }
1407  
1408  
1409 < badvalue(vc)                    /* report bad variable value and exit */
1410 < int     vc;
1409 > static void
1410 > badvalue(int vc)                        /* report bad variable value and exit */
1411   {
1412          fprintf(stderr, "%s: bad value for variable '%s'\n",
1413                          progname, vnam(vc));
# Line 1380 | Line 1415 | int    vc;
1415   }
1416  
1417  
1418 < char *
1419 < dirfile(df, path)               /* separate path into directory and file */
1420 < char    *df;
1421 < register char   *path;
1418 > static char *
1419 > dirfile(                /* separate path into directory and file */
1420 > char    *df,
1421 > register char   *path
1422 > )
1423   {
1424          register int    i;
1425          int     psep;
# Line 1405 | Line 1441 | register char  *path;
1441   }
1442  
1443  
1444 < int
1444 > static int
1445   getblur(double *bf)             /* get # blur samples (and fraction) */
1446   {
1447          double  blurf;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines