compress.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include <grass/config.h>
  2. #include <grass/gis.h>
  3. /* compressors:
  4. * 0: no compression
  5. * 1: RLE, unit is one byte
  6. * 2: ZLIB's DEFLATE (default)
  7. * 3: LZ4, fastest but lowest compression ratio
  8. * 4: BZIP2: slowest but highest compression ratio
  9. * 5: ZSTD: faster than ZLIB, higher compression than ZLIB
  10. */
  11. /* adding a new compressor:
  12. * add the corresponding functions G_*compress() and G_*_expand()
  13. * if needed, add checks to configure.ac and include/grass/config.h.in
  14. * modify compress.h (this file)
  15. * nothing to change in compress.c
  16. */
  17. /* upper bounds of the size of the compressed buffer */
  18. int G_no_compress_bound(int);
  19. int G_rle_compress_bound(int);
  20. int G_zlib_compress_bound(int);
  21. int G_lz4_compress_bound(int);
  22. int G_bz2_compress_bound(int);
  23. int G_zstd_compress_bound(int);
  24. typedef int compress_fn(unsigned char *src, int src_sz, unsigned char *dst,
  25. int dst_sz);
  26. typedef int expand_fn(unsigned char *src, int src_sz, unsigned char *dst,
  27. int dst_sz);
  28. typedef int bound_fn(int src_sz);
  29. struct compressor_list
  30. {
  31. int available;
  32. compress_fn *compress;
  33. expand_fn *expand;
  34. bound_fn *bound;
  35. char *name;
  36. };
  37. /* DO NOT CHANGE the order
  38. * 0: None
  39. * 1: RLE
  40. * 2: ZLIB
  41. * 3: LZ4
  42. * 4: BZIP2
  43. * 5: ZSTD
  44. */
  45. static int n_compressors = 6;
  46. struct compressor_list compressor[] = {
  47. {1, G_no_compress, G_no_expand, G_no_compress_bound, "NONE"},
  48. {1, G_rle_compress, G_rle_expand, G_rle_compress_bound, "RLE"},
  49. {1, G_zlib_compress, G_zlib_expand, G_zlib_compress_bound, "ZLIB"},
  50. {1, G_lz4_compress, G_lz4_expand, G_lz4_compress_bound, "LZ4"},
  51. #ifdef HAVE_BZLIB_H
  52. {1, G_bz2_compress, G_bz2_expand, G_bz2_compress_bound, "BZIP2"},
  53. #else
  54. {0, G_bz2_compress, G_bz2_expand, G_bz2_compress_bound, "BZIP2"},
  55. #endif
  56. #ifdef HAVE_ZSTD_H
  57. {1, G_zstd_compress, G_zstd_expand, G_zstd_compress_bound, "ZSTD"},
  58. #else
  59. {0, G_zstd_compress, G_zstd_expand, G_zstd_compress_bound, "ZSTD"},
  60. #endif
  61. {0, NULL, NULL, NULL, NULL}
  62. };