ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/depthcodec.h
Revision: 2.2
Committed: Fri Jul 26 17:04:12 2019 UTC (4 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.1: +8 -7 lines
Log Message:
Added control for stderr output

File Contents

# Content
1 /* RCSid $Id: depthcodec.h,v 2.1 2019/07/26 16:18:06 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 /* expect input header */
23 #define HF_HEADOUT 0x2 /* write header to stdout */
24 #define HF_RESIN 0x4 /* expect resolution string */
25 #define HF_RESOUT 0x8 /* write resolution to stdout */
26 #define HF_STDERR 0x10 /* report errors to stderr */
27 #define HF_ALL 0x1f /* all flags above */
28 #define HF_ENCODE 0x20 /* we are encoding */
29
30 /* Structure for encoding/decoding depths and world points */
31 typedef struct {
32 FILE *finp; /* input stream */
33 const char *inpname; /* input name */
34 int format; /* decoded format */
35 long dstart; /* start of data */
36 long curpos; /* current input position */
37 double refdepth; /* reference depth */
38 char depth_unit[32]; /* string including units */
39 int hdrflags; /* header i/o flags */
40 char inpfmt[MAXFMTLEN]; /* format from header */
41 VIEW vw; /* input view parameters */
42 int gotview; /* got input view? */
43 RESOLU res; /* input resolution */
44 } DEPTHCODEC;
45
46 /* Encode depth as 16-bit signed integer */
47 #define depth2code(d, dref) \
48 ( (d) > (dref) ? (int)(32768.001 - 32768.*(dref)/(d))-1 : \
49 (d) > .0 ? (int)(32767.*(d)/(dref) - 32768.) : -32768 )
50
51 /* Decode depth from 16-bit signed integer */
52 extern double code2depth(int c, double dref);
53
54 /* Set codec defaults */
55 extern void set_dc_defaults(DEPTHCODEC *dcp);
56
57 /* Load/copy header */
58 extern int process_dc_header(DEPTHCODEC *dcp, int ac, char *av[]);
59
60 /* Check that we have what we need to decode depths */
61 extern int check_decode_depths(DEPTHCODEC *dcp);
62
63 /* Decode next depth pixel from input */
64 extern double decode_depth_next(DEPTHCODEC *dcp);
65
66 /* Seek to the indicated pixel position */
67 extern int seek_dc_pix(DEPTHCODEC *dcp, int x, int y);
68
69 /* Read and decode depth for the given pixel */
70 extern double decode_depth_pix(DEPTHCODEC *dcp, int x, int y);
71
72 /* Check that we have what we need to decode world positions */
73 extern int check_decode_worldpos(DEPTHCODEC *dcp);
74
75 /* Compute world position from pixel position and depth */
76 extern int compute_worldpos(FVECT wpos, DEPTHCODEC *dcp,
77 int x, int y, double d);
78
79 /* Decode the next world position from input */
80 int decode_worldpos_next(FVECT wpos, DEPTHCODEC *dcp);
81
82 /* Decode depth and compute world position for the given pixel */
83 extern int get_worldpos_pix(FVECT wpos, DEPTHCODEC *dcp, int x, int y);
84
85 extern char *progname; /* global argv[0] (set by main) */
86
87 #ifdef __cplusplus
88 }
89 #endif
90 #endif /* _RAD_DEPTHCODEC_H_ */