2 * BriefLZ - small fast Lempel-Ziv
6 * Copyright (c) 2002-2020 Joergen Ibsen
8 * This software is provided 'as-is', without any express or implied
9 * warranty. In no event will the authors be held liable for any damages
10 * arising from the use of this software.
12 * Permission is granted to anyone to use this software for any purpose,
13 * including commercial applications, and to alter it and redistribute it
14 * freely, subject to the following restrictions:
16 * 1. The origin of this software must not be misrepresented; you must
17 * not claim that you wrote the original software. If you use this
18 * software in a product, an acknowledgment in the product
19 * documentation would be appreciated but is not required.
21 * 2. Altered source versions must be plainly marked as such, and must
22 * not be misrepresented as being the original software.
24 * 3. This notice may not be removed or altered from any source
27 module chibackend
.pack
.libbrieflz
;
28 pragma(lib
, "brieflz");
30 public nothrow @nogc @trusted:
33 enum BLZ_VER_MAJOR
= 1; /**< Major version number */
34 enum BLZ_VER_MINOR
= 3; /**< Minor version number */
35 enum BLZ_VER_PATCH
= 0; /**< Patch version number */
36 enum BLZ_VER_STRING
= "1.3.0"; /**< Version number as a string */
39 * Return value on error.
41 * @see blz_depack_safe
43 enum BLZ_ERROR
= cast(uint)~0; // -1
46 * Get bound on compressed data size.
50 * @param src_size number of bytes to compress
51 * @return maximum size of compressed data
53 usize
blz_max_packed_size (usize src_size
);
56 * Get required size of `workmem` buffer.
60 * @param src_size number of bytes to compress
61 * @return required size in bytes of `workmem` buffer
63 usize
blz_workmem_size (usize src_size
);
66 * Compress `src_size` bytes of data from `src` to `dst`.
68 * @param src pointer to data
69 * @param dst pointer to where to place compressed data
70 * @param src_size number of bytes to compress
71 * @param workmem pointer to memory for temporary use
72 * @return size of compressed data
74 uint blz_pack(const(void)* src
, void* dst
, uint src_size
, void* workmem
);
77 * Get required size of `workmem` buffer.
81 * @param src_size number of bytes to compress
82 * @param level compression level
83 * @return required size in bytes of `workmem` buffer
85 usize
blz_workmem_size_level (usize src_size
, int level
);
88 * Compress `src_size` bytes of data from `src` to `dst`.
90 * Compression levels between 1 and 9 offer a trade-off between
91 * time/space and ratio. Level 10 is optimal but very slow.
93 * @param src pointer to data
94 * @param dst pointer to where to place compressed data
95 * @param src_size number of bytes to compress
96 * @param workmem pointer to memory for temporary use
97 * @param level compression level
98 * @return size of compressed data
100 uint blz_pack_level (const(void)* src
, void* dst
, uint src_size
, void *workmem
, int level
);
103 * Decompress `depacked_size` bytes of data from `src` to `dst`.
105 * @param src pointer to compressed data
106 * @param dst pointer to where to place decompressed data
107 * @param depacked_size size of decompressed data
108 * @return size of decompressed data
110 uint blz_depack (const(void)* src
, void* dst
, uint depacked_size
);
113 * Decompress `depacked_size` bytes of data from `src` to `dst`.
115 * Reads at most `src_size` bytes from `src`.
116 * Writes at most `depacked_size` bytes to `dst`.
118 * @param src pointer to compressed data
119 * @param src_size size of compressed data
120 * @param dst pointer to where to place decompressed data
121 * @param depacked_size size of decompressed data
122 * @return size of decompressed data, `BLZ_ERROR` on error
124 uint blz_depack_safe (const(void)* src
, uint src_size
, void* dst
, uint depacked_size
);