Path: blob/main/sys/contrib/zstd/doc/educational_decoder/zstd_decompress.h
48378 views
/*1* Copyright (c) Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under both the BSD-style license (found in the5* LICENSE file in the root directory of this source tree) and the GPLv2 (found6* in the COPYING file in the root directory of this source tree).7* You may select, at your option, one of the above-listed licenses.8*/910#include <stddef.h> /* size_t */1112/******* EXPOSED TYPES ********************************************************/13/*14* Contains the parsed contents of a dictionary15* This includes Huffman and FSE tables used for decoding and data on offsets16*/17typedef struct dictionary_s dictionary_t;18/******* END EXPOSED TYPES ****************************************************/1920/******* DECOMPRESSION FUNCTIONS **********************************************/21/// Zstandard decompression functions.22/// `dst` must point to a space at least as large as the reconstructed output.23size_t ZSTD_decompress(void *const dst, const size_t dst_len,24const void *const src, const size_t src_len);2526/// If `dict != NULL` and `dict_len >= 8`, does the same thing as27/// `ZSTD_decompress` but uses the provided dict28size_t ZSTD_decompress_with_dict(void *const dst, const size_t dst_len,29const void *const src, const size_t src_len,30dictionary_t* parsed_dict);3132/// Get the decompressed size of an input stream so memory can be allocated in33/// advance34/// Returns -1 if the size can't be determined35/// Assumes decompression of a single frame36size_t ZSTD_get_decompressed_size(const void *const src, const size_t src_len);37/******* END DECOMPRESSION FUNCTIONS ******************************************/3839/******* DICTIONARY MANAGEMENT ***********************************************/40/*41* Return a valid dictionary_t pointer for use with dictionary initialization42* or decompression43*/44dictionary_t* create_dictionary(void);4546/*47* Parse a provided dictionary blob for use in decompression48* `src` -- must point to memory space representing the dictionary49* `src_len` -- must provide the dictionary size50* `dict` -- will contain the parsed contents of the dictionary and51* can be used for decompression52*/53void parse_dictionary(dictionary_t *const dict, const void *src,54size_t src_len);5556/*57* Free internal Huffman tables, FSE tables, and dictionary content58*/59void free_dictionary(dictionary_t *const dict);60/******* END DICTIONARY MANAGEMENT *******************************************/616263