ZXC 1.0.3
High-performance asymmetric lossless compression library
Loading...
Searching...
No Matches
zxc_opts.h File Reference

Compression and decompression parameters. More...

#include <stddef.h>
#include <stdint.h>
#include "zxc_export.h"

Go to the source code of this file.

Typedefs

typedef void(* zxc_progress_callback_t) (uint64_t bytes_processed, uint64_t bytes_total, const void *user_data)
 Progress callback function type.

Enumerations

enum  zxc_cparam_t {
  ZXC_C_LEVEL = 1 , ZXC_C_BLOCK_SIZE = 2 , ZXC_C_THREADS = 3 , ZXC_C_CHECKSUM = 4 ,
  ZXC_C_SEEKABLE = 5
}
 Compression parameters, set on a zxc_cctx with zxc_cctx_set_param(). More...
enum  zxc_dparam_t { ZXC_D_THREADS = 1 , ZXC_D_CHECKSUM = 2 }
 Decompression parameters, set on a zxc_dctx with zxc_dctx_set_param(). More...

Functions

int zxc_cparam_bounds (zxc_cparam_t param, int64_t *min, int64_t *max)
 Reports the accepted range of a compression parameter.
int zxc_dparam_bounds (zxc_dparam_t param, int64_t *min, int64_t *max)
 Reports the accepted range of a decompression parameter.

Detailed Description

Compression and decompression parameters.

The parameter identifiers set on a context with zxc_cctx_set_param() and zxc_dctx_set_param() (zxc_cparam_t, zxc_dparam_t), their bounds, and zxc_progress_callback_t. A configured context carries these settings into every public API: one-shot buffer, multi-threaded FILE* streaming, push streaming, block. No need to include it directly: the API header you actually use (zxc_buffer.h, zxc_stream.h, zxc_pstream.h, ...) pulls it in.

Definition in file zxc_opts.h.

Typedef Documentation

◆ zxc_progress_callback_t

typedef void(* zxc_progress_callback_t) (uint64_t bytes_processed, uint64_t bytes_total, const void *user_data)

Progress callback function type.

Called from the writer thread after each block, or batch of blocks, is processed.

Parameters
[in]bytes_processedInput bytes processed so far.
[in]bytes_totalTotal input bytes to process (0 if unknown, e.g. stdin).
[in]user_dataContext pointer passed through from the API call.
Note
Keep it fast and non-blocking: no heavy I/O, no mutex.

Definition at line 40 of file zxc_opts.h.

Enumeration Type Documentation

◆ zxc_cparam_t

Compression parameters, set on a zxc_cctx with zxc_cctx_set_param().

Every parameter has a default, which the value 0 restores (zxc_cctx_reset() restores them all). Any other value must sit within the bounds reported by zxc_cparam_bounds(). Identifiers are stable: new parameters are appended, and an existing value never changes meaning. The dictionary and the progress callback are pointers, so they have their own setters, zxc_cctx_set_dict() and zxc_cctx_set_progress().

Enumerator
ZXC_C_LEVEL 

Compression level, 1 to 7 (zxc_compression_level_t); default ZXC_LEVEL_DEFAULT.

ZXC_C_BLOCK_SIZE 

Block size in bytes, a power of two in [ZXC_BLOCK_SIZE_MIN, ZXC_BLOCK_SIZE_MAX]; default ZXC_BLOCK_SIZE_DEFAULT.

ZXC_C_THREADS 

Workers of the FILE* pipeline, at most ZXC_MAX_THREADS; the reader and writer come on top.

0 (default): online processors, capped at ZXC_MAX_THREADS, minus one; at least one, at most 511. The buffer, block and push APIs are single-threaded and ignore it.

ZXC_C_CHECKSUM 

1 appends the block checksums and the archive digest; default 0.

ZXC_C_SEEKABLE 

1 appends a seek table for random-access decompression; default 0.

Definition at line 53 of file zxc_opts.h.

◆ zxc_dparam_t

Decompression parameters, set on a zxc_dctx with zxc_dctx_set_param().

Same rules as zxc_cparam_t, so 0 restores the default and other values must sit within zxc_dparam_bounds(). The dictionary and the progress callback go through zxc_dctx_set_dict() and zxc_dctx_set_progress().

Enumerator
ZXC_D_THREADS 

Workers of the FILE* pipeline, at most ZXC_MAX_THREADS; the reader and writer come on top.

0 (default): online processors, capped at ZXC_MAX_THREADS, minus one unless the workers read a regular file themselves; at least one, at most 511 or 512.

ZXC_D_CHECKSUM 

1 verifies the block checksums and the archive digest when the archive carries them; default 0, no verification.

Definition at line 78 of file zxc_opts.h.

Function Documentation

◆ zxc_cparam_bounds()

int zxc_cparam_bounds ( zxc_cparam_t param,
int64_t * min,
int64_t * max )

Reports the accepted range of a compression parameter.

Lets a caller, or a binding, validate a value before setting it, and tells whether this library knows param at all. The range is necessary, not always sufficient: ZXC_C_BLOCK_SIZE must also be a power of two, which only zxc_cctx_set_param() checks.

Parameters
[in]paramParameter identifier.
[out]minLowest accepted value; may be NULL.
[out]maxHighest accepted value; may be NULL.
Returns
ZXC_OK, or ZXC_ERROR_BAD_PARAM for an unknown param.

Definition at line 1123 of file zxc_dispatch.c.

References ZXC_BLOCK_SIZE_MAX, ZXC_BLOCK_SIZE_MIN, ZXC_C_BLOCK_SIZE, ZXC_C_CHECKSUM, ZXC_C_LEVEL, ZXC_C_SEEKABLE, ZXC_C_THREADS, ZXC_ERROR_BAD_PARAM, ZXC_LEVEL_FASTEST, ZXC_LEVEL_ULTRA, ZXC_MAX_THREADS, and ZXC_OK.

Referenced by zxc_cctx_set_param().

◆ zxc_dparam_bounds()

int zxc_dparam_bounds ( zxc_dparam_t param,
int64_t * min,
int64_t * max )

Reports the accepted range of a decompression parameter.

See also
zxc_cparam_bounds

Definition at line 1448 of file zxc_dispatch.c.

References ZXC_D_CHECKSUM, ZXC_D_THREADS, ZXC_ERROR_BAD_PARAM, ZXC_MAX_THREADS, and ZXC_OK.

Referenced by zxc_dctx_set_param().