ZXC 0.15.0
High-performance asymmetric lossless compression library
Loading...
Searching...
No Matches
zxc_seekable.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * ZXC - High-performance lossless compression
4 *
5 * Copyright (c) Bertrand Lebonnois and contributors.
6 */
7
59#ifndef ZXC_SEEKABLE_H
60#define ZXC_SEEKABLE_H
61
62#include <stddef.h>
63#include <stdint.h>
64
65#include "zxc_export.h"
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
77/* ========================================================================= */
78/* Seekable Reader (Random-Access Decompression) */
79/* ========================================================================= */
80
88typedef struct zxc_seekable_s zxc_seekable;
89
103ZXC_EXPORT zxc_seekable* zxc_seekable_open(const void* src, const size_t src_size);
104
120typedef struct {
132 int64_t (*read_at)(void* ctx, void* dst, size_t len, uint64_t offset);
133
135 void* ctx;
136
138 uint64_t size;
140
153
163ZXC_EXPORT uint64_t zxc_seekable_get_num_blocks(const zxc_seekable* s);
164
171ZXC_EXPORT uint64_t zxc_seekable_get_decompressed_size(const zxc_seekable* s);
172
185ZXC_EXPORT uint32_t zxc_seekable_get_block_comp_size(const zxc_seekable* s,
186 const uint64_t block_idx);
187
195ZXC_EXPORT uint32_t zxc_seekable_get_block_decomp_size(const zxc_seekable* s,
196 const uint64_t block_idx);
197
218ZXC_EXPORT int64_t zxc_seekable_decompress_range(zxc_seekable* s, void* dst,
219 const size_t dst_capacity, const uint64_t offset,
220 const size_t len);
221
242ZXC_EXPORT int64_t zxc_seekable_decompress_range_mt(zxc_seekable* s, void* dst,
243 const size_t dst_capacity,
244 const uint64_t offset, const size_t len,
245 int n_threads);
246
254ZXC_EXPORT void zxc_seekable_free(zxc_seekable* s);
255
268ZXC_EXPORT int zxc_seekable_set_checksum(zxc_seekable* s, int enabled);
269
288ZXC_EXPORT int zxc_seekable_set_dict(zxc_seekable* s, const void* dict, size_t dict_size,
289 const void* dict_huf);
290
291/* ========================================================================= */
292/* Seek Table Writer (low-level) */
293/* ========================================================================= */
294
309ZXC_EXPORT int64_t zxc_write_seek_table(uint8_t* dst, const size_t dst_capacity,
310 const uint32_t* comp_sizes, const uint64_t num_blocks);
311
318ZXC_EXPORT size_t zxc_seek_table_size(const uint64_t num_blocks);
319
/* end of seekable_api */
321
322#ifdef __cplusplus
323}
324#endif
325
326#endif /* ZXC_SEEKABLE_H */
int64_t zxc_seekable_decompress_range_mt(zxc_seekable *s, void *dst, const size_t dst_capacity, const uint64_t offset, const size_t len, int n_threads)
Multi-threaded variant of zxc_seekable_decompress_range().
void zxc_seekable_free(zxc_seekable *s)
Frees a seekable handle and all associated resources.
int64_t zxc_seekable_decompress_range(zxc_seekable *s, void *dst, const size_t dst_capacity, const uint64_t offset, const size_t len)
Decompresses an arbitrary byte range of the original data.
uint64_t zxc_seekable_get_num_blocks(const zxc_seekable *s)
Returns the total number of blocks in the seekable archive.
uint32_t zxc_seekable_get_block_decomp_size(const zxc_seekable *s, const uint64_t block_idx)
Returns the decompressed size of a specific block.
int64_t zxc_write_seek_table(uint8_t *dst, const size_t dst_capacity, const uint32_t *comp_sizes, const uint64_t num_blocks)
Writes a seek table to the destination buffer.
Definition zxc_common.c:786
size_t zxc_seek_table_size(const uint64_t num_blocks)
Returns the encoded size of a seek table for the given block count.
Definition zxc_common.c:731
uint64_t zxc_seekable_get_decompressed_size(const zxc_seekable *s)
Returns the total decompressed size of the seekable archive.
int zxc_seekable_set_dict(zxc_seekable *s, const void *dict, size_t dict_size, const void *dict_huf)
Attaches a pre-trained dictionary to a seekable handle.
uint32_t zxc_seekable_get_block_comp_size(const zxc_seekable *s, const uint64_t block_idx)
Returns the compressed size of a specific block.
int zxc_seekable_set_checksum(zxc_seekable *s, int enabled)
Turns per-block checksum verification on or off.
zxc_seekable * zxc_seekable_open(const void *src, const size_t src_size)
Opens a seekable archive from a memory buffer.
zxc_seekable * zxc_seekable_open_reader(const zxc_reader_t *r)
Opens a seekable archive through a user-supplied reader.
struct zxc_seekable_s zxc_seekable
Opaque handle for a seekable ZXC archive.
Storage-agnostic reader interface for seekable archives.
uint64_t size
Total size of the compressed archive in bytes.
void * ctx
Opaque user context passed unchanged to read_at.
Platform-specific symbol visibility macros.