1 |
– |
/* Copyright (c) 1996 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 |
|
* pfilt.c - program to post-process picture file. |
6 |
|
* |
8 |
|
* 6/23/93 Added additional buffers for value spreading |
9 |
|
*/ |
10 |
|
|
11 |
< |
#include "standard.h" |
11 |
> |
#include "copyright.h" |
12 |
|
|
13 |
|
#include <signal.h> |
14 |
+ |
#include <string.h> |
15 |
|
|
16 |
+ |
#include "platform.h" |
17 |
+ |
#include "standard.h" |
18 |
+ |
#include "rtio.h" |
19 |
|
#include "color.h" |
19 |
– |
|
20 |
|
#include "view.h" |
21 |
– |
|
22 |
– |
#include "resolu.h" |
23 |
– |
|
21 |
|
#include "paths.h" |
22 |
+ |
#include "pfilt.h" |
23 |
|
|
26 |
– |
extern float *matchlamp(); |
24 |
|
|
25 |
|
#define FEQ(a,b) ((a) >= .98*(b) && (a) <= 1.02*(b)) |
26 |
|
|
27 |
< |
double CHECKRAD = 1.5; /* radius to check for filtering */ |
27 |
> |
double CHECKRAD = 2.0; /* radius to check for filtering */ |
28 |
|
|
29 |
|
#define THRESHRAD 5.0 /* maximum sample spread in output */ |
30 |
|
|
84 |
|
|
85 |
|
char *progname; |
86 |
|
|
87 |
+ |
static gethfunc headline; |
88 |
+ |
static double rgb_bright(COLOR clr); |
89 |
+ |
static double xyz_bright(COLOR clr); |
90 |
+ |
static void copyfile(FILE *in, FILE *out); |
91 |
+ |
static void pass1(FILE *in); |
92 |
+ |
static void pass2(FILE *in); |
93 |
+ |
static void scan2init(void); |
94 |
+ |
static void scan2sync(int r); |
95 |
+ |
static void scan2flush(void); |
96 |
|
|
97 |
< |
main(argc, argv) |
98 |
< |
int argc; |
99 |
< |
char **argv; |
97 |
> |
|
98 |
> |
int |
99 |
> |
main( |
100 |
> |
int argc, |
101 |
> |
char **argv |
102 |
> |
) |
103 |
|
{ |
95 |
– |
extern long ftell(); |
96 |
– |
extern int quit(), headline(); |
104 |
|
FILE *fin; |
105 |
|
float *lampcolor; |
106 |
|
char *lamptype = NULL; |
108 |
|
double outaspect = 0.0; |
109 |
|
double d; |
110 |
|
int i, j; |
111 |
< |
#ifdef MSDOS |
112 |
< |
extern int _fmode; |
113 |
< |
_fmode = O_BINARY; |
107 |
< |
setmode(fileno(stdin), O_BINARY); |
108 |
< |
setmode(fileno(stdout), O_BINARY); |
109 |
< |
#endif |
111 |
> |
SET_DEFAULT_BINARY(); |
112 |
> |
SET_FILE_BINARY(stdin); |
113 |
> |
SET_FILE_BINARY(stdout); |
114 |
|
if (signal(SIGINT, quit) == SIG_IGN) |
115 |
|
signal(SIGINT, SIG_IGN); |
116 |
+ |
#ifdef SIGHUP |
117 |
|
if (signal(SIGHUP, quit) == SIG_IGN) |
118 |
|
signal(SIGHUP, SIG_IGN); |
119 |
+ |
#endif |
120 |
|
signal(SIGTERM, quit); |
121 |
+ |
#ifdef SIGPIPE |
122 |
|
signal(SIGPIPE, quit); |
123 |
+ |
#endif |
124 |
|
#ifdef SIGXCPU |
125 |
|
signal(SIGXCPU, quit); |
126 |
|
signal(SIGXFSZ, quit); |
213 |
|
case 'm': |
214 |
|
thresh = atof(argv[++i]); |
215 |
|
if (rad <= FTINY) |
216 |
< |
rad = 1.0; |
216 |
> |
rad = 0.6; |
217 |
|
break; |
218 |
|
case 'b': |
219 |
|
rad = thresh = 0.0; |
318 |
|
pass2(fin); |
319 |
|
|
320 |
|
quit(estatus); |
321 |
+ |
return estatus; /* pro forma return */ |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
< |
double |
326 |
< |
rgb_bright(clr) |
327 |
< |
COLOR clr; |
325 |
> |
static double |
326 |
> |
rgb_bright( |
327 |
> |
COLOR clr |
328 |
> |
) |
329 |
|
{ |
330 |
|
return(bright(clr)); |
331 |
|
} |
332 |
|
|
333 |
|
|
334 |
< |
double |
335 |
< |
xyz_bright(clr) |
336 |
< |
COLOR clr; |
334 |
> |
static double |
335 |
> |
xyz_bright( |
336 |
> |
COLOR clr |
337 |
> |
) |
338 |
|
{ |
339 |
|
return(clr[CIEY]); |
340 |
|
} |
343 |
|
double (*ourbright)() = rgb_bright; |
344 |
|
|
345 |
|
|
346 |
< |
int |
347 |
< |
headline(s) /* process line from header */ |
348 |
< |
char *s; |
346 |
> |
static int |
347 |
> |
headline( /* process line from header */ |
348 |
> |
char *s, |
349 |
> |
void *p |
350 |
> |
) |
351 |
|
{ |
352 |
|
char fmt[32]; |
353 |
|
|
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
< |
copyfile(in, out) /* copy a file */ |
374 |
< |
register FILE *in, *out; |
373 |
> |
static void |
374 |
> |
copyfile( /* copy a file */ |
375 |
> |
register FILE *in, |
376 |
> |
register FILE *out |
377 |
> |
) |
378 |
|
{ |
379 |
|
register int c; |
380 |
|
|
388 |
|
} |
389 |
|
|
390 |
|
|
391 |
< |
pass1(in) /* first pass of picture file */ |
392 |
< |
FILE *in; |
391 |
> |
static void |
392 |
> |
pass1( /* first pass of picture file */ |
393 |
> |
FILE *in |
394 |
> |
) |
395 |
|
{ |
396 |
|
int i; |
397 |
|
COLOR *scan; |
419 |
|
} |
420 |
|
pass1scan(scan, i); |
421 |
|
} |
422 |
< |
free((char *)scan); |
422 |
> |
free((void *)scan); |
423 |
|
} |
424 |
|
|
425 |
|
|
426 |
< |
pass2(in) /* last pass on file, write to stdout */ |
427 |
< |
FILE *in; |
426 |
> |
static void |
427 |
> |
pass2( /* last pass on file, write to stdout */ |
428 |
> |
FILE *in |
429 |
> |
) |
430 |
|
{ |
431 |
|
int yread; |
432 |
|
int ycent, xcent; |
476 |
|
} |
477 |
|
|
478 |
|
|
479 |
< |
scan2init() /* prepare scanline arrays */ |
479 |
> |
static void |
480 |
> |
scan2init(void) /* prepare scanline arrays */ |
481 |
|
{ |
482 |
|
COLOR ctmp; |
483 |
|
double d; |
515 |
|
if (obarsize > 0) { |
516 |
|
scoutbar = (COLOR **)malloc(obarsize*sizeof(COLOR *)); |
517 |
|
greybar = (float **)malloc(obarsize*sizeof(float *)); |
518 |
< |
if (scoutbar == NULL | greybar == NULL) |
518 |
> |
if ((scoutbar == NULL) | (greybar == NULL)) |
519 |
|
goto memerr; |
520 |
|
for (i = 0; i < obarsize; i++) { |
521 |
|
scoutbar[i] = (COLOR *)malloc(ncols*sizeof(COLOR)); |
522 |
|
greybar[i] = (float *)malloc(ncols*sizeof(float)); |
523 |
< |
if (scoutbar[i] == NULL | greybar[i] == NULL) |
523 |
> |
if ((scoutbar[i] == NULL) | (greybar[i] == NULL)) |
524 |
|
goto memerr; |
525 |
|
} |
526 |
|
} else { |
554 |
|
} |
555 |
|
|
556 |
|
|
557 |
< |
scan2sync(r) /* synchronize grey averages and output scan */ |
558 |
< |
int r; |
557 |
> |
static void |
558 |
> |
scan2sync( /* synchronize grey averages and output scan */ |
559 |
> |
int r |
560 |
> |
) |
561 |
|
{ |
562 |
|
static int nextrow = 0; |
563 |
|
COLOR ctmp; |
571 |
|
greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); |
572 |
|
} |
573 |
|
/* and zero output scanline */ |
574 |
< |
bzero((char *)scoutbar[nextrow%obarsize], ncols*sizeof(COLOR)); |
574 |
> |
memset((char *)scoutbar[nextrow%obarsize], '\0', ncols*sizeof(COLOR)); |
575 |
|
nextrow++; |
576 |
|
} |
577 |
|
/* point to top scanline for output */ |
582 |
|
} |
583 |
|
|
584 |
|
|
585 |
< |
scan2flush() /* flush output buffer */ |
585 |
> |
static void |
586 |
> |
scan2flush(void) /* flush output buffer */ |
587 |
|
{ |
588 |
|
register int r; |
589 |
|
|
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
+ |
void |
601 |
|
quit(code) /* remove temporary file and exit */ |
602 |
|
int code; |
603 |
|
{ |