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.1 by greg, Mon Mar 18 12:15:41 1991 UTC vs.
Revision 1.3 by greg, Tue Mar 19 17:06:27 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #define vfork           fork
21   #endif
22  
23 < #define NSCANS          16              /* number of scanlines to buffer */
23 > #define NSCANS          64              /* number of scanlines to buffer */
24  
25   int     rt_pid = -1;            /* process id for rtrace */
26   int     fd_tort, fd_fromrt;     /* pipe descriptors */
# Line 36 | Line 36 | struct {
36          COLR    *sl;            /* scanline contents */
37   } scan[NSCANS];         /* buffered scanlines */
38  
39 + static long     ncall = 0L;     /* number of calls to getpictscan */
40 + static long     nread = 0L;     /* number of scanlines read */
41  
42 +
43   COLR *
44   getpictscan(y)                  /* get picture scanline */
45   int     y;
46   {
47          extern long     ftell();
45        static long     ncall = 0;
48          int     minused;
49          register int    i;
50                                          /* first check our buffers */
# Line 58 | Line 60 | int    y;
60          }
61                                          /* not there, read it in */
62          if (scanpos[y] == -1) {                 /* need to search */
61                if (verbose)
62                        fprintf(stderr, "%s: reading picture...\n",
63                                        progname);
63                  while (curpos > y) {
64                          scanpos[curpos] = ftell(pictfp);
65                          if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0)
# Line 71 | Line 70 | int    y;
70                  fprintf(stderr, "%s: picture seek error\n", progname);
71                  exit(1);
72          }
74        if (verbose)
75                fprintf(stderr, "%s: reading scanline %d...\n", progname, y);
73          if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0)
74                  goto readerr;
75 +        nread++;
76          curpos = y-1;
77          scan[minused].lused = ncall;
78          scan[minused].y = y;
# Line 85 | Line 83 | readerr:
83   }
84  
85  
86 + pict_stats()                    /* print out picture read statistics */
87 + {
88 +        static long     lastcall = 0L;  /* ncall at last report */
89 +        static long     lastread = 0L;  /* nread at last report */
90 +
91 +        if (ncall == lastcall)
92 +                return;
93 +        fprintf(stderr, "%s: %ld scanlines read, %ld reused\n",
94 +                        progname, nread-lastread,
95 +                        (ncall-lastcall)-(nread-lastread));
96 +        lastcall = ncall;
97 +        lastread = nread;
98 + }
99 +
100 +
101   double
102   pict_val(vd)                    /* find picture value for view direction */
103   FVECT   vd;
# Line 136 | Line 149 | int    vv;
149   float   *vb;
150   {
151          float   rt_buf[6*MAXPIX];       /* rtrace send/receive buffer */
152 <        int     npix_tort;              /* number of pixels in buffer */
152 >        register int    n;              /* number of pixels in buffer */
153          short   buf_vh[MAXPIX];         /* pixel positions */
154          FVECT   dir;
155          register int    vh;
143        register int    i;
156  
157          if (verbose)
158                  fprintf(stderr, "%s: computing view span at %d...\n",
159                                  progname, vv);
160 <        npix_tort = 0;
160 >        n = 0;
161          for (vh = -hsize; vh <= hsize; vh++) {
162                  if (compdir(dir, vh, vv) < 0) { /* off viewable region */
163                          vb[vh+hsize] = -1.0;
# Line 156 | Line 168 | float  *vb;
168                  if (rt_pid == -1)               /* missing information */
169                          continue;
170                                                  /* send to rtrace */
171 <                if (npix_tort >= MAXPIX) {              /* flush */
172 <                        rt_compute(rt_buf, npix_tort);
173 <                        for (i = 0; i < npix_tort; i++)
174 <                                vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i);
163 <                        npix_tort = 0;
171 >                if (n >= MAXPIX) {                      /* flush */
172 >                        rt_compute(rt_buf, n);
173 >                        while (n-- > 0)
174 >                                vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n);
175                  }
176 <                rt_buf[npix_tort] = ourview.vp[0];
177 <                rt_buf[npix_tort+1] = ourview.vp[1];
178 <                rt_buf[npix_tort+2] = ourview.vp[2];
179 <                rt_buf[npix_tort+3] = dir[0];
180 <                rt_buf[npix_tort+4] = dir[1];
181 <                rt_buf[npix_tort+5] = dir[2];
182 <                buf_vh[npix_tort++] = vh;
176 >                rt_buf[6*n] = ourview.vp[0];
177 >                rt_buf[6*n+1] = ourview.vp[1];
178 >                rt_buf[6*n+2] = ourview.vp[2];
179 >                rt_buf[6*n+3] = dir[0];
180 >                rt_buf[6*n+4] = dir[1];
181 >                rt_buf[6*n+5] = dir[2];
182 >                buf_vh[n++] = vh;
183          }
184 <        if (npix_tort > 0) {                    /* process pending buffer */
185 <                rt_compute(rt_buf, npix_tort);
186 <                for (i = 0; i < npix_tort; i++)
187 <                        vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i);
184 >        if (verbose)
185 >                pict_stats();
186 >        if (n > 0) {                            /* process pending buffer */
187 >                rt_compute(rt_buf, n);
188 >                while (n-- > 0)
189 >                        vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n);
190          }
191   }
192  
# Line 283 | Line 296 | char   *av[];
296                  perror(progname);
297                  exit(1);
298          }
299 +        close(p0[0]);
300 +        close(p1[1]);
301          fd_tort = p0[1];
302          fd_fromrt = p1[0];
303   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines