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.23 by greg, Wed Jan 24 04:39:52 2018 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 339 | Line 329 | setmotion(             /* compute motion vector for this pixel */
329                  multp3(ovp, wpos, obj_move[moi].bxfm);
330                  wpos = ovp;
331          }
332 <        viewloc(ovp, &vwprev, wpos);
343 <        if (ovp[2] <= FTINY)
332 >        if (viewloc(ovp, &vwprev, wpos) <= 0)
333                  return;
334          xp = (int)(ovp[0]*hres);
335          yp = (int)(ovp[1]*vres);
# Line 579 | Line 568 | comperr(               /* estimate relative error in neighborhood *
568                  }
569                  if (sbuffer[n] != 1)
570                          error(CONSISTENCY, "bad count in comperr");
571 <                copycolor(ctmp, cbuffer[n]);
572 <                multcolor(ctmp, ctmp);
571 >                setcolor(ctmp,
572 >                        colval(cbuffer[n],RED)*colval(cbuffer[n],RED),
573 >                        colval(cbuffer[n],GRN)*colval(cbuffer[n],GRN),
574 >                        colval(cbuffer[n],BLU)*colval(cbuffer[n],BLU));
575                  addcolor(csum2, ctmp);
576                  ns++;
577          }
# Line 787 | Line 778 | filter_frame(void)                     /* interpolation, motion-blur, an
778                  scalecolor(cbuffer[n], w);
779              }
780                                          /* motion blur if requested */
781 <        if (outbuffer != cbuffer) {
781 >        if (mblur > .02) {
782                  int     xs, ys, xl, yl;
783                  int     rise, run;
784                  long    rise2, run2;
785                  int     n2;
786                  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);
787                                          /* sum in motion streaks */
788 <                memset(outbuffer, 0, sizeof(COLOR)*hres*vres);
789 <                memset(wbuffer, 0, sizeof(float)*hres*vres);
788 >                memset(outbuffer, '\0', sizeof(COLOR)*hres*vres);
789 >                memset(wbuffer, '\0', sizeof(float)*hres*vres);
790                  for (y = vres; y--; )
791                      for (x = hres; x--; ) {
792                          n = fndx(x, y);
# Line 812 | Line 801 | fprintf(stderr, "outbuffer=0x%lx, cbuffer=0x%lx, cprev
801                                  wbuffer[n] += 1.;
802                                  continue;
803                          }
804 <                        xl = x; yl = y;
804 >                        xl = x - run/4;
805 >                        yl = y - rise/4;
806                          if (run < 0) { xs = -1; run = -run; }
807                          else xs = 1;
808                          if (rise < 0) { ys = -1; rise = -rise; }
# Line 863 | Line 853 | fprintf(stderr, "outbuffer=0x%lx, cbuffer=0x%lx, cprev
853                          }
854                      }
855                                          /* compute final results */
856 <                for (n = hres*vres; n--; )
857 <                        if (wbuffer[n] > 1.02) {
858 <                                w = 1./wbuffer[n];
859 <                                scalecolor(outbuffer[n], w);
860 <                        } else if (wbuffer[n] < 0.98) {
861 <                                w = 1.-wbuffer[n];
862 <                                copycolor(cval, cprev[n]);
863 <                                scalecolor(cval, w);
864 <                                addcolor(outbuffer[n], cval);
865 <                        }
856 >                for (n = hres*vres; n--; ) {
857 >                        if (wbuffer[n] <= FTINY)
858 >                                continue;
859 >                        w = expval/wbuffer[n];
860 >                        scalecolor(outbuffer[n], w);
861 >                }
862 >        } else {                        /* no blur -- just exposure */
863 >                memcpy(outbuffer, cbuffer, sizeof(COLOR)*hres*vres);
864 >                for (n = ((expval < 0.99) | (expval > 1.01))*hres*vres; n--; )
865 >                        scalecolor(outbuffer[n], expval);
866          }
877                                        /* adjust exposure */
878        for (n = ((expval < 0.98) | (expval > 1.02))*hres*vres; n--; )
879                scalecolor(outbuffer[n], expval);
867          /*
868             for (n = hres*vres; n--; )
869                     if (!sbuffer[n])
# Line 1009 | Line 996 | free_frame(void)                       /* free frame allocation */
996   {
997          if (cbuffer == NULL)
998                  return;
1012        if (outbuffer != cbuffer)
1013                free((void *)outbuffer);
1014        outbuffer = NULL;
999          free((void *)cbuffer); cbuffer = NULL;
1000          free((void *)zbuffer); zbuffer = NULL;
1001          free((void *)obuffer); obuffer = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines