Block encoder cleanups
[xz/debian.git] / src / liblzma / common / block_encoder.h
blob3113dab74e7c33cfc9ecce27981431d243a697a1
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file block_encoder.h
4 /// \brief Encodes .xz Blocks
5 //
6 // Copyright (C) 2007 Lasse Collin
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
20 #ifndef LZMA_BLOCK_ENCODER_H
21 #define LZMA_BLOCK_ENCODER_H
23 #include "common.h"
26 /// \brief Biggest Compressed Size value that the Block encoder supports
27 ///
28 /// The maximum size of a single Block is limited by the maximum size of
29 /// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).
30 /// While the size is really big and no one should hit it in practice, we
31 /// take it into account in some places anyway to catch some errors e.g. if
32 /// application passes insanely big value to some function.
33 ///
34 /// We could take into account the headers etc. to determine the exact
35 /// maximum size of the Compressed Data field, but the complexity would give
36 /// us nothing useful. Instead, limit the size of Compressed Data so that
37 /// even with biggest possible Block Header and Check fields the total
38 /// encoded size of the Block stays as a valid VLI. This doesn't guarantee
39 /// that the size of the Stream doesn't grow too big, but that problem is
40 /// taken care outside the Block handling code.
41 ///
42 /// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of
43 /// the Compressed Data field, it will still stay in the proper limit.
44 ///
45 /// This constant is in this file because it is needed in both
46 /// block_encoder.c and block_buffer_encoder.c.
47 #define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \
48 - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))
51 extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,
52 lzma_allocator *allocator, lzma_block *block);
54 #endif