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

Comparing ray/src/util/glareval.c (file contents):
Revision 1.19 by greg, Mon Jul 22 09:40:20 1991 UTC vs.
Revision 2.4 by gregl, Wed Jul 9 11:22:11 1997 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include "glare.h"
12 + #include "resolu.h"
13                                          /* maximum rtrace buffer size */
14   #define MAXPIX          (4096/(6*sizeof(float)))
15  
# Line 40 | Line 41 | static int     maxpix;         /* maximum number of pixels to buf
41   static SCAN     *freelist;              /* scanline free list */
42   static SCAN     *hashtab[HSIZE];        /* scanline hash table */
43  
44 + static long     scanbufsiz;             /* size of allocated scanline buffer */
45 +
46   static long     ncall = 0L;     /* number of calls to getpictscan */
47   static long     nread = 0L;     /* number of scanlines read */
48   static long     nrecl = 0L;     /* number of scanlines reclaimed */
# Line 153 | Line 156 | pict_val(vd)                   /* find picture value for view directio
156   FVECT   vd;
157   {
158          FVECT   pp;
159 <        double  vpx, vpy, vpz;
159 >        FVECT   ip;
160          COLOR   res;
161  
162          if (pictfp == NULL)
# Line 161 | Line 164 | FVECT  vd;
164          pp[0] = pictview.vp[0] + vd[0];
165          pp[1] = pictview.vp[1] + vd[1];
166          pp[2] = pictview.vp[2] + vd[2];
167 <        viewpixel(&vpx, &vpy, &vpz, &pictview, pp);
168 <        if (vpz <= FTINY || vpx < 0. || vpx >= 1. || vpy < 0. || vpy >= 1.)
167 >        viewloc(ip, &pictview, pp);
168 >        if (ip[2] <= FTINY || ip[0] < 0. || ip[0] >= 1. ||
169 >                        ip[1] < 0. || ip[1] >= 1.)
170                  return(-1.0);
171 <        colr_color(res, getpictscan((int)(vpy*pysiz))[(int)(vpx*pxsiz)]);
171 >        colr_color(res, getpictscan((int)(ip[1]*pysiz))[(int)(ip[0]*pxsiz)]);
172          return(luminance(res)/exposure);
173   }
174  
# Line 260 | Line 264 | int    np;
264                  fprintf(stderr, "%s: sending %d samples to rtrace...\n",
265                                  progname, np);
266   #endif
267 <        pb[6*np+3] = 0.; pb[6*np+4] = 0.; pb[6*np+5] = 0.;
268 <        if (process(rt_pd, pb, pb, 3*sizeof(float)*np,
269 <                        6*sizeof(float)*(np+1)) < 3*sizeof(float)*np) {
267 >        bzero(pb+6*np, 6*sizeof(float));
268 >        if (process(rt_pd, pb, pb, 3*sizeof(float)*(np+1),
269 >                        6*sizeof(float)*(np+1)) < 3*sizeof(float)*(np+1)) {
270                  fprintf(stderr, "%s: rtrace communication error\n",
271                                  progname);
272                  exit(1);
# Line 288 | Line 292 | open_pict(fn)                  /* open picture file */
292   char    *fn;
293   {
294          if ((pictfp = fopen(fn, "r")) == NULL) {
295 <                fprintf("%s: cannot open\n", fn);
295 >                fprintf(stderr, "%s: cannot open\n", fn);
296                  exit(1);
297          }
298          exposure = 1.0;
299          getheader(pictfp, getexpos, NULL);
300 <        if (wrongformat ||
301 <                        fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) {
298 <                fprintf("%s: bad picture format\n", fn);
300 >        if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) {
301 >                fprintf(stderr, "%s: incompatible picture format\n", fn);
302                  exit(1);
303          }
304          initscans();
# Line 397 | Line 400 | initscans()                            /* initialize scanline buffers */
400          register SCAN   *ptr;
401          register int    i;
402                                          /* initialize positions */
403 <        scanpos = (long *)malloc(pysiz*sizeof(long));
403 >        scanpos = (long *)bmalloc(pysiz*sizeof(long));
404          if (scanpos == NULL)
405                  memerr("scanline positions");
406          for (i = pysiz-1; i >= 0; i--)
# Line 414 | Line 417 | initscans()                            /* initialize scanline buffers */
417          i = MAXSBUF / scansize;         /* compute number to allocate */
418          if (i > HSIZE)
419                  i = HSIZE;
420 <        scan_buf = malloc(i*scansize);  /* get in one big chunk */
420 >        scanbufsiz = i*scansize;
421 >        scan_buf = bmalloc(scanbufsiz); /* get in one big chunk */
422          if (scan_buf == NULL)
423                  memerr("scanline buffers");
424          ptr = (SCAN *)scan_buf;
# Line 431 | Line 435 | initscans()                            /* initialize scanline buffers */
435  
436   donescans()                             /* free up scanlines */
437   {
438 <        free(scan_buf);
439 <        free((char *)scanpos);
438 >        bfree(scan_buf, scanbufsiz);
439 >        bfree((char *)scanpos, pysiz*sizeof(long));
440   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines