fastlz.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. FastLZ - lightning-fast lossless compression library
  3. Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
  4. Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
  5. Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. */
  22. #ifndef FASTLZ_H
  23. #define FASTLZ_H
  24. #define FASTLZ_VERSION 0x000100
  25. #define FASTLZ_VERSION_MAJOR 0
  26. #define FASTLZ_VERSION_MINOR 0
  27. #define FASTLZ_VERSION_REVISION 0
  28. #define FASTLZ_VERSION_STRING "0.1.0"
  29. #if defined (__cplusplus)
  30. extern "C" {
  31. #endif
  32. /**
  33. Compress a block of data in the input buffer and returns the size of
  34. compressed block. The size of input buffer is specified by length. The
  35. minimum input buffer size is 16.
  36. The output buffer must be at least 5% larger than the input buffer
  37. and can not be smaller than 66 bytes.
  38. If the input is not compressible, the return value might be larger than
  39. length (input buffer size).
  40. The input buffer and the output buffer can not overlap.
  41. */
  42. int fastlz_compress(const void* input, int length, void* output);
  43. /**
  44. Decompress a block of compressed data and returns the size of the
  45. decompressed block. If error occurs, e.g. the compressed data is
  46. corrupted or the output buffer is not large enough, then 0 (zero)
  47. will be returned instead.
  48. The input buffer and the output buffer can not overlap.
  49. Decompression is memory safe and guaranteed not to write the output buffer
  50. more than what is specified in maxout.
  51. */
  52. int fastlz_decompress(const void* input, int length, void* output);
  53. /**
  54. Compress a block of data in the input buffer and returns the size of
  55. compressed block. The size of input buffer is specified by length. The
  56. minimum input buffer size is 16.
  57. The output buffer must be at least 5% larger than the input buffer
  58. and can not be smaller than 66 bytes.
  59. If the input is not compressible, the return value might be larger than
  60. length (input buffer size).
  61. The input buffer and the output buffer can not overlap.
  62. Compression level can be specified in parameter level. At the moment,
  63. only level 1 and level 2 are supported.
  64. Level 1 is the fastest compression and generally useful for short data.
  65. Level 2 is slightly slower but it gives better compression ratio.
  66. Note that the compressed data, regardless of the level, can always be
  67. decompressed using the function fastlz_decompress above.
  68. */
  69. #if defined (__cplusplus)
  70. }
  71. #endif
  72. #endif /* FASTLZ_H */