8 |
|
#include "copyright.h" |
9 |
|
|
10 |
|
#include <stdlib.h> |
11 |
– |
#include <string.h> |
11 |
|
#include <math.h> |
12 |
|
#include <ctype.h> |
13 |
|
#include "rtio.h" |
41 |
|
|
42 |
|
if (c >= 32767) |
43 |
|
return FHUGE; |
44 |
< |
|
45 |
< |
if (c < 0) |
46 |
< |
return dref*(32767.5 + c)*(1./32767.); |
47 |
< |
|
48 |
< |
return dref*32768./(32766.5 - c); |
44 |
> |
|
45 |
> |
if (c >= 0) |
46 |
> |
return dref*32768./(32766.5 - c); |
47 |
> |
|
48 |
> |
return dref*(32767.5 + c)*(1./32767.); |
49 |
|
} |
50 |
|
#endif |
51 |
|
|
71 |
|
headline(char *s, void *p) |
72 |
|
{ |
73 |
|
DEPTHCODEC *dcp = (DEPTHCODEC *)p; |
74 |
+ |
int rv; |
75 |
|
|
76 |
|
if (formatval(dcp->inpfmt, s)) /* don't pass format */ |
77 |
|
return 0; |
78 |
+ |
|
79 |
+ |
if ((rv = isbigendian(s)) >= 0) { |
80 |
+ |
dcp->swapped = (nativebigendian() != rv); |
81 |
+ |
return 0; |
82 |
+ |
} |
83 |
|
/* check for reference depth */ |
84 |
|
if (!strncmp(s, DEPTHSTR, LDEPTHSTR)) { |
85 |
|
char *cp; |
97 |
|
} |
98 |
|
return -1; |
99 |
|
} |
100 |
< |
} else if (isview(s)) /* get view params */ |
100 |
> |
} else if (!strncmp(s, "SAMP360=", 8)) |
101 |
> |
dcp->gotview--; |
102 |
> |
else if (isview(s)) /* get view params */ |
103 |
|
dcp->gotview += (sscanview(&dcp->vw, s) > 0); |
104 |
|
if (dcp->hdrflags & HF_HEADOUT) |
105 |
|
fputs(s, stdout); /* copy to standard output */ |
119 |
|
} |
120 |
|
return 0; |
121 |
|
} |
122 |
+ |
dcp->gotview *= (dcp->gotview > 0); |
123 |
|
if (dcp->hdrflags & HF_HEADOUT) { /* finish header */ |
124 |
|
if (!(dcp->hdrflags & HF_HEADIN)) |
125 |
|
newheader("RADIANCE", stdout); |
136 |
|
fputformat("ascii", stdout); |
137 |
|
break; |
138 |
|
case 'f': |
139 |
+ |
fputendian(stdout); |
140 |
|
fputformat("float", stdout); |
141 |
|
break; |
142 |
|
case 'd': |
143 |
+ |
fputendian(stdout); |
144 |
|
fputformat("double", stdout); |
145 |
|
break; |
146 |
|
} |
225 |
|
double |
226 |
|
decode_depth_next(DEPTHCODEC *dcp) |
227 |
|
{ |
228 |
< |
int c = getint(2, dcp->finp); |
228 |
> |
int c; |
229 |
|
|
230 |
+ |
if (dcp->use_last) { |
231 |
+ |
dcp->use_last = 0; |
232 |
+ |
return code2depth(dcp->last_dc, dcp->refdepth); |
233 |
+ |
} |
234 |
+ |
c = getint(2, dcp->finp); |
235 |
+ |
|
236 |
|
if (c == EOF && feof(dcp->finp)) |
237 |
|
return -1.; |
238 |
|
|
239 |
+ |
dcp->last_dc = c; |
240 |
|
dcp->curpos += 2; |
241 |
|
|
242 |
|
return code2depth(c, dcp->refdepth); |
304 |
|
} |
305 |
|
seekpos = dcp->dstart + 2*((long)y*scanlen(&dcp->res) + x); |
306 |
|
|
307 |
+ |
if (seekpos == dcp->curpos-2) { |
308 |
+ |
dcp->use_last++; /* avoids seek/read */ |
309 |
+ |
return 1; |
310 |
+ |
} |
311 |
|
if (seekpos != dcp->curpos && |
312 |
|
fseek(dcp->finp, seekpos, SEEK_SET) == EOF) { |
313 |
|
if (dcp->hdrflags & HF_STDERR) { |