block_encoder.h 1.8 KB

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