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.32 by gwlarson, Fri Jul 16 16:11:31 1999 UTC vs.
Revision 2.43 by greg, Wed Feb 8 13:43:21 2012 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1999 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Interpolate and extrapolate pictures with different view parameters.
6   *
7   *      Greg Ward       09Dec89
8   */
9  
10 < #include "standard.h"
10 > #include "copyright.h"
11  
12   #include <ctype.h>
13 + #include <string.h>
14  
15 + #include "platform.h"
16 + #include "standard.h"
17 + #include "rtprocess.h" /* Windows: must come before color.h */
18   #include "view.h"
18
19   #include "color.h"
20  
21 #include "resolu.h"
22
21   #define LOG2            0.69314718055994530942
22  
23   #define pscan(y)        (ourpict+(y)*hresolu)
# Line 30 | Line 28 | static char SCCSid[] = "$SunId$ SGI";
28   #define averaging       (ourweigh != NULL)
29   #define blurring        (ourbpict != NULL)
30   #define usematrix       (hasmatrix & !averaging)
31 < #define zisnorm         (!usematrix | ourview.type != VT_PER)
31 > #define zisnorm         ((!usematrix) | (ourview.type != VT_PER))
32  
33   #define MAXWT           1000.           /* maximum pixel weight (averaging) */
34  
# Line 70 | Line 68 | char   *progname;
68  
69   int     fillo = F_FORE|F_BACK;          /* selected fill options */
70   int     fillsamp = 0;                   /* sample separation (0 == inf) */
73 extern int      backfill(), rcalfill(); /* fill functions */
74 int     (*fillfunc)() = backfill;       /* selected fill function */
71   COLR    backcolr = BLKCOLR;             /* background color */
72   COLOR   backcolor = BLKCOLOR;           /* background color (float) */
73   double  backz = 0.0;                    /* background z value */
# Line 89 | Line 85 | double theirexp;                       /* input picture exposure */
85   MAT4    theirs2ours;                    /* transformation matrix */
86   int     hasmatrix = 0;                  /* has transformation matrix */
87  
88 < int     PDesc[3] = {-1,-1,-1};          /* rtrace process descriptor */
93 < #define childpid        (PDesc[2])
88 > static SUBPROC PDesc = SP_INACTIVE; /* rtrace process descriptor */
89   unsigned short  queue[PACKSIZ][2];      /* pending pixels */
90   int     packsiz;                        /* actual packet size */
91   int     queuesiz = 0;                   /* number of pixels pending */
92  
93 < extern double   movepixel();
93 > typedef void fillfunc_t(int x, int y);
94  
95 + static gethfunc headline;
96 + static int nextview(FILE *fp);
97 + static void compavgview(void);
98 + static void addpicture(char *pfile, char *zspec);
99 + static int pixform(MAT4 xfmat, VIEW *vw1, VIEW *vw2);
100 + static void addscanline(struct bound *xl, int y,
101 +        COLR *pline, float *zline, struct position *lasty);
102 + static void addpixel(struct position *p0, struct position *p1,
103 +        struct position *p2, COLR pix, double w, double z);
104 + static double movepixel(FVECT pos);
105 + static int getperim(struct bound *xl, struct bound *yl, float *zline, int zfd);
106 + static void backpicture(fillfunc_t *fill, int samp);
107 + static void fillpicture(fillfunc_t *fill);
108 + static int clipaft(void);
109 + static int addblur(void);
110 + static void writepicture(void);
111 + static void writedistance(char *fname);
112 + static fillfunc_t backfill;
113 + static fillfunc_t rcalfill;
114 + static void calstart(char *prog, char *args);
115 + static void caldone(void);
116 + static void clearqueue(void);
117 + static void syserror(char *s);
118  
119 < main(argc, argv)                        /* interpolate pictures */
120 < int     argc;
121 < char    *argv[];
119 > fillfunc_t *fillfunc = backfill;        /* selected fill function */
120 >
121 > int
122 > main(                   /* interpolate pictures */
123 >        int     argc,
124 >        char    *argv[]
125 > )
126   {
127   #define  check(ol,al)           if (argv[an][ol] || \
128                                  badarg(argc-an-1,argv+an+1,al)) \
# Line 112 | Line 134 | char   *argv[];
134          char    *expcomp = NULL;
135          int     i, an, rval;
136  
137 +        SET_DEFAULT_BINARY();
138 +        SET_FILE_BINARY(stdout);
139 +
140          progname = argv[0];
141  
142          for (an = 1; an < argc && argv[an][0] == '-'; an++) {
# Line 213 | Line 238 | char   *argv[];
238                          if (argv[an][2] != 'f')
239                                  goto badopt;
240                          check(3,"s");
241 <                        gotvfile = viewfile(argv[++an], &ourview, 0, 0);
241 >                        gotvfile = viewfile(argv[++an], &ourview, NULL);
242                          if (gotvfile < 0)
243                                  syserror(argv[an]);
244                          else if (gotvfile == 0) {
# Line 236 | Line 261 | char   *argv[];
261                  fillo &= ~F_BACK;
262          if (doavg < 0)
263                  doavg = (argc-an) > 2;
264 <        if (expcomp != NULL)
265 <                if (expcomp[0] == '+' | expcomp[0] == '-') {
264 >        if (expcomp != NULL) {
265 >                if ((expcomp[0] == '+') | (expcomp[0] == '-')) {
266                          expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5);
267                          if (doavg | doblur)
268                                  rexpadj = pow(2.0, atof(expcomp));
# Line 251 | Line 276 | char   *argv[];
276                          if (!(doavg | doblur))
277                                  rexpadj = pow(2.0, (double)expadj);
278                  }
279 +        }
280                                                  /* set view */
281          if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) {
282                  fprintf(stderr, "%s: no view on standard input!\n",
# Line 262 | Line 288 | char   *argv[];
288          if (doavg) {
289                  ourspict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR));
290                  ourweigh = (float *)bmalloc(hresolu*vresolu*sizeof(float));
291 <                if (ourspict == NULL | ourweigh == NULL)
291 >                if ((ourspict == NULL) | (ourweigh == NULL))
292                          syserror(progname);
293          } else {
294                  ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR));
# Line 279 | Line 305 | char   *argv[];
305                  syserror(progname);
306                                                          /* new header */
307          newheader("RADIANCE", stdout);
308 +        fputnow(stdout);
309                                                          /* run pictures */
310          do {
311 <                bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
311 >                memset((char *)ourzbuf, '\0', hresolu*vresolu*sizeof(float));
312                  for (i = an; i < argc; i += 2)
313                          addpicture(argv[i], argv[i+1]);
314                  if (fillo&F_BACK)                       /* fill in spaces */
# Line 301 | Line 328 | char   *argv[];
328                  fprintview(&avgview, stdout);
329                  putc('\n', stdout);
330          }
331 <        if (pixaspect < .99 | pixaspect > 1.01)
331 >        if ((pixaspect < .99) | (pixaspect > 1.01))
332                  fputaspect(pixaspect, stdout);
333          if (ourexp > 0)
334                  ourexp *= rexpadj;
335          else
336                  ourexp = rexpadj;
337 <        if (ourexp < .995 | ourexp > 1.005)
337 >        if ((ourexp < .995) | (ourexp > 1.005))
338                  fputexpos(ourexp, stdout);
339          if (strcmp(ourfmt, PICFMT))             /* print format if known */
340                  fputformat(ourfmt, stdout);
# Line 328 | Line 355 | userr:
355   }
356  
357  
358 < int
359 < headline(s)                             /* process header string */
360 < char    *s;
358 > static int
359 > headline(                               /* process header string */
360 >        char    *s,
361 >        void    *p
362 > )
363   {
364          char    fmt[32];
365  
# Line 358 | Line 387 | char   *s;
387   }
388  
389  
390 < nextview(fp)                            /* get and set next view */
391 < FILE    *fp;
390 > static int
391 > nextview(                               /* get and set next view */
392 >        FILE    *fp
393 > )
394   {
395          char    linebuf[256];
396          char    *err;
# Line 377 | Line 408 | FILE   *fp;
408                  exit(1);
409          }
410          if (!nvavg) {                   /* first view */
411 <                copystruct(&avgview, &ourview);
411 >                avgview = ourview;
412                  return(nvavg++);
413          }
414                                          /* add to average view */
# Line 386 | Line 417 | FILE   *fp;
417                  avgview.vdir[i] += ourview.vdir[i];
418                  avgview.vup[i] += ourview.vup[i];
419          }
420 +        avgview.vdist += ourview.vdist;
421          avgview.horiz += ourview.horiz;
422          avgview.vert += ourview.vert;
423          avgview.hoff += ourview.hoff;
# Line 396 | Line 428 | FILE   *fp;
428   }
429  
430  
431 < compavgview()                           /* compute average view */
431 > static void
432 > compavgview(void)                               /* compute average view */
433   {
434          register int    i;
435          double  f;
# Line 409 | Line 442 | compavgview()                          /* compute average view */
442                  avgview.vdir[i] *= f;
443                  avgview.vup[i] *= f;
444          }
445 +        avgview.vdist *= f;
446          avgview.horiz *= f;
447          avgview.vert *= f;
448          avgview.hoff *= f;
# Line 416 | Line 450 | compavgview()                          /* compute average view */
450          avgview.vfore *= f;
451          avgview.vaft *= f;
452          if (setview(&avgview) != NULL)          /* in case of emergency... */
453 <                copystruct(&avgview, &ourview);
453 >                avgview = ourview;
454          pixaspect = viewaspect(&avgview) * hresolu / vresolu;
455   }
456  
457  
458 < addpicture(pfile, zspec)                /* add picture to output */
459 < char    *pfile, *zspec;
458 > static void
459 > addpicture(             /* add picture to output */
460 >        char    *pfile,
461 >        char    *zspec
462 > )
463   {
464          FILE    *pfp;
465          int     zfd;
# Line 437 | Line 474 | char   *pfile, *zspec;
474                  syserror(pfile);
475                                          /* get header with exposure and view */
476          theirexp = 1.0;
477 <        copystruct(&theirview, &stdview);
477 >        theirview = stdview;
478          gotview = 0;
479          if (nvavg < 2)
480                  printf("%s:\n", pfile);
# Line 450 | Line 487 | char   *pfile, *zspec;
487                  ourexp = theirexp;
488          else if (ABS(theirexp-ourexp) > .01*ourexp)
489                  fprintf(stderr, "%s: different exposure (warning)\n", pfile);
490 <        if (err = setview(&theirview)) {
490 >        if ( (err = setview(&theirview)) ) {
491                  fprintf(stderr, "%s: %s\n", pfile, err);
492                  exit(1);
493          }
# Line 473 | Line 510 | char   *pfile, *zspec;
510          if (xlim == NULL)
511                  syserror(progname);
512          if (!getperim(xlim, &ylim, zin, zfd)) { /* overlapping area? */
513 <                free((char *)zin);
514 <                free((char *)xlim);
513 >                free((void *)zin);
514 >                free((void *)xlim);
515                  if (zfd != -1)
516                          close(zfd);
517                  fclose(pfp);
# Line 484 | Line 521 | char   *pfile, *zspec;
521          scanin = (COLR *)malloc(scanlen(&tresolu)*sizeof(COLR));
522          plast = (struct position *)calloc(scanlen(&tresolu),
523                          sizeof(struct position));
524 <        if (scanin == NULL | plast == NULL)
524 >        if ((scanin == NULL) | (plast == NULL))
525                  syserror(progname);
526                                          /* skip to starting point */
527          for (y = 0; y < ylim.min; y++)
# Line 493 | Line 530 | char   *pfile, *zspec;
530                          exit(1);
531                  }
532          if (zfd != -1 && lseek(zfd,
533 <                        (long)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
533 >                        (off_t)ylim.min*scanlen(&tresolu)*sizeof(float),
534 >                        SEEK_SET) < 0)
535                  syserror(zspec);
536                                          /* load image */
537          for (y = ylim.min; y <= ylim.max; y++) {
# Line 508 | Line 546 | char   *pfile, *zspec;
546                  addscanline(xlim+y, y, scanin, zin, plast);
547          }
548                                          /* clean up */
549 <        free((char *)xlim);
550 <        free((char *)scanin);
551 <        free((char *)zin);
552 <        free((char *)plast);
549 >        free((void *)xlim);
550 >        free((void *)scanin);
551 >        free((void *)zin);
552 >        free((void *)plast);
553          fclose(pfp);
554          if (zfd != -1)
555                  close(zfd);
556   }
557  
558  
559 < pixform(xfmat, vw1, vw2)                /* compute view1 to view2 matrix */
560 < register MAT4   xfmat;
561 < register VIEW   *vw1, *vw2;
559 > static int
560 > pixform(                /* compute view1 to view2 matrix */
561 >        register MAT4   xfmat,
562 >        register VIEW   *vw1,
563 >        register VIEW   *vw2
564 > )
565   {
566          double  m4t[4][4];
567  
568 <        if (vw1->type != VT_PER & vw1->type != VT_PAR)
568 >        if ((vw1->type != VT_PER) & (vw1->type != VT_PAR))
569                  return(0);
570 <        if (vw2->type != VT_PER & vw2->type != VT_PAR)
570 >        if ((vw2->type != VT_PER) & (vw2->type != VT_PAR))
571                  return(0);
572          setident4(xfmat);
573          xfmat[0][0] = vw1->hvec[0];
# Line 559 | Line 600 | register VIEW  *vw1, *vw2;
600   }
601  
602  
603 < addscanline(xl, y, pline, zline, lasty) /* add scanline to output */
604 < struct bound    *xl;
605 < int     y;
606 < COLR    *pline;
607 < float   *zline;
608 < struct position *lasty;         /* input/output */
603 > static void
604 > addscanline(    /* add scanline to output */
605 >        struct bound    *xl,
606 >        int     y,
607 >        COLR    *pline,
608 >        float   *zline,
609 >        struct position *lasty          /* input/output */
610 > )
611   {
612          FVECT   pos;
613          struct position lastx, newpos;
# Line 591 | Line 634 | struct position        *lasty;         /* input/output */
634   }
635  
636  
637 < addpixel(p0, p1, p2, pix, w, z)         /* fill in pixel parallelogram */
638 < struct position *p0, *p1, *p2;
639 < COLR    pix;
640 < double  w;
641 < double  z;
637 > static void
638 > addpixel(               /* fill in pixel parallelogram */
639 >        struct position *p0,
640 >        struct position *p1,
641 >        struct position *p2,
642 >        COLR    pix,
643 >        double  w,
644 >        double  z
645 > )
646   {
647          double  zt = 2.*zeps*p0->z;             /* threshold */
648          COLOR   pval;                           /* converted+weighted pixel */
# Line 610 | Line 657 | double z;
657                  s1x = p1->x - p0->x;
658                  s1y = p1->y - p0->y;
659                  l1 = ABS(s1x);
660 <                if (p1isy = (ABS(s1y) > l1))
660 >                if ( (p1isy = (ABS(s1y) > l1)) )
661                          l1 = ABS(s1y);
662                  else if (l1 < 1)
663                          l1 = 1;
# Line 643 | Line 690 | double z;
690                  y1 = p0->y + c1*s1y/l1;
691                  for (c2 = l2; c2-- > 0; ) {
692                          x = x1 + c2*s2x/l2;
693 <                        if (x < 0 | x >= hresolu)
693 >                        if ((x < 0) | (x >= hresolu))
694                                  continue;
695                          y = y1 + c2*s2y/l2;
696 <                        if (y < 0 | y >= vresolu)
696 >                        if ((y < 0) | (y >= vresolu))
697                                  continue;
698                          if (averaging) {
699                                  if (zscan(y)[x] <= 0 || zscan(y)[x]-z
# Line 668 | Line 715 | double z;
715   }
716  
717  
718 < double
719 < movepixel(pos)                          /* reposition image point */
720 < register FVECT  pos;
718 > static double
719 > movepixel(                              /* reposition image point */
720 >        register FVECT  pos
721 > )
722   {
723          FVECT   pt, tdir, odir;
724          double  d;
# Line 680 | Line 728 | register FVECT pos;
728          if (usematrix) {
729                  pos[0] += theirview.hoff - .5;
730                  pos[1] += theirview.voff - .5;
731 <                if (normdist & theirview.type == VT_PER)
731 >                if (normdist & (theirview.type == VT_PER))
732                          d = sqrt(1. + pos[0]*pos[0]*theirview.hn2
733                                          + pos[1]*pos[1]*theirview.vn2);
734                  else
# Line 704 | Line 752 | register FVECT pos;
752          } else {
753                  if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY)
754                          return(0);
755 <                if (!normdist & theirview.type == VT_PER)       /* adjust */
755 >                if ((!normdist) & (theirview.type == VT_PER))   /* adjust */
756                          pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2
757                                          + pos[1]*pos[1]*theirview.vn2);
758                  pt[0] += tdir[0]*pos[2];
# Line 714 | Line 762 | register FVECT pos;
762                  if (pos[2] <= 0)
763                          return(0);
764          }
765 <        if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY)
765 >        if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | (pos[1] < 0) | (pos[1] >= 1-FTINY))
766                  return(0);
767          if (!averaging)
768                  return(1);
# Line 733 | Line 781 | register FVECT pos;
781   }
782  
783  
784 < getperim(xl, yl, zline, zfd)            /* compute overlapping image area */
785 < register struct bound   *xl;
786 < struct bound    *yl;
787 < float   *zline;
788 < int     zfd;
784 > static int
785 > getperim(               /* compute overlapping image area */
786 >        register struct bound   *xl,
787 >        struct bound    *yl,
788 >        float   *zline,
789 >        int     zfd
790 > )
791   {
792          int     step;
793          FVECT   pos;
# Line 760 | Line 810 | int    zfd;
810          yl->min = 32000; yl->max = 0;           /* search for points on image */
811          for (y = step - 1; y < numscans(&tresolu); y += step) {
812                  if (zfd != -1) {
813 <                        if (lseek(zfd, (long)y*scanlen(&tresolu)*sizeof(float),
814 <                                        0) < 0)
813 >                        if (lseek(zfd, (off_t)y*scanlen(&tresolu)*sizeof(float),
814 >                                        SEEK_SET) < 0)
815                                  syserror("lseek");
816                          if (read(zfd, (char *)zline,
817                                          scanlen(&tresolu)*sizeof(float))
# Line 806 | Line 856 | int    zfd;
856                                  xl[y-1].max = xl[y-step].max;
857                  }
858                  for (x = 2; x < step; x++)
859 <                        copystruct(xl+y-x, xl+y-1);
859 >                        *(xl+y-x) = *(xl+y-1);
860          }
861          if (yl->max >= numscans(&tresolu))
862                  yl->max = numscans(&tresolu) - 1;
863          y -= step;
864          for (x = numscans(&tresolu) - 1; x > y; x--)    /* fill bottom rows */
865 <                copystruct(xl+x, xl+y);
865 >                *(xl+x) = *(xl+y);
866          return(yl->max >= yl->min);
867   }
868  
869  
870 < backpicture(fill, samp)                 /* background fill algorithm */
871 < int     (*fill)();
872 < int     samp;
870 > static void
871 > backpicture(                    /* background fill algorithm */
872 >        fillfunc_t *fill,
873 >        int     samp
874 > )
875   {
876          int     *yback, xback;
877          int     y;
# Line 921 | Line 973 | int    samp;
973                                  xback = -2;
974                          }
975          }
976 <        free((char *)yback);
976 >        free((void *)yback);
977   }
978  
979  
980 < fillpicture(fill)               /* paint in empty pixels using fill */
981 < int     (*fill)();
980 > static void
981 > fillpicture(            /* paint in empty pixels using fill */
982 >        fillfunc_t *fill
983 > )
984   {
985          register int    x, y;
986  
# Line 939 | Line 993 | int    (*fill)();
993   }
994  
995  
996 < clipaft()                       /* perform aft clipping as indicated */
996 > static int
997 > clipaft(void)                   /* perform aft clipping as indicated */
998   {
999          register int    x, y;
1000 <        int     adjtest = ourview.type == VT_PER & zisnorm;
1000 >        int     adjtest = (ourview.type == VT_PER) & zisnorm;
1001          double  tstdist;
1002          double  yzn2, vx;
1003  
# Line 965 | Line 1020 | clipaft()                      /* perform aft clipping as indicated */
1020                                                  continue;
1021                                  }
1022                                  if (averaging)
1023 <                                        bzero(sscan(y)[x], sizeof(COLOR));
1023 >                                        memset(sscan(y)[x], '\0', sizeof(COLOR));
1024                                  else
1025 <                                        bzero(pscan(y)[x], sizeof(COLR));
1025 >                                        memset(pscan(y)[x], '\0', sizeof(COLR));
1026                                  zscan(y)[x] = 0.0;
1027                          }
1028          }
# Line 975 | Line 1030 | clipaft()                      /* perform aft clipping as indicated */
1030   }
1031  
1032  
1033 < addblur()                               /* add to blurred picture */
1033 > static int
1034 > addblur(void)                           /* add to blurred picture */
1035   {
1036          COLOR   cval;
1037          double  d;
# Line 1015 | Line 1071 | addblur()                              /* add to blurred picture */
1071   }
1072  
1073  
1074 < writepicture()                          /* write out picture (alters buffer) */
1074 > static void
1075 > writepicture(void)                              /* write out picture (alters buffer) */
1076   {
1077          int     y;
1078          register int    x;
# Line 1046 | Line 1103 | writepicture()                         /* write out picture (alters buffer)
1103   }
1104  
1105  
1106 < writedistance(fname)                    /* write out z file (alters buffer) */
1107 < char    *fname;
1106 > static void
1107 > writedistance(                  /* write out z file (alters buffer) */
1108 >        char    *fname
1109 > )
1110   {
1111          int     donorm = normdist & !zisnorm ? 1 :
1112 <                        ourview.type == VT_PER & !normdist & zisnorm ? -1 : 0;
1112 >                        (ourview.type == VT_PER) & !normdist & zisnorm ? -1 : 0;
1113          int     fd;
1114          int     y;
1115  
# Line 1079 | Line 1138 | char   *fname;
1138   }
1139  
1140  
1141 < backfill(x, y)                          /* fill pixel with background */
1142 < int     x, y;
1141 > static void
1142 > backfill(                               /* fill pixel with background */
1143 >        int     x,
1144 >        int     y
1145 > )
1146   {
1147          if (averaging) {
1148                  copycolor(sscan(y)[x], backcolor);
# Line 1091 | Line 1153 | int    x, y;
1153   }
1154  
1155  
1156 < calstart(prog, args)                    /* start fill calculation */
1157 < char    *prog, *args;
1156 > static void
1157 > calstart(                    /* start fill calculation */
1158 >        char    *prog,
1159 >        char    *args
1160 > )
1161   {
1162          char    combuf[512];
1163          char    *argv[64];
1164          int     rval;
1165          register char   **wp, *cp;
1166  
1167 <        if (childpid != -1) {
1167 >        if (PDesc.running) {
1168                  fprintf(stderr, "%s: too many calculations\n", progname);
1169                  exit(1);
1170          }
# Line 1118 | Line 1183 | char   *prog, *args;
1183          }
1184          *wp = NULL;
1185                                                  /* start process */
1186 <        if ((rval = open_process(PDesc, argv)) < 0)
1186 >        if ((rval = open_process(&PDesc, argv)) < 0)
1187                  syserror(progname);
1188          if (rval == 0) {
1189                  fprintf(stderr, "%s: command not found\n", argv[0]);
# Line 1131 | Line 1196 | char   *prog, *args;
1196   }
1197  
1198  
1199 < caldone()                               /* done with calculation */
1199 > static void
1200 > caldone(void)                               /* done with calculation */
1201   {
1202 <        if (childpid == -1)
1202 >        if (!PDesc.running)
1203                  return;
1204          clearqueue();
1205 <        close_process(PDesc);
1140 <        childpid = -1;
1205 >        close_process(&PDesc);
1206   }
1207  
1208  
1209 < rcalfill(x, y)                          /* fill with ray-calculated pixel */
1210 < int     x, y;
1209 > static void
1210 > rcalfill(                               /* fill with ray-calculated pixel */
1211 >        int     x,
1212 >        int     y
1213 > )
1214   {
1215          if (queuesiz >= packsiz)        /* flush queue if needed */
1216                  clearqueue();
# Line 1153 | Line 1221 | int    x, y;
1221   }
1222  
1223  
1224 < clearqueue()                            /* process queue */
1224 > static void
1225 > clearqueue(void)                                /* process queue */
1226   {
1227          FVECT   orig, dir;
1228          float   fbuf[6*(PACKSIZ+1)];
# Line 1172 | Line 1241 | clearqueue()                           /* process queue */
1241                  *fbp++ = dir[0]; *fbp++ = dir[1]; *fbp++ = dir[2];
1242          }
1243                                          /* mark end and get results */
1244 <        bzero((char *)fbp, 6*sizeof(float));
1245 <        if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*(queuesiz+1),
1244 >        memset((char *)fbp, '\0', 6*sizeof(float));
1245 >        if (process(&PDesc, (char *)fbuf, (char *)fbuf,
1246 >                        4*sizeof(float)*(queuesiz+1),
1247                          6*sizeof(float)*(queuesiz+1)) !=
1248                          4*sizeof(float)*(queuesiz+1)) {
1249                  fprintf(stderr, "%s: error reading from rtrace process\n",
# Line 1208 | Line 1278 | clearqueue()                           /* process queue */
1278   }
1279  
1280  
1281 < syserror(s)                     /* report error and exit */
1282 < char    *s;
1281 > static void
1282 > syserror(                       /* report error and exit */
1283 >        char    *s
1284 > )
1285   {
1286          perror(s);
1287          exit(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines