1/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
2/*
3 * Copyright (c) Meta Platforms, Inc. and affiliates.
4 * All rights reserved.
5 *
6 * This source code is licensed under both the BSD-style license (found in the
7 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
8 * in the COPYING file in the root directory of this source tree).
9 * You may select, at your option, one of the above-listed licenses.
10 */
11
12
13#ifndef ZSTD_DEC_BLOCK_H
14#define ZSTD_DEC_BLOCK_H
15
16/*-*******************************************************
17 * Dependencies
18 *********************************************************/
19#include "../common/zstd_deps.h" /* size_t */
20#include <linux/zstd.h> /* DCtx, and some public functions */
21#include "../common/zstd_internal.h" /* blockProperties_t, and some public functions */
22#include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */
23
24
25/* === Prototypes === */
26
27/* note: prototypes already published within `zstd.h` :
28 * ZSTD_decompressBlock()
29 */
30
31/* note: prototypes already published within `zstd_internal.h` :
32 * ZSTD_getcBlockSize()
33 * ZSTD_decodeSeqHeaders()
34 */
35
36
37 /* Streaming state is used to inform allocation of the literal buffer */
38typedef enum {
39 not_streaming = 0,
40 is_streaming = 1
41} streaming_operation;
42
43/* ZSTD_decompressBlock_internal() :
44 * decompress block, starting at `src`,
45 * into destination buffer `dst`.
46 * @return : decompressed block size,
47 * or an error code (which can be tested using ZSTD_isError())
48 */
49size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
50 void* dst, size_t dstCapacity,
51 const void* src, size_t srcSize, const streaming_operation streaming);
52
53/* ZSTD_buildFSETable() :
54 * generate FSE decoding table for one symbol (ll, ml or off)
55 * this function must be called with valid parameters only
56 * (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
57 * in which case it cannot fail.
58 * The workspace must be 4-byte aligned and at least ZSTD_BUILD_FSE_TABLE_WKSP_SIZE bytes, which is
59 * defined in zstd_decompress_internal.h.
60 * Internal use only.
61 */
62void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
63 const short* normalizedCounter, unsigned maxSymbolValue,
64 const U32* baseValue, const U8* nbAdditionalBits,
65 unsigned tableLog, void* wksp, size_t wkspSize,
66 int bmi2);
67
68/* Internal definition of ZSTD_decompressBlock() to avoid deprecation warnings. */
69size_t ZSTD_decompressBlock_deprecated(ZSTD_DCtx* dctx,
70 void* dst, size_t dstCapacity,
71 const void* src, size_t srcSize);
72
73
74#endif /* ZSTD_DEC_BLOCK_H */
75