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

Comparing ray/src/px/pinterp.c (file contents):
Revision 2.22 by greg, Tue Dec 27 18:04:29 1994 UTC vs.
Revision 2.33 by greg, Sat Feb 22 02:07:27 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Interpolate and extrapolate pictures with different view parameters.
6   *
# Line 18 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15  
16   #include "color.h"
17  
21 #include "resolu.h"
22
18   #define LOG2            0.69314718055994530942
19  
20   #define pscan(y)        (ourpict+(y)*hresolu)
21   #define sscan(y)        (ourspict+(y)*hresolu)
22   #define wscan(y)        (ourweigh+(y)*hresolu)
23   #define zscan(y)        (ourzbuf+(y)*hresolu)
24 + #define bscan(y)        (ourbpict+(y)*hresolu)
25   #define averaging       (ourweigh != NULL)
26 + #define blurring        (ourbpict != NULL)
27   #define usematrix       (hasmatrix & !averaging)
28   #define zisnorm         (!usematrix | ourview.type != VT_PER)
29  
# Line 37 | Line 34 | static char SCCSid[] = "$SunId$ LBL";
34  
35   #define PACKSIZ         256             /* max. calculation packet size */
36  
37 < #define RTCOM           "rtrace -h- -ovl -fff "
37 > #define RTCOM           "rtrace -h- -ovl -fff -ld- -i- -I- "
38  
39   #define ABS(x)          ((x)>0?(x):-(x))
40  
# Line 59 | Line 56 | COLR   *ourpict;                       /* output picture (COLR's) */
56   COLOR   *ourspict;                      /* output pixel sums (averaging) */
57   float   *ourweigh = NULL;               /* output pixel weights (averaging) */
58   float   *ourzbuf;                       /* corresponding z-buffer */
59 + COLOR   *ourbpict = NULL;               /* blurred picture (view averaging) */
60  
61 + VIEW    avgview;                        /* average view for -B option */
62 + int     nvavg;                          /* number of views averaged */
63 +
64   char    *progname;
65  
66   int     fillo = F_FORE|F_BACK;          /* selected fill options */
# Line 70 | Line 71 | COLR   backcolr = BLKCOLR;             /* background color */
71   COLOR   backcolor = BLKCOLOR;           /* background color (float) */
72   double  backz = 0.0;                    /* background z value */
73   int     normdist = 1;                   /* i/o normalized distance? */
74 + char    ourfmt[LPICFMT+1] = PICFMT;     /* original picture format */
75   double  ourexp = -1;                    /* original picture exposure */
76   int     expadj = 0;                     /* exposure adjustment (f-stops) */
77   double  rexpadj = 1;                    /* real exposure adjustment */
78  
79 < VIEW    theirview = STDVIEW;            /* input view */
79 > VIEW    theirview;                      /* input view */
80   int     gotview;                        /* got input view? */
81   int     wrongformat = 0;                /* input in another format? */
82   RESOLU  tresolu;                        /* input resolution */
# Line 86 | Line 88 | int    PDesc[3] = {-1,-1,-1};          /* rtrace process descript
88   #define childpid        (PDesc[2])
89   unsigned short  queue[PACKSIZ][2];      /* pending pixels */
90   int     packsiz;                        /* actual packet size */
91 < int     queuesiz;                       /* number of pixels pending */
91 > int     queuesiz = 0;                   /* number of pixels pending */
92  
93   extern double   movepixel();
94  
# Line 95 | Line 97 | main(argc, argv)                       /* interpolate pictures */
97   int     argc;
98   char    *argv[];
99   {
100 < #define  check(ol,al)           if (argv[i][ol] || \
101 <                                badarg(argc-i-1,argv+i+1,al)) \
100 > #define  check(ol,al)           if (argv[an][ol] || \
101 >                                badarg(argc-an-1,argv+an+1,al)) \
102                                  goto badopt
103          int     gotvfile = 0;
104          int     doavg = -1;
105 +        int     doblur = 0;
106          char    *zfile = NULL;
107          char    *expcomp = NULL;
108 <        char    *err;
106 <        int     i, rval;
108 >        int     i, an, rval;
109  
110          progname = argv[0];
111  
112 <        for (i = 1; i < argc && argv[i][0] == '-'; i++) {
113 <                rval = getviewopt(&ourview, argc-i, argv+i);
112 >        for (an = 1; an < argc && argv[an][0] == '-'; an++) {
113 >                rval = getviewopt(&ourview, argc-an, argv+an);
114                  if (rval >= 0) {
115 <                        i += rval;
115 >                        an += rval;
116                          continue;
117                  }
118 <                switch (argv[i][1]) {
118 >                switch (argv[an][1]) {
119                  case 'e':                               /* exposure */
120                          check(2,"f");
121 <                        expcomp = argv[++i];
121 >                        expcomp = argv[++an];
122                          break;
123                  case 't':                               /* threshold */
124                          check(2,"f");
125 <                        zeps = atof(argv[++i]);
125 >                        zeps = atof(argv[++an]);
126                          break;
127                  case 'a':                               /* average */
128                          check(2,NULL);
129                          doavg = 1;
130                          break;
131 +                case 'B':                               /* blur views */
132 +                        check(2,NULL);
133 +                        doblur = 1;
134 +                        break;
135                  case 'q':                               /* quick (no avg.) */
136                          check(2,NULL);
137                          doavg = 0;
# Line 135 | Line 141 | char   *argv[];
141                          normdist = !normdist;
142                          break;
143                  case 'f':                               /* fill type */
144 <                        switch (argv[i][2]) {
144 >                        switch (argv[an][2]) {
145                          case '0':                               /* none */
146                                  check(3,NULL);
147                                  fillo = 0;
# Line 154 | Line 160 | char   *argv[];
160                                  break;
161                          case 's':                               /* sample */
162                                  check(3,"i");
163 <                                fillsamp = atoi(argv[++i]);
163 >                                fillsamp = atoi(argv[++an]);
164                                  break;
165                          case 'c':                               /* color */
166                                  check(3,"fff");
167                                  fillfunc = backfill;
168 <                                setcolor(backcolor, atof(argv[i+1]),
169 <                                        atof(argv[i+2]), atof(argv[i+3]));
168 >                                setcolor(backcolor, atof(argv[an+1]),
169 >                                        atof(argv[an+2]), atof(argv[an+3]));
170                                  setcolr(backcolr, colval(backcolor,RED),
171                                                  colval(backcolor,GRN),
172                                                  colval(backcolor,BLU));
173 <                                i += 3;
173 >                                an += 3;
174                                  break;
175                          case 'z':                               /* z value */
176                                  check(3,"f");
177                                  fillfunc = backfill;
178 <                                backz = atof(argv[++i]);
178 >                                backz = atof(argv[++an]);
179                                  break;
180                          case 'r':                               /* rtrace */
181                                  check(3,"s");
182                                  fillfunc = rcalfill;
183 <                                calstart(RTCOM, argv[++i]);
183 >                                calstart(RTCOM, argv[++an]);
184                                  break;
185                          default:
186                                  goto badopt;
# Line 182 | Line 188 | char   *argv[];
188                          break;
189                  case 'z':                               /* z file */
190                          check(2,"s");
191 <                        zfile = argv[++i];
191 >                        zfile = argv[++an];
192                          break;
193                  case 'x':                               /* x resolution */
194                          check(2,"i");
195 <                        hresolu = atoi(argv[++i]);
195 >                        hresolu = atoi(argv[++an]);
196                          break;
197                  case 'y':                               /* y resolution */
198                          check(2,"i");
199 <                        vresolu = atoi(argv[++i]);
199 >                        vresolu = atoi(argv[++an]);
200                          break;
201                  case 'p':                               /* pixel aspect */
202 <                        if (argv[i][2] != 'a')
202 >                        if (argv[an][2] != 'a')
203                                  goto badopt;
204                          check(3,"f");
205 <                        pixaspect = atof(argv[++i]);
205 >                        pixaspect = atof(argv[++an]);
206                          break;
207                  case 'v':                               /* view file */
208 <                        if (argv[i][2] != 'f')
208 >                        if (argv[an][2] != 'f')
209                                  goto badopt;
210                          check(3,"s");
211 <                        gotvfile = viewfile(argv[++i], &ourview, 0, 0);
211 >                        gotvfile = viewfile(argv[++an], &ourview, NULL);
212                          if (gotvfile < 0)
213 <                                syserror(argv[i]);
213 >                                syserror(argv[an]);
214                          else if (gotvfile == 0) {
215                                  fprintf(stderr, "%s: bad view file\n",
216 <                                                argv[i]);
216 >                                                argv[an]);
217                                  exit(1);
218                          }
219                          break;
220                  default:
221                  badopt:
222                          fprintf(stderr, "%s: command line error at '%s'\n",
223 <                                        progname, argv[i]);
223 >                                        progname, argv[an]);
224                          goto userr;
225                  }
226          }
227                                                  /* check arguments */
228 <        if ((argc-i)%2)
228 >        if ((argc-an)%2)
229                  goto userr;
230          if (fillsamp == 1)
231                  fillo &= ~F_BACK;
232          if (doavg < 0)
233 <                doavg = (argc-i) > 2;
233 >                doavg = (argc-an) > 2;
234          if (expcomp != NULL)
235                  if (expcomp[0] == '+' | expcomp[0] == '-') {
236                          expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5);
237 <                        if (doavg)
237 >                        if (doavg | doblur)
238                                  rexpadj = pow(2.0, atof(expcomp));
239                          else
240                                  rexpadj = pow(2.0, (double)expadj);
# Line 237 | Line 243 | char   *argv[];
243                                  goto userr;
244                          rexpadj = atof(expcomp);
245                          expadj = log(rexpadj)/LOG2 + (rexpadj>1 ? .5 : -.5);
246 <                        if (!doavg)
246 >                        if (!(doavg | doblur))
247                                  rexpadj = pow(2.0, (double)expadj);
248                  }
249                                                  /* set view */
250 <        if ((err = setview(&ourview)) != NULL) {
251 <                fprintf(stderr, "%s: %s\n", progname, err);
250 >        if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) {
251 >                fprintf(stderr, "%s: no view on standard input!\n",
252 >                                progname);
253                  exit(1);
254          }
255          normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu);
# Line 257 | Line 264 | char   *argv[];
264                  if (ourpict == NULL)
265                          syserror(progname);
266          }
267 +        if (doblur) {
268 +                ourbpict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR));
269 +                if (ourbpict == NULL)
270 +                        syserror(progname);
271 +        }
272          ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float));
273          if (ourzbuf == NULL)
274                  syserror(progname);
263        bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
275                                                          /* new header */
276          newheader("RADIANCE", stdout);
277 <                                                        /* get input */
278 <        for ( ; i < argc; i += 2)
279 <                addpicture(argv[i], argv[i+1]);
280 <                                                        /* fill in spaces */
281 <        if (fillo&F_BACK)
282 <                backpicture(fillfunc, fillsamp);
283 <        else
284 <                fillpicture(fillfunc);
277 >        fputnow(stdout);
278 >                                                        /* run pictures */
279 >        do {
280 >                bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
281 >                for (i = an; i < argc; i += 2)
282 >                        addpicture(argv[i], argv[i+1]);
283 >                if (fillo&F_BACK)                       /* fill in spaces */
284 >                        backpicture(fillfunc, fillsamp);
285 >                else
286 >                        fillpicture(fillfunc);
287 >                                                        /* aft clipping */
288 >                clipaft();
289 >        } while (addblur() && nextview(stdin) != EOF);
290                                                          /* close calculation */
291          caldone();
276                                                        /* aft clipping */
277        clipaft();
292                                                          /* add to header */
293          printargs(argc, argv, stdout);
294 <        if (gotvfile) {
294 >        compavgview();
295 >        if (doblur | gotvfile) {
296                  fputs(VIEWSTR, stdout);
297 <                fprintview(&ourview, stdout);
297 >                fprintview(&avgview, stdout);
298                  putc('\n', stdout);
299          }
300          if (pixaspect < .99 | pixaspect > 1.01)
# Line 290 | Line 305 | char   *argv[];
305                  ourexp = rexpadj;
306          if (ourexp < .995 | ourexp > 1.005)
307                  fputexpos(ourexp, stdout);
308 <        fputformat(COLRFMT, stdout);
308 >        if (strcmp(ourfmt, PICFMT))             /* print format if known */
309 >                fputformat(ourfmt, stdout);
310          putc('\n', stdout);
311                                                          /* write picture */
312          writepicture();
# Line 301 | Line 317 | char   *argv[];
317          exit(0);
318   userr:
319          fprintf(stderr,
320 <        "Usage: %s [view opts][-t eps][-z zout][-e spec][-a|-q][-fT][-n] pfile zspec ..\n",
320 >        "Usage: %s [view opts][-t eps][-z zout][-e spec][-B][-a|-q][-fT][-n] pfile zspec ..\n",
321                          progname);
322          exit(1);
323   #undef check
324   }
325  
326  
327 + int
328   headline(s)                             /* process header string */
329   char    *s;
330   {
331          char    fmt[32];
332  
333          if (isheadid(s))
334 <                return;
334 >                return(0);
335          if (formatval(fmt, s)) {
336 <                wrongformat = strcmp(fmt, COLRFMT);
337 <                return;
336 >                if (globmatch(ourfmt, fmt)) {
337 >                        wrongformat = 0;
338 >                        strcpy(ourfmt, fmt);
339 >                } else
340 >                        wrongformat = 1;
341 >                return(0);
342          }
343 <        putc('\t', stdout);
344 <        fputs(s, stdout);
345 <
343 >        if (nvavg < 2) {
344 >                putc('\t', stdout);
345 >                fputs(s, stdout);
346 >        }
347          if (isexpos(s)) {
348                  theirexp *= exposval(s);
349 <                return;
349 >                return(0);
350          }
351          if (isview(s) && sscanview(&theirview, s) > 0)
352                  gotview++;
353 +        return(0);
354   }
355  
356  
357 + nextview(fp)                            /* get and set next view */
358 + FILE    *fp;
359 + {
360 +        char    linebuf[256];
361 +        char    *err;
362 +        register int    i;
363 +
364 +        if (fp != NULL) {
365 +                do                      /* get new view */
366 +                        if (fgets(linebuf, sizeof(linebuf), fp) == NULL)
367 +                                return(EOF);
368 +                while (!isview(linebuf) || !sscanview(&ourview, linebuf));
369 +        }
370 +                                        /* set new view */
371 +        if ((err = setview(&ourview)) != NULL) {
372 +                fprintf(stderr, "%s: %s\n", progname, err);
373 +                exit(1);
374 +        }
375 +        if (!nvavg) {                   /* first view */
376 +                copystruct(&avgview, &ourview);
377 +                return(nvavg++);
378 +        }
379 +                                        /* add to average view */
380 +        for (i = 0; i < 3; i++) {
381 +                avgview.vp[i] += ourview.vp[i];
382 +                avgview.vdir[i] += ourview.vdir[i];
383 +                avgview.vup[i] += ourview.vup[i];
384 +        }
385 +        avgview.horiz += ourview.horiz;
386 +        avgview.vert += ourview.vert;
387 +        avgview.hoff += ourview.hoff;
388 +        avgview.voff += ourview.voff;
389 +        avgview.vfore += ourview.vfore;
390 +        avgview.vaft += ourview.vaft;
391 +        return(nvavg++);
392 + }
393 +
394 +
395 + compavgview()                           /* compute average view */
396 + {
397 +        register int    i;
398 +        double  f;
399 +
400 +        if (nvavg < 2)
401 +                return;
402 +        f = 1.0/nvavg;
403 +        for (i = 0; i < 3; i++) {
404 +                avgview.vp[i] *= f;
405 +                avgview.vdir[i] *= f;
406 +                avgview.vup[i] *= f;
407 +        }
408 +        avgview.horiz *= f;
409 +        avgview.vert *= f;
410 +        avgview.hoff *= f;
411 +        avgview.voff *= f;
412 +        avgview.vfore *= f;
413 +        avgview.vaft *= f;
414 +        if (setview(&avgview) != NULL)          /* in case of emergency... */
415 +                copystruct(&avgview, &ourview);
416 +        pixaspect = viewaspect(&avgview) * hresolu / vresolu;
417 + }
418 +
419 +
420   addpicture(pfile, zspec)                /* add picture to output */
421   char    *pfile, *zspec;
422   {
# Line 347 | Line 433 | char   *pfile, *zspec;
433                  syserror(pfile);
434                                          /* get header with exposure and view */
435          theirexp = 1.0;
436 +        copystruct(&theirview, &stdview);
437          gotview = 0;
438 <        printf("%s:\n", pfile);
438 >        if (nvavg < 2)
439 >                printf("%s:\n", pfile);
440          getheader(pfp, headline, NULL);
441          if (wrongformat || !gotview || !fgetsresolu(&tresolu, pfp)) {
442                  fprintf(stderr, "%s: picture format error\n", pfile);
# Line 381 | Line 469 | char   *pfile, *zspec;
469          if (xlim == NULL)
470                  syserror(progname);
471          if (!getperim(xlim, &ylim, zin, zfd)) { /* overlapping area? */
472 <                free((char *)zin);
473 <                free((char *)xlim);
472 >                free((void *)zin);
473 >                free((void *)xlim);
474                  if (zfd != -1)
475                          close(zfd);
476                  fclose(pfp);
# Line 401 | Line 489 | char   *pfile, *zspec;
489                          exit(1);
490                  }
491          if (zfd != -1 && lseek(zfd,
492 <                        (long)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
492 >                        (off_t)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
493                  syserror(zspec);
494                                          /* load image */
495          for (y = ylim.min; y <= ylim.max; y++) {
# Line 416 | Line 504 | char   *pfile, *zspec;
504                  addscanline(xlim+y, y, scanin, zin, plast);
505          }
506                                          /* clean up */
507 <        free((char *)xlim);
508 <        free((char *)scanin);
509 <        free((char *)zin);
510 <        free((char *)plast);
507 >        free((void *)xlim);
508 >        free((void *)scanin);
509 >        free((void *)zin);
510 >        free((void *)plast);
511          fclose(pfp);
512          if (zfd != -1)
513                  close(zfd);
# Line 432 | Line 520 | register VIEW  *vw1, *vw2;
520   {
521          double  m4t[4][4];
522  
523 <        if (vw1->type != VT_PER && vw1->type != VT_PAR)
523 >        if (vw1->type != VT_PER & vw1->type != VT_PAR)
524                  return(0);
525 <        if (vw2->type != VT_PER && vw2->type != VT_PAR)
525 >        if (vw2->type != VT_PER & vw2->type != VT_PAR)
526                  return(0);
527          setident4(xfmat);
528          xfmat[0][0] = vw1->hvec[0];
# Line 551 | Line 639 | double z;
639                  y1 = p0->y + c1*s1y/l1;
640                  for (c2 = l2; c2-- > 0; ) {
641                          x = x1 + c2*s2x/l2;
642 <                        if (x < 0 || x >= hresolu)
642 >                        if (x < 0 | x >= hresolu)
643                                  continue;
644                          y = y1 + c2*s2y/l2;
645 <                        if (y < 0 || y >= vresolu)
645 >                        if (y < 0 | y >= vresolu)
646                                  continue;
647                          if (averaging) {
648                                  if (zscan(y)[x] <= 0 || zscan(y)[x]-z
# Line 582 | Line 670 | register FVECT pos;
670   {
671          FVECT   pt, tdir, odir;
672          double  d;
585        register int    i;
673          
674          if (pos[2] <= 0)                /* empty pixel */
675                  return(0);
676          if (usematrix) {
677                  pos[0] += theirview.hoff - .5;
678                  pos[1] += theirview.voff - .5;
679 +                if (normdist & theirview.type == VT_PER)
680 +                        d = sqrt(1. + pos[0]*pos[0]*theirview.hn2
681 +                                        + pos[1]*pos[1]*theirview.vn2);
682 +                else
683 +                        d = 1.;
684 +                pos[2] += d*theirview.vfore;
685                  if (theirview.type == VT_PER) {
686 <                        if (normdist)                   /* adjust distance */
594 <                                pos[2] /= sqrt(1. + pos[0]*pos[0]*theirview.hn2
595 <                                                + pos[1]*pos[1]*theirview.vn2);
686 >                        pos[2] /= d;
687                          pos[0] *= pos[2];
688                          pos[1] *= pos[2];
689                  }
690                  multp3(pos, pos, theirs2ours);
691 <                if (pos[2] <= 0)
691 >                if (pos[2] <= ourview.vfore)
692                          return(0);
693                  if (ourview.type == VT_PER) {
694                          pos[0] /= pos[2];
# Line 605 | Line 696 | register FVECT pos;
696                  }
697                  pos[0] += .5 - ourview.hoff;
698                  pos[1] += .5 - ourview.voff;
699 +                pos[2] -= ourview.vfore;
700          } else {
701                  if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY)
702                          return(0);
# Line 618 | Line 710 | register FVECT pos;
710                  if (pos[2] <= 0)
711                          return(0);
712          }
713 <        if (pos[0] < 0 || pos[0] >= 1-FTINY || pos[1] < 0 || pos[1] >= 1-FTINY)
713 >        if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY)
714                  return(0);
715          if (!averaging)
716                  return(1);
717 <        if (ourview.type == VT_PAR)             /* compute our direction */
718 <                VCOPY(odir, ourview.vdir);
719 <        else
720 <                for (i = 0; i < 3; i++)
721 <                        odir[i] = (pt[i] - ourview.vp[i])/pos[2];
722 <        d = DOT(odir,tdir);                     /* compute pixel weight */
723 <        if (d >= 1.-1./MAXWT/MAXWT)
717 >                                                /* compute pixel weight */
718 >        if (ourview.type == VT_PAR) {
719 >                d = DOT(ourview.vdir,tdir);
720 >                d = 1. - d*d;
721 >        } else {
722 >                VSUB(odir, pt, ourview.vp);
723 >                d = DOT(odir,tdir);
724 >                d = 1. - d*d/DOT(odir,odir);
725 >        }
726 >        if (d <= 1./MAXWT/MAXWT)
727                  return(MAXWT);          /* clip to maximum weight */
728 <        return(1./sqrt(1.-d));
728 >        return(1./sqrt(d));
729   }
730  
731  
# Line 661 | Line 756 | int    zfd;
756          yl->min = 32000; yl->max = 0;           /* search for points on image */
757          for (y = step - 1; y < numscans(&tresolu); y += step) {
758                  if (zfd != -1) {
759 <                        if (lseek(zfd, (long)y*scanlen(&tresolu)*sizeof(float),
759 >                        if (lseek(zfd, (off_t)y*scanlen(&tresolu)*sizeof(float),
760                                          0) < 0)
761                                  syserror("lseek");
762                          if (read(zfd, (char *)zline,
# Line 822 | Line 917 | int    samp;
917                                  xback = -2;
918                          }
919          }
920 <        free((char *)yback);
920 >        free((void *)yback);
921   }
922  
923  
# Line 835 | Line 930 | int    (*fill)();
930                  for (x = 0; x < hresolu; x++)
931                          if (zscan(y)[x] <= 0)
932                                  (*fill)(x,y);
933 +        if (fill == rcalfill)
934 +                clearqueue();
935   }
936  
937  
# Line 846 | Line 943 | clipaft()                      /* perform aft clipping as indicated */
943          double  yzn2, vx;
944  
945          if (ourview.vaft <= FTINY)
946 <                return;
946 >                return(0);
947          tstdist = ourview.vaft - ourview.vfore;
948          for (y = 0; y < vresolu; y++) {
949                  if (adjtest) {                          /* adjust test */
# Line 870 | Line 967 | clipaft()                      /* perform aft clipping as indicated */
967                                  zscan(y)[x] = 0.0;
968                          }
969          }
970 +        return(1);
971   }
972  
973  
974 + addblur()                               /* add to blurred picture */
975 + {
976 +        COLOR   cval;
977 +        double  d;
978 +        register int    i;
979 +
980 +        if (!blurring)
981 +                return(0);
982 +        i = hresolu*vresolu;
983 +        if (nvavg < 2)
984 +                if (averaging)
985 +                        while (i--) {
986 +                                copycolor(ourbpict[i], ourspict[i]);
987 +                                d = 1.0/ourweigh[i];
988 +                                scalecolor(ourbpict[i], d);
989 +                        }
990 +                else
991 +                        while (i--)
992 +                                colr_color(ourbpict[i], ourpict[i]);
993 +        else
994 +                if (averaging)
995 +                        while (i--) {
996 +                                copycolor(cval, ourspict[i]);
997 +                                d = 1.0/ourweigh[i];
998 +                                scalecolor(cval, d);
999 +                                addcolor(ourbpict[i], cval);
1000 +                        }
1001 +                else
1002 +                        while (i--) {
1003 +                                colr_color(cval, ourpict[i]);
1004 +                                addcolor(ourbpict[i], cval);
1005 +                        }
1006 +                                /* print view */
1007 +        printf("VIEW%d:", nvavg);
1008 +        fprintview(&ourview, stdout);
1009 +        putchar('\n');
1010 +        return(1);
1011 + }
1012 +
1013 +
1014   writepicture()                          /* write out picture (alters buffer) */
1015   {
1016          int     y;
# Line 881 | Line 1019 | writepicture()                         /* write out picture (alters buffer)
1019  
1020          fprtresolu(hresolu, vresolu, stdout);
1021          for (y = vresolu-1; y >= 0; y--)
1022 <                if (averaging) {
1022 >                if (blurring) {
1023 >                        for (x = 0; x < hresolu; x++) { /* compute avg. */
1024 >                                d = rexpadj/nvavg;
1025 >                                scalecolor(bscan(y)[x], d);
1026 >                        }
1027 >                        if (fwritescan(bscan(y), hresolu, stdout) < 0)
1028 >                                syserror(progname);
1029 >                } else if (averaging) {
1030                          for (x = 0; x < hresolu; x++) { /* average pixels */
1031                                  d = rexpadj/wscan(y)[x];
1032                                  scalecolor(sscan(y)[x], d);
# Line 1024 | Line 1169 | clearqueue()                           /* process queue */
1169          }
1170                                          /* mark end and get results */
1171          bzero((char *)fbp, 6*sizeof(float));
1172 <        if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*queuesiz,
1172 >        if (process(PDesc, (char *)fbuf, (char *)fbuf,
1173 >                        4*sizeof(float)*(queuesiz+1),
1174                          6*sizeof(float)*(queuesiz+1)) !=
1175 <                        4*sizeof(float)*queuesiz) {
1175 >                        4*sizeof(float)*(queuesiz+1)) {
1176                  fprintf(stderr, "%s: error reading from rtrace process\n",
1177                                  progname);
1178                  exit(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines