28 #define HEADERS_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 \
29 + LZMA_CHECK_SIZE_MAX + 3) & ~3)
65 lzma2_size = (lzma2_size + 3) & ~
UINT64_C(3);
78 #if SIZE_MAX < UINT64_MAX
109 if (lzma_block_header_size(block) !=
LZMA_OK) {
145 const size_t copy_size
147 out[(*out_pos)++] = (copy_size - 1) >> 8;
148 out[(*out_pos)++] = (copy_size - 1) & 0xFF;
159 out[(*out_pos)++] = 0x00;
175 if (out_size - *out_pos <= block->header_size)
178 const size_t out_start = *
out_pos;
206 ret = lzma_block_header_encode(block,
out + out_start);
227 bool try_to_compress)
243 if (!lzma_check_is_supported(block->
check))
249 out_size -= (out_size - *
out_pos) & 3;
252 const size_t check_size = lzma_check_size(block->
check);
256 if (out_size - *
out_pos <= check_size)
259 out_size -= check_size;
296 out[(*out_pos)++] = 0x00;
300 if (check_size > 0) {
#define LZMA_CHECK_ID_MAX
Maximum valid Check ID.
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
const lzma_allocator const uint8_t size_t * in_pos
const lzma_allocator const uint8_t size_t in_size
const lzma_allocator * allocator
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
uint64_t lzma_block_buffer_bound64(uint64_t uncompressed_size)
LZMA_API(size_t)
Calculate maximum output size for single-call Block encoding.
static lzma_ret block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size)
static uint64_t lzma2_bound(uint64_t uncompressed_size)
static lzma_ret block_encode_normal(lzma_block *block, const lzma_allocator *allocator, const uint8_t *in, size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size)
static lzma_ret block_buffer_encode(lzma_block *block, const lzma_allocator *allocator, const uint8_t *in, size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size, bool try_to_compress)
Single-call .xz Block encoder.
#define COMPRESSED_SIZE_MAX
Biggest Compressed Size value that the Block encoder supports.
void lzma_check_finish(lzma_check_state *check, lzma_check type)
Finish the check calculation and store the result to check->buffer.u8.
void lzma_check_update(lzma_check_state *check, lzma_check type, const uint8_t *buf, size_t size)
Update the check state.
void lzma_check_init(lzma_check_state *check, lzma_check type)
Initialize *check depending on type.
const lzma_filter * filters
lzma_ret lzma_raw_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, const lzma_filter *options)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
#define LZMA_FILTER_LZMA2
LZMA2 Filter ID.
#define LZMA_DICT_SIZE_MIN
#define LZMA2_HEADER_UNCOMPRESSED
Size of a header for uncompressed chunk.
#define LZMA2_CHUNK_MAX
Maximum number of bytes of actual data per chunk (no headers)
assert(limit<=UINT32_MAX/2)
Custom functions for memory handling.
Options for the Block and Block Header encoders and decoders.
lzma_vli uncompressed_size
Uncompressed Size in bytes.
uint8_t raw_check[LZMA_CHECK_SIZE_MAX]
Raw value stored in the Check field.
lzma_filter * filters
Array of filters.
uint32_t header_size
Size of the Block Header field.
lzma_check check
Type of integrity Check.
lzma_vli compressed_size
Size of the Compressed Data in bytes.
uint32_t version
Block format version.
Structure to hold internal state of the check being calculated.
void * options
Pointer to filter-specific options structure.
Hold data and function pointers of the next filter in the chain.
lzma_code_function code
Pointer to function to do the actual coding.
void * coder
Pointer to coder-specific data.
Options specific to the LZMA1 and LZMA2 filters.
uint32_t dict_size
Dictionary size in bytes.
#define LZMA_NEXT_CODER_INIT
Macro to initialize lzma_next_coder structure.
#define return_if_error(expr)
Return if expression doesn't evaluate to LZMA_OK.
uint64_t uncompressed_size
#define LZMA_VLI_UNKNOWN
VLI value to denote that the value is unknown.
lzma_ret
Return values used by several functions in liblzma.
@ LZMA_PROG_ERROR
Programming error.
@ LZMA_DATA_ERROR
Data is corrupt.
@ LZMA_STREAM_END
End of stream was reached.
@ LZMA_UNSUPPORTED_CHECK
Cannot calculate the integrity check.
@ LZMA_BUF_ERROR
No progress is possible.
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
@ LZMA_OK
Operation completed successfully.
@ LZMA_FINISH
Finish the coding operation.
void lzma_next_end(lzma_next_coder *next, const lzma_allocator *allocator)