]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/zstd/doc/educational_decoder/zstd_decompress.h
Update to Zstandard 1.4.4
[FreeBSD/FreeBSD.git] / sys / contrib / zstd / doc / educational_decoder / zstd_decompress.h
1 /*
2  * Copyright (c) 2016-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under both the BSD-style license (found in the
6  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7  * in the COPYING file in the root directory of this source tree).
8  */
9
10 #include <stddef.h>   /* size_t */
11
12 /******* EXPOSED TYPES ********************************************************/
13 /*
14 * Contains the parsed contents of a dictionary
15 * This includes Huffman and FSE tables used for decoding and data on offsets
16 */
17 typedef struct dictionary_s dictionary_t;
18 /******* END EXPOSED TYPES ****************************************************/
19
20 /******* DECOMPRESSION FUNCTIONS **********************************************/
21 /// Zstandard decompression functions.
22 /// `dst` must point to a space at least as large as the reconstructed output.
23 size_t ZSTD_decompress(void *const dst, const size_t dst_len,
24                     const void *const src, const size_t src_len);
25
26 /// If `dict != NULL` and `dict_len >= 8`, does the same thing as
27 /// `ZSTD_decompress` but uses the provided dict
28 size_t ZSTD_decompress_with_dict(void *const dst, const size_t dst_len,
29                               const void *const src, const size_t src_len,
30                               dictionary_t* parsed_dict);
31
32 /// Get the decompressed size of an input stream so memory can be allocated in
33 /// advance
34 /// Returns -1 if the size can't be determined
35 /// Assumes decompression of a single frame
36 size_t ZSTD_get_decompressed_size(const void *const src, const size_t src_len);
37 /******* END DECOMPRESSION FUNCTIONS ******************************************/
38
39 /******* DICTIONARY MANAGEMENT ***********************************************/
40 /*
41  * Return a valid dictionary_t pointer for use with dictionary initialization
42  * or decompression
43  */
44 dictionary_t* create_dictionary(void);
45
46 /*
47  * Parse a provided dictionary blob for use in decompression
48  * `src` -- must point to memory space representing the dictionary
49  * `src_len` -- must provide the dictionary size
50  * `dict` -- will contain the parsed contents of the dictionary and
51  *        can be used for decompression
52  */
53 void parse_dictionary(dictionary_t *const dict, const void *src,
54                              size_t src_len);
55
56 /*
57  * Free internal Huffman tables, FSE tables, and dictionary content
58  */
59 void free_dictionary(dictionary_t *const dict);
60 /******* END DICTIONARY MANAGEMENT *******************************************/