Path: blob/master/Utilities/cmliblzma/liblzma/common/block_encoder.h
3153 views
// SPDX-License-Identifier: 0BSD12///////////////////////////////////////////////////////////////////////////////3//4/// \file block_encoder.h5/// \brief Encodes .xz Blocks6//7// Author: Lasse Collin8//9///////////////////////////////////////////////////////////////////////////////1011#ifndef LZMA_BLOCK_ENCODER_H12#define LZMA_BLOCK_ENCODER_H1314#include "common.h"151617/// \brief Biggest Compressed Size value that the Block encoder supports18///19/// The maximum size of a single Block is limited by the maximum size of20/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).21/// While the size is really big and no one should hit it in practice, we22/// take it into account in some places anyway to catch some errors e.g. if23/// application passes insanely big value to some function.24///25/// We could take into account the headers etc. to determine the exact26/// maximum size of the Compressed Data field, but the complexity would give27/// us nothing useful. Instead, limit the size of Compressed Data so that28/// even with biggest possible Block Header and Check fields the total29/// encoded size of the Block stays as a valid VLI. This doesn't guarantee30/// that the size of the Stream doesn't grow too big, but that problem is31/// taken care outside the Block handling code.32///33/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of34/// the Compressed Data field, it will still stay in the proper limit.35///36/// This constant is in this file because it is needed in both37/// block_encoder.c and block_buffer_encoder.c.38#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \39- LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))404142extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,43const lzma_allocator *allocator, lzma_block *block);4445#endif464748