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.44 by greg, Tue Dec 9 22:46:41 2003 UTC vs.
Revision 2.49 by greg, Mon Feb 7 17:08:17 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 "paths.h"
26 < #include "rtio.h"
27 < #include "rterror.h"
26 > #include "standard.h"
27   #include "view.h"
28   #include "vars.h"
29   #include "netproc.h"
# Line 33 | Line 32 | static const char RCSid[] = "$Id$";
32   #define DEF_NBLUR       5
33   #endif
34                                  /* default remote shell */
35 < #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               /* motion blur parameters */
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 +        {"DBLUR",       2,      0,      NULL,   onevalue},
71          {"DIRECTORY",   3,      0,      NULL,   onevalue},
72          {"DISKSPACE",   3,      0,      NULL,   fltvalue},
73          {"END",         2,      0,      NULL,   intvalue},
# Line 130 | Line 133 | static VIEW * getview(int n);
133  
134   static char * dirfile(char *df, register char *path);
135   static char * getexp(int n);
136 < static int getblur(double *bf);
136 > static int getblur(double *mbf, double *dbf);
137   static int getastat(void);
138   static void getradfile(char *rfargs);
139   static void badvalue(int vc);
# Line 140 | Line 143 | static int pruncom(char *com, char *ppins, int maxcopi
143   static void bwait(int ncoms);
144   static int bruncom(char *com, int fout, int (*rf)());
145   static int serverdown(void);
146 < static int donecom(PSERVER *ps, int pn, int status);
146 > static pscompfunc donecom;
147   static int countviews(void);
148   static int dofilt(int frame, int rvr);
149   static void archive(void);
# Line 157 | Line 160 | static void setdefaults(void);
160   static void putastat(void);
161  
162  
163 < main(argc, argv)
164 < int     argc;
165 < char    *argv[];
163 > int
164 > main(
165 >        int     argc,
166 >        char    *argv[]
167 > )
168   {
169          int     explicate = 0;
170          int     i;
# Line 222 | Line 227 | char   *argv[];
227                  quit(1);
228          }
229          quit(0);
230 +        return 0; /* pro forma return */
231   userr:
232          fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname);
233          quit(1);
234 +        return 1; /* pro forma return */
235   }
236  
237  
# Line 491 | Line 498 | getradfile(char *rfargs)               /* run rad and get needed va
498          char    combuf[256];
499          register int    i;
500          register char   *cp;
501 <        char    *pippt;
501 >        char    *pippt = NULL;
502                                          /* create rad command */
503          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
504          sprintf(combuf,
# Line 564 | Line 571 | animate(void)                  /* run animation */
571          }
572                                          /* figure # frames per batch */
573          d1 = mult*xres*mult*yres*4;             /* space for orig. picture */
574 <        if ((i=vint(INTERP)) || getblur(NULL) > 1)
574 >        if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1)
575                  d1 += mult*xres*mult*yres*sizeof(float);        /* Z-buffer */
576          d2 = xres*yres*4;                       /* space for final picture */
577          frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
# Line 655 | Line 662 | renderframes(int nframes)              /* render next nframes fram
662   static void
663   filterframes(void)                              /* catch up with filtering */
664   {
658        VIEW    *vp;
665          register int    i;
666  
667          if (astat.tnext < astat.fnext)  /* other work to do first */
# Line 738 | Line 744 | int last,
744   char    *vfn
745   )
746   {
747 <        double  blurf;
748 <        int     nblur = getblur(&blurf);
747 >        double  mblurf, dblurf;
748 >        int     nblur = getblur(&mblurf, &dblurf);
749          char    combuf[2048];
750          register char   *inspoint;
751          register int    i;
# Line 757 | Line 763 | char   *vfn
763          inspoint = combuf;
764          while (*inspoint) inspoint++;
765          if (nblur) {
766 <                sprintf(inspoint, " -pm %.3f", blurf/nblur);
766 >                sprintf(inspoint, " -pm %.3f", mblurf/nblur);
767                  while (*inspoint) inspoint++;
768 +                sprintf(inspoint, " -pd %.3f", dblurf/nblur);
769 +                while (*inspoint) inspoint++;
770          }
771          if (nblur > 1 || vint(INTERP)) {
772                  sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
# Line 791 | Line 799 | recover(int frame)                     /* recover the specified frame */
799   {
800          static int      *rfrm;          /* list of recovered frames */
801          static int      nrfrms = 0;
802 <        double  blurf;
803 <        int     nblur = getblur(&blurf);
802 >        double  mblurf, dblurf;
803 >        int     nblur = getblur(&mblurf, &dblurf);
804          char    combuf[2048];
805          char    fname[128];
806          register char   *cp;
# Line 811 | Line 819 | recover(int frame)                     /* recover the specified frame */
819          cp = combuf;
820          while (*cp) cp++;
821          if (nblur) {
822 <                sprintf(cp, " -pm %.3f", blurf/nblur);
822 >                sprintf(cp, " -pm %.3f", mblurf/nblur);
823                  while (*cp) cp++;
824 +                sprintf(cp, " -pd %.3f", dblurf/nblur);
825 +                while (*cp) cp++;
826          }
827          if (nblur > 1 || vint(INTERP)) {
828                  sprintf(cp, " -z %s.zbf", fname);
# Line 900 | Line 910 | int    rvr
910   )
911   {
912          static int      iter = 0;
913 <        double  blurf;
914 <        int     nblur = getblur(&blurf);
913 >        double  mblurf, dblurf;
914 >        int     nblur = getblur(&mblurf, &dblurf);
915          VIEW    *vp = getview(frame);
916          char    *ep = getexp(frame);
917          char    fnbefore[128], fnafter[128], *fbase;
# Line 915 | Line 925 | int    rvr
925                                            progname, frame);
926                  quit(1);
927          }
918        if (ep == NULL) {
919                 fprintf(stderr,
920                        "%s: unexpected error reading exposure for frame %d\n",
921                                          progname, frame);
922                quit(1);
923        }
928          usepinterp = (nblur > 1);
929          usepfilt = pfiltalways | (ep==NULL);
930          if (ep != NULL && !strcmp(ep, "1"))
# Line 966 | Line 970 | int    rvr
970          if (usepinterp) {                       /* using pinterp */
971                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
972                          return(1);
973 <                if (nblur > 1) {                /* with pmblur */
973 >                if (nblur > 1) {                /* with pdmblur */
974                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
975                                          'a'+(iter%26));
976                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
# Line 993 | Line 997 | int    rvr
997                                  putc('\n', fp); fclose(fp);
998                          }
999                          sprintf(combuf,
1000 <                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
1001 <                                        blurf, nblur,
1000 >                        "(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
1001 >                                        mblurf, dblurf, nblur,
1002                                          fname0, fname1, fname0, fname1);
1003                          iter++;
1004                  } else                          /* no blurring */
# Line 1205 | Line 1209 | findpslot(int pid)                     /* find or allocate a process slo
1209  
1210   static int
1211   donecom(                /* clean up after finished process */
1212 < PSERVER *ps,
1213 < int     pn,
1214 < int     status
1212 >        PSERVER *ps,
1213 >        int     pn,
1214 >        int     status
1215   )
1216   {
1217          register NETPROC        *pp;
# Line 1446 | Line 1450 | register char  *path
1450  
1451  
1452   static int
1453 < getblur(double *bf)             /* get # blur samples (and fraction) */
1453 > getblur(double *mbf, double *dbf)       /* get # blur samples (and fraction) */
1454   {
1455 <        double  blurf;
1456 <        int     nblur;
1455 >        double  mblurf, dblurf;
1456 >        int     nmblur, ndblur;
1457          char    *s;
1458 <
1459 <        if (!vdef(MBLUR)) {
1460 <                if (bf != NULL)
1461 <                        *bf = 0.0;
1462 <                return(0);
1463 <        }
1464 <        blurf = atof(vval(MBLUR));
1465 <        if (blurf < 0.0)
1466 <                blurf = 0.0;
1467 <        if (bf != NULL)
1468 <                *bf = blurf;
1469 <        if (blurf <= FTINY)
1470 <                return(0);
1471 <        s = sskip(vval(MBLUR));
1472 <        if (!*s)
1473 <                return(DEF_NBLUR);
1474 <        nblur = atoi(s);
1475 <        if (nblur <= 0)
1458 >                                        /* get motion blur */
1459 >        if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0)
1460 >                mblurf = 0.0;
1461 >        if (mbf != NULL)
1462 >                *mbf = mblurf;
1463 >        if (mblurf <= FTINY)
1464 >                nmblur = 0;
1465 >        else if (!*(s = sskip(vval(MBLUR))))
1466 >                nmblur = DEF_NBLUR;
1467 >        else if ((nmblur = atoi(s)) <= 0)
1468 >                nmblur = 1;
1469 >                                        /* get depth-of-field blur */
1470 >        if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0)
1471 >                dblurf = 0.0;
1472 >        if (dbf != NULL)
1473 >                *dbf = dblurf;
1474 >        if (dblurf <= FTINY)
1475 >                ndblur = 0;
1476 >        else if (!*(s = sskip(vval(DBLUR))))
1477 >                ndblur = DEF_NBLUR;
1478 >        else if ((ndblur = atoi(s)) <= 0)
1479 >                ndblur = 1;
1480 >        if ((nmblur == 1) & (ndblur == 1))
1481                  return(1);
1482 <        return(nblur);
1482 >                                        /* return combined samples */
1483 >        return(nmblur + ndblur);
1484   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines