XZ Utils 5.3.4alpha
|
Single-call .xz Block encoder. More...
#include "block_buffer_encoder.h"
#include "block_encoder.h"
#include "filter_encoder.h"
#include "lzma2_encoder.h"
#include "check.h"
Macros | |
#define | HEADERS_BOUND |
Functions | |
static uint64_t | lzma2_bound (uint64_t uncompressed_size) |
uint64_t | lzma_block_buffer_bound64 (uint64_t uncompressed_size) |
size_t | lzma_block_buffer_bound (size_t uncompressed_size) |
Calculate maximum output size for single-call Block encoding. More... | |
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 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) |
lzma_ret | lzma_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) |
Single-call .xz Block encoder. More... | |
lzma_ret | lzma_block_uncomp_encode (lzma_block *block, const uint8_t *in, size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size) |
Single-call uncompressed .xz Block encoder. More... | |
Single-call .xz Block encoder.
#define HEADERS_BOUND |
Estimate the maximum size of the Block Header and Check fields for a Block that uses LZMA2 uncompressed chunks. We could use lzma_block_header_size() but this is simpler.
Block Header Size + Block Flags + Compressed Size
uint64_t lzma_block_buffer_bound64 | ( | uint64_t | uncompressed_size | ) |
uint64_t version of lzma_block_buffer_bound(). It is used by stream_encoder_mt.c. Probably the original lzma_block_buffer_bound() should have been 64-bit, but fixing it would break the ABI.
size_t lzma_block_buffer_bound | ( | size_t | uncompressed_size | ) |
Calculate maximum output size for single-call Block encoding.
This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. See the documentation of lzma_stream_buffer_bound().
lzma_ret lzma_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 | ||
) |
Single-call .xz Block encoder.
In contrast to the multi-call encoder initialized with lzma_block_encoder(), this function encodes also the Block Header. This is required to make it possible to write appropriate Block Header also in case the data isn't compressible, and different filter chain has to be used to encode the data in uncompressed form using uncompressed chunks of the LZMA2 filter.
When the data isn't compressible, header_size, compressed_size, and uncompressed_size are set just like when the data was compressible, but it is possible that header_size is too small to hold the filter chain specified in block->filters, because that isn't necessarily the filter chain that was actually used to encode the data. lzma_block_unpadded_size() still works normally, because it doesn't read the filters array.
block | Block options: block->version, block->check, and block->filters must have been initialized. |
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]. |
lzma_ret lzma_block_uncomp_encode | ( | lzma_block * | block, |
const uint8_t * | in, | ||
size_t | in_size, | ||
uint8_t * | out, | ||
size_t * | out_pos, | ||
size_t | out_size | ||
) |
Single-call uncompressed .xz Block encoder.
This is like lzma_block_buffer_encode() except this doesn't try to compress the data and instead encodes the data using LZMA2 uncompressed chunks. The required output buffer size can be determined with lzma_block_buffer_bound().
Since the data won't be compressed, this function ignores block->filters. This function doesn't take lzma_allocator because this function doesn't allocate any memory from the heap.