| 1 |
/* RCSid $Id: normcodec.h,v 2.4 2019/11/07 23:20:28 greg Exp $ */ |
| 2 |
/* |
| 3 |
* Definitions and declarations for 32-bit vector normal encode/decode |
| 4 |
* |
| 5 |
* Include after rtio.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 |
short hdrflags; /* header i/o flags */ |
| 36 |
char inpfmt[MAXFMTLEN]; /* format from header */ |
| 37 |
RESOLU res; /* input resolution */ |
| 38 |
} NORMCODEC; |
| 39 |
|
| 40 |
/* Set codec defaults */ |
| 41 |
extern void set_nc_defaults(NORMCODEC *ncp); |
| 42 |
|
| 43 |
/* Load/copy header */ |
| 44 |
extern int process_nc_header(NORMCODEC *ncp, int ac, char *av[]); |
| 45 |
|
| 46 |
/* Check that we have what we need to decode normals */ |
| 47 |
extern int check_decode_normals(NORMCODEC *ncp); |
| 48 |
|
| 49 |
/* Decode next normal from input */ |
| 50 |
extern int decode_normal_next(FVECT nrm, NORMCODEC *ncp); |
| 51 |
|
| 52 |
/* Seek to the indicated pixel position */ |
| 53 |
extern int seek_nc_pix(NORMCODEC *ncp, int x, int y); |
| 54 |
|
| 55 |
/* Read and decode normal for the given pixel */ |
| 56 |
extern int decode_normal_pix(FVECT nrm, NORMCODEC *ncp, int x, int y); |
| 57 |
|
| 58 |
extern char *progname; /* global argv[0] (set by main) */ |
| 59 |
|
| 60 |
#ifdef __cplusplus |
| 61 |
} |
| 62 |
#endif |
| 63 |
#endif /* _RAD_NORMALCODEC_H_ */ |