Single-call .xz Stream encoder. More...
#include "index.h"
Defines | |
#define | INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3) |
#define | HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND) |
Stream Header, Stream Footer, and Index. | |
Functions | |
size_t | lzma_stream_buffer_bound (size_t uncompressed_size) |
Calculate output buffer size for single-call Stream encoder. | |
lzma_ret | lzma_stream_buffer_encode (lzma_filter *filters, lzma_check check, lzma_allocator *allocator, const uint8_t *in, size_t in_size, uint8_t *out, size_t *out_pos_ptr, size_t out_size) |
Single-call .xz Stream encoder. |
Single-call .xz Stream encoder.
#define INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3) |
Maximum size of Index that has exactly one Record. Index Indicator + Number of Records + Record + CRC32 rounded up to the next multiple of four.
#define HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND) |
Stream Header, Stream Footer, and Index.
Referenced by lzma_stream_buffer_bound().
size_t lzma_stream_buffer_bound | ( | size_t | uncompressed_size | ) |
Calculate output buffer size for single-call Stream encoder.
When trying to compress uncompressible data, the encoded size will be slightly bigger than the input data. This function calculates how much output buffer space is required to be sure that lzma_stream_buffer_encode() doesn't return LZMA_BUF_ERROR.
The calculated value is not exact, but it is guaranteed to be big enough. The actual maximum output space required may be slightly smaller (up to about 100 bytes). This should not be a problem in practice.
If the calculated maximum size doesn't fit into size_t or would make the Stream grow past LZMA_VLI_MAX (which should never happen in practice), zero is returned to indicate the error.
References HEADERS_BOUND, lzma_block_buffer_bound(), and LZMA_VLI_MAX.
lzma_ret lzma_stream_buffer_encode | ( | lzma_filter * | filters, | |
lzma_check | check, | |||
lzma_allocator * | allocator, | |||
const uint8_t * | in, | |||
size_t | in_size, | |||
uint8_t * | out, | |||
size_t * | out_pos, | |||
size_t | out_size | |||
) |
Single-call .xz Stream encoder.
filters | Array of filters. This must be terminated with filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for more information. | |
check | Type of the integrity check to calculate from uncompressed data. | |
allocator | lzma_allocator for custom allocator functions. Set to NULL to use malloc() and free(). | |
in | Beginning of the input buffer | |
in_size | Size of the input buffer | |
out | Beginning of the output buffer | |
out_pos | The next byte will be written to out[*out_pos]. *out_pos is updated only if encoding succeeds. | |
out_size | Size of the out buffer; the first byte into which no data is written to is out[out_size]. |
References lzma_stream_flags::backward_size, lzma_block_buffer_encode(), lzma_block_unpadded_size(), LZMA_CHECK_ID_MAX, lzma_index_append(), lzma_index_buffer_encode(), lzma_index_end(), lzma_index_init(), lzma_index_size(), LZMA_OK, lzma_stream_footer_encode(), lzma_stream_header_encode(), LZMA_STREAM_HEADER_SIZE, return_if_error, and lzma_block::uncompressed_size.
Referenced by lzma_easy_buffer_encode().