ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/depthcodec.h
Revision: 2.4
Committed: Wed Aug 14 21:00:14 2019 UTC (4 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.3: +3 -2 lines
Log Message:
Added byte order to gendaymtx, rsplit, dctimestep, rcode_depth, and rcode_normal

File Contents

# Content
1 /* RCSid $Id: depthcodec.h,v 2.3 2019/07/26 18:52:32 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 short format; /* decoded format */
35 short swapped; /* byte-swapped input */
36 long dstart; /* start of data */
37 long curpos; /* current input position */
38 double refdepth; /* reference depth */
39 char depth_unit[32]; /* string including units */
40 int hdrflags; /* header i/o flags */
41 char inpfmt[MAXFMTLEN]; /* format from header */
42 VIEW vw; /* input view parameters */
43 int gotview; /* got input view? */
44 RESOLU res; /* input resolution */
45 } DEPTHCODEC;
46
47 /* Encode depth as 16-bit signed integer */
48 #if 1
49 #define depth2code(d, dref) \
50 ( (d) > (dref) ? (int)(32768.001 - 32768.*(dref)/(d))-1 : \
51 (d) > .0 ? (int)(32767.*(d)/(dref) - 32768.) : -32768 )
52 #else
53 extern int depth2code(double d, double dref);
54 #endif
55
56 /* Decode depth from 16-bit signed integer */
57 #if 1
58 #define code2depth(c, dref) \
59 ( (c) <= -32768 ? .0 : (c) >= 32767 ? FHUGE : \
60 (c) < 0 ? (dref)*(32767.5 + (c))*(1./32767.) : \
61 (dref)*32768./(32766.5 - (c)) )
62 #else
63 extern double code2depth(int c, double dref);
64 #endif
65
66 /* Set codec defaults */
67 extern void set_dc_defaults(DEPTHCODEC *dcp);
68
69 /* Load/copy header */
70 extern int process_dc_header(DEPTHCODEC *dcp, int ac, char *av[]);
71
72 /* Check that we have what we need to decode depths */
73 extern int check_decode_depths(DEPTHCODEC *dcp);
74
75 /* Decode next depth pixel from input */
76 extern double decode_depth_next(DEPTHCODEC *dcp);
77
78 /* Seek to the indicated pixel position */
79 extern int seek_dc_pix(DEPTHCODEC *dcp, int x, int y);
80
81 /* Read and decode depth for the given pixel */
82 extern double decode_depth_pix(DEPTHCODEC *dcp, int x, int y);
83
84 /* Check that we have what we need to decode world positions */
85 extern int check_decode_worldpos(DEPTHCODEC *dcp);
86
87 /* Compute world position from pixel position and depth */
88 extern int compute_worldpos(FVECT wpos, DEPTHCODEC *dcp,
89 int x, int y, double d);
90
91 /* Decode the next world position from input */
92 int decode_worldpos_next(FVECT wpos, DEPTHCODEC *dcp);
93
94 /* Decode depth and compute world position for the given pixel */
95 extern int get_worldpos_pix(FVECT wpos, DEPTHCODEC *dcp, int x, int y);
96
97 extern char *progname; /* global argv[0] (set by main) */
98
99 #ifdef __cplusplus
100 }
101 #endif
102 #endif /* _RAD_DEPTHCODEC_H_ */