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" |
26 |
|
if (d > dref) |
27 |
|
return (int)(32768.001 - 32768.*dref/d) - 1; |
28 |
|
|
29 |
< |
return (int)(32767.*d/dref - 32768.); |
29 |
> |
return (int)(32767.*d/dref - 32768.999); |
30 |
|
} |
31 |
|
#endif |
32 |
|
|
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 >= -1) |
46 |
> |
return dref*32768./(32766.5 - c); |
47 |
> |
|
48 |
> |
return dref*(32768.5 + c)*(1./32767.); |
49 |
|
} |
50 |
|
#endif |
51 |
|
|
58 |
|
dcp->finp = stdin; |
59 |
|
dcp->inpname = "<stdin>"; |
60 |
|
dcp->format = 'a'; |
62 |
– |
dcp->swapped = 0; |
61 |
|
dcp->refdepth = 1.; |
62 |
|
dcp->depth_unit[0] = '1'; |
63 |
|
dcp->vw = stdview; |
97 |
|
} |
98 |
|
return -1; |
99 |
|
} |
100 |
< |
} else if (isview(s)) /* get view params */ |
100 |
> |
if (dcp->hdrflags & HF_ENCODE) |
101 |
> |
return 0; /* will add this later */ |
102 |
> |
} else if (!strncmp(s, "SAMP360=", 8)) |
103 |
> |
dcp->gotview--; |
104 |
> |
else if (isview(s)) /* get view params */ |
105 |
|
dcp->gotview += (sscanview(&dcp->vw, s) > 0); |
106 |
|
if (dcp->hdrflags & HF_HEADOUT) |
107 |
|
fputs(s, stdout); /* copy to standard output */ |
121 |
|
} |
122 |
|
return 0; |
123 |
|
} |
124 |
+ |
dcp->gotview *= (dcp->gotview > 0); |
125 |
|
if (dcp->hdrflags & HF_HEADOUT) { /* finish header */ |
126 |
|
if (!(dcp->hdrflags & HF_HEADIN)) |
127 |
|
newheader("RADIANCE", stdout); |
227 |
|
double |
228 |
|
decode_depth_next(DEPTHCODEC *dcp) |
229 |
|
{ |
230 |
< |
int c = getint(2, dcp->finp); |
230 |
> |
int c; |
231 |
|
|
232 |
+ |
if (dcp->use_last) { |
233 |
+ |
dcp->use_last = 0; |
234 |
+ |
return code2depth(dcp->last_dc, dcp->refdepth); |
235 |
+ |
} |
236 |
+ |
c = getint(2, dcp->finp); |
237 |
+ |
|
238 |
|
if (c == EOF && feof(dcp->finp)) |
239 |
|
return -1.; |
240 |
|
|
241 |
+ |
dcp->last_dc = c; |
242 |
|
dcp->curpos += 2; |
243 |
|
|
244 |
|
return code2depth(c, dcp->refdepth); |
306 |
|
} |
307 |
|
seekpos = dcp->dstart + 2*((long)y*scanlen(&dcp->res) + x); |
308 |
|
|
309 |
+ |
if (seekpos == dcp->curpos-2) { |
310 |
+ |
dcp->use_last++; /* avoids seek/read */ |
311 |
+ |
return 1; |
312 |
+ |
} |
313 |
|
if (seekpos != dcp->curpos && |
314 |
|
fseek(dcp->finp, seekpos, SEEK_SET) == EOF) { |
315 |
|
if (dcp->hdrflags & HF_STDERR) { |
319 |
|
return -1; |
320 |
|
} |
321 |
|
dcp->curpos = seekpos; |
322 |
+ |
dcp->use_last = 0; |
323 |
|
return 1; |
324 |
|
} |
325 |
|
|