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

Comparing ray/src/px/pfilt.c (file contents):
Revision 2.23 by schorsch, Thu Jun 5 19:29:34 2003 UTC vs.
Revision 2.35 by greg, Thu Dec 7 21:15:54 2023 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   *     6/23/93  Added additional buffers for value spreading
9   */
10  
11 < #include  <signal.h>
11 > #include  "copyright.h"
12  
13 < #include  "standard.h"
14 < #include  "color.h"
15 < #include  "view.h"
13 > #include  <signal.h>
14 > #include  "pfilt.h"
15 > #include  "platform.h"
16   #include  "paths.h"
17 + #include  "view.h"
18  
18 extern float  *matchlamp();
19
19   #define  FEQ(a,b)       ((a) >= .98*(b) && (a) <= 1.02*(b))
20  
21   double   CHECKRAD = 2.0;        /* radius to check for filtering */
# Line 79 | Line 78 | int  orad = 0;                 /* output window radius */
78  
79   char  *progname;
80  
81 + static gethfunc headline;
82 + static brightfunc_t rgb_bright;
83 + static brightfunc_t xyz_bright;
84 + static void copyfile(FILE  *in, FILE  *out);
85 + static void pass1(FILE  *in);
86 + static void pass2(FILE  *in);
87 + static void scan2init(void);
88 + static void scan2sync(int  r);
89 + static void scan2flush(void);
90  
91 < main(argc, argv)
92 < int  argc;
93 < char  **argv;
91 >
92 > int
93 > main(
94 >        int  argc,
95 >        char  **argv
96 > )
97   {
87        extern int  headline();
98          FILE  *fin;
99          float  *lampcolor;
100          char  *lamptype = NULL;
# Line 97 | Line 107 | char  **argv;
107          SET_FILE_BINARY(stdout);
108          if (signal(SIGINT, quit) == SIG_IGN)
109                  signal(SIGINT, SIG_IGN);
110 + #ifdef SIGHUP
111          if (signal(SIGHUP, quit) == SIG_IGN)
112                  signal(SIGHUP, SIG_IGN);
113 + #endif
114          signal(SIGTERM, quit);
115 + #ifdef SIGPIPE
116          signal(SIGPIPE, quit);
117 + #endif
118   #ifdef  SIGXCPU
119          signal(SIGXCPU, quit);
120          signal(SIGXFSZ, quit);
# Line 298 | Line 312 | char  **argv;
312          pass2(fin);
313  
314          quit(estatus);
315 +        return estatus; /* pro forma return */
316   }
317  
318  
319 < double
320 < rgb_bright(clr)
321 < COLOR  clr;
319 > static double
320 > rgb_bright(
321 >        COLOR  clr
322 > )
323   {
324          return(bright(clr));
325   }
326  
327  
328 < double
329 < xyz_bright(clr)
330 < COLOR  clr;
328 > static double
329 > xyz_bright(
330 >        COLOR  clr
331 > )
332   {
333          return(clr[CIEY]);
334   }
335  
336  
337 < double  (*ourbright)() = rgb_bright;
337 > brightfunc_t *ourbright = rgb_bright;
338  
339 <
340 < int
341 < headline(s)                             /* process line from header */
342 < char  *s;
339 > static int
340 > headline(                               /* process line from header */
341 >        char    *s,
342 >        void    *p
343 > )
344   {
345 <        char  fmt[32];
345 >        char  fmt[MAXFMTLEN];
346  
347          fputs(s, stdout);               /* copy to output */
348          if (isaspect(s))                /* get aspect ratio */
# Line 345 | Line 363 | char  *s;
363   }
364  
365  
366 < copyfile(in, out)                       /* copy a file */
367 < register FILE  *in, *out;
366 > static void
367 > copyfile(                       /* copy a file */
368 >        FILE  *in,
369 >        FILE  *out
370 > )
371   {
372 <        register int  c;
372 >        int  c;
373  
374          while ((c = getc(in)) != EOF)
375                  putc(c, out);
# Line 360 | Line 381 | register FILE  *in, *out;
381   }
382  
383  
384 < pass1(in)                               /* first pass of picture file */
385 < FILE  *in;
384 > static void
385 > pass1(                          /* first pass of picture file */
386 >        FILE  *in
387 > )
388   {
389          int  i;
390          COLOR  *scan;
# Line 393 | Line 416 | FILE  *in;
416   }
417  
418  
419 < pass2(in)                       /* last pass on file, write to stdout */
420 < FILE  *in;
419 > static void
420 > pass2(                  /* last pass on file, write to stdout */
421 >        FILE  *in
422 > )
423   {
424          int  yread;
425          int  ycent, xcent;
# Line 444 | Line 469 | FILE  *in;
469   }
470  
471  
472 < scan2init()                     /* prepare scanline arrays */
472 > static void
473 > scan2init(void)                 /* prepare scanline arrays */
474   {
475          COLOR   ctmp;
476          double  d;
477 <        register int  i;
477 >        int  i;
478  
479          xbrad = xres/ncols/2 + 1;
480          ybrad = yres/nrows/2 + 1;
# Line 482 | Line 508 | scan2init()                    /* prepare scanline arrays */
508          if (obarsize > 0) {
509                  scoutbar = (COLOR **)malloc(obarsize*sizeof(COLOR *));
510                  greybar = (float **)malloc(obarsize*sizeof(float *));
511 <                if (scoutbar == NULL | greybar == NULL)
511 >                if ((scoutbar == NULL) | (greybar == NULL))
512                          goto memerr;
513                  for (i = 0; i < obarsize; i++) {
514                          scoutbar[i] = (COLOR *)malloc(ncols*sizeof(COLOR));
515                          greybar[i] = (float *)malloc(ncols*sizeof(float));
516 <                        if (scoutbar[i] == NULL | greybar[i] == NULL)
516 >                        if ((scoutbar[i] == NULL) | (greybar[i] == NULL))
517                                  goto memerr;
518                  }
519          } else {
# Line 521 | Line 547 | memerr:
547   }
548  
549  
550 < scan2sync(r)                    /* synchronize grey averages and output scan */
551 < int  r;
550 > static void
551 > scan2sync(                      /* synchronize grey averages and output scan */
552 >        int  r
553 > )
554   {
555          static int  nextrow = 0;
556          COLOR  ctmp;
557          int  ybot;
558 <        register int  c;
558 >        int  c;
559                                          /* average input scanlines */
560          while (nextrow <= r+orad && nextrow < nrows) {
561                  ybot = (nextrow+.5)*yres/nrows;
# Line 536 | Line 564 | int  r;
564                          greybar[nextrow%obarsize][c] = (*ourbright)(ctmp);
565                  }
566                                          /* and zero output scanline */
567 <                bzero((char *)scoutbar[nextrow%obarsize], ncols*sizeof(COLOR));
567 >                memset((char *)scoutbar[nextrow%obarsize], '\0', ncols*sizeof(COLOR));
568                  nextrow++;
569          }
570                                          /* point to top scanline for output */
# Line 547 | Line 575 | int  r;
575   }
576  
577  
578 < scan2flush()                    /* flush output buffer */
578 > static void
579 > scan2flush(void)                        /* flush output buffer */
580   {
581 <        register int  r;
581 >        int  r;
582  
583          for (r = nrows-orad; r < nrows; r++)
584                  if (fwritescan(scoutbar[r%obarsize], ncols, stdout) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines