18 |
|
char *progname = "depth_codec"; |
19 |
|
|
20 |
|
|
21 |
+ |
#if 0 /* defined as macro in depthcodec.h */ |
22 |
|
/* Encode depth as 16-bit signed integer */ |
23 |
< |
short |
23 |
> |
int |
24 |
|
depth2code(double d, double dref) |
25 |
|
{ |
26 |
|
if (d <= .0) |
27 |
|
return -32768; |
28 |
|
|
29 |
|
if (d > dref) |
30 |
< |
return 32767 - 32768*dref/d; |
30 |
> |
return (int)(32768 - 32768*dref/d) - 1; |
31 |
|
|
32 |
< |
return 32767*d/dref - 32768; |
32 |
> |
return (int)(32767*d/dref - 32768); |
33 |
|
} |
34 |
+ |
#endif |
35 |
|
|
36 |
|
|
37 |
|
/* Decode depth from 16-bit signed integer */ |
38 |
|
double |
39 |
< |
code2depth(short c, double dref) |
39 |
> |
code2depth(int c, double dref) |
40 |
|
{ |
41 |
< |
if (c < 0) |
42 |
< |
return dref*(32768 + c)*(1./32767.); |
43 |
< |
|
44 |
< |
if (c == 32767) |
41 |
> |
if (c <= -32768) |
42 |
> |
return .0; |
43 |
> |
|
44 |
> |
if (c >= 32767) |
45 |
|
return FHUGE; |
46 |
+ |
|
47 |
+ |
if (c < 0) |
48 |
+ |
return dref*(32767.5 + c)*(1./32767.); |
49 |
|
|
50 |
< |
return dref*32768./(32767 - c); |
50 |
> |
return dref*32768./(32766.5 - c); |
51 |
|
} |
52 |
|
|
53 |
|
|