GRASS GIS 8 Programmer's Manual 8.2.1(2023)-exported
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 */
21int G_no_compress_bound(int);
27
28typedef int compress_fn(unsigned char *src, int src_sz, unsigned char *dst,
29 int dst_sz);
30typedef int expand_fn(unsigned char *src, int src_sz, unsigned char *dst,
31 int dst_sz);
32typedef int bound_fn(int src_sz);
33
35{
40 char *name;
41};
42
43/* DO NOT CHANGE the order
44 * 0: None
45 * 1: RLE
46 * 2: ZLIB
47 * 3: LZ4
48 * 4: BZIP2
49 * 5: ZSTD
50 */
51
52static int n_compressors = 6;
53
57 {1, G_zlib_compress, G_zlib_expand, G_zlib_compress_bound, "ZLIB"},
59#ifdef HAVE_BZLIB_H
61#else
63#endif
64#ifdef HAVE_ZSTD_H
66#else
68#endif
69 {0, NULL, NULL, NULL, NULL}
70};
71
#define NULL
Definition: ccmath.h:32
int G_bz2_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprbzip.c:88
int G_bz2_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprbzip.c:169
int G_lz4_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprlz4.c:80
int G_lz4_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprlz4.c:148
int G_rle_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprrle.c:74
int G_rle_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprrle.c:141
int G_zstd_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzstd.c:88
int G_zstd_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: cmprzstd.c:163
int G_no_compress(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.c:156
int G_no_expand(unsigned char *src, int src_sz, unsigned char *dst, int dst_sz)
Definition: compress.c:178
int G_bz2_compress_bound(int)
Definition: cmprbzip.c:74
int G_lz4_compress_bound(int)
Definition: cmprlz4.c:71
int G_zlib_compress_bound(int)
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:54
int G_zstd_compress_bound(int)
Definition: cmprzstd.c:74
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
char * dst
Definition: lz4.h:599
bound_fn * bound
Definition: compress.h:39
compress_fn * compress
Definition: compress.h:37
expand_fn * expand
Definition: compress.h:38
char * name
Definition: compress.h:40