162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) Yann Collet, Facebook, Inc.
362306a36Sopenharmony_ci * All rights reserved.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * This source code is licensed under both the BSD-style license (found in the
662306a36Sopenharmony_ci * LICENSE file in the root directory of this source tree) and the GPLv2 (found
762306a36Sopenharmony_ci * in the COPYING file in the root directory of this source tree).
862306a36Sopenharmony_ci * You may select, at your option, one of the above-listed licenses.
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifndef ZSTD_DEC_BLOCK_H
1362306a36Sopenharmony_ci#define ZSTD_DEC_BLOCK_H
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/*-*******************************************************
1662306a36Sopenharmony_ci *  Dependencies
1762306a36Sopenharmony_ci *********************************************************/
1862306a36Sopenharmony_ci#include "../common/zstd_deps.h"   /* size_t */
1962306a36Sopenharmony_ci#include <linux/zstd.h>    /* DCtx, and some public functions */
2062306a36Sopenharmony_ci#include "../common/zstd_internal.h"  /* blockProperties_t, and some public functions */
2162306a36Sopenharmony_ci#include "zstd_decompress_internal.h"  /* ZSTD_seqSymbol */
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/* ===   Prototypes   === */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* note: prototypes already published within `zstd.h` :
2762306a36Sopenharmony_ci * ZSTD_decompressBlock()
2862306a36Sopenharmony_ci */
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* note: prototypes already published within `zstd_internal.h` :
3162306a36Sopenharmony_ci * ZSTD_getcBlockSize()
3262306a36Sopenharmony_ci * ZSTD_decodeSeqHeaders()
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci /* Streaming state is used to inform allocation of the literal buffer */
3762306a36Sopenharmony_citypedef enum {
3862306a36Sopenharmony_ci    not_streaming = 0,
3962306a36Sopenharmony_ci    is_streaming = 1
4062306a36Sopenharmony_ci} streaming_operation;
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* ZSTD_decompressBlock_internal() :
4362306a36Sopenharmony_ci * decompress block, starting at `src`,
4462306a36Sopenharmony_ci * into destination buffer `dst`.
4562306a36Sopenharmony_ci * @return : decompressed block size,
4662306a36Sopenharmony_ci *           or an error code (which can be tested using ZSTD_isError())
4762306a36Sopenharmony_ci */
4862306a36Sopenharmony_cisize_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
4962306a36Sopenharmony_ci                               void* dst, size_t dstCapacity,
5062306a36Sopenharmony_ci                         const void* src, size_t srcSize, const int frame, const streaming_operation streaming);
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* ZSTD_buildFSETable() :
5362306a36Sopenharmony_ci * generate FSE decoding table for one symbol (ll, ml or off)
5462306a36Sopenharmony_ci * this function must be called with valid parameters only
5562306a36Sopenharmony_ci * (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
5662306a36Sopenharmony_ci * in which case it cannot fail.
5762306a36Sopenharmony_ci * The workspace must be 4-byte aligned and at least ZSTD_BUILD_FSE_TABLE_WKSP_SIZE bytes, which is
5862306a36Sopenharmony_ci * defined in zstd_decompress_internal.h.
5962306a36Sopenharmony_ci * Internal use only.
6062306a36Sopenharmony_ci */
6162306a36Sopenharmony_civoid ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
6262306a36Sopenharmony_ci             const short* normalizedCounter, unsigned maxSymbolValue,
6362306a36Sopenharmony_ci             const U32* baseValue, const U8* nbAdditionalBits,
6462306a36Sopenharmony_ci                   unsigned tableLog, void* wksp, size_t wkspSize,
6562306a36Sopenharmony_ci                   int bmi2);
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#endif /* ZSTD_DEC_BLOCK_H */
69