zstd_decompress_block.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifndef ZSTD_DEC_BLOCK_H
  12. #define ZSTD_DEC_BLOCK_H
  13. /*-*******************************************************
  14. * Dependencies
  15. *********************************************************/
  16. #include "../common/zstd_deps.h" /* size_t */
  17. #include <linux/zstd.h> /* DCtx, and some public functions */
  18. #include "../common/zstd_internal.h" /* blockProperties_t, and some public functions */
  19. #include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */
  20. /* === Prototypes === */
  21. /* note: prototypes already published within `zstd.h` :
  22. * ZSTD_decompressBlock()
  23. */
  24. /* note: prototypes already published within `zstd_internal.h` :
  25. * ZSTD_getcBlockSize()
  26. * ZSTD_decodeSeqHeaders()
  27. */
  28. /* Streaming state is used to inform allocation of the literal buffer */
  29. typedef enum {
  30. not_streaming = 0,
  31. is_streaming = 1
  32. } streaming_operation;
  33. /* ZSTD_decompressBlock_internal() :
  34. * decompress block, starting at `src`,
  35. * into destination buffer `dst`.
  36. * @return : decompressed block size,
  37. * or an error code (which can be tested using ZSTD_isError())
  38. */
  39. size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
  40. void* dst, size_t dstCapacity,
  41. const void* src, size_t srcSize, const streaming_operation streaming);
  42. /* ZSTD_buildFSETable() :
  43. * generate FSE decoding table for one symbol (ll, ml or off)
  44. * this function must be called with valid parameters only
  45. * (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
  46. * in which case it cannot fail.
  47. * The workspace must be 4-byte aligned and at least ZSTD_BUILD_FSE_TABLE_WKSP_SIZE bytes, which is
  48. * defined in zstd_decompress_internal.h.
  49. * Internal use only.
  50. */
  51. void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
  52. const short* normalizedCounter, unsigned maxSymbolValue,
  53. const U32* baseValue, const U8* nbAdditionalBits,
  54. unsigned tableLog, void* wksp, size_t wkspSize,
  55. int bmi2);
  56. /* Internal definition of ZSTD_decompressBlock() to avoid deprecation warnings. */
  57. size_t ZSTD_decompressBlock_deprecated(ZSTD_DCtx* dctx,
  58. void* dst, size_t dstCapacity,
  59. const void* src, size_t srcSize);
  60. #endif /* ZSTD_DEC_BLOCK_H */