ZXC 0.15.0
High-performance asymmetric lossless compression library
Loading...
Searching...
No Matches
zxc_pstream.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
56#ifndef ZXC_PSTREAM_H
57#define ZXC_PSTREAM_H
58
59#include <stddef.h>
60#include <stdint.h>
61
62#include "zxc_export.h"
63#include "zxc_opts.h"
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
81typedef struct {
82 const void* src;
83 size_t size;
84 size_t pos;
86
100typedef struct {
101 void* dst;
102 size_t size;
103 size_t pos;
105
106/* Opaque streaming contexts. */
108typedef struct zxc_cstream_s zxc_cstream;
110typedef struct zxc_dstream_s zxc_dstream;
111
112/* ===== Compression =================================================== */
113
131ZXC_EXPORT zxc_cstream* zxc_cstream_create(const zxc_compress_opts_t* opts);
132
140ZXC_EXPORT void zxc_cstream_free(zxc_cstream* cs);
141
171ZXC_EXPORT int64_t zxc_cstream_compress(zxc_cstream* cs, zxc_outbuf_t* out, zxc_inbuf_t* in);
172
190ZXC_EXPORT int64_t zxc_cstream_end(zxc_cstream* cs, zxc_outbuf_t* out);
191
200ZXC_EXPORT size_t zxc_cstream_in_size(const zxc_cstream* cs);
201
211ZXC_EXPORT size_t zxc_cstream_out_size(const zxc_cstream* cs);
212
213/* ===== Decompression ================================================= */
214
230
236ZXC_EXPORT void zxc_dstream_free(zxc_dstream* ds);
237
265ZXC_EXPORT int64_t zxc_dstream_decompress(zxc_dstream* ds, zxc_outbuf_t* out, zxc_inbuf_t* in);
266
279ZXC_EXPORT int zxc_dstream_finished(const zxc_dstream* ds);
280
287ZXC_EXPORT size_t zxc_dstream_in_size(const zxc_dstream* ds);
288
297ZXC_EXPORT size_t zxc_dstream_out_size(const zxc_dstream* ds);
298
/* end of pstream */
300
301#ifdef __cplusplus
302}
303#endif
304
305#endif /* ZXC_PSTREAM_H */
struct zxc_dstream_s zxc_dstream
Opaque push-model decompression stream (see zxc_dstream_create).
size_t zxc_dstream_out_size(const zxc_dstream *ds)
Suggested output chunk size for the decompressor.
void zxc_cstream_free(zxc_cstream *cs)
Releases a compression stream and all internal buffers.
struct zxc_cstream_s zxc_cstream
Opaque push-model compression stream (see zxc_cstream_create).
size_t zxc_dstream_in_size(const zxc_dstream *ds)
Suggested input chunk size for the decompressor.
size_t zxc_cstream_out_size(const zxc_cstream *cs)
Suggested output chunk size that never triggers a partial drain.
int64_t zxc_dstream_decompress(zxc_dstream *ds, zxc_outbuf_t *out, zxc_inbuf_t *in)
Pushes compressed input and drains decompressed output.
size_t zxc_cstream_in_size(const zxc_cstream *cs)
Suggested input chunk size for best throughput.
void zxc_dstream_free(zxc_dstream *ds)
Releases a decompression stream.
zxc_dstream * zxc_dstream_create(const zxc_decompress_opts_t *opts)
Creates a push decompression stream.
zxc_cstream * zxc_cstream_create(const zxc_compress_opts_t *opts)
Creates a push compression stream.
int64_t zxc_cstream_compress(zxc_cstream *cs, zxc_outbuf_t *out, zxc_inbuf_t *in)
Pushes input bytes into the stream and drains compressed output.
int64_t zxc_cstream_end(zxc_cstream *cs, zxc_outbuf_t *out)
Finalises the stream: flushes pending data, writes EOF block + footer.
int zxc_dstream_finished(const zxc_dstream *ds)
Reports whether the decoder has fully consumed a valid stream.
Options for compression.
Definition zxc_opts.h:58
Options for decompression.
Definition zxc_opts.h:86
Input buffer descriptor for push streaming.
Definition zxc_pstream.h:81
size_t size
Total bytes available in src.
Definition zxc_pstream.h:83
size_t pos
Bytes already consumed by the library (in/out).
Definition zxc_pstream.h:84
const void * src
Caller-owned input bytes.
Definition zxc_pstream.h:82
Output buffer descriptor for push streaming.
size_t size
Total capacity available at dst.
void * dst
Caller-owned output region.
size_t pos
Bytes already produced by the library (in/out).
Platform-specific symbol visibility macros.
Shared option structures for the ZXC compression APIs.