ZXC 1.0.3
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
57
58#ifndef ZXC_PSTREAM_H
59#define ZXC_PSTREAM_H
60
61#include <stddef.h>
62#include <stdint.h>
63
64#include "zxc_buffer.h"
65#include "zxc_export.h"
66#include "zxc_opts.h"
67
68#ifdef __cplusplus
69extern "C" {
70#endif
71
77
84typedef struct {
85 const void* src;
86 size_t size;
87 size_t pos;
89
103typedef struct {
104 void* dst;
105 size_t size;
106 size_t pos;
108
109/* Opaque streaming contexts. */
111typedef struct zxc_cstream_s zxc_cstream;
113typedef struct zxc_dstream_s zxc_dstream;
114
115/* ===== Compression =================================================== */
116
135ZXC_EXPORT zxc_cstream* zxc_cstream_create(const zxc_cctx* cfg);
136
144ZXC_EXPORT void zxc_cstream_free(zxc_cstream* cs);
145
175ZXC_EXPORT int64_t zxc_cstream_compress(zxc_cstream* cs, zxc_outbuf_t* out, zxc_inbuf_t* in);
176
194ZXC_EXPORT int64_t zxc_cstream_end(zxc_cstream* cs, zxc_outbuf_t* out);
195
204ZXC_EXPORT size_t zxc_cstream_in_size(const zxc_cstream* cs);
205
215ZXC_EXPORT size_t zxc_cstream_out_size(const zxc_cstream* cs);
216
217/* ===== Decompression ================================================= */
218
233ZXC_EXPORT zxc_dstream* zxc_dstream_create(const zxc_dctx* cfg);
234
240ZXC_EXPORT void zxc_dstream_free(zxc_dstream* ds);
241
269ZXC_EXPORT int64_t zxc_dstream_decompress(zxc_dstream* ds, zxc_outbuf_t* out, zxc_inbuf_t* in);
270
283ZXC_EXPORT int zxc_dstream_finished(const zxc_dstream* ds);
284
291ZXC_EXPORT size_t zxc_dstream_in_size(const zxc_dstream* ds);
292
301ZXC_EXPORT size_t zxc_dstream_out_size(const zxc_dstream* ds);
302 /* end of pstream */
304
305#ifdef __cplusplus
306}
307#endif
308
309#endif /* ZXC_PSTREAM_H */
struct zxc_cctx_s zxc_cctx
Opaque reusable compression context (see zxc_create_cctx).
Definition zxc_buffer.h:370
struct zxc_dctx_s zxc_dctx
Opaque reusable decompression context (see zxc_create_dctx).
Definition zxc_buffer.h:372
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.
zxc_cstream * zxc_cstream_create(const zxc_cctx *cfg)
Creates a push compression stream.
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_dctx *cfg)
Creates a push decompression 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.
Input buffer descriptor for push streaming.
Definition zxc_pstream.h:84
size_t size
Total bytes available in src.
Definition zxc_pstream.h:86
size_t pos
Bytes already consumed by the library (in/out).
Definition zxc_pstream.h:87
const void * src
Caller-owned input bytes.
Definition zxc_pstream.h:85
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).
One-shot buffer compression and decompression.
Platform-specific symbol visibility macros.
Compression and decompression parameters.