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.7 by greg, Wed Jan 24 12:22:15 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 406 | Line 409 | sethosts()                     /* set up process servers */
409   }
410  
411  
412 < getradfile(rfname)              /* run rad and get needed variables */
413 < char    *rfname;
412 > getradfile(rfargs)              /* run rad and get needed variables */
413 > char    *rfargs;
414   {
415          static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
416          char    combuf[256];
# Line 417 | Line 420 | char   *rfname;
420          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
421          sprintf(combuf,
422          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
423 <                        rfname, rendopt+2);
423 >                        rfargs, rendopt+2);
424          cp = combuf;
425          while (*cp) cp++;               /* match unset variables */
426          for (i = 0; mvar[i] >= 0; i++)
# Line 429 | Line 432 | char   *rfname;
432          sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
433          cp += 11;                       /* point to file name */
434          if (system(combuf)) {
435 <                fprintf(stderr, "%s: bad rad input file \"%s\"\n",
436 <                                progname, rfname);
435 >                fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
436 >                                progname, combuf);
437                  quit(1);
438          }
439          loadvars(cp);                   /* load variables and remove file */
# Line 487 | Line 490 | animate()                      /* run animation */
490                                  progname);
491                  quit(1);
492          }
493 +                                        /* initialize archive argument list */
494 +        i = 16;
495 +        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
496 +                i = strlen(vval(ARCHIVE));
497 +        arcnext = arcfirst = arcargs + i;
498                                          /* initialize status file */
499          if (astat.rnext == 0)
500                  astat.rnext = astat.fnext = astat.tnext = vint(START);
# Line 581 | Line 589 | filterframes()                         /* catch up with filtering */
589                  dofilt(i, vp, getexp(i), 0);            /* filter frame */
590          }
591          bwait(0);                       /* wait for filter processes */
592 <        archive(astat.fnext, i-1);      /* archive originals */
592 >        archive();                      /* archive originals */
593          astat.fnext = i;                /* update status */
594          putastat();
595   }
# Line 662 | Line 670 | char   *vfn;
670          inspoint = combuf + strlen(combuf);
671          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
672                                          /* run in parallel */
673 <        if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) {
673 >        i = (last-first+1)/(vint(INTERP)+1);
674 >        if (i < 1) i = 1;
675 >        if (pruncom(combuf, inspoint, i)) {
676                  fprintf(stderr, "%s: error rendering frames %d through %d\n",
677                                  progname, first, last);
678                  quit(1);
# Line 740 | Line 750 | int    frame;
750   }
751  
752  
753 < archive(first, last)                    /* archive and remove renderings */
744 < int     first, last;
753 > archive()                       /* archive and remove renderings */
754   {
755   #define RMCOML  (sizeof(rmcom)-1)
756          static char     rmcom[] = "rm -f";
748        int     offset = RMCOML;
749        char    combuf[10240];
750        struct stat     stb;
751        register char   *cp;
757          register int    i;
758  
759 <        if (noaction)
760 <                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;
759 >        if (arcnext == arcfirst)
760 >                return;                         /* nothing to do */
761          if (vdef(ARCHIVE)) {                    /* run archive command */
762                  i = strlen(vval(ARCHIVE));
763 <                strncpy(combuf+offset-i, vval(ARCHIVE), i);
764 <                if (runcom(combuf+offset-i)) {
765 <                        fprintf(stderr,
766 <                "%s: error running archive command on frames %d through %d\n",
783 <                                        progname, first, last);
763 >                strncpy(arcfirst-i, vval(ARCHIVE), i);
764 >                if (runcom(arcfirst-i)) {
765 >                        fprintf(stderr, "%s: error running archive command\n",
766 >                                        progname);
767                          quit(1);
768                  }
769          }
770                                                  /* run remove command */
771 <        strncpy(combuf+offset-RMCOML, rmcom, RMCOML);
772 <        runcom(combuf+offset-RMCOML);
771 >        strncpy(arcfirst-RMCOML, rmcom, RMCOML);
772 >        runcom(arcfirst-RMCOML);
773 >        arcnext = arcfirst;                     /* reset argument list */
774   #undef RMCOML
775   }
776  
# Line 799 | Line 783 | char   *ep;
783   int     rvr;
784   {
785          extern int      frecover();
786 +        static int      iter = 0;
787          char    fnbefore[128], fnafter[128];
788 <        char    combuf[1024], fname[128];
789 <        int     usepinterp, usepfilt;
788 >        char    combuf[1024], fname0[128], fname1[128];
789 >        int     usepinterp, usepfilt, nora_rgbe;
790          int     frseq[2];
791                                                  /* check what is needed */
792          usepinterp = atoi(vval(MBLUR));
793          usepfilt = pfiltalways | ep==NULL;
794 +        if (ep != NULL && !strcmp(ep, "1"))
795 +                ep = "+0";
796 +        nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
797 +                        *ep != '+' || *ep != '-' || !isint(ep);
798                                                  /* compute rendered views */
799          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
800          frseq[1] = frseq[0] + vint(INTERP) + 1;
# Line 814 | Line 803 | int    rvr;
803          if (frseq[1] == frame) {                        /* pfilt only */
804                  frseq[0] = frseq[1];
805                  usepinterp = 0;                 /* update what's needed */
806 <                usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
807 <        } else if (frseq[0] == frame) {         /* no interpolation */
808 <                                                /* update what's needed */
809 <                if (!usepinterp)
810 <                        usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
806 >                usepfilt |= nora_rgbe;
807 >        } else if (frseq[0] == frame) {         /* no interpolation needed */
808 >                if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
809 >                        *arcnext++ = ' ';
810 >                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
811 >                        while (*arcnext) arcnext++;
812 >                        strcpy(arcnext, ".unf");
813 >                        arcnext += 4;
814 >                        if (usepinterp || vint(INTERP)) {       /* and z-buf */
815 >                                *arcnext++ = ' ';
816 >                                sprintf(arcnext, vval(BASENAME),
817 >                                                frame-vint(INTERP)-1);
818 >                                while (*arcnext) arcnext++;
819 >                                strcpy(arcnext, ".zbf");
820 >                                arcnext += 4;
821 >                        }
822 >                }
823 >                if (!usepinterp)                /* update what's needed */
824 >                        usepfilt |= nora_rgbe;
825          } else                                  /* interpolation needed */
826                  usepinterp++;
827          if (frseq[1] >= astat.rnext)            /* next batch unavailable */
# Line 833 | Line 836 | int    rvr;
836                          return(1);
837                  if (atoi(vval(MBLUR))) {
838                          FILE    *fp;            /* motion blurring */
839 <                        sprintf(fname, "%s/vw0", vval(DIRECTORY));
840 <                        if (access(fname, F_OK) == 0)
841 <                                sleep(10);
842 <                        if ((fp = fopen(fname, "w")) == NULL) {
840 <                                perror(fname); quit(1);
839 >                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
840 >                                        'a'+(iter%26));
841 >                        if ((fp = fopen(fname0, "w")) == NULL) {
842 >                                perror(fname0); quit(1);
843                          }
844                          fputs(VIEWSTR, fp);
845                          fprintview(vp, fp);
# Line 848 | Line 850 | int    rvr;
850                                                  progname, frame+1);
851                                  quit(1);
852                          }
853 <                        sprintf(fname, "%s/vw1", vval(DIRECTORY));
854 <                        if ((fp = fopen(fname, "w")) == NULL) {
855 <                                perror(fname); quit(1);
853 >                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
854 >                                        'a'+(iter%26));
855 >                        if ((fp = fopen(fname1, "w")) == NULL) {
856 >                                perror(fname1); quit(1);
857                          }
858                          fputs(VIEWSTR, fp);
859                          fprintview(vp, fp);
860                          putc('\n', fp); fclose(fp);
861                          sprintf(combuf,
862 <        "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B",
862 >                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
863                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
864 <                                        atoi(vval(MBLUR)), vval(DIRECTORY),
865 <                                        vval(DIRECTORY), vval(DIRECTORY),
866 <                                        vval(DIRECTORY), vval(DIRECTORY));
864 >                                        atoi(vval(MBLUR)),
865 >                                        fname0, fname1, fname0, fname1);
866 >                        iter++;
867                  } else                          /* no blurring */
868                          strcpy(combuf, "pinterp");
869                  strcat(combuf, viewopt(vp));
# Line 907 | Line 910 | int    rvr;
910          } else {                                /* else just check it */
911                  if (rvr == 2)
912                          return(1);
913 <                sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore);
913 >                sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore);
914          }
915                                                  /* output file name */
916 <        sprintf(fname, vval(BASENAME), frame);
917 <        sprintf(combuf+strlen(combuf), " > %s.pic", fname);
916 >        sprintf(fname0, vval(BASENAME), frame);
917 >        sprintf(combuf+strlen(combuf), " > %s.pic", fname0);
918          if (rvr)                                /* in recovery */
919                  return(runcom(combuf));
920          bruncom(combuf, frame, frecover);       /* else run in background */
# Line 1166 | Line 1169 | int    maxcopies;
1169          register PSERVER        *ps;
1170  
1171          if (!silent)
1172 <                printf("\t%s &\n", com);        /* echo command */
1172 >                printf("\t%s\n", com);  /* echo command */
1173          if (noaction)
1174                  return(0);
1175          fflush(stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines