huf.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include <contrib/libs/zstd06/renames.h>
  2. /* ******************************************************************
  3. Huffman coder, part of New Generation Entropy library
  4. header file
  5. Copyright (C) 2013-2016, Yann Collet.
  6. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are
  9. met:
  10. * Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the following disclaimer
  14. in the documentation and/or other materials provided with the
  15. distribution.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  20. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. You can contact the author at :
  28. - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
  29. ****************************************************************** */
  30. #ifndef HUF_H
  31. #define HUF_H
  32. #if defined (__cplusplus)
  33. extern "C" {
  34. #endif
  35. /* ****************************************
  36. * Dependency
  37. ******************************************/
  38. #include <stddef.h> /* size_t */
  39. /* ****************************************
  40. * HUF simple functions
  41. ******************************************/
  42. size_t HUF_compress(void* dst, size_t dstCapacity,
  43. const void* src, size_t srcSize);
  44. size_t HUF_decompress(void* dst, size_t dstSize,
  45. const void* cSrc, size_t cSrcSize);
  46. /*
  47. HUF_compress() :
  48. Compress content of buffer 'src', of size 'srcSize', into destination buffer 'dst'.
  49. 'dst' buffer must be already allocated. Compression runs faster if dstCapacity >= HUF_compressBound(srcSize).
  50. Note : srcSize must be <= 128 KB
  51. @return : size of compressed data (<= dstCapacity)
  52. Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
  53. if return == 1, srcData is a single repeated byte symbol (RLE compression).
  54. if HUF_isError(return), compression failed (more details using HUF_getErrorName())
  55. HUF_decompress() :
  56. Decompress HUF data from buffer 'cSrc', of size 'cSrcSize',
  57. into already allocated destination buffer 'dst', of size 'dstSize'.
  58. `dstSize` : must be the **exact** size of original (uncompressed) data.
  59. Note : in contrast with FSE, HUF_decompress can regenerate
  60. RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data,
  61. because it knows size to regenerate.
  62. @return : size of regenerated data (== dstSize)
  63. or an error code, which can be tested using HUF_isError()
  64. */
  65. /* ****************************************
  66. * Tool functions
  67. ******************************************/
  68. size_t HUF_compressBound(size_t size); /**< maximum compressed size */
  69. /* Error Management */
  70. unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */
  71. const char* HUF_getErrorName(size_t code); /**< provides error code string (useful for debugging) */
  72. /* ****************************************
  73. * Advanced functions
  74. ******************************************/
  75. size_t HUF_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
  76. #if defined (__cplusplus)
  77. }
  78. #endif
  79. #endif /* HUF_H */