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.21 by greg, Fri Oct 5 00:59:38 2012 UTC vs.
Revision 3.22 by greg, Fri Oct 5 01:03:22 2012 UTC

# Line 32 | Line 32 | short          *xmbuffer;      /* x motion at each pixel */
32   short           *ymbuffer;      /* y motion at each pixel */
33   uby8            *abuffer;       /* accuracy at each pixel */
34   uby8            *sbuffer;       /* sample count per pixel */
35 COLOR           *outbuffer;     /* output buffer (may equal cbuffer) */
35  
36   VIEW            vwprev;         /* last frame's view */
37   COLOR           *cprev;         /* last frame colors */
# Line 108 | Line 107 | next_frame(void)                       /* prepare next frame buffer */
107                  error(USER, errmsg);
108          }
109          if (cbuffer == NULL) {
110 <                int     n;              /* compute resolution and allocate */
110 >                int     n;
111 >                                        /* compute resolution and allocate */
112                  switch (sscanf(vval(RESOLUTION), "%d %d %lf",
113                                  &hres, &vres, &pixaspect)) {
114                  case 1:
# Line 137 | Line 137 | next_frame(void)                       /* prepare next frame buffer */
137                  zprev = (float *)malloc(sizeof(float)*hres*vres);
138                  oprev = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres);
139                  aprev = (uby8 *)malloc(sizeof(uby8)*hres*vres);
140                if (mblur > .02)
141                        outbuffer = (COLOR *)malloc(sizeof(COLOR)*hres*vres);
142                else
143                        outbuffer = cbuffer;
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) |
149 <                                (outbuffer==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                          oprev[n] = OVOID;
149                  }
150                  frm_stop = getTime() + rtperfrm;
151 <        } else {                        /* else just swap buffers */
151 >        } else {
152 >                COLOR   *cp;            /* else just swap buffers */
153                  float   *fp;
154                  OBJECT  *op;
155                  uby8    *bp;
156 <                if (outbuffer != cbuffer) {
161 <                        COLOR   *cp = cprev;
162 <                        cprev = cbuffer; cbuffer = cp;
163 <                } else {
164 <                        outbuffer = cprev; cprev = cbuffer;
165 <                        cbuffer = outbuffer;
166 <                }
156 >                cp = cprev; cprev = cbuffer; cbuffer = cp;
157                  fp = zprev; zprev = zbuffer; zbuffer = fp;
158                  op = oprev; oprev = obuffer; obuffer = op;
159                  bp = aprev; aprev = abuffer; abuffer = bp;
160 <                memset(abuffer, 0, sizeof(uby8)*hres*vres);
161 <                memset(sbuffer, 0, sizeof(uby8)*hres*vres);
160 >                memset(abuffer, '\0', sizeof(uby8)*hres*vres);
161 >                memset(sbuffer, '\0', sizeof(uby8)*hres*vres);
162                  frm_stop += rtperfrm;
163          }
164          cerrmap = NULL;
# Line 579 | Line 569 | comperr(               /* estimate relative error in neighborhood *
569                  }
570                  if (sbuffer[n] != 1)
571                          error(CONSISTENCY, "bad count in comperr");
572 <                copycolor(ctmp, cbuffer[n]);
573 <                multcolor(ctmp, ctmp);
572 >                setcolor(ctmp,
573 >                        colval(cbuffer[n],RED)*colval(cbuffer[n],RED),
574 >                        colval(cbuffer[n],GRN)*colval(cbuffer[n],GRN),
575 >                        colval(cbuffer[n],BLU)*colval(cbuffer[n],BLU));
576                  addcolor(csum2, ctmp);
577                  ns++;
578          }
# Line 787 | Line 779 | filter_frame(void)                     /* interpolation, motion-blur, an
779                  scalecolor(cbuffer[n], w);
780              }
781                                          /* motion blur if requested */
782 <        if (outbuffer != cbuffer) {
782 >        if (mblur > .02) {
783                  int     xs, ys, xl, yl;
784                  int     rise, run;
785                  long    rise2, run2;
786                  int     n2;
787                  int     cnt;
796 fprintf(stderr, "outbuffer=0x%lx, cbuffer=0x%lx, cprev=0x%lx\n",
797 (size_t)outbuffer, (size_t)cbuffer, (size_t)cprev);
788                                          /* sum in motion streaks */
789 <                memset(outbuffer, 0, sizeof(COLOR)*hres*vres);
790 <                memset(wbuffer, 0, sizeof(float)*hres*vres);
789 >                memset(outbuffer, '\0', sizeof(COLOR)*hres*vres);
790 >                memset(wbuffer, '\0', sizeof(float)*hres*vres);
791                  for (y = vres; y--; )
792                      for (x = hres; x--; ) {
793                          n = fndx(x, y);
# Line 812 | Line 802 | fprintf(stderr, "outbuffer=0x%lx, cbuffer=0x%lx, cprev
802                                  wbuffer[n] += 1.;
803                                  continue;
804                          }
805 <                        xl = x; yl = y;
805 >                        xl = x - run/4;
806 >                        yl = y - rise/4;
807                          if (run < 0) { xs = -1; run = -run; }
808                          else xs = 1;
809                          if (rise < 0) { ys = -1; rise = -rise; }
# Line 863 | Line 854 | fprintf(stderr, "outbuffer=0x%lx, cbuffer=0x%lx, cprev
854                          }
855                      }
856                                          /* compute final results */
857 <                for (n = hres*vres; n--; )
858 <                        if (wbuffer[n] > 1.02) {
859 <                                w = 1./wbuffer[n];
860 <                                scalecolor(outbuffer[n], w);
861 <                        } else if (wbuffer[n] < 0.98) {
862 <                                w = 1.-wbuffer[n];
863 <                                copycolor(cval, cprev[n]);
864 <                                scalecolor(cval, w);
865 <                                addcolor(outbuffer[n], cval);
866 <                        }
857 >                for (n = hres*vres; n--; ) {
858 >                        if (wbuffer[n] <= FTINY)
859 >                                continue;
860 >                        w = expval/wbuffer[n];
861 >                        scalecolor(outbuffer[n], w);
862 >                }
863 >        } else {                        /* no blur -- just exposure */
864 >                memcpy(outbuffer, cbuffer, sizeof(COLOR)*hres*vres);
865 >                for (n = ((expval < 0.99) | (expval > 1.01))*hres*vres; n--; )
866 >                        scalecolor(outbuffer[n], expval);
867          }
877                                        /* adjust exposure */
878        for (n = ((expval < 0.98) | (expval > 1.02))*hres*vres; n--; )
879                scalecolor(outbuffer[n], expval);
868          /*
869             for (n = hres*vres; n--; )
870                     if (!sbuffer[n])
# Line 1009 | Line 997 | free_frame(void)                       /* free frame allocation */
997   {
998          if (cbuffer == NULL)
999                  return;
1012        if (outbuffer != cbuffer)
1013                free((void *)outbuffer);
1014        outbuffer = NULL;
1000          free((void *)cbuffer); cbuffer = NULL;
1001          free((void *)zbuffer); zbuffer = NULL;
1002          free((void *)obuffer); obuffer = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines