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.43 by schorsch, Mon Oct 27 10:32:06 2003 UTC vs.
Revision 2.50 by schorsch, Mon Sep 12 14:40:14 2005 UTC

# Line 19 | Line 19 | static const char RCSid[] = "$Id$";
19   #include <ctype.h>
20   #include <sys/stat.h>
21   #include <time.h>
22 + #include <signal.h>
23  
23 /*#include "standard.h"*/
24   #include "platform.h"
25 + #include "rtprocess.h"
26   #include "paths.h"
27 < #include "rtio.h"
27 < #include "rterror.h"
27 > #include "standard.h"
28   #include "view.h"
29   #include "vars.h"
30   #include "netproc.h"
# Line 33 | Line 33 | static const char RCSid[] = "$Id$";
33   #define DEF_NBLUR       5
34   #endif
35                                  /* default remote shell */
36 < #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},
# Line 91 | Line 95 | VARIABLE       vv[] = {                /* variable-value pairs */
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 */
# Line 115 | Line 119 | char   arcargs[10240];         /* files to archive */
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 */
# Line 124 | Line 128 | int    npslots;                /* number of process slots */
128   #define phostname(ps)   ((ps)->hostname[0] ? (ps)->hostname : astat.host)
129   PSERVER *lastpserver;           /* last process server with error */
130  
131 < static struct pslot * findpslot(int pid);
131 > static struct pslot * findpslot(RT_PID pid);
132   static void checkdir(void);
133   static VIEW * getview(int n);
134  
135   static char * dirfile(char *df, register char *path);
136   static char * getexp(int n);
137 < static int getblur(double *bf);
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);
# Line 138 | Line 142 | 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 int bruncom(char *com, int fout, int (*rf)());
145 > static RT_PID bruncom(char *com, int fout, int (*rf)());
146   static int serverdown(void);
147 < static int donecom(PSERVER *ps, int pn, int status);
147 > static pscompfunc donecom;
148   static int countviews(void);
149   static int dofilt(int frame, int rvr);
150   static void archive(void);
# Line 157 | Line 161 | 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;
# Line 222 | Line 228 | char   *argv[];
228                  quit(1);
229          }
230          quit(0);
231 +        return 0; /* pro forma return */
232   userr:
233          fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname);
234          quit(1);
235 +        return 1; /* pro forma return */
236   }
237  
238  
# Line 491 | Line 499 | getradfile(char *rfargs)               /* run rad and get needed va
499          char    combuf[256];
500          register int    i;
501          register char   *cp;
502 <        char    *pippt;
502 >        char    *pippt = NULL;
503                                          /* create rad command */
504          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
505          sprintf(combuf,
# Line 564 | Line 572 | animate(void)                  /* run animation */
572          }
573                                          /* figure # frames per batch */
574          d1 = mult*xres*mult*yres*4;             /* space for orig. picture */
575 <        if ((i=vint(INTERP)) || getblur(NULL) > 1)
575 >        if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1)
576                  d1 += mult*xres*mult*yres*sizeof(float);        /* Z-buffer */
577          d2 = xres*yres*4;                       /* space for final picture */
578          frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
# Line 655 | Line 663 | renderframes(int nframes)              /* render next nframes fram
663   static void
664   filterframes(void)                              /* catch up with filtering */
665   {
658        VIEW    *vp;
666          register int    i;
667  
668          if (astat.tnext < astat.fnext)  /* other work to do first */
# Line 718 | Line 725 | int    frame,
725   VIEW    *vp
726   )
727   {
721        extern int      recover();
728          char    combuf[2048];
729          char    fname[128];
730  
# Line 739 | Line 745 | int last,
745   char    *vfn
746   )
747   {
748 <        double  blurf;
749 <        int     nblur = getblur(&blurf);
748 >        double  mblurf, dblurf;
749 >        int     nblur = getblur(&mblurf, &dblurf);
750          char    combuf[2048];
751          register char   *inspoint;
752          register int    i;
# Line 758 | Line 764 | char   *vfn
764          inspoint = combuf;
765          while (*inspoint) inspoint++;
766          if (nblur) {
767 <                sprintf(inspoint, " -pm %.3f", blurf/nblur);
767 >                sprintf(inspoint, " -pm %.3f", mblurf/nblur);
768                  while (*inspoint) inspoint++;
769 +                sprintf(inspoint, " -pd %.3f", dblurf/nblur);
770 +                while (*inspoint) inspoint++;
771          }
772          if (nblur > 1 || vint(INTERP)) {
773                  sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
# Line 788 | Line 796 | char   *vfn
796  
797  
798   static int
799 < recover(int frame)                              /* recover the specified frame */
799 > recover(int frame)                      /* recover the specified frame */
800   {
801          static int      *rfrm;          /* list of recovered frames */
802          static int      nrfrms = 0;
803 <        double  blurf;
804 <        int     nblur = getblur(&blurf);
803 >        double  mblurf, dblurf;
804 >        int     nblur = getblur(&mblurf, &dblurf);
805          char    combuf[2048];
806          char    fname[128];
807          register char   *cp;
# Line 812 | Line 820 | recover(int frame)                             /* recover the specified frame *
820          cp = combuf;
821          while (*cp) cp++;
822          if (nblur) {
823 <                sprintf(cp, " -pm %.3f", blurf/nblur);
823 >                sprintf(cp, " -pm %.3f", mblurf/nblur);
824                  while (*cp) cp++;
825 +                sprintf(cp, " -pd %.3f", dblurf/nblur);
826 +                while (*cp) cp++;
827          }
828          if (nblur > 1 || vint(INTERP)) {
829                  sprintf(cp, " -z %s.zbf", fname);
# Line 900 | Line 910 | int    frame,
910   int     rvr
911   )
912   {
903        extern int      frecover();
913          static int      iter = 0;
914 <        double  blurf;
915 <        int     nblur = getblur(&blurf);
914 >        double  mblurf, dblurf;
915 >        int     nblur = getblur(&mblurf, &dblurf);
916          VIEW    *vp = getview(frame);
917          char    *ep = getexp(frame);
918          char    fnbefore[128], fnafter[128], *fbase;
# Line 917 | Line 926 | int    rvr
926                                            progname, frame);
927                  quit(1);
928          }
920        if (ep == NULL) {
921                 fprintf(stderr,
922                        "%s: unexpected error reading exposure for frame %d\n",
923                                          progname, frame);
924                quit(1);
925        }
929          usepinterp = (nblur > 1);
930          usepfilt = pfiltalways | (ep==NULL);
931          if (ep != NULL && !strcmp(ep, "1"))
# Line 968 | Line 971 | int    rvr
971          if (usepinterp) {                       /* using pinterp */
972                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
973                          return(1);
974 <                if (nblur > 1) {                /* with pmblur */
974 >                if (nblur > 1) {                /* with pdmblur */
975                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
976                                          'a'+(iter%26));
977                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
# Line 995 | Line 998 | int    rvr
998                                  putc('\n', fp); fclose(fp);
999                          }
1000                          sprintf(combuf,
1001 <                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
1002 <                                        blurf, nblur,
1001 >                        "(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
1002 >                                        mblurf, dblurf, nblur,
1003                                          fname0, fname1, fname0, fname1);
1004                          iter++;
1005                  } else                          /* no blurring */
# Line 1190 | Line 1193 | getexp(int n)                  /* get exposure for nth frame */
1193  
1194  
1195   static struct pslot *
1196 < findpslot(int pid)                      /* find or allocate a process slot */
1196 > findpslot(RT_PID pid)                   /* find or allocate a process slot */
1197   {
1198          register struct pslot   *psempty = NULL;
1199          register int    i;
# Line 1207 | Line 1210 | findpslot(int pid)                     /* find or allocate a process slo
1210  
1211   static int
1212   donecom(                /* clean up after finished process */
1213 < PSERVER *ps,
1214 < int     pn,
1215 < int     status
1213 >        PSERVER *ps,
1214 >        int     pn,
1215 >        int     status
1216   )
1217   {
1218          register NETPROC        *pp;
# Line 1264 | Line 1267 | serverdown(void)                       /* check status of last process ser
1267   }
1268  
1269  
1270 < static int
1270 > static RT_PID
1271   bruncom(                /* run a command in the background */
1272   char    *com,
1273   int     fout,
1274   int     (*rf)()
1275   )
1276   {
1277 <        int     pid;
1277 >        RT_PID  pid;
1278          register struct pslot   *psl;
1279  
1280          if (noaction) {
# Line 1284 | Line 1287 | int    (*rf)()
1287                  bwait(1);
1288          if (!silent) {                          /* echo command */
1289                  PSERVER *ps;
1290 <                int     psn = pid;
1290 >                RT_PID  psn = pid;
1291                  ps = findjob(&psn);
1292                  printf("\t%s\n", com);
1293                  printf("\tProcess started on %s\n", phostname(ps));
# Line 1448 | Line 1451 | register char  *path
1451  
1452  
1453   static int
1454 < getblur(double *bf)             /* get # blur samples (and fraction) */
1454 > getblur(double *mbf, double *dbf)       /* get # blur samples (and fraction) */
1455   {
1456 <        double  blurf;
1457 <        int     nblur;
1456 >        double  mblurf, dblurf;
1457 >        int     nmblur, ndblur;
1458          char    *s;
1459 <
1460 <        if (!vdef(MBLUR)) {
1461 <                if (bf != NULL)
1462 <                        *bf = 0.0;
1463 <                return(0);
1464 <        }
1465 <        blurf = atof(vval(MBLUR));
1466 <        if (blurf < 0.0)
1467 <                blurf = 0.0;
1468 <        if (bf != NULL)
1469 <                *bf = blurf;
1470 <        if (blurf <= FTINY)
1471 <                return(0);
1472 <        s = sskip(vval(MBLUR));
1473 <        if (!*s)
1474 <                return(DEF_NBLUR);
1475 <        nblur = atoi(s);
1476 <        if (nblur <= 0)
1459 >                                        /* get motion blur */
1460 >        if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0)
1461 >                mblurf = 0.0;
1462 >        if (mbf != NULL)
1463 >                *mbf = mblurf;
1464 >        if (mblurf <= FTINY)
1465 >                nmblur = 0;
1466 >        else if (!*(s = sskip(vval(MBLUR))))
1467 >                nmblur = DEF_NBLUR;
1468 >        else if ((nmblur = atoi(s)) <= 0)
1469 >                nmblur = 1;
1470 >                                        /* get depth-of-field blur */
1471 >        if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0)
1472 >                dblurf = 0.0;
1473 >        if (dbf != NULL)
1474 >                *dbf = dblurf;
1475 >        if (dblurf <= FTINY)
1476 >                ndblur = 0;
1477 >        else if (!*(s = sskip(vval(DBLUR))))
1478 >                ndblur = DEF_NBLUR;
1479 >        else if ((ndblur = atoi(s)) <= 0)
1480 >                ndblur = 1;
1481 >        if ((nmblur == 1) & (ndblur == 1))
1482                  return(1);
1483 <        return(nblur);
1483 >                                        /* return combined samples */
1484 >        return(nmblur + ndblur);
1485   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines