ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/depthcodec.h
Revision: 2.1
Committed: Thu Jul 18 18:51:56 2019 UTC (4 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Created rcode_depth utility to encode/decode 16-bit depth maps

File Contents

# User Rev Content
1 greg 2.1 /* RCSid $Id$ */
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     extern short depth2code(double d, double dref);
47    
48     /* Decode depth from 16-bit signed integer */
49     extern double code2depth(short c, double dref);
50    
51     /* Set codec defaults */
52     extern void set_dc_defaults(DEPTHCODEC *dcp);
53    
54     /* Load/copy header */
55     extern int process_dc_header(DEPTHCODEC *dcp, int ac, char *av[]);
56    
57     /* Check that we have what we need to decode depths */
58     extern int check_decode_depths(DEPTHCODEC *dcp);
59    
60     /* Decode next depth pixel */
61     extern double decode_depth_next(DEPTHCODEC *dcp);
62    
63     /* Seek to the indicated pixel position */
64     extern int seek_dc_pix(DEPTHCODEC *dcp, int x, int y);
65    
66     /* Read and decode depth for the given pixel */
67     extern double decode_depth_pix(DEPTHCODEC *dcp, int x, int y);
68    
69     /* Check that we have what we need to decode world positions */
70     extern int check_decode_worldpos(DEPTHCODEC *dcp);
71    
72     /* Compute world position from depth */
73     extern int compute_worldpos(FVECT wpos, DEPTHCODEC *dcp,
74     int x, int y, double d);
75    
76     /* Decode the next world position */
77     int decode_worldpos_next(FVECT wpos, DEPTHCODEC *dcp);
78    
79     /* Read and decode the world position at the given pixel */
80     extern int get_worldpos_pix(FVECT wpos, DEPTHCODEC *dcp, int x, int y);
81    
82     extern char *progname; /* global argv[0] (set by main) */
83    
84     #ifdef __cplusplus
85     }
86     #endif
87     #endif /* _RAD_DEPTHCODEC_H_ */