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.20 by greg, Tue Jul 30 12:56:36 1991 UTC vs.
Revision 2.5 by gwlarson, Tue Oct 27 08:47:18 1998 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 261 | Line 265 | int    np;
265                                  progname, np);
266   #endif
267          bzero(pb+6*np, 6*sizeof(float));
268 <        if (process(rt_pd, pb, pb, 3*sizeof(float)*np,
269 <                        6*sizeof(float)*(np+1)) < 3*sizeof(float)*np) {
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 270 | Line 274 | int    np;
274   }
275  
276  
277 + int
278   getexpos(s)                     /* get exposure from header line */
279   char    *s;
280   {
# Line 281 | Line 286 | char   *s;
286                  formatval(fmt, s);
287                  wrongformat = strcmp(fmt, COLRFMT);
288          }
289 +        return(0);
290   }
291  
292  
# Line 288 | Line 294 | open_pict(fn)                  /* open picture file */
294   char    *fn;
295   {
296          if ((pictfp = fopen(fn, "r")) == NULL) {
297 <                fprintf("%s: cannot open\n", fn);
297 >                fprintf(stderr, "%s: cannot open\n", fn);
298                  exit(1);
299          }
300          exposure = 1.0;
301          getheader(pictfp, getexpos, NULL);
302 <        if (wrongformat ||
303 <                        fgetresolu(&pxsiz, &pysiz, pictfp) != (YMAJOR|YDECR)) {
298 <                fprintf("%s: bad picture format\n", fn);
302 >        if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) {
303 >                fprintf(stderr, "%s: incompatible picture format\n", fn);
304                  exit(1);
305          }
306          initscans();
# Line 397 | Line 402 | initscans()                            /* initialize scanline buffers */
402          register SCAN   *ptr;
403          register int    i;
404                                          /* initialize positions */
405 <        scanpos = (long *)malloc(pysiz*sizeof(long));
405 >        scanpos = (long *)bmalloc(pysiz*sizeof(long));
406          if (scanpos == NULL)
407                  memerr("scanline positions");
408          for (i = pysiz-1; i >= 0; i--)
# Line 414 | Line 419 | initscans()                            /* initialize scanline buffers */
419          i = MAXSBUF / scansize;         /* compute number to allocate */
420          if (i > HSIZE)
421                  i = HSIZE;
422 <        scan_buf = malloc(i*scansize);  /* get in one big chunk */
422 >        scanbufsiz = i*scansize;
423 >        scan_buf = bmalloc(scanbufsiz); /* get in one big chunk */
424          if (scan_buf == NULL)
425                  memerr("scanline buffers");
426          ptr = (SCAN *)scan_buf;
# Line 431 | Line 437 | initscans()                            /* initialize scanline buffers */
437  
438   donescans()                             /* free up scanlines */
439   {
440 <        free(scan_buf);
441 <        free((char *)scanpos);
440 >        bfree(scan_buf, scanbufsiz);
441 >        bfree((char *)scanpos, pysiz*sizeof(long));
442   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines