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

Comparing ray/src/util/ranimove1.c (file contents):
Revision 3.7 by schorsch, Tue Oct 21 19:19:29 2003 UTC vs.
Revision 3.18 by greg, Fri Sep 28 22:20:49 2012 UTC

# Line 4 | Line 4 | static const char      RCSid[] = "$Id$";
4   /*
5   *  ranimove1.c
6   *
7 < *  Basic frame rendering routines for ranimate(1).
7 > *  Basic frame rendering routines for ranimove(1).
8   *
9   *  Created by Gregory Ward on Wed Jan 08 2003.
10   */
# Line 16 | Line 16 | static const char      RCSid[] = "$Id$";
16   #include "platform.h"
17   #include "ranimove.h"
18   #include "otypes.h"
19 + #include "source.h"
20   #include "random.h"
21  
22   double          acctab[256];    /* accuracy value table */
# Line 29 | Line 30 | float          *zbuffer;       /* depth at each pixel */
30   OBJECT          *obuffer;       /* object id at each pixel */
31   short           *xmbuffer;      /* x motion at each pixel */
32   short           *ymbuffer;      /* y motion at each pixel */
33 < BYTE            *abuffer;       /* accuracy at each pixel */
34 < BYTE            *sbuffer;       /* sample count per pixel */
33 > uby8            *abuffer;       /* accuracy at each pixel */
34 > uby8            *sbuffer;       /* sample count per pixel */
35  
36   VIEW            vwprev;         /* last frame's view */
37   COLOR           *cprev;         /* last frame colors */
38   float           *zprev;         /* last frame depth */
39   OBJECT          *oprev;         /* last frame objects */
40 < BYTE            *aprev;         /* last frame accuracy */
40 > uby8            *aprev;         /* last frame accuracy */
41  
42   float           *cerrmap;       /* conspicuous error map */
43   COLOR           *val2map;       /* value-squared map for variance */
# Line 46 | Line 47 | double         frm_stop;       /* when to stop rendering this frame
47   double          hlsmax;         /* maximum high-level saliency this frame */
48  
49  
50 < void
51 < write_map(mp, fn)               /* write out float map (debugging) */
52 < float   *mp;
53 < char    *fn;
50 > static void next_frame(void);
51 > static int sample_here(int      x, int  y);
52 > static int offset_cmp(const void        *p1, const void *p2);
53 > static void setmotion(int       n, FVECT        wpos);
54 > static void init_frame_sample(void);
55 >
56 >
57 > #if 0
58 > extern void
59 > write_map(              /* write out float map (debugging) */
60 >        float   *mp,
61 >        char    *fn
62 > )
63   {
64          FILE    *fp = fopen(fn, "w");
65          COLOR   scanbuf[2048];
# Line 70 | Line 80 | char   *fn;
80          }
81          fclose(fp);
82   }
83 + #endif
84  
85  
86   static void
87 < next_frame()                    /* prepare next frame buffer */
87 > next_frame(void)                        /* prepare next frame buffer */
88   {
89          VIEW    *fv;
90          char    *err;
# Line 96 | Line 107 | next_frame()                   /* prepare next frame buffer */
107                  error(USER, errmsg);
108          }
109          if (cbuffer == NULL) {
110 +                int     n;
111                                          /* compute resolution and allocate */
112                  switch (sscanf(vval(RESOLUTION), "%d %d %lf",
113                                  &hres, &vres, &pixaspect)) {
# Line 119 | Line 131 | next_frame()                   /* prepare next frame buffer */
131                  obuffer = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres);
132                  xmbuffer = (short *)malloc(sizeof(short)*hres*vres);
133                  ymbuffer = (short *)malloc(sizeof(short)*hres*vres);
134 <                abuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE));
135 <                sbuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE));
134 >                abuffer = (uby8 *)calloc(hres*vres, sizeof(uby8));
135 >                sbuffer = (uby8 *)calloc(hres*vres, sizeof(uby8));
136                  cprev = (COLOR *)malloc(sizeof(COLOR)*hres*vres);
137                  zprev = (float *)malloc(sizeof(float)*hres*vres);
138                  oprev = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres);
139 <                aprev = (BYTE *)malloc(sizeof(BYTE)*hres*vres);
139 >                aprev = (uby8 *)malloc(sizeof(uby8)*hres*vres);
140                  if ((cbuffer==NULL) | (zbuffer==NULL) | (obuffer==NULL) |
141                                  (xmbuffer==NULL) | (ymbuffer==NULL) |
142                                  (abuffer==NULL) | (sbuffer==NULL) |
143                                  (cprev==NULL) | (zprev == NULL) |
144                                  (oprev==NULL) | (aprev==NULL))
145                          error(SYSTEM, "out of memory in init_frame");
146 +                for (n = hres*vres; n--; ) {
147 +                        zprev[n] = -1.f;
148 +                        xmbuffer[n] = ymbuffer[n] = MO_UNK;
149 +                        oprev[n] = OVOID;
150 +                }
151                  frm_stop = getTime() + rtperfrm;
152          } else {
153                  COLOR   *cp;            /* else just swap buffers */
154                  float   *fp;
155                  OBJECT  *op;
156 <                BYTE    *bp;
156 >                uby8    *bp;
157                  cp = cprev; cprev = cbuffer; cbuffer = cp;
158                  fp = zprev; zprev = zbuffer; zbuffer = fp;
159                  op = oprev; oprev = obuffer; obuffer = op;
160                  bp = aprev; aprev = abuffer; abuffer = bp;
161 <                memset(abuffer, '\0', sizeof(BYTE)*hres*vres);
162 <                memset(sbuffer, '\0', sizeof(BYTE)*hres*vres);
161 >                memset(abuffer, '\0', sizeof(uby8)*hres*vres);
162 >                memset(sbuffer, '\0', sizeof(uby8)*hres*vres);
163                  frm_stop += rtperfrm;
164          }
165          cerrmap = NULL;
# Line 155 | Line 172 | next_frame()                   /* prepare next frame buffer */
172  
173  
174   static int
175 < sample_here(x, y)               /* 4x4 quincunx sample at this pixel? */
176 < register int    x, y;
175 > sample_here(            /* 4x4 quincunx sample at this pixel? */
176 >        int     x,
177 >        int     y
178 > )
179   {
180          if (y & 0x1)            /* every other row has samples */
181                  return(0);
# Line 166 | Line 185 | register int   x, y;
185   }
186  
187  
188 < void
189 < sample_pos(hv, x, y, sn)        /* compute jittered sample position */
190 < double  hv[2];
191 < int     x, y;
192 < int     sn;
188 > extern void
189 > sample_pos(     /* compute jittered sample position */
190 >        double  hv[2],
191 >        int     x,
192 >        int     y,
193 >        int     sn
194 > )
195   {
196          int     hl[2];
197  
# Line 181 | Line 202 | int    sn;
202   }
203  
204  
205 < double
206 < sample_wt(xo, yo)               /* compute interpolant sample weight */
207 < int     xo, yo;
205 > extern double
206 > sample_wt(              /* compute interpolant sample weight */
207 >        int     xo,
208 >        int yo
209 > )
210   {
211          static double   etab[400];
212          /* we can't use the name rad2 here, for some reason Visual C
# Line 204 | Line 227 | int    xo, yo;
227  
228  
229   static int
230 < offset_cmp(p1, p2)              /* compare offset distances */
231 < const void      *p1, *p2;
230 > offset_cmp(             /* compare offset distances */
231 >        const void      *p1,
232 >        const void      *p2
233 > )
234   {
235          return(*(const int *)p1 - *(const int *)p2);
236   }
237  
238  
239 < int
240 < getclosest(iarr, nc, x, y)      /* get nc closest neighbors on same object */
241 < int     *iarr;
242 < int     nc;
243 < int     x, y;
239 > extern int
240 > getclosest(     /* get nc closest neighbors on same object */
241 >        int     *iarr,
242 >        int     nc,
243 >        int     x,
244 >        int     y
245 > )
246   {
247   #define NSCHECK         ((2*SAMPDIST+1)*(2*SAMPDIST+1))
248          static int      hro, vro;
249          static int      ioffs[NSCHECK];
250          OBJECT  myobj;
251          int     i0, nf;
252 <        register int    i, j;
252 >        int     i, j;
253                                          /* get our object number */
254          myobj = obuffer[fndx(x, y)];
255                                          /* special case for borders */
# Line 285 | Line 312 | int    x, y;
312  
313  
314   static void
315 < setmotion(n, wpos)              /* compute motion vector for this pixel */
316 < register int    n;
317 < FVECT   wpos;
315 > setmotion(              /* compute motion vector for this pixel */
316 >                int     n,
317 >                FVECT   wpos
318 > )
319   {
320          FVECT   ovp;
293        MAT4    xfm;
294        double  d;
321          int     moi;
322          int     xp, yp;
323                                          /* ID object and update maximum HLS */
# Line 322 | Line 348 | FVECT  wpos;
348  
349  
350   static void
351 < init_frame_sample()             /* sample our initial frame */
351 > init_frame_sample(void)         /* sample our initial frame */
352   {
353          RAY     ir;
354          int     x, y;
355 <        register int    n;
355 >        int     n;
356  
357          if (!silent) {
358                  printf("\tComputing initial samples...");
# Line 349 | Line 375 | init_frame_sample()            /* sample our initial frame */
375                          continue;
376                  }
377                  if (!sample_here(x, y)) {       /* just cast */
378 <                        rayorigin(&ir, NULL, PRIMARY, 1.0);
378 >                        rayorigin(&ir, PRIMARY, NULL, NULL);
379                          if (!localhit(&ir, &thescene)) {
380 <                                if (ir.ro != &Aftplane)
381 <                                        sourcehit(&ir);
380 >                                if (ir.ro != &Aftplane && sourcehit(&ir)) {
381 >                                        rayshade(&ir, ir.ro->omod);
382 >                                        rayparticipate(&ir);
383 >                                }
384                                  copycolor(cbuffer[n], ir.rcol);
385                                  zbuffer[n] = ir.rot;
386                                  obuffer[n] = ir.robj;
# Line 367 | Line 395 | init_frame_sample()            /* sample our initial frame */
395                  }
396                  if (nprocs > 1) {               /* get sample */
397                          int     rval;
398 <                        rayorigin(&ir, NULL, PRIMARY, 1.0);
398 >                        rayorigin(&ir, PRIMARY, NULL, NULL);
399                          ir.rno = n;
400                          rval = ray_pqueue(&ir);
401                          if (!rval)
# Line 381 | Line 409 | init_frame_sample()            /* sample our initial frame */
409                  zbuffer[n] = ir.rot;
410                  obuffer[n] = ir.robj;
411                  sbuffer[n] = 1;
412 <                if (ir.rot >= FHUGE)
412 >                if (ir.rot >= 0.99*FHUGE)
413                          abuffer[n] = ADISTANT;
414                  else {
415                          abuffer[n] = ALOWQ;
# Line 424 | Line 452 | init_frame_sample()            /* sample our initial frame */
452   }
453  
454  
455 < int
456 < getambcolor(clr, obj)           /* get ambient color for object if we can */
457 < COLOR   clr;
458 < int     obj;
455 > extern int
456 > getambcolor(            /* get ambient color for object if we can */
457 >                COLOR   clr,
458 >                int     obj
459 > )
460   {
461 <        register OBJREC *op;
461 >        OBJREC  *op;
462  
463          if (obj == OVOID)
464                  return(0);
465 <        op = objptr(obj);
466 <        if ((op->otype == OBJ_INSTANCE) & (op->omod == OVOID))
465 >        op = objptr(obj);               /* search for material */
466 >        if (op->omod == OVOID)
467                  return(0);
468 <                                        /* search for material */
469 <        do {
470 <                if (op->omod == OVOID || ofun[op->otype].flags & T_X)
442 <                        return(0);
443 <                op = objptr(op->omod);
444 <        } while (!ismaterial(op->otype));
468 >        op = findmaterial(objptr(op->omod));
469 >        if (op == NULL)
470 >                return(0);
471          /*
472           * Since this routine is called to compute the difference
473           * from rendering with and without interreflections,
# Line 455 | Line 481 | int    obj;
481                          if (lv[0] == op->oname[0] &&
482                                          !strcmp(lv+1, op->oname+1))
483                                  break;
484 <                if ((lv != NULL) != hirendparams.ambincl)
484 >                if ((lv != NULL) ^ hirendparams.ambincl)
485                          return(0);
486          }
487          switch (op->otype) {
# Line 494 | Line 520 | int    obj;
520   }
521  
522  
523 < double
524 < estimaterr(cs, cs2, ns, ns0)    /* estimate relative error from samples */
525 < COLOR   cs, cs2;
526 < int     ns;
523 > extern double
524 > estimaterr(             /* estimate relative error from samples */
525 >                COLOR   cs,
526 >                COLOR   cs2,
527 >                int     ns,
528 >                int ns0
529 > )
530   {
531          double  d, d2, brt;
532  
# Line 517 | Line 546 | int    ns;
546   }
547  
548  
549 < double
550 < comperr(neigh, nc, ns0)         /* estimate relative error in neighborhood */
551 < int     *neigh;
552 < int     nc;
553 < int     ns0;
549 > extern double
550 > comperr(                /* estimate relative error in neighborhood */
551 >                int     *neigh,
552 >                int     nc,
553 >                int     ns0
554 > )
555   {
556          COLOR   csum, csum2;
557          COLOR   ctmp;
558          int     i;
559          int     ns;
560 <        register int    n;
560 >        int     n;
561                                          /* add together samples */
562          setcolor(csum, 0., 0., 0.);
563          setcolor(csum2, 0., 0., 0.);
# Line 552 | Line 582 | int    ns0;
582   }
583  
584  
585 < void
586 < comp_frame_error()              /* initialize frame error values */
585 > extern void
586 > comp_frame_error(void)          /* initialize frame error values */
587   {
588 <        BYTE    *edone = NULL;
588 >        uby8    *edone = NULL;
589          COLOR   objamb;
590          double  eest;
591          int     neigh[NSAMPOK];
592          int     nc;
593 <        int     x, y, i, j;
594 <        register int    n;
593 >        int     x, y, i;
594 >        int     n;
595  
596          if (!silent) {
597                  printf("\tComputing error map\n");
# Line 579 | Line 609 | comp_frame_error()             /* initialize frame error values *
609                   * error should be less than the ambient value divided
610                   * by the returned ray value -- we take half of this.
611                   */
612 <                edone = (BYTE *)calloc(hres*vres, sizeof(BYTE));
612 >                edone = (uby8 *)calloc(hres*vres, sizeof(uby8));
613                  for (y = vres; y--; )
614                      for (x = hres; x--; ) {
615                          n = fndx(x, y);
# Line 631 | Line 661 | comp_frame_error()             /* initialize frame error values *
661   }
662  
663  
664 < void
665 < init_frame()                    /* render base (low quality) frame */
664 > extern void
665 > init_frame(void)                        /* render base (low quality) frame */
666   {
667          int     restart;
638
668                                          /* allocate/swap buffers */
669          next_frame();
670                                          /* check rendering status */
671          restart = (!nobjects || vdef(MOVE));
672          if (!restart && curparams != &lorendparams && nprocs > 1)
673                  restart = -1;
645        if (restart > 0) {
646                if (nprocs > 1)
647                        ray_pdone(1);
648                else
649                        ray_done(1);
650        }
674                                          /* post low quality parameters */
675          if (curparams != &lorendparams)
676                  ray_restore(curparams = &lorendparams);
# Line 679 | Line 702 | init_frame()                   /* render base (low quality) frame */
702          init_frame_sample();
703                                          /* initialize frame error */
704          comp_frame_error();
705 < return;
705 > #if 0
706   {
707          float   *ebuf = (float *)malloc(sizeof(float)*hres*vres);
708          char    fnm[256];
709 <        register int    n;
709 >        int     n;
710          for (n = hres*vres; n--; )
711                  ebuf[n] = acctab[abuffer[n]];
712          sprintf(fnm, vval(BASENAME), fcur);
# Line 691 | Line 714 | return;
714          write_map(ebuf, fnm);
715          free((void *)ebuf);
716   }
717 + #endif
718   }
719  
720  
721 < void
722 < filter_frame()                  /* interpolation, motion-blur, and exposure */
721 > extern void
722 > filter_frame(void)                      /* interpolation, motion-blur, and exposure */
723   {
724          double  expval = expspec_val(getexp(fcur));
725          int     x, y;
# Line 703 | Line 727 | filter_frame()                 /* interpolation, motion-blur, and ex
727          int     nc;
728          COLOR   cval;
729          double  w, wsum;
730 <        register int    n;
730 >        int     n;
731  
732   #if 0
733 < /* XXX TEMPORARY!! */
734 < conspicuity();
735 < write_map(cerrmap, "outcmap.pic");
736 < {
737 <        float   *ebuf = (float *)malloc(sizeof(float)*hres*vres);
738 <        for (n = hres*vres; n--; )
739 <                ebuf[n] = acctab[abuffer[n]];
740 <        write_map(ebuf, "outerr.pic");
741 <        free((void *)ebuf);
742 < }
733 >        /* XXX TEMPORARY!! */
734 >        conspicuity();
735 >        write_map(cerrmap, "outcmap.pic");
736 >        {
737 >                float   *ebuf = (float *)malloc(sizeof(float)*hres*vres);
738 >                for (n = hres*vres; n--; )
739 >                        ebuf[n] = acctab[abuffer[n]];
740 >                write_map(ebuf, "outerr.pic");
741 >                free((void *)ebuf);
742 >        }
743   #endif
744  
745          if (!silent) {
# Line 739 | Line 763 | write_map(cerrmap, "outcmap.pic");
763                          continue;
764                  nc = getclosest(neigh, NPINTERP, x, y);
765                  setcolor(cbuffer[n], 0., 0., 0.);
766 +                if (nc <= 0) {          /* no acceptable neighbors */
767 +                        if (y < vres-1)
768 +                                nc = fndx(x, y+1);
769 +                        else if (x < hres-1)
770 +                                nc = fndx(x+1, y);
771 +                        else
772 +                                continue;
773 +                        copycolor(cbuffer[n], cbuffer[nc]);
774 +                        continue;
775 +                }
776                  wsum = 0.;
777                  while (nc-- > 0) {
778                          copycolor(cval, cbuffer[neigh[nc]]);
# Line 748 | Line 782 | write_map(cerrmap, "outcmap.pic");
782                          addcolor(cbuffer[n], cval);
783                          wsum += w;
784                  }
785 <                if (wsum > FTINY) {
786 <                        w = 1.0/wsum;
753 <                        scalecolor(cbuffer[n], w);
754 <                }
785 >                w = 1.0/wsum;
786 >                scalecolor(cbuffer[n], w);
787              }
788                                          /* motion blur if requested */
789          if (mblur > .02) {
758                int     len;
790                  int     xs, ys, xl, yl;
791                  int     rise, run;
792                  long    rise2, run2;
# Line 793 | Line 824 | write_map(cerrmap, "outcmap.pic");
824                                  while (cnt)
825                                          if (rise2 >= run2) {
826                                                  if ((xl >= 0) & (xl < hres) &
827 <                                                        (yl >= 0) & (yl < vres)) {
827 >                                                    (yl >= 0) & (yl < vres)) {
828                                                          n2 = fndx(xl, yl);
829                                                          addcolor(outbuffer[n2],
830                                                                          cval);
# Line 814 | Line 845 | write_map(cerrmap, "outcmap.pic");
845                                  while (cnt)
846                                          if (run2 >= rise2) {
847                                                  if ((xl >= 0) & (xl < hres) &
848 <                                                        (yl >= 0) & (yl < vres)) {
848 >                                                    (yl >= 0) & (yl < vres)) {
849                                                          n2 = fndx(xl, yl);
850                                                          addcolor(outbuffer[n2],
851                                                                          cval);
# Line 841 | Line 872 | write_map(cerrmap, "outcmap.pic");
872          } else
873                  for (n = hres*vres; n--; )
874                          copycolor(outbuffer[n], cbuffer[n]);
875 < /*
876 < for (n = hres*vres; n--; )
877 <        if (!sbuffer[n])
878 <                setcolor(outbuffer[n], 0., 0., 0.);
879 < */
880 <                                /* adjust exposure */
875 >        /*
876 >           for (n = hres*vres; n--; )
877 >                   if (!sbuffer[n])
878 >                           setcolor(outbuffer[n], 0., 0., 0.);
879 >         */
880 >        /* adjust exposure */
881          if ((expval < 0.99) | (expval > 1.01))
882                  for (n = hres*vres; n--; )
883                          scalecolor(outbuffer[n], expval);
884 < return;
885 < {
886 <        float   *sbuf = (float *)malloc(sizeof(float)*hres*vres);
887 <        char    fnm[256];
888 <        sprintf(fnm, vval(BASENAME), fcur);
889 <        strcat(fnm, "_outsamp.pic");
890 <        for (n = hres*vres; n--; )
891 <                sbuf[n] = (float)sbuffer[n];
892 <        write_map(sbuf, fnm);
893 <        free((void *)sbuf);
884 > #if 0
885 >        {
886 >                float   *sbuf = (float *)malloc(sizeof(float)*hres*vres);
887 >                char    fnm[256];
888 >                sprintf(fnm, vval(BASENAME), fcur);
889 >                strcat(fnm, "_outsamp.pic");
890 >                for (n = hres*vres; n--; )
891 >                        sbuf[n] = (float)sbuffer[n];
892 >                write_map(sbuf, fnm);
893 >                free((void *)sbuf);
894 >        }
895 > #endif
896   }
864 }
897  
898  
899 < void
900 < send_frame()                    /* send frame to destination */
899 > extern void
900 > send_frame(void)                        /* send frame to destination */
901   {
902 <        char    pfname[1024];
902 >        char    fname[1024];
903          double  d;
904          FILE    *fp;
905          int     y;
906                                          /* open output picture */
907 <        sprintf(pfname, vval(BASENAME), fcur);
908 <        strcat(pfname, ".pic");
909 <        fp = fopen(pfname, "w");
907 >        sprintf(fname, vval(BASENAME), fcur);
908 >        strcat(fname, ".hdr");
909 >        fp = fopen(fname, "w");
910          if (fp == NULL) {
911 <                sprintf(errmsg, "cannot open output frame \"%s\"", pfname);
911 >                sprintf(errmsg, "cannot open output frame \"%s\"", fname);
912                  error(SYSTEM, errmsg);
913          }
914          SET_FILE_BINARY(fp);
915          if (!silent) {
916 <                printf("\tWriting to \"%s\"\n", pfname);
916 >                printf("\tWriting to \"%s\"\n", fname);
917                  fflush(stdout);
918          }
919                                          /* write header */
# Line 910 | Line 942 | send_frame()                   /* send frame to destination */
942                          goto writerr;
943          if (fclose(fp) == EOF)
944                  goto writerr;
945 +        if (vdef(ZNAME)) {              /* output z-buffer */
946 +                sprintf(fname, vval(ZNAME), fcur);
947 +                strcat(fname, ".zbf");
948 +                fp = fopen(fname, "w");
949 +                if (fp == NULL) {
950 +                        sprintf(errmsg, "cannot open z-file \"%s\"\n", fname);
951 +                        error(SYSTEM, errmsg);
952 +                }
953 +                SET_FILE_BINARY(fp);
954 +                if (!silent) {
955 +                        printf("\tWriting depths to \"%s\"\n", fname);
956 +                        fflush(stdout);
957 +                }
958 +                for (y = vres; y--; )
959 +                        if (fwrite(zbuffer+y*hres, sizeof(float),
960 +                                                hres, fp) != hres)
961 +                                goto writerr;
962 +                if (fclose(fp) == EOF)
963 +                        goto writerr;
964 +        }
965 +        if (vdef(MNAME)) {              /* output motion buffer */
966 +                unsigned short  *mbuffer = (unsigned short *)malloc(
967 +                                                sizeof(unsigned short)*3*hres);
968 +                int             x;
969 +                if (mbuffer == NULL)
970 +                        error(SYSTEM, "out of memory in send_frame()");
971 +                sprintf(fname, vval(MNAME), fcur);
972 +                strcat(fname, ".mvo");
973 +                fp = fopen(fname, "w");
974 +                if (fp == NULL) {
975 +                        sprintf(errmsg, "cannot open motion file \"%s\"\n",
976 +                                                        fname);
977 +                        error(SYSTEM, errmsg);
978 +                }
979 +                SET_FILE_BINARY(fp);
980 +                if (!silent) {
981 +                        printf("\tWriting motion vectors to \"%s\"\n", fname);
982 +                        fflush(stdout);
983 +                }
984 +                for (y = vres; y--; ) {
985 +                        for (x = hres; x--; ) {
986 +                                mbuffer[3*x] = xmbuffer[fndx(x,y)] + 0x8000;
987 +                                mbuffer[3*x+1] = ymbuffer[fndx(x,y)] + 0x8000;
988 +                                mbuffer[3*x+2] = (oprev[fndx(x,y)]!=OVOID)*0x8000;
989 +                        }
990 +                        if (fwrite(mbuffer, sizeof(*mbuffer),
991 +                                                3*hres, fp) != 3*hres)
992 +                                goto writerr;
993 +                }
994 +                free((void *)mbuffer);
995 +                if (fclose(fp) == EOF)
996 +                        goto writerr;
997 +        }
998          return;                         /* all is well */
999   writerr:
1000 <        sprintf(errmsg, "error writing frame \"%s\"", pfname);
1000 >        sprintf(errmsg, "error writing file \"%s\"", fname);
1001          error(SYSTEM, errmsg);
1002   }
1003  
1004  
1005 < void
1006 < free_frame()                    /* free frame allocation */
1005 > extern void
1006 > free_frame(void)                        /* free frame allocation */
1007   {
1008          if (cbuffer == NULL)
1009                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines