GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-cf81aadc39
compress.h
Go to the documentation of this file.
1 #include <grass/config.h>
2 #include <grass/gis.h>
3 
4 /* compressors:
5  * 0: no compression
6  * 1: RLE, unit is one byte
7  * 2: ZLIB's DEFLATE (default)
8  * 3: LZ4, fastest but lowest compression ratio
9  * 4: BZIP2: slowest but highest compression ratio
10  * 5: ZSTD: faster than ZLIB, higher compression than ZLIB
11  */
12 
13 /* adding a new compressor:
14  * add the corresponding functions G_*compress() and G_*_expand()
15  * if needed, add checks to configure.ac and include/grass/config.h.in
16  * modify compress.h (this file)
17  * nothing to change in compress.c
18  */
19 
20 /* upper bounds of the size of the compressed buffer */
21 int G_no_compress_bound(int);
22 int G_rle_compress_bound(int);
23 int G_zlib_compress_bound(int);
24 int G_lz4_compress_bound(int);
25 int G_bz2_compress_bound(int);
26 int G_zstd_compress_bound(int);
27 
28 typedef int compress_fn(unsigned char *src, int src_sz, unsigned char *dst,
29  int dst_sz);
30 typedef int expand_fn(unsigned char *src, int src_sz, unsigned char *dst,
31  int dst_sz);
32 typedef int bound_fn(int src_sz);
33 
35  int available;
39  char *name;
40 };
41 
42 /* DO NOT CHANGE the order
43  * 0: None
44  * 1: RLE
45  * 2: ZLIB
46  * 3: LZ4
47  * 4: BZIP2
48  * 5: ZSTD
49  */
50 
51 static int n_compressors = 6;
52 
53 struct compressor_list compressor[] = {
58 #ifdef HAVE_BZLIB_H
60 #else
62 #endif
63 #ifdef HAVE_ZSTD_H
65 #else
67 #endif
68  {0, NULL, NULL, NULL, NULL}};
#define NULL
Definition: ccmath.h:32
int G_bz2_compress_bound(int)
Definition: cmprbzip.c:72
int G_lz4_compress_bound(int)
Definition: cmprlz4.c:70
int G_zlib_compress_bound(int)
Definition: cmprzlib.c:76
int expand_fn(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.h:30
struct compressor_list compressor[]
Definition: compress.h:53
int G_zstd_compress_bound(int)
Definition: cmprzstd.c:72
int compress_fn(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.h:28
int bound_fn(int src_sz)
Definition: compress.h:32
int G_rle_compress_bound(int)
Definition: cmprrle.c:68
int G_no_compress_bound(int)
Definition: compress.c:150
int G_zlib_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzlib.c:165
int G_bz2_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprbzip.c:85
int G_lz4_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprlz4.c:78
int G_bz2_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprbzip.c:168
int G_lz4_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprlz4.c:146
int G_no_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.c:155
int G_rle_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprrle.c:73
int G_rle_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprrle.c:139
int G_zlib_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzlib.c:87
int G_zstd_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzstd.c:86
int G_zstd_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzstd.c:162
int G_no_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.c:176
char * dst
Definition: lz4.h:981
const char * src
Definition: lz4.h:989
bound_fn * bound
Definition: compress.h:38
compress_fn * compress
Definition: compress.h:36
expand_fn * expand
Definition: compress.h:37
char * name
Definition: compress.h:39