1 |
/* RCSid $Id: depthcodec.h,v 2.3 2019/07/19 00:01:49 greg Exp $ */ |
2 |
/* |
3 |
* Definitions and declarations for 16-bit depth encode/decode |
4 |
* |
5 |
* Include after stdio.h and fvect.h |
6 |
* Includes view.h |
7 |
*/ |
8 |
|
9 |
#ifndef _RAD_DEPTHCODEC_H_ |
10 |
#define _RAD_DEPTHCODEC_H_ |
11 |
|
12 |
#include "view.h" |
13 |
|
14 |
#ifdef __cplusplus |
15 |
extern "C" { |
16 |
#endif |
17 |
|
18 |
#define DEPTHSTR "REFDEPTH=" |
19 |
#define LDEPTHSTR 9 |
20 |
#define DEPTH16FMT "16-bit_encoded_depth" |
21 |
|
22 |
#define HF_HEADIN 0x1 |
23 |
#define HF_HEADOUT 0x2 |
24 |
#define HF_RESIN 0x4 |
25 |
#define HF_RESOUT 0x8 |
26 |
#define HF_ALL 0xf |
27 |
#define HF_ENCODE 0x10 |
28 |
|
29 |
/* Structure for encoding/decoding depths and world points */ |
30 |
typedef struct { |
31 |
FILE *finp; /* input stream */ |
32 |
const char *inpname; /* input name */ |
33 |
int format; /* decoded format */ |
34 |
long dstart; /* start of data */ |
35 |
long curpos; /* current input position */ |
36 |
double refdepth; /* reference depth */ |
37 |
char depth_unit[32]; /* string including units */ |
38 |
int hdrflags; /* header i/o flags */ |
39 |
char inpfmt[MAXFMTLEN]; /* format from header */ |
40 |
VIEW vw; /* input view parameters */ |
41 |
int gotview; /* got input view? */ |
42 |
RESOLU res; /* input resolution */ |
43 |
} DEPTHCODEC; |
44 |
|
45 |
/* Encode depth as 16-bit signed integer */ |
46 |
#define depth2code(d, dref) \ |
47 |
( (d) > (dref) ? (int)(32768.001 - 32768.*(dref)/(d))-1 : \ |
48 |
(d) > .0 ? (int)(32767.*(d)/(dref) - 32768.) : -32768 ) |
49 |
|
50 |
/* Decode depth from 16-bit signed integer */ |
51 |
extern double code2depth(int c, double dref); |
52 |
|
53 |
/* Set codec defaults */ |
54 |
extern void set_dc_defaults(DEPTHCODEC *dcp); |
55 |
|
56 |
/* Load/copy header */ |
57 |
extern int process_dc_header(DEPTHCODEC *dcp, int ac, char *av[]); |
58 |
|
59 |
/* Check that we have what we need to decode depths */ |
60 |
extern int check_decode_depths(DEPTHCODEC *dcp); |
61 |
|
62 |
/* Decode next depth pixel from input */ |
63 |
extern double decode_depth_next(DEPTHCODEC *dcp); |
64 |
|
65 |
/* Seek to the indicated pixel position */ |
66 |
extern int seek_dc_pix(DEPTHCODEC *dcp, int x, int y); |
67 |
|
68 |
/* Read and decode depth for the given pixel */ |
69 |
extern double decode_depth_pix(DEPTHCODEC *dcp, int x, int y); |
70 |
|
71 |
/* Check that we have what we need to decode world positions */ |
72 |
extern int check_decode_worldpos(DEPTHCODEC *dcp); |
73 |
|
74 |
/* Compute world position from pixel position and depth */ |
75 |
extern int compute_worldpos(FVECT wpos, DEPTHCODEC *dcp, |
76 |
int x, int y, double d); |
77 |
|
78 |
/* Decode the next world position from input */ |
79 |
int decode_worldpos_next(FVECT wpos, DEPTHCODEC *dcp); |
80 |
|
81 |
/* Decode depth and compute world position for the given pixel */ |
82 |
extern int get_worldpos_pix(FVECT wpos, DEPTHCODEC *dcp, int x, int y); |
83 |
|
84 |
extern char *progname; /* global argv[0] (set by main) */ |
85 |
|
86 |
#ifdef __cplusplus |
87 |
} |
88 |
#endif |
89 |
#endif /* _RAD_DEPTHCODEC_H_ */ |