1 |
/* RCSid $Id: normcodec.h,v 2.2 2019/07/26 17:04:12 greg Exp $ */ |
2 |
/* |
3 |
* Definitions and declarations for 32-bit vector normal encode/decode |
4 |
* |
5 |
* Include after stdio.h and fvect.h |
6 |
* Includes resolu.h |
7 |
*/ |
8 |
|
9 |
#ifndef _RAD_NORMALCODEC_H_ |
10 |
#define _RAD_NORMALCODEC_H_ |
11 |
|
12 |
#include "resolu.h" |
13 |
|
14 |
#ifdef __cplusplus |
15 |
extern "C" { |
16 |
#endif |
17 |
|
18 |
#define NORMAL32FMT "32-bit_encoded_normal" |
19 |
|
20 |
#define HF_HEADIN 0x1 /* expect input header */ |
21 |
#define HF_HEADOUT 0x2 /* write header to stdout */ |
22 |
#define HF_RESIN 0x4 /* expect resolution string */ |
23 |
#define HF_RESOUT 0x8 /* write resolution to stdout */ |
24 |
#define HF_STDERR 0x10 /* report errors to stderr */ |
25 |
#define HF_ALL 0x1f /* all flags above */ |
26 |
#define HF_ENCODE 0x20 /* we are encoding */ |
27 |
|
28 |
/* Structure for encoding/decoding normals */ |
29 |
typedef struct { |
30 |
FILE *finp; /* input stream */ |
31 |
const char *inpname; /* input name */ |
32 |
short format; /* decoded format */ |
33 |
short swapped; /* byte-swapped input */ |
34 |
long dstart; /* start of data */ |
35 |
long curpos; /* current input position */ |
36 |
int hdrflags; /* header i/o flags */ |
37 |
char inpfmt[MAXFMTLEN]; /* format from header */ |
38 |
RESOLU res; /* input resolution */ |
39 |
} NORMCODEC; |
40 |
|
41 |
/* Set codec defaults */ |
42 |
extern void set_nc_defaults(NORMCODEC *ncp); |
43 |
|
44 |
/* Load/copy header */ |
45 |
extern int process_nc_header(NORMCODEC *ncp, int ac, char *av[]); |
46 |
|
47 |
/* Check that we have what we need to decode normals */ |
48 |
extern int check_decode_normals(NORMCODEC *ncp); |
49 |
|
50 |
/* Decode next normal from input */ |
51 |
extern int decode_normal_next(FVECT nrm, NORMCODEC *ncp); |
52 |
|
53 |
/* Seek to the indicated pixel position */ |
54 |
extern int seek_nc_pix(NORMCODEC *ncp, int x, int y); |
55 |
|
56 |
/* Read and decode normal for the given pixel */ |
57 |
extern int decode_normal_pix(FVECT nrm, NORMCODEC *ncp, int x, int y); |
58 |
|
59 |
extern char *progname; /* global argv[0] (set by main) */ |
60 |
|
61 |
#ifdef __cplusplus |
62 |
} |
63 |
#endif |
64 |
#endif /* _RAD_NORMALCODEC_H_ */ |