19 #define BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2)
35 *bufs_alloc_size = *bufs_count * buf_size_max;
72 #if SIZE_MAX < UINT64_MAX
123 buf->finished =
false;
153 if (outq->bufs_used == 0)
157 uint32_t i = outq->bufs_pos - outq->bufs_used;
158 if (outq->bufs_pos < outq->bufs_used)
159 i += outq->bufs_allocated;
172 if (outq->read_pos <
buf->size)
const lzma_allocator lzma_vli unpadded_size
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
const lzma_allocator * allocator
const lzma_allocator const uint8_t size_t uint8_t * out
assert(limit<=UINT32_MAX/2)
lzma_outbuf * lzma_outq_get_buf(lzma_outq *outq)
Get a new buffer.
void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator)
Free the memory associated with the output queue.
static lzma_ret get_options(uint64_t *bufs_alloc_size, uint32_t *bufs_count, uint64_t buf_size_max, uint32_t threads)
bool lzma_outq_is_readable(const lzma_outq *outq)
Test if there is data ready to be read.
lzma_ret lzma_outq_read(lzma_outq *restrict outq, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, lzma_vli *restrict unpadded_size, lzma_vli *restrict uncompressed_size)
Read finished data.
uint64_t lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads)
Calculate the memory usage of an output queue.
lzma_ret lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator, uint64_t buf_size_max, uint32_t threads)
Initialize an output queue.
Output queue handling in multithreaded coding.
Custom functions for memory handling.
Output buffer for a single thread.
uint8_t * buf
Pointer to the output buffer of lzma_outq.buf_size_max bytes.
lzma_outbuf * bufs
Array of buffers that are used cyclically.
size_t buf_size_max
Amount of buffer space available in each buffer.
uint32_t bufs_allocated
Number of buffers allocated.
size_t read_pos
Position in the buffer in lzma_outq_read()
uint32_t bufs_used
Number of buffers in use.
uint8_t * bufs_mem
Memory allocated for all the buffers.
#define return_if_error(expr)
Return if expression doesn't evaluate to LZMA_OK.
void * lzma_alloc(size_t size, const lzma_allocator *allocator) lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
Allocates memory.
uint64_t uncompressed_size
static uv_thread_t * threads
uint64_t lzma_vli
Variable-length integer type.
lzma_ret
Return values used by several functions in liblzma.
@ LZMA_MEM_ERROR
Cannot allocate memory.
@ LZMA_STREAM_END
End of stream was reached.
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
@ LZMA_OK
Operation completed successfully.
void lzma_free(void *ptr, const lzma_allocator *allocator)
Frees memory.
size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size)