9#define XDR_DOUBLE_LENGTH 8
10#define XDR_DOUBLE_NOF_EXP_BYTES 2
11#define XDR_FLOAT_LENGTH 4
12#define XDR_FLOAT_NOF_EXP_BYTES 1
24 printf(
"%d", (*((
unsigned char *)c) &
bit) != 0);
51static unsigned char clearMask[9] = {255, 128, 192, 224, 240,
56#define ALL_NULL_CODE 2
57#define ZERO_NULL_CODE 1
58#define SOME_NULL_CODE 0
62static void G_fpcompress_rearrangeEncodeFloats(
unsigned char *src,
int size,
64 unsigned char *dst,
int *length,
68 register unsigned char *
srcStop;
70 unsigned char mask, isNull;
76 if ((precision >= 23) || (precision == -1)) {
96 while (
srcStop != (
unsigned char *)f)
112 gt16 = precision > 16;
127 mask = clearMask[precision];
161 if (
nBits && precision) {
166 if (8 -
nBits < (
unsigned int)precision) {
171 *
cp1 = (
unsigned char)((
unsigned char)((*src &
mask))
173 nBits += precision - 8;
195 *length += size / 8 + ((size % 8) != 0);
198 *length += (
gt8 +
gt16 + (precision == 0) + 1) * (size -
nofNull) +
199 ((precision * (size -
nofNull)) / 8) +
200 (((precision * (size -
nofNull)) % 8) != 0);
207static void G_fpcompress_rearrangeEncodeDoubles(
unsigned char *src,
int size,
209 unsigned char *dst,
int *length,
213 unsigned char isNull;
214 register unsigned char *
srcStop;
223 if ((precision >= 52) || (precision == -1)) {
254 while (
srcStop != (
unsigned char *)d)
268 gt48 = precision > 48;
269 gt40 = precision > 40;
270 gt32 = precision > 32;
271 gt24 = precision > 24;
272 gt16 = precision > 16;
291 mask = clearMask[precision];
338 if (
nBits && precision) {
340 if (8 -
nBits < (
unsigned int)precision) {
342 *
cp1 = (
unsigned char)(((
unsigned char)(*src &
mask))
344 nBits += precision - 8;
365 *length += size / 8 + ((size % 8) != 0);
369 ((precision * (size -
nofNull)) / 8) +
370 (((precision * (size -
nofNull)) % 8) != 0);
380static void G_fpcompress_rearrangeDecodeFloats(
unsigned char *src,
int size,
385 register unsigned char *
dstStop;
387 unsigned char mask, isNull;
391 if ((precision != -1) && (precision <= 15)) {
399 if (precision <= 7) {
411 if ((precision >= 23) || (precision == -1)) {
428 while (
dstStop != (
unsigned char *)f)
436 gt16 = precision > 16;
448 while (
fStop != f++) {
466 mask = clearMask[precision];
491 if (
nBits && precision) {
494 if (8 -
nBits < (
unsigned int)precision) {
497 nBits += precision - 8;
518static void G_fpcompress_rearrangeDecodeDoubles(
unsigned char *src,
int size,
523 register unsigned char *
dstStop;
526 unsigned char mask, isNull;
530 if ((precision != -1) && (precision <= 44)) {
543 if ((precision >= 52) || (precision == -1)) {
570 while (
dstStop != (
unsigned char *)d)
578 gt48 = precision > 48;
579 gt40 = precision > 40;
580 gt32 = precision > 32;
581 gt24 = precision > 24;
582 gt16 = precision > 16;
595 while (
dStop != d++) {
617 mask = clearMask[precision];
658 if (
nBits && precision) {
661 if (8 -
nBits < (
unsigned int)precision) {
664 nBits += precision - 8;
694 G_fpcompress_rearrangeEncodeFloats(
695 (
unsigned char *)src,
nofNum, precision,
698 G_fpcompress_rearrangeEncodeDoubles(
699 (
unsigned char *)src,
nofNum, precision,
707 Rast3d_error(
"Rast3d_fpcompress_write_xdr_nums: write error");
731 Rast3d_error(
"Rast3d_fpcompress_read_xdr_nums: read error");
761 precision, (
unsigned char *)dst);
763 G_fpcompress_rearrangeDecodeDoubles((
unsigned char *)
compressBuf,
765 (
unsigned char *)dst);
int G_read_compressed(int, int, unsigned char *, int, int)
int G_write_compressed(int, unsigned char *, int, int)
int Rast3d_is_xdr_null_double(const double *)
void Rast3d_set_xdr_null_double(double *)
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_is_xdr_null_float(const float *)
void Rast3d_set_xdr_null_float(float *)
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
void Rast3d_rle_decode(char *, char *, int, int, int *, int *)
dglInt32_t sign(dglInt32_t x)
int Rast3d_fpcompress_read_xdr_nums(int fd, char *dst, int nofNum, int fileBytes, int precision, char *compressBuf, int isFloat)
int Rast3d_fpcompress_write_xdr_nums(int fd, char *src, int nofNum, int precision, char *compressBuf, int isFloat)
#define XDR_DOUBLE_LENGTH
void Rast3d_fpcompress_print_binary(char *c, int numBits)
void Rast3d_fpcompress_dissect_xdr_double(unsigned char *numPointer)