--- ray/src/util/glareval.c 2003/07/03 22:41:45 2.10 +++ ray/src/util/glareval.c 2018/08/02 18:33:50 2.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: glareval.c,v 2.10 2003/07/03 22:41:45 schorsch Exp $"; +static const char RCSid[] = "$Id: glareval.c,v 2.16 2018/08/02 18:33:50 greg Exp $"; #endif /* * Compute pixels for glare calculation @@ -10,6 +10,7 @@ static const char RCSid[] = "$Id: glareval.c,v 2.10 20 #include #include +#include "platform.h" #include "rtprocess.h" /* Windows: must come first because of conflicts */ #include "glare.h" @@ -52,14 +53,20 @@ static long nrecl = 0L; /* number of scanlines reclaim static int wrongformat = 0; -SCAN *scanretire(); +static SCAN * claimscan(int y); +static COLR * getpictscan(int y); +static double pict_val(FVECT vd); +static void rt_compute(float *pb, int np); +static gethfunc getexpos; +static SCAN * scanretire(void); +static void initscans(void); +static void donescans(void); -extern long ftell(); - -SCAN * -claimscan(y) /* claim scanline from buffers */ -int y; +static SCAN * +claimscan( /* claim scanline from buffers */ + int y +) { int hi = shash(y); SCAN *slast; @@ -85,9 +92,10 @@ int y; } -COLR * -getpictscan(y) /* get picture scanline */ -int y; +static COLR * +getpictscan( /* get picture scanline */ + int y +) { register SCAN *sl; register int i; @@ -137,7 +145,8 @@ seekerr: #ifdef DEBUG -pict_stats() /* print out picture read statistics */ +void +pict_stats(void) /* print out picture read statistics */ { static long lastcall = 0L; /* ncall at last report */ static long lastread = 0L; /* nread at last report */ @@ -154,9 +163,10 @@ pict_stats() /* print out picture read statistics */ #endif -double -pict_val(vd) /* find picture value for view direction */ -FVECT vd; +static double +pict_val( /* find picture value for view direction */ + FVECT vd +) { FVECT pp; FVECT ip; @@ -167,18 +177,18 @@ FVECT vd; pp[0] = pictview.vp[0] + vd[0]; pp[1] = pictview.vp[1] + vd[1]; pp[2] = pictview.vp[2] + vd[2]; - viewloc(ip, &pictview, pp); - if (ip[2] <= FTINY || ip[0] < 0. || ip[0] >= 1. || - ip[1] < 0. || ip[1] >= 1.) + if (viewloc(ip, &pictview, pp) != 1) return(-1.0); colr_color(res, getpictscan((int)(ip[1]*pysiz))[(int)(ip[0]*pxsiz)]); return(luminance(res)/exposure); } -double -getviewpix(vh, vv) /* compute single view pixel */ -int vh, vv; +extern double +getviewpix( /* compute single view pixel */ + int vh, + int vv +) { FVECT dir; float rt_buf[12]; @@ -204,9 +214,11 @@ int vh, vv; } -getviewspan(vv, vb) /* compute a span of view pixels */ -int vv; -float *vb; +extern void +getviewspan( /* compute a span of view pixels */ + int vv, + float *vb +) { float rt_buf[6*MAXPIX]; /* rtrace send/receive buffer */ register int n; /* number of pixels in buffer */ @@ -235,8 +247,10 @@ float *vb; /* send to rtrace */ if (n >= maxpix) { /* flush */ rt_compute(rt_buf, n); - while (n-- > 0) + while (n > 0) { + --n; vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n); + } } rt_buf[6*n] = ourview.vp[0]; rt_buf[6*n+1] = ourview.vp[1]; @@ -258,9 +272,11 @@ float *vb; } -rt_compute(pb, np) /* process buffer through rtrace */ -float *pb; -int np; +static void +rt_compute( /* process buffer through rtrace */ + float *pb, + int np +) { #ifdef DEBUG if (verbose && np > 1) @@ -277,11 +293,13 @@ int np; } -int -getexpos(s) /* get exposure from header line */ -char *s; +static int +getexpos( /* get exposure from header line */ + char *s, + void *p +) { - char fmt[32]; + char fmt[MAXFMTLEN]; if (isexpos(s)) exposure *= exposval(s); @@ -293,13 +311,16 @@ char *s; } -open_pict(fn) /* open picture file */ -char *fn; +extern void +open_pict( /* open picture file */ + char *fn +) { if ((pictfp = fopen(fn, "r")) == NULL) { fprintf(stderr, "%s: cannot open\n", fn); exit(1); } + SET_FILE_BINARY(pictfp); exposure = 1.0; getheader(pictfp, getexpos, NULL); if (wrongformat || !fscnresolu(&pxsiz, &pysiz, pictfp)) { @@ -310,7 +331,8 @@ char *fn; } -close_pict() /* done with picture */ +extern void +close_pict(void) /* done with picture */ { if (pictfp == NULL) return; @@ -320,8 +342,10 @@ close_pict() /* done with picture */ } -fork_rtrace(av) /* open pipe and start rtrace */ -char *av[]; +extern void +fork_rtrace( /* open pipe and start rtrace */ + char *av[] +) { int rval; @@ -341,7 +365,8 @@ char *av[]; } -done_rtrace() /* wait for rtrace to finish */ +extern void +done_rtrace(void) /* wait for rtrace to finish */ { int status; @@ -355,8 +380,8 @@ done_rtrace() /* wait for rtrace to finish */ } -SCAN * -scanretire() /* retire old scanlines to free list */ +static SCAN * +scanretire(void) /* retire old scanlines to free list */ { SCAN *sold[NRETIRE]; int n; @@ -399,7 +424,8 @@ scanretire() /* retire old scanlines to free list */ static char *scan_buf; -initscans() /* initialize scanline buffers */ +static void +initscans(void) /* initialize scanline buffers */ { int scansize; register SCAN *ptr; @@ -438,7 +464,8 @@ initscans() /* initialize scanline buffers */ } -donescans() /* free up scanlines */ +static void +donescans(void) /* free up scanlines */ { bfree(scan_buf, scanbufsiz); bfree((char *)scanpos, pysiz*sizeof(long));