GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-3f124c5c78
fpcompress.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <sys/types.h>
4 #include <unistd.h>
5 #include "raster3d_intern.h"
6 
7 /*--------------------------------------------------------------------------*/
8 
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
13 
14 /*--------------------------------------------------------------------------*/
15 
16 void Rast3d_fpcompress_print_binary(char *c, int numBits)
17 {
18  unsigned char bit;
19  int i;
20 
21  bit = 1 << (numBits - 1);
22 
23  for (i = 0; i < numBits; i++) {
24  printf("%d", (*((unsigned char *)c) & bit) != 0);
25  bit >>= 1;
26  }
27 }
28 
29 /*--------------------------------------------------------------------------*/
30 
31 void Rast3d_fpcompress_dissect_xdr_double(unsigned char *numPointer)
32 {
33  char sign, exponent;
34 
35  sign = *numPointer >> 7;
36  exponent = (*numPointer << 1) | (*(numPointer + 1) >> 7);
37 
38  printf("%f: sign = ", *((float *)numPointer));
40  printf(" exp = ");
41  Rast3d_fpcompress_print_binary(&exponent, 8);
42  printf(" mantissa = ");
43  Rast3d_fpcompress_print_binary((char *)(numPointer + 1), 7);
44  Rast3d_fpcompress_print_binary((char *)(numPointer + 2), 8);
45  Rast3d_fpcompress_print_binary((char *)(numPointer + 3), 8);
46  printf("\n");
47 }
48 
49 /*--------------------------------------------------------------------------*/
50 
51 static unsigned char clearMask[9] = {255, 128, 192, 224, 240,
52  248, 252, 254, 255};
53 
54 /*--------------------------------------------------------------------------*/
55 
56 #define ALL_NULL_CODE 2
57 #define ZERO_NULL_CODE 1
58 #define SOME_NULL_CODE 0
59 
60 /*--------------------------------------------------------------------------*/
61 
62 static void G_fpcompress_rearrangeEncodeFloats(unsigned char *src, int size,
63  int precision,
64  unsigned char *dst, int *length,
65  int *offsetMantissa)
66 {
67  unsigned int nNullBits, nBits;
68  register unsigned char *srcStop;
69  register unsigned char *cp0, *cp1, *cp2, *cp3, *nullBits;
70  unsigned char mask, isNull;
71  int gt8, gt16, srcIncrement, nofNull;
72  float *f;
73 
74  srcStop = src + size * XDR_FLOAT_LENGTH;
75 
76  if ((precision >= 23) || (precision == -1)) {
77  cp3 = dst;
78  cp2 = cp3 + size;
79  cp1 = cp2 + size;
80  cp0 = cp1 + size;
81  while (srcStop != src) {
82  *cp3++ = *src++; /* sign + 7 exponent bits */
83  *cp2++ = *src++; /* 1 exponent bit + 7 ms mantissa bits */
84  *cp1++ = *src++; /* 8 mantissa bits */
85  *cp0++ = *src++; /* 8 ls mantissa bits */
86  }
87 
88  *length = size * XDR_FLOAT_LENGTH;
89  *offsetMantissa = size;
90 
91  return;
92  }
93 
94  f = (float *)src;
95  nofNull = 0;
96  while (srcStop != (unsigned char *)f)
97  nofNull += Rast3d_is_xdr_null_float(f++);
98 
99  if (nofNull == size) {
100  *dst = (unsigned char)ALL_NULL_CODE;
101 
102  *length = 1;
103  *offsetMantissa = 1;
104 
105  return;
106  }
107 
108  precision += 1; /* treat the ls exponent bit like an addl mantissa bit */
109 
110  *dst = (unsigned char)(nofNull == 0 ? ZERO_NULL_CODE : SOME_NULL_CODE);
111 
112  gt16 = precision > 16;
113  gt8 = precision > 8;
114  srcIncrement = 1 + (!gt8) + (!gt16);
115 
116  precision %= 8;
117 
118  nullBits = dst + 1;
119  if (nofNull)
120  cp0 = nullBits + size / 8 + ((size % 8) != 0);
121  else
122  cp0 = nullBits;
123  cp3 = cp0 + size - nofNull;
124  cp2 = cp3 + size - nofNull;
125  cp1 = cp3 + (gt8 + gt16) * (size - nofNull);
126 
127  mask = clearMask[precision];
128  nBits = nNullBits = 0;
129 
130  while (srcStop != src) {
131  if (nofNull) {
132  isNull = Rast3d_is_xdr_null_float((float *)src);
133 
134  if (nNullBits) {
135  *nullBits |= ((unsigned char)isNull << nNullBits++);
136  if (nNullBits == 8) {
137  nullBits++;
138  nNullBits = 0;
139  }
140  }
141  else {
142  *nullBits = (unsigned char)isNull;
143  nNullBits++;
144  }
145 
146  if (isNull) {
147  src += XDR_FLOAT_LENGTH;
148  continue;
149  }
150  }
151 
152  /* printf ("write src cp0 %d %d (%d %d) %d\n", *src, *cp0, src, cp0,
153  * nullBits); */
154 
155  *cp0++ = *src++;
156  if (gt8)
157  *cp3++ = *src++;
158  if (gt16)
159  *cp2++ = *src++;
160 
161  if (nBits && precision) {
162  *cp1 |= (unsigned char)((unsigned char)(*src & mask) >> nBits);
163 
164  /*printf ("%d\n", ((*src & mask) >> nBits) << nBits); */
165 
166  if (8 - nBits < (unsigned int)precision) {
167  cp1++;
168 
169  /*printf ("%d %d\n", *cp1, (*src & mask) << (8 - nBits)); */
170 
171  *cp1 = (unsigned char)((unsigned char)((*src & mask))
172  << (8 - nBits));
173  nBits += precision - 8;
174  }
175  else {
176  nBits = (nBits + precision) % 8;
177  if (!nBits)
178  cp1++;
179  }
180  }
181  else {
182  *cp1 = (unsigned char)(*src & mask);
183  /* printf ("%d %d %d\n", *cp1, *src, nBits); */
184  nBits = (nBits + precision) % 8;
185  if (!nBits)
186  cp1++;
187  }
188 
189  src += srcIncrement;
190  }
191 
192  *length = 1; /* null-bit-vector indicator-byte */
193 
194  if (nofNull) /* length of null-bit-vector */
195  *length += size / 8 + ((size % 8) != 0);
196 
197  /* length of data */
198  *length += (gt8 + gt16 + (precision == 0) + 1) * (size - nofNull) +
199  ((precision * (size - nofNull)) / 8) +
200  (((precision * (size - nofNull)) % 8) != 0);
201 
202  *offsetMantissa = size - nofNull;
203 }
204 
205 /*--------------------------------------------------------------------------*/
206 
207 static void G_fpcompress_rearrangeEncodeDoubles(unsigned char *src, int size,
208  int precision,
209  unsigned char *dst, int *length,
210  int *offsetMantissa)
211 {
212  unsigned int nNullBits, nBits;
213  unsigned char isNull;
214  register unsigned char *srcStop;
215  register unsigned char *cp0, *cp1, *cp2, *cp3;
216  register unsigned char *cp4, *cp5, *cp6, *cp7, *nullBits;
217  unsigned char mask;
218  int gt8, gt16, gt24, gt32, gt40, gt48, srcIncrement, nofNull;
219  double *d;
220 
221  srcStop = src + size * XDR_DOUBLE_LENGTH;
222 
223  if ((precision >= 52) || (precision == -1)) {
224  cp7 = dst;
225  cp6 = cp7 + size;
226  cp5 = cp6 + size;
227  cp4 = cp5 + size;
228  cp3 = cp4 + size;
229  cp2 = cp3 + size;
230  cp1 = cp2 + size;
231  cp0 = cp1 + size;
232 
233  while (srcStop != src) {
234  *cp7++ = *src++; /* sign + 7 ms exponent bits */
235  *cp6++ = *src++; /* 4 exponent bits + 4 ms mantissa bits */
236  *cp5++ = *src++; /* 8 mantissa bits */
237  *cp4++ = *src++;
238  *cp3++ = *src++;
239  *cp2++ = *src++;
240  *cp1++ = *src++;
241  *cp0++ = *src++; /* 8 ls mantissa bits */
242  }
243 
244  *length = size * XDR_DOUBLE_LENGTH;
245  *offsetMantissa = size;
246 
247  return;
248  }
249 
250  precision += 4; /* treat the 4 ls exponent bits like addl mantissa bits */
251 
252  d = (double *)src;
253  nofNull = 0;
254  while (srcStop != (unsigned char *)d)
255  nofNull += Rast3d_is_xdr_null_double(d++);
256 
257  if (nofNull == size) {
258  *dst = (unsigned char)ALL_NULL_CODE;
259 
260  *length = 1;
261  *offsetMantissa = 1;
262 
263  return;
264  }
265 
266  *dst = (unsigned char)(nofNull == 0 ? ZERO_NULL_CODE : SOME_NULL_CODE);
267 
268  gt48 = precision > 48;
269  gt40 = precision > 40;
270  gt32 = precision > 32;
271  gt24 = precision > 24;
272  gt16 = precision > 16;
273  gt8 = precision > 8;
274  srcIncrement = 1 + (!gt8) + (!gt16) + (!gt24) + (!gt32) + (!gt40) + (!gt48);
275 
276  precision %= 8;
277 
278  nullBits = dst + 1;
279  if (nofNull)
280  cp0 = nullBits + size / 8 + ((size % 8) != 0);
281  else
282  cp0 = nullBits;
283  cp7 = cp0 + size - nofNull;
284  cp6 = cp7 + size - nofNull;
285  cp5 = cp6 + size - nofNull;
286  cp4 = cp5 + size - nofNull;
287  cp3 = cp4 + size - nofNull;
288  cp2 = cp3 + size - nofNull;
289  cp1 = cp7 + (gt8 + gt16 + gt24 + gt32 + gt40 + gt48) * (size - nofNull);
290 
291  mask = clearMask[precision];
292  nBits = nNullBits = 0;
293 
294  while (srcStop != src) {
295  if (nofNull) {
296  isNull = Rast3d_is_xdr_null_double((double *)src);
297 
298  if (nNullBits) {
299  *nullBits |= ((unsigned char)isNull << nNullBits++);
300  if (nNullBits == 8) {
301  nullBits++;
302  nNullBits = 0;
303  }
304  }
305  else {
306  *nullBits = (unsigned char)isNull;
307  nNullBits++;
308  }
309 
310  if (isNull) {
311  src += XDR_DOUBLE_LENGTH;
312  continue;
313  }
314  }
315 
316  *cp0++ = *src++;
317  if (gt32) {
318  *cp7++ = *src++;
319  *cp6++ = *src++;
320  *cp5++ = *src++;
321 
322  if (gt32)
323  *cp4++ = *src++;
324  if (gt40)
325  *cp3++ = *src++;
326  if (gt48)
327  *cp2++ = *src++;
328  }
329  else {
330  if (gt8)
331  *cp7++ = *src++;
332  if (gt16)
333  *cp6++ = *src++;
334  if (gt24)
335  *cp5++ = *src++;
336  }
337 
338  if (nBits && precision) {
339  *cp1 |= (unsigned char)((unsigned char)(*src & mask) >> nBits);
340  if (8 - nBits < (unsigned int)precision) {
341  cp1++;
342  *cp1 = (unsigned char)(((unsigned char)(*src & mask))
343  << (8 - nBits));
344  nBits += precision - 8;
345  }
346  else {
347  nBits = (nBits + precision) % 8;
348  if (!nBits)
349  cp1++;
350  }
351  }
352  else {
353  *cp1 = (unsigned char)(*src & mask);
354  nBits = (nBits + precision) % 8;
355  if (!nBits)
356  cp1++;
357  }
358 
359  src += srcIncrement;
360  }
361 
362  *length = 1;
363 
364  if (nofNull)
365  *length += size / 8 + ((size % 8) != 0);
366 
367  *length += (1 + gt8 + gt16 + gt24 + gt32 + gt40 + gt48 + (precision == 0)) *
368  (size - nofNull) +
369  ((precision * (size - nofNull)) / 8) +
370  (((precision * (size - nofNull)) % 8) != 0);
371 
372  if (gt8)
373  *offsetMantissa = 2 * (size - nofNull);
374  else
375  *offsetMantissa = *length;
376 }
377 
378 /*--------------------------------------------------------------------------*/
379 
380 static void G_fpcompress_rearrangeDecodeFloats(unsigned char *src, int size,
381  int precision,
382  unsigned char *dst)
383 {
384  unsigned int nNullBits, nBits;
385  register unsigned char *dstStop;
386  register unsigned char *cp0, *cp1, *cp2, *cp3, *nullBits;
387  unsigned char mask, isNull;
388  int gt8, gt16, dstIncrement, nofNull;
389  float *f, *fStop;
390 
391  if ((precision != -1) && (precision <= 15)) { /* 23 - 8 */
392  cp3 = dst + 3;
393  dstStop = dst + XDR_FLOAT_LENGTH * size + 3;
394  while (dstStop != cp3) {
395  *cp3 = 0;
396  cp3 += XDR_FLOAT_LENGTH;
397  }
398 
399  if (precision <= 7) {
400  cp3 = dst + 2;
401  dstStop = dst + XDR_FLOAT_LENGTH * size + 2;
402  while (dstStop != cp3) {
403  *cp3 = 0;
404  cp3 += XDR_FLOAT_LENGTH;
405  }
406  }
407  }
408 
409  dstStop = dst + size * XDR_FLOAT_LENGTH;
410 
411  if ((precision >= 23) || (precision == -1)) {
412  cp3 = src;
413  cp2 = cp3 + size;
414  cp1 = cp2 + size;
415  cp0 = cp1 + size;
416  while (dstStop != dst) {
417  *dst++ = *cp3++;
418  *dst++ = *cp2++;
419  *dst++ = *cp1++;
420  *dst++ = *cp0++;
421  }
422 
423  return;
424  }
425 
426  if (*src == (unsigned char)ALL_NULL_CODE) {
427  f = (float *)dst;
428  while (dstStop != (unsigned char *)f)
430 
431  return;
432  }
433 
434  precision += 1; /* treat the ls exponent bit like an addl mantissa bit */
435 
436  gt16 = precision > 16;
437  gt8 = precision > 8;
438  dstIncrement = 1 + (!gt8) + (!gt16);
439 
440  precision %= 8;
441 
442  nofNull = 0;
443  nullBits = src + 1;
444  nNullBits = 0;
445  if (*src == (unsigned char)SOME_NULL_CODE) {
446  f = (float *)src;
447  fStop = (float *)(src + size * XDR_FLOAT_LENGTH);
448  while (fStop != f++) {
449  nofNull += ((*nullBits & ((unsigned char)1 << nNullBits++)) != 0);
450  if (nNullBits == 8) {
451  nullBits++;
452  nNullBits = 0;
453  }
454  }
455  }
456 
457  nullBits = src + 1;
458  if (nofNull)
459  cp0 = nullBits + size / 8 + ((size % 8) != 0);
460  else
461  cp0 = nullBits;
462  cp3 = cp0 + size - nofNull;
463  cp2 = cp3 + size - nofNull;
464  cp1 = cp3 + (gt8 + gt16) * (size - nofNull);
465 
466  mask = clearMask[precision];
467  nBits = nNullBits = 0;
468 
469  while (dstStop != dst) {
470  if (nofNull) {
471  isNull = *nullBits & ((unsigned char)1 << nNullBits++);
472 
473  if (nNullBits == 8) {
474  nullBits++;
475  nNullBits = 0;
476  }
477 
478  if (isNull) {
479  Rast3d_set_xdr_null_float((float *)dst);
480  dst += XDR_FLOAT_LENGTH;
481  continue;
482  }
483  }
484 
485  *dst++ = *cp0++;
486  if (gt8)
487  *dst++ = *cp3++;
488  if (gt16)
489  *dst++ = *cp2++;
490 
491  if (nBits && precision) {
492  *dst = (unsigned char)((*cp1 << nBits) & mask);
493 
494  if (8 - nBits < (unsigned int)precision) {
495  cp1++;
496  *dst |= (unsigned char)((*cp1 >> (8 - nBits)) & mask);
497  nBits += precision - 8;
498  }
499  else {
500  nBits = (nBits + precision) % 8;
501  if (!nBits)
502  cp1++;
503  }
504  }
505  else {
506  *dst = (unsigned char)(*cp1 & mask);
507  nBits = (nBits + precision) % 8;
508  if (!nBits)
509  cp1++;
510  }
511 
512  dst += dstIncrement;
513  }
514 }
515 
516 /*--------------------------------------------------------------------------*/
517 
518 static void G_fpcompress_rearrangeDecodeDoubles(unsigned char *src, int size,
519  int precision,
520  unsigned char *dst)
521 {
522  unsigned int nNullBits, nBits;
523  register unsigned char *dstStop;
524  register unsigned char *cp0, *cp1, *cp2, *cp3;
525  register unsigned char *cp4, *cp5, *cp6, *cp7, *nullBits;
526  unsigned char mask, isNull;
527  int gt8, gt16, gt24, gt32, gt40, gt48, dstIncrement, offs, nofNull;
528  double *d, *dStop;
529 
530  if ((precision != -1) && (precision <= 44)) {
531  for (offs = 7; offs >= (precision + 19) / 8; offs--) {
532  cp7 = dst + offs;
533  dstStop = dst + XDR_DOUBLE_LENGTH * size + offs;
534  while (dstStop != cp7) {
535  *cp7 = 0;
536  cp7 += XDR_DOUBLE_LENGTH;
537  }
538  }
539  }
540 
541  dstStop = dst + size * XDR_DOUBLE_LENGTH;
542 
543  if ((precision >= 52) || (precision == -1)) {
544  cp7 = src;
545  cp6 = cp7 + size;
546  cp5 = cp6 + size;
547  cp4 = cp5 + size;
548  cp3 = cp4 + size;
549  cp2 = cp3 + size;
550  cp1 = cp2 + size;
551  cp0 = cp1 + size;
552 
553  while (dstStop != dst) {
554  *dst++ = *cp7++;
555  *dst++ = *cp6++;
556  *dst++ = *cp5++;
557  *dst++ = *cp4++;
558  *dst++ = *cp3++;
559  *dst++ = *cp2++;
560  *dst++ = *cp1++;
561  *dst++ = *cp0++;
562  }
563 
564  return;
565  }
566 
567  if (*src == (unsigned char)ALL_NULL_CODE) {
568  /*printf ("all null\n"); */
569  d = (double *)dst;
570  while (dstStop != (unsigned char *)d)
572 
573  return;
574  }
575 
576  precision += 4; /* treat the 4 ls exponent bits like addl mantissa bits */
577 
578  gt48 = precision > 48;
579  gt40 = precision > 40;
580  gt32 = precision > 32;
581  gt24 = precision > 24;
582  gt16 = precision > 16;
583  gt8 = precision > 8;
584 
585  dstIncrement = 1 + (!gt8) + (!gt16) + (!gt24) + (!gt32) + (!gt40) + (!gt48);
586 
587  precision %= 8;
588 
589  nofNull = 0;
590  nullBits = src + 1;
591  nNullBits = 0;
592  if (*src == (unsigned char)SOME_NULL_CODE) {
593  d = (double *)src;
594  dStop = (double *)(src + size * XDR_DOUBLE_LENGTH);
595  while (dStop != d++) {
596  nofNull += ((*nullBits & ((unsigned char)1 << nNullBits++)) != 0);
597  if (nNullBits == 8) {
598  nullBits++;
599  nNullBits = 0;
600  }
601  }
602  }
603 
604  nullBits = src + 1;
605  if (nofNull)
606  cp0 = nullBits + size / 8 + ((size % 8) != 0);
607  else
608  cp0 = nullBits;
609  cp7 = cp0 + size - nofNull;
610  cp6 = cp7 + size - nofNull;
611  cp5 = cp6 + size - nofNull;
612  cp4 = cp5 + size - nofNull;
613  cp3 = cp4 + size - nofNull;
614  cp2 = cp3 + size - nofNull;
615  cp1 = cp7 + (gt8 + gt16 + gt24 + gt32 + gt40 + gt48) * (size - nofNull);
616 
617  mask = clearMask[precision];
618  nBits = nNullBits = 0;
619 
620  while (dstStop != dst) {
621  if (nofNull) {
622  isNull = *nullBits & ((unsigned char)1 << nNullBits++);
623 
624  if (nNullBits == 8) {
625  nullBits++;
626  nNullBits = 0;
627  }
628 
629  if (isNull) {
630  Rast3d_set_xdr_null_double((double *)dst);
631  dst += XDR_DOUBLE_LENGTH;
632  continue;
633  }
634  }
635 
636  *dst++ = *cp0++;
637  if (gt32) {
638  *dst++ = *cp7++;
639  *dst++ = *cp6++;
640  *dst++ = *cp5++;
641 
642  if (gt32)
643  *dst++ = *cp4++;
644  if (gt40)
645  *dst++ = *cp3++;
646  if (gt48)
647  *dst++ = *cp2++;
648  }
649  else {
650  if (gt8)
651  *dst++ = *cp7++;
652  if (gt16)
653  *dst++ = *cp6++;
654  if (gt24)
655  *dst++ = *cp5++;
656  }
657 
658  if (nBits && precision) {
659  *dst = (unsigned char)((*cp1 << nBits) & mask);
660 
661  if (8 - nBits < (unsigned int)precision) {
662  cp1++;
663  *dst |= (unsigned char)((*cp1 >> (8 - nBits)) & mask);
664  nBits += precision - 8;
665  }
666  else {
667  nBits = (nBits + precision) % 8;
668  if (!nBits)
669  cp1++;
670  }
671  }
672  else {
673  *dst = (unsigned char)(*cp1 & mask);
674  nBits = (nBits + precision) % 8;
675  if (!nBits)
676  cp1++;
677  }
678 
679  dst += dstIncrement;
680  }
681 }
682 
683 /*--------------------------------------------------------------------------*/
684 
685 int Rast3d_fpcompress_write_xdr_nums(int fd, char *src, int nofNum,
686  int precision, char *compressBuf,
687  int isFloat)
688 {
689  int status;
690  int nBytes;
691  int offsetMantissa;
692 
693  if (isFloat)
694  G_fpcompress_rearrangeEncodeFloats(
695  (unsigned char *)src, nofNum, precision,
696  (unsigned char *)(compressBuf + 1), &nBytes, &offsetMantissa);
697  else
698  G_fpcompress_rearrangeEncodeDoubles(
699  (unsigned char *)src, nofNum, precision,
700  (unsigned char *)(compressBuf + 1), &nBytes, &offsetMantissa);
701 
702  *compressBuf = 0;
703  status =
704  G_write_compressed(fd, (unsigned char *)compressBuf, nBytes + 1, 2);
705 
706  if (status < 0) {
707  Rast3d_error("Rast3d_fpcompress_write_xdr_nums: write error");
708  return 0;
709  }
710 
711  return 1;
712 }
713 
714 /*--------------------------------------------------------------------------*/
715 
716 int Rast3d_fpcompress_read_xdr_nums(int fd, char *dst, int nofNum,
717  int fileBytes, int precision,
718  char *compressBuf, int isFloat)
719 {
720  int status;
721  int lengthEncode, lengthDecode;
722  int nBytes;
723  char *src, *dest, *srcStop;
724 
725  nBytes = (isFloat ? XDR_FLOAT_LENGTH : XDR_DOUBLE_LENGTH);
726 
727  status = G_read_compressed(fd, fileBytes, (unsigned char *)compressBuf,
728  nofNum * nBytes + 1, 2);
729 
730  if (status < 0) {
731  Rast3d_error("Rast3d_fpcompress_read_xdr_nums: read error");
732  return 0;
733  }
734 
735  /* This code is kept for backward compatibility */
736  if (*compressBuf++ == 1) {
737  status--;
738  Rast3d_rle_decode(compressBuf, dst, nofNum * nBytes, 1, &lengthEncode,
739  &lengthDecode);
740  if (*dst == ALL_NULL_CODE)
741  Rast3d_fatal_error("Rast3d_fpcompress_read_xdr_nums: wrong code");
742 
743  if (status == nofNum * nBytes)
744  status -= lengthDecode - lengthEncode;
745 
746  src = compressBuf + status - 1;
747  srcStop = compressBuf + lengthEncode - 1;
748  dest = compressBuf + (status - lengthEncode) + lengthDecode - 1;
749  while (src != srcStop)
750  *dest-- = *src--;
751 
752  src = dst;
753  srcStop = src + lengthDecode;
754  dest = compressBuf;
755  while (src != srcStop)
756  *dest++ = *src++;
757  }
758 
759  if (isFloat)
760  G_fpcompress_rearrangeDecodeFloats((unsigned char *)compressBuf, nofNum,
761  precision, (unsigned char *)dst);
762  else
763  G_fpcompress_rearrangeDecodeDoubles((unsigned char *)compressBuf,
764  nofNum, precision,
765  (unsigned char *)dst);
766 
767  return 1;
768 }
int G_read_compressed(int, int, unsigned char *, int, int)
Definition: compress.c:244
int G_write_compressed(int, unsigned char *, int, int)
Definition: compress.c:323
int Rast3d_is_xdr_null_double(const double *)
Definition: fpxdr.c:31
void Rast3d_set_xdr_null_double(double *)
Definition: fpxdr.c:49
void Rast3d_error(const char *,...) __attribute__((format(printf
int Rast3d_is_xdr_null_float(const float *)
Definition: fpxdr.c:24
void Rast3d_set_xdr_null_float(float *)
Definition: fpxdr.c:56
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
void Rast3d_rle_decode(char *, char *, int, int, int *, int *)
Definition: rle.c:236
dglInt32_t sign(dglInt32_t x)
Definition: flow.c:25
#define XDR_FLOAT_LENGTH
Definition: fpcompress.c:11
#define ALL_NULL_CODE
Definition: fpcompress.c:56
#define SOME_NULL_CODE
Definition: fpcompress.c:58
int Rast3d_fpcompress_read_xdr_nums(int fd, char *dst, int nofNum, int fileBytes, int precision, char *compressBuf, int isFloat)
Definition: fpcompress.c:716
#define ZERO_NULL_CODE
Definition: fpcompress.c:57
int Rast3d_fpcompress_write_xdr_nums(int fd, char *src, int nofNum, int precision, char *compressBuf, int isFloat)
Definition: fpcompress.c:685
#define XDR_DOUBLE_LENGTH
Definition: fpcompress.c:9
void Rast3d_fpcompress_print_binary(char *c, int numBits)
Definition: fpcompress.c:16
void Rast3d_fpcompress_dissect_xdr_double(unsigned char *numPointer)
Definition: fpcompress.c:31