block_encoder.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: 0BSD
  2. ///////////////////////////////////////////////////////////////////////////////
  3. //
  4. /// \file block_encoder.h
  5. /// \brief Encodes .xz Blocks
  6. //
  7. // Author: Lasse Collin
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef LZMA_BLOCK_ENCODER_H
  11. #define LZMA_BLOCK_ENCODER_H
  12. #include "common.h"
  13. /// \brief Biggest Compressed Size value that the Block encoder supports
  14. ///
  15. /// The maximum size of a single Block is limited by the maximum size of
  16. /// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).
  17. /// While the size is really big and no one should hit it in practice, we
  18. /// take it into account in some places anyway to catch some errors e.g. if
  19. /// application passes insanely big value to some function.
  20. ///
  21. /// We could take into account the headers etc. to determine the exact
  22. /// maximum size of the Compressed Data field, but the complexity would give
  23. /// us nothing useful. Instead, limit the size of Compressed Data so that
  24. /// even with biggest possible Block Header and Check fields the total
  25. /// encoded size of the Block stays as a valid VLI. This doesn't guarantee
  26. /// that the size of the Stream doesn't grow too big, but that problem is
  27. /// taken care outside the Block handling code.
  28. ///
  29. /// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of
  30. /// the Compressed Data field, it will still stay in the proper limit.
  31. ///
  32. /// This constant is in this file because it is needed in both
  33. /// block_encoder.c and block_buffer_encoder.c.
  34. #define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \
  35. - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))
  36. extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,
  37. const lzma_allocator *allocator, lzma_block *block);
  38. #endif