compress.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. */
  10. /* adding a new compressor:
  11. * add the corresponding functions G_*compress() and G_*_expand()
  12. * if needed, add checks to configure.in and include/config.in
  13. * modify compress.h
  14. * modify G_compress(), G_expand()
  15. */
  16. typedef int compress_fn(unsigned char *src, int src_sz, unsigned char *dst,
  17. int dst_sz);
  18. typedef int expand_fn(unsigned char *src, int src_sz, unsigned char *dst,
  19. int dst_sz);
  20. struct compressor_list
  21. {
  22. int available;
  23. compress_fn *compress;
  24. expand_fn *expand;
  25. char *name;
  26. };
  27. /* DO NOT CHANGE the order
  28. * 0: None
  29. * 1: RLE
  30. * 2: ZLIB
  31. * 3: LZ4
  32. * 4: BZIP2 */
  33. static int n_compressors = 5;
  34. struct compressor_list compressor[] = {
  35. {1, G_no_compress, G_no_expand, "NONE"},
  36. {1, G_rle_compress, G_rle_expand, "RLE"},
  37. {1, G_zlib_compress, G_zlib_expand, "ZLIB"},
  38. {1, G_lz4_compress, G_lz4_expand, "LZ4"},
  39. #ifdef HAVE_BZLIB_H
  40. {1, G_bz2_compress, G_bz2_expand, "BZIP2"},
  41. #else
  42. {0, G_bz2_compress, G_bz2_expand, "BZIP2"},
  43. #endif
  44. {0, NULL, NULL, NULL}
  45. };