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.5 by greg, Tue Jan 23 16:14:28 1996 UTC vs.
Revision 2.9 by greg, Wed Feb 7 16:42:41 1996 UTC

# Line 89 | Line 89 | char   rresopt[32];            /* rendering resolution options */
89   char    fresopt[32];            /* filter resolution options */
90   int     pfiltalways;            /* always use pfilt? */
91  
92 + char    arcargs[10240];         /* files to archive */
93 + char    *arcfirst, *arcnext;    /* pointers to first and next argument */
94 +
95   struct pslot {
96          int     pid;                    /* process ID (0 if empty) */
97          int     fout;                   /* output frame number */
# Line 201 | Line 204 | getastat()                     /* check/set animation status */
204                  goto fmterr;
205          fclose(fp);
206          if (astat.pid != 0) {                   /* thinks it's still running */
207 <                gethostname(buf, sizeof(buf));
205 <                if (strcmp(buf, astat.host)) {
207 >                if (strcmp(myhostname(), astat.host)) {
208                          fprintf(stderr,
209                          "%s: process %d may still be running on host %s\n",
210                                          progname, astat.pid, astat.host);
# Line 221 | Line 223 | getastat()                     /* check/set animation status */
223                  return(-1);
224          }
225   setours:                                        /* set our values */
226 <        gethostname(astat.host, sizeof(astat.host));
226 >        strcpy(astat.host, myhostname());
227          astat.pid = getpid();
228          strcpy(astat.cfname, cfname);
229          return(0);
# Line 406 | Line 408 | sethosts()                     /* set up process servers */
408   }
409  
410  
411 < getradfile(rfname)              /* run rad and get needed variables */
412 < char    *rfname;
411 > getradfile(rfargs)              /* run rad and get needed variables */
412 > char    *rfargs;
413   {
414          static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
415          char    combuf[256];
# Line 417 | Line 419 | char   *rfname;
419          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
420          sprintf(combuf,
421          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
422 <                        rfname, rendopt+2);
422 >                        rfargs, rendopt+2);
423          cp = combuf;
424          while (*cp) cp++;               /* match unset variables */
425          for (i = 0; mvar[i] >= 0; i++)
# Line 429 | Line 431 | char   *rfname;
431          sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
432          cp += 11;                       /* point to file name */
433          if (system(combuf)) {
434 <                fprintf(stderr, "%s: bad rad input file \"%s\"\n",
435 <                                progname, rfname);
434 >                fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
435 >                                progname, combuf);
436                  quit(1);
437          }
438          loadvars(cp);                   /* load variables and remove file */
# Line 487 | Line 489 | animate()                      /* run animation */
489                                  progname);
490                  quit(1);
491          }
492 +                                        /* initialize archive argument list */
493 +        i = 16;
494 +        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
495 +                i = strlen(vval(ARCHIVE));
496 +        arcnext = arcfirst = arcargs + i;
497                                          /* initialize status file */
498          if (astat.rnext == 0)
499                  astat.rnext = astat.fnext = astat.tnext = vint(START);
# Line 581 | Line 588 | filterframes()                         /* catch up with filtering */
588                  dofilt(i, vp, getexp(i), 0);            /* filter frame */
589          }
590          bwait(0);                       /* wait for filter processes */
591 <        archive(astat.fnext, i-1);      /* archive originals */
591 >        archive();                      /* archive originals */
592          astat.fnext = i;                /* update status */
593          putastat();
594   }
# Line 662 | Line 669 | char   *vfn;
669          inspoint = combuf + strlen(combuf);
670          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
671                                          /* run in parallel */
672 <        if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) {
672 >        i = (last-first+1)/(vint(INTERP)+1);
673 >        if (i < 1) i = 1;
674 >        if (pruncom(combuf, inspoint, i)) {
675                  fprintf(stderr, "%s: error rendering frames %d through %d\n",
676                                  progname, first, last);
677                  quit(1);
# Line 740 | Line 749 | int    frame;
749   }
750  
751  
752 < archive(first, last)                    /* archive and remove renderings */
744 < int     first, last;
752 > archive()                       /* archive and remove renderings */
753   {
754   #define RMCOML  (sizeof(rmcom)-1)
755          static char     rmcom[] = "rm -f";
748        int     offset = RMCOML;
749        char    combuf[10240];
750        struct stat     stb;
751        register char   *cp;
756          register int    i;
757  
758 <        if (noaction)
759 <                return;
756 <        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset)
757 <                offset = strlen(vval(ARCHIVE));
758 <        cp = combuf + offset;
759 <        *cp++ = ' ';                            /* make argument list */
760 <        for (i = first; i <= last; i++) {
761 <                sprintf(cp, vval(BASENAME), i);
762 <                strcat(cp, ".unf");
763 <                if (stat(cp, &stb) == 0 && stb.st_size > 0) {   /* non-zero? */
764 <                        while (*cp) cp++;
765 <                        *cp++ = ' ';
766 <                        sprintf(cp, vval(BASENAME), i);
767 <                        strcat(cp, ".zbf");
768 <                        if (access(cp, F_OK) == 0) {            /* exists? */
769 <                                while (*cp) cp++;
770 <                                *cp++ = ' ';
771 <                        }
772 <                }
773 <        }
774 <        *--cp = '\0';
775 <        if (cp <= combuf + offset)              /* no files? */
776 <                return;
758 >        if (arcnext == arcfirst)
759 >                return;                         /* nothing to do */
760          if (vdef(ARCHIVE)) {                    /* run archive command */
761                  i = strlen(vval(ARCHIVE));
762 <                strncpy(combuf+offset-i, vval(ARCHIVE), i);
763 <                if (runcom(combuf+offset-i)) {
764 <                        fprintf(stderr,
765 <                "%s: error running archive command on frames %d through %d\n",
783 <                                        progname, first, last);
762 >                strncpy(arcfirst-i, vval(ARCHIVE), i);
763 >                if (runcom(arcfirst-i)) {
764 >                        fprintf(stderr, "%s: error running archive command\n",
765 >                                        progname);
766                          quit(1);
767                  }
768          }
769                                                  /* run remove command */
770 <        strncpy(combuf+offset-RMCOML, rmcom, RMCOML);
771 <        runcom(combuf+offset-RMCOML);
770 >        strncpy(arcfirst-RMCOML, rmcom, RMCOML);
771 >        runcom(arcfirst-RMCOML);
772 >        arcnext = arcfirst;                     /* reset argument list */
773   #undef RMCOML
774   }
775  
# Line 799 | Line 782 | char   *ep;
782   int     rvr;
783   {
784          extern int      frecover();
785 +        static int      iter = 0;
786          char    fnbefore[128], fnafter[128];
787 <        char    combuf[1024], fname[128];
788 <        int     usepinterp, usepfilt;
787 >        char    combuf[1024], fname0[128], fname1[128];
788 >        int     usepinterp, usepfilt, nora_rgbe;
789          int     frseq[2];
790                                                  /* check what is needed */
791          usepinterp = atoi(vval(MBLUR));
792          usepfilt = pfiltalways | ep==NULL;
793 +        if (ep != NULL && !strcmp(ep, "1"))
794 +                ep = "+0";
795 +        nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
796 +                        *ep != '+' || *ep != '-' || !isint(ep);
797                                                  /* compute rendered views */
798          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
799          frseq[1] = frseq[0] + vint(INTERP) + 1;
# Line 814 | Line 802 | int    rvr;
802          if (frseq[1] == frame) {                        /* pfilt only */
803                  frseq[0] = frseq[1];
804                  usepinterp = 0;                 /* update what's needed */
805 <                usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
806 <        } else if (frseq[0] == frame) {         /* no interpolation */
807 <                                                /* update what's needed */
808 <                if (!usepinterp)
809 <                        usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
805 >                usepfilt |= nora_rgbe;
806 >        } else if (frseq[0] == frame) {         /* no interpolation needed */
807 >                if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
808 >                        *arcnext++ = ' ';
809 >                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
810 >                        while (*arcnext) arcnext++;
811 >                        strcpy(arcnext, ".unf");
812 >                        arcnext += 4;
813 >                        if (usepinterp || vint(INTERP)) {       /* and z-buf */
814 >                                *arcnext++ = ' ';
815 >                                sprintf(arcnext, vval(BASENAME),
816 >                                                frame-vint(INTERP)-1);
817 >                                while (*arcnext) arcnext++;
818 >                                strcpy(arcnext, ".zbf");
819 >                                arcnext += 4;
820 >                        }
821 >                }
822 >                if (!usepinterp)                /* update what's needed */
823 >                        usepfilt |= nora_rgbe;
824          } else                                  /* interpolation needed */
825                  usepinterp++;
826          if (frseq[1] >= astat.rnext)            /* next batch unavailable */
# Line 833 | Line 835 | int    rvr;
835                          return(1);
836                  if (atoi(vval(MBLUR))) {
837                          FILE    *fp;            /* motion blurring */
838 <                        sprintf(fname, "%s/vw0", vval(DIRECTORY));
839 <                        if (access(fname, F_OK) == 0)
840 <                                sleep(10);
841 <                        if ((fp = fopen(fname, "w")) == NULL) {
840 <                                perror(fname); quit(1);
838 >                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
839 >                                        'a'+(iter%26));
840 >                        if ((fp = fopen(fname0, "w")) == NULL) {
841 >                                perror(fname0); quit(1);
842                          }
843                          fputs(VIEWSTR, fp);
844                          fprintview(vp, fp);
# Line 848 | Line 849 | int    rvr;
849                                                  progname, frame+1);
850                                  quit(1);
851                          }
852 <                        sprintf(fname, "%s/vw1", vval(DIRECTORY));
853 <                        if ((fp = fopen(fname, "w")) == NULL) {
854 <                                perror(fname); quit(1);
852 >                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
853 >                                        'a'+(iter%26));
854 >                        if ((fp = fopen(fname1, "w")) == NULL) {
855 >                                perror(fname1); quit(1);
856                          }
857                          fputs(VIEWSTR, fp);
858                          fprintview(vp, fp);
859                          putc('\n', fp); fclose(fp);
860                          sprintf(combuf,
861 <        "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B",
861 >                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
862                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
863 <                                        atoi(vval(MBLUR)), vval(DIRECTORY),
864 <                                        vval(DIRECTORY), vval(DIRECTORY),
865 <                                        vval(DIRECTORY), vval(DIRECTORY));
863 >                                        atoi(vval(MBLUR)),
864 >                                        fname0, fname1, fname0, fname1);
865 >                        iter++;
866                  } else                          /* no blurring */
867                          strcpy(combuf, "pinterp");
868                  strcat(combuf, viewopt(vp));
# Line 907 | Line 909 | int    rvr;
909          } else {                                /* else just check it */
910                  if (rvr == 2)
911                          return(1);
912 <                sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore);
912 >                sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore);
913          }
914                                                  /* output file name */
915 <        sprintf(fname, vval(BASENAME), frame);
916 <        sprintf(combuf+strlen(combuf), " > %s.pic", fname);
915 >        sprintf(fname0, vval(BASENAME), frame);
916 >        sprintf(combuf+strlen(combuf), " > %s.pic", fname0);
917          if (rvr)                                /* in recovery */
918                  return(runcom(combuf));
919          bruncom(combuf, frame, frecover);       /* else run in background */
# Line 943 | Line 945 | int    n;
945                          quit(1);
946                  }
947          } else if (n < viewnum) {       /* rewind file */
948 +                if (viewnum == 1 && feof(viewfp))
949 +                        return(&curview);               /* just one view */
950                  if (fseek(viewfp, 0L, 0) == EOF) {
951                          perror(vval(VIEWFILE));
952                          quit(1);
# Line 952 | Line 956 | int    n;
956          }
957          while (n > viewnum) {           /* scan to desired view */
958                  if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL)
959 <                        return(NULL);
959 >                        return(viewnum==1 ? &curview : NULL);
960                  if (isview(linebuf) && sscanview(&curview, linebuf) > 0)
961                          viewnum++;
962          }
# Line 1166 | Line 1170 | int    maxcopies;
1170          register PSERVER        *ps;
1171  
1172          if (!silent)
1173 <                printf("\t%s &\n", com);        /* echo command */
1173 >                printf("\t%s\n", com);  /* echo command */
1174          if (noaction)
1175                  return(0);
1176          fflush(stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines