--- ray/src/px/pf2.c 2004/03/28 20:33:14 2.7 +++ ray/src/px/pf2.c 2023/12/08 17:56:26 2.11 @@ -1,22 +1,13 @@ #ifndef lint -static const char RCSid[] = "$Id: pf2.c,v 2.7 2004/03/28 20:33:14 schorsch Exp $"; +static const char RCSid[] = "$Id: pf2.c,v 2.11 2023/12/08 17:56:26 greg Exp $"; #endif /* * pf2.c - routines used by pfilt. */ -#include -#include -#include - -#include "rterror.h" -#include "random.h" -#include "color.h" #include "pfilt.h" +#include "random.h" -#define PI 3.14159265359 -#define FTINY (1e-6) - #define AVGLVL 0.5 /* target mean brightness */ double avgbrt; /* average picture brightness */ @@ -33,10 +24,10 @@ HOTPIX *head; /* head of avgbrt pixel list */ double sprdfact; /* computed spread factor */ -static void starpoint(COLOR fcol, int x, int y, HOTPIX *hp); +static void starpoint(SCOLOR fcol, int x, int y, HOTPIX *hp); -extern void +void pass1init(void) /* prepare for first pass */ { avgbrt = 0.0; @@ -45,7 +36,7 @@ pass1init(void) /* prepare for first pass */ } -extern void +void pass1default(void) /* for single pass */ { avgbrt = AVGLVL; @@ -54,19 +45,19 @@ pass1default(void) /* for single pass */ } -extern void +void pass1scan( /* process first pass scanline */ - register COLOR *scan, + COLORV *scan, int y ) { double cbrt; - register int x; - register HOTPIX *hp; + int x; + HOTPIX *hp; for (x = 0; x < xres; x++) { - cbrt = (*ourbright)(scan[x]); + cbrt = (*ourbright)(scan+x*NCSAMP); if (cbrt <= 0) continue; @@ -82,10 +73,10 @@ pass1scan( /* process first pass scanline */ progname); quit(1); } - copycolor(hp->val, scan[x]); + scolor_color(hp->val, scan+x*NCSAMP); hp->x = x; hp->y = y; - hp->slope = tan(PI*(0.5-(random()%npts+0.5)/npts)); + hp->slope = ttan(PI*(0.5-(irandom(npts)+0.5)/npts)); hp->next = head; head = hp; } @@ -93,7 +84,7 @@ pass1scan( /* process first pass scanline */ } -extern void +void pass2init(void) /* prepare for final pass */ { if (!npix) { @@ -105,20 +96,20 @@ pass2init(void) /* prepare for final pass */ scalecolor(exposure, AVGLVL/avgbrt); - sprdfact = spread / (hotlvl * (*ourbright)(exposure)) + sprdfact = spread / (hotlvl * bright(exposure)) * ((double)xres*xres + (double)yres*yres) / 4.0; } -extern void +void pass2scan( /* process final pass scanline */ - register COLOR *scan, + COLORV *scan, int y ) { int xmin, xmax; - register int x; - register HOTPIX *hp; + int x; + HOTPIX *hp; for (hp = head; hp != NULL; hp = hp->next) { if (hp->slope > FTINY) { @@ -139,19 +130,19 @@ pass2scan( /* process final pass scanline */ if (xmax >= xres) xmax = xres-1; for (x = xmin; x <= xmax; x++) - starpoint(scan[x], x, y, hp); + starpoint(scan+x*NCSAMP, x, y, hp); } for (x = 0; x < xres; x++) - multcolor(scan[x], exposure); + smultcolor(scan+x*NCSAMP, exposure); } static void starpoint( /* pixel is on the star's point */ - COLOR fcol, + SCOLOR fcol, int x, int y, - register HOTPIX *hp + HOTPIX *hp ) { COLOR ctmp; @@ -164,8 +155,8 @@ starpoint( /* pixel is on the star's point */ return; copycolor(ctmp, hp->val); scalecolor(ctmp, d2); - addcolor(fcol, ctmp); + saddcolor(fcol, ctmp); } else if (d2 > FTINY) { - addcolor(fcol, hp->val); + saddcolor(fcol, hp->val); } }