1 |
– |
/* Copyright (c) 1991 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 |
|
* Compute pixels for glare calculation |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
+ |
#include <stdlib.h> |
11 |
+ |
#include <string.h> |
12 |
+ |
|
13 |
+ |
#include "rtprocess.h" /* Windows: must come first because of conflicts */ |
14 |
|
#include "glare.h" |
15 |
< |
#include "resolu.h" |
15 |
> |
|
16 |
|
/* maximum rtrace buffer size */ |
17 |
|
#define MAXPIX (4096/(6*sizeof(float))) |
18 |
|
|
20 |
|
#define HSIZE 317 /* size of scanline hash table */ |
21 |
|
#define NRETIRE 16 /* number of scanlines to retire at once */ |
22 |
|
|
23 |
< |
int rt_pd[3] = {-1,-1,-1}; /* process id & descriptors for rtrace */ |
23 |
> |
static SUBPROC rt_pd = SP_INACTIVE; /* process id & descriptors for rtrace */ |
24 |
|
|
25 |
|
FILE *pictfp = NULL; /* picture file pointer */ |
26 |
|
double exposure; /* picture exposure */ |
189 |
|
npixinvw++; |
190 |
|
if ((res = pict_val(dir)) >= 0.0) |
191 |
|
return(res); |
192 |
< |
if (rt_pd[0] == -1) { |
192 |
> |
if (rt_pd.r == -1) { |
193 |
|
npixmiss++; |
194 |
|
return(-1.0); |
195 |
|
} |
228 |
|
npixinvw++; |
229 |
|
if ((vb[vh+hsize] = pict_val(dir)) >= 0.0) |
230 |
|
continue; |
231 |
< |
if (rt_pd[0] == -1) { /* missing information */ |
231 |
> |
if (rt_pd.r == -1) { /* missing information */ |
232 |
|
npixmiss++; |
233 |
|
continue; |
234 |
|
} |
267 |
|
fprintf(stderr, "%s: sending %d samples to rtrace...\n", |
268 |
|
progname, np); |
269 |
|
#endif |
270 |
< |
bzero(pb+6*np, 6*sizeof(float)); |
271 |
< |
if (process(rt_pd, pb, pb, 3*sizeof(float)*np, |
272 |
< |
6*sizeof(float)*(np+1)) < 3*sizeof(float)*np) { |
270 |
> |
memset(pb+6*np, '\0', 6*sizeof(float)); |
271 |
> |
if (process(&rt_pd, (char *)pb, (char *)pb, 3*sizeof(float)*(np+1), |
272 |
> |
6*sizeof(float)*(np+1)) < 3*sizeof(float)*(np+1)) { |
273 |
|
fprintf(stderr, "%s: rtrace communication error\n", |
274 |
|
progname); |
275 |
|
exit(1); |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
+ |
int |
281 |
|
getexpos(s) /* get exposure from header line */ |
282 |
|
char *s; |
283 |
|
{ |
289 |
|
formatval(fmt, s); |
290 |
|
wrongformat = strcmp(fmt, COLRFMT); |
291 |
|
} |
292 |
+ |
return(0); |
293 |
|
} |
294 |
|
|
295 |
|
|
325 |
|
{ |
326 |
|
int rval; |
327 |
|
|
328 |
< |
rval = open_process(rt_pd, av); |
328 |
> |
rval = open_process(&rt_pd, av); |
329 |
|
if (rval < 0) { |
330 |
|
perror(progname); |
331 |
|
exit(1); |
345 |
|
{ |
346 |
|
int status; |
347 |
|
|
348 |
< |
status = close_process(rt_pd); |
348 |
> |
status = close_process(&rt_pd); |
349 |
|
if (status > 0) { |
350 |
|
fprintf(stderr, "%s: bad status (%d) from rtrace\n", |
351 |
|
progname, status); |
352 |
|
exit(1); |
353 |
|
} |
354 |
< |
rt_pd[0] = -1; |
354 |
> |
rt_pd.r = -1; |
355 |
|
} |
356 |
|
|
357 |
|
|
416 |
|
hashtab[i] = NULL; |
417 |
|
/* allocate scanline buffers */ |
418 |
|
scansize = sizeof(SCAN) + pxsiz*sizeof(COLR); |
419 |
< |
#ifdef ALIGN |
420 |
< |
scansize = scansize+(sizeof(ALIGN)-1) & ~(sizeof(ALIGN)-1); |
419 |
> |
#ifdef ALIGNT |
420 |
> |
scansize = scansize+(sizeof(ALIGNT)-1) & ~(sizeof(ALIGNT)-1); |
421 |
|
#endif |
422 |
|
i = MAXSBUF / scansize; /* compute number to allocate */ |
423 |
|
if (i > HSIZE) |