|
ZXC 0.15.0
High-performance asymmetric lossless compression library
|
Block-level decompression: GLO / GHI / RAW decoding with SIMD-accelerated bit-unpacking and overlapping copies. More...
Go to the source code of this file.
Macros | |
| #define | DECODE_MATCH_SAFE(ml, off, COPY) |
| #define | DECODE_MATCH_FAST(ml, off, COPY) |
| #define | GLO_OFF8 (gh.enc_off == 1) |
| True when the GLO offset stream stores 1-byte offsets, 2-byte otherwise. | |
| #define | DECODE_GLO_SEQ(LL, ML, OFF, RESERVE, N_REM, DECODE, ON_FAIL) |
Decodes one GLO sequence of a 4x batch: extracts ll/ml, applies the varint extensions with their bounds checks, then emits via DECODE. | |
| #define | DECODE_GLO_BATCH_4X(DECODE, ON_FAIL) |
| One full GLO 4x batch: token word, four offsets (1- or 2-byte form), four DECODE_GLO_SEQ emissions, sequence-count update. | |
| #define | DECODE_GHI_SEQ(S, RESERVE, N_REM, DECODE, ON_FAIL) |
GHI twin of DECODE_GLO_SEQ, decoding one sequence word S (ll in the top byte, ml bits, 16-bit offset). | |
| #define | DECODE_GHI_BATCH_4X(DECODE, ON_FAIL, PREFETCH) |
| One full GHI 4x batch. | |
Functions | |
| static void | zxc_decode_copy_overlap_run32 (uint8_t *dst, const uint32_t off, const uint64_t ml) |
Copies an ml-byte run of period off (2..31) with 32-byte stores. | |
| static void | zxc_decode_copy_overlap_short (uint8_t *dst, const uint32_t off, const uint64_t ml) |
Overlap copy for a run of period off (2..31) bounded by ml <= 32. | |
| static void | zxc_decode_fill_run (uint8_t *dst, const uint8_t byte, const uint64_t ml) |
Fills an ml-byte single-byte run (LZ offset == 1) with wild stores. | |
| static void | zxc_wild_copy32 (uint8_t *dst, const uint8_t *src, const size_t len) |
Copies len bytes in 32-byte wild chunks (the zxc_copy32 width). | |
| static void | zxc_decode_copy_literals (uint8_t *dst, const uint8_t *src, const uint64_t ll) |
Copies ll literal bytes from src to dst using 32-byte wild copies. | |
| static void | zxc_decode_copy_match (uint8_t *d_ptr, const uint32_t off, const uint64_t ml) |
Copies an ml-byte LZ match from d_ptr-off to d_ptr, handling overlap. | |
| static void | zxc_decode_copy_match_short (uint8_t *d_ptr, const uint32_t off, const uint64_t ml) |
| Match copy for a length that cannot exceed 32 bytes. | |
| static void | zxc_decode_copy_match_glo (uint8_t *d_ptr, const uint32_t off, const uint64_t ml) |
| GLO match copy: bounded form when the ml nibble did not saturate. | |
| static void | zxc_decode_copy_match_exact (uint8_t *d_ptr, const uint8_t *match_src, const size_t off, const size_t ml) |
| Exact-size match copy for the tail loops (no overshoot headroom). | |
| static int | zxc_ensure_entropy_scratch (const zxc_cctx_t *ctx) |
| Ensures the entropy decode scratch (tok_buffer + pivco_scratch) is available before decoding an entropy section. | |
| static int | zxc_decode_lit_pivco (const zxc_cctx_t *ctx, const uint8_t *payload, const size_t psize, const size_t required_size) |
| static int | zxc_decode_lit_pivco_dict (const zxc_cctx_t *ctx, const uint8_t *payload, const size_t psize, const size_t required_size) |
| static int | zxc_decode_tok_pivco (const zxc_cctx_t *ctx, const uint8_t *payload, const size_t psize, const size_t n_tok) |
| static int | zxc_decode_block_glo_entropy (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Cold specializations for entropy-coded GLO tokens (level 7). | |
| static int | zxc_decode_block_glo_entropy_dict (const zxc_cctx_t *ctx, const uint8_t *src, size_t src_size, uint8_t *dst, size_t dst_capacity) |
| static int | zxc_decode_block_glo_entropy_safe (const zxc_cctx_t *ctx, const uint8_t *src, size_t src_size, uint8_t *dst, size_t dst_capacity) |
| static int | zxc_decode_block_glo_impl (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const int safe, const int has_dict, const int tok_entropy) |
| Unified GLO (General Low) block decoder body, shared by the fast, safe, dictionary and entropy-token variants. | |
| static int | zxc_decode_block_ghi_impl (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const int safe, const int has_dict) |
| Unified GHI (General High) block decoder body, shared by the fast, safe and dictionary variants. | |
| static int | zxc_decode_block_glo (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a no-dict GLO block (plain, inlinable path). | |
| static int | zxc_decode_block_ghi (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a no-dict GHI block (plain, inlinable path). | |
| static int | zxc_decode_block_glo_dict (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a GLO block against a dictionary prefix (cold path). | |
| static int | zxc_decode_block_ghi_dict (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a GHI block against a dictionary prefix (cold path). | |
| static int | zxc_decode_block_glo_safe (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a GLO block with the strict-tail safe loop (no wild copies). | |
| static int | zxc_decode_block_ghi_safe (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity) |
| Decode a GHI block with the strict-tail safe loop (no wild copies). | |
| static int | zxc_decompress_chunk_wrapper_body (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index, const int has_dict, const int safe) |
| Shared chunk-decode body: validates the header, decodes, then verifies the optional checksum. | |
| int | zxc_decompress_chunk_wrapper (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index) |
| Public no-dict chunk decoder (decompression hot path). | |
| int | zxc_decompress_chunk_wrapper_dict (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index) |
| Public dictionary chunk decoder. | |
| int | zxc_decompress_chunk_wrapper_safe (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index) |
| Public strict-tail safe chunk decoder (dst_cap == exact decoded size). | |
Variables | |
| static const uint8_t | zxc_overlap_strides32 [32] |
Store stride for the 32-byte pattern: (32 / off) * off. | |
Block-level decompression: GLO / GHI / RAW decoding with SIMD-accelerated bit-unpacking and overlapping copies.
Like zxc_compress.c, this file is compiled multiple times with ZXC_FUNCTION_SUFFIX to produce per-ISA variants.
Definition in file zxc_decompress.c.
| #define DECODE_GHI_BATCH_4X | ( | DECODE, | |
| ON_FAIL, | |||
| PREFETCH | |||
| ) |
One full GHI 4x batch.
PREFETCH is the literal-stream prefetch statement of the post-threshold FAST loops ((void)0 elsewhere), placed exactly where the hand-unrolled bodies had it.
Definition at line 675 of file zxc_decompress.c.
| #define DECODE_GHI_SEQ | ( | S, | |
| RESERVE, | |||
| N_REM, | |||
| DECODE, | |||
| ON_FAIL | |||
| ) |
GHI twin of DECODE_GLO_SEQ, decoding one sequence word S (ll in the top byte, ml bits, 16-bit offset).
References the call site's extras_ptr/extras_end instead of e_ptr/e_end.
Definition at line 642 of file zxc_decompress.c.
| #define DECODE_GLO_BATCH_4X | ( | DECODE, | |
| ON_FAIL | |||
| ) |
One full GLO 4x batch: token word, four offsets (1- or 2-byte form), four DECODE_GLO_SEQ emissions, sequence-count update.
The offsets stay packed in one u64 of 16-bit lanes, 1-byte offsets spread into it, and each sequence extracts its own: four decoded offsets held live cost x86-64 spills.
Definition at line 608 of file zxc_decompress.c.
| #define DECODE_GLO_SEQ | ( | LL, | |
| ML, | |||
| OFF, | |||
| RESERVE, | |||
| N_REM, | |||
| DECODE, | |||
| ON_FAIL | |||
| ) |
Decodes one GLO sequence of a 4x batch: extracts ll/ml, applies the varint extensions with their bounds checks, then emits via DECODE.
Like DECODE_MATCH_SAFE, references the call site's local names (e_ptr, e_end, l_ptr, l_end, d_ptr, d_end). RESERVE is the sum of the inline (pre-varint) literal lengths of the batch's remaining sequences, so one l_ptr bound covers the whole batch; N_REM counts the remaining sequences, reserving their worst-case inline output in the d_ptr bound (0 for the last sequence - the compiler folds the dead terms). ON_FAIL is goto rollback_* in the state-saving safe variants and return ZXC_ERROR_OVERFLOW otherwise.
Definition at line 568 of file zxc_decompress.c.
| #define DECODE_MATCH_FAST | ( | ml, | |
| off, | |||
| COPY | |||
| ) |
Definition at line 536 of file zxc_decompress.c.
| #define DECODE_MATCH_SAFE | ( | ml, | |
| off, | |||
| COPY | |||
| ) |
Definition at line 527 of file zxc_decompress.c.
| #define GLO_OFF8 (gh.enc_off == 1) |
True when the GLO offset stream stores 1-byte offsets, 2-byte otherwise.
The single definition of the offset width: the stream-size check, the validation span and every read site expand from this, so a bound can never drift from the width actually consumed. A macro rather than a local flag on purpose – holding one more value live across the decode costs more spills in these register-starved loops than re-reading the header field.
References the call site's gh, like the DECODE_* macros below.
Definition at line 553 of file zxc_decompress.c.
|
static |
Decode a no-dict GHI block (plain, inlinable path).
Wrapper over zxc_decode_block_ghi_impl with safe=0, has_dict=0.
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed GHI block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer. |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1474 of file zxc_decompress.c.
|
static |
Decode a GHI block against a dictionary prefix (cold path).
Wrapper over zxc_decode_block_ghi_impl with safe=0, has_dict=1 (NOINLINE; see zxc_decode_block_glo_dict).
| [in,out] | ctx | Decompression context (dict prefix in its buffer). |
| [in] | src | Compressed GHI block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer. |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1514 of file zxc_decompress.c.
|
inlinestatic |
Unified GHI (General High) block decoder body, shared by the fast, safe and dictionary variants.
Decodes a block in the internal GHI format. The decompressed size is not on the wire: it falls out of walking the sequences. safe and has_dict must be compile-time constants (0 or 1): the 4x-unrolled loops are duplicated inside if(safe)/else branches so each variant keeps single-assignment const save pointers, and after constant propagation only one branch survives per wrapper.
| [in,out] | ctx | Decompression context (dict buffer, tables). |
| [in] | src | Compressed block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer for decoded bytes. |
| [in] | dst_capacity | Capacity of dst in bytes. |
| [in] | safe | Compile-time flag: 1 = strict bounds-checked loop. |
| [in] | has_dict | Compile-time flag: 1 = resolve matches against a dict prefix. |
dst on success, or a negative zxc_error_t. Definition at line 1173 of file zxc_decompress.c.
|
static |
Decode a GHI block with the strict-tail safe loop (no wild copies).
Wrapper over zxc_decode_block_ghi_impl with safe=1, has_dict=0 (the strict-tail safe path never carries a dict; see zxc_decode_block_glo_safe).
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed GHI block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer (capacity == exact decoded size). |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1556 of file zxc_decompress.c.
|
static |
Decode a no-dict GLO block (plain, inlinable path).
Wrapper over zxc_decode_block_glo_impl with safe=0, has_dict=0, so the no-dict chunk wrapper inlines it exactly like the dict-free build.
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed GLO block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer. |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1456 of file zxc_decompress.c.
|
static |
Decode a GLO block against a dictionary prefix (cold path).
Wrapper over zxc_decode_block_glo_impl with safe=0, has_dict=1. NOINLINE: only reached on the cold dict path (zxc_decompress_chunk_wrapper_dict), so it never loads into I-cache on a no-dict stream.
| [in,out] | ctx | Decompression context (dict prefix in its buffer). |
| [in] | src | Compressed GLO block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer. |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1494 of file zxc_decompress.c.
|
static |
Cold specializations for entropy-coded GLO tokens (level 7).
Each wrapper fixes tok_entropy=1 plus one (safe, has_dict) combo as compile-time constants, so the inlined impl is fully specialized and the RAW-token fast path stays untouched.
Definition at line 1420 of file zxc_decompress.c.
|
static |
Definition at line 1427 of file zxc_decompress.c.
|
static |
Definition at line 1435 of file zxc_decompress.c.
|
inlinestatic |
Unified GLO (General Low) block decoder body, shared by the fast, safe, dictionary and entropy-token variants.
Decodes a block in the internal GLO format. The decompressed size is not on the wire: it falls out of walking the sequences. safe, has_dict and tok_entropy must be compile-time constants (0 or 1): the 4x-unrolled loops are duplicated inside if(safe)/else branches so each variant keeps single-assignment const save pointers, and after constant propagation only one branch survives per wrapper (codegen equivalent to a hand-written pair).
The tok_entropy dimension keeps the token pointer on a SINGLE provenance per instantiation (in-place src tokens vs ctx->tok_buffer): the tok_entropy=0 instantiations tail-call their entropy twin right after the header parse when they meet enc_tok == 2.
| [in,out] | ctx | Decompression context (dict buffer, scratch). |
| [in] | src | Compressed block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer for decoded bytes. |
| [in] | dst_capacity | Capacity of dst in bytes. |
| [in] | safe | Compile-time flag: 1 = strict bounds-checked loop. |
| [in] | has_dict | Compile-time flag: 1 = resolve matches against a dict prefix. |
| [in] | tok_entropy | Compile-time flag: 1 = tokens are a PivCo section decoded into ctx->tok_buffer (level 7). |
dst on success, or a negative zxc_error_t. Definition at line 787 of file zxc_decompress.c.
|
static |
Decode a GLO block with the strict-tail safe loop (no wild copies).
Wrapper over zxc_decode_block_glo_impl with safe=1, has_dict=0. The safe path never carries a dict (block_safe routes dict inputs to the bounce path), so has_dict=0 folds the dead dict handling.
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed GLO block payload. |
| [in] | src_size | Size of src in bytes. |
| [out] | dst | Destination buffer (capacity == exact decoded size). |
| [in] | dst_capacity | Capacity of dst in bytes. |
Definition at line 1535 of file zxc_decompress.c.
|
inlinestatic |
Copies ll literal bytes from src to dst using 32-byte wild copies.
Writes in 32-byte chunks – the width of zxc_copy32 – and may overshoot by up to 31 bytes past ll; the caller must guarantee dst has at least ZXC_PAD_SIZE bytes of writable headroom (the unrolled loops and the trailing-literal margins ensure this). Pointers are taken by value and the caller advances its own cursors by ll, keeping them in registers on the hot path.
| [out] | dst | Output cursor. Must not overlap src and must have ZXC_PAD_SIZE bytes of overshoot headroom. |
| [in] | src | Literal-stream source. Must not overlap dst (RESTRICT). |
| [in] | ll | Number of literal bytes to copy. |
Definition at line 403 of file zxc_decompress.c.
References zxc_wild_copy32().
|
inlinestatic |
Copies an ml-byte LZ match from d_ptr-off to d_ptr, handling overlap.
The source d_ptr-off may overlap the destination (the LZ repeat case), so the copy strategy is chosen by back-reference distance:
off >= 32 : 32-byte wild copies (no overlap within a chunk);off == 1 : single-byte run via zxc_decode_fill_run;The 32 and 16 below are the widths of zxc_copy32 and zxc_copy16 – a copy may never be wider than the distance it reads back, or it would read bytes it is still writing. They are not ZXC_PAD_SIZE, which measures the overshoot the caller leaves writable and merely happens to equal 32.
Like zxc_decode_copy_literals it may overshoot up to 31 bytes past ml, so d_ptr must have ZXC_PAD_SIZE bytes of headroom. d_ptr is taken by value; the caller advances its cursor by ml.
| [in,out] | d_ptr | Output cursor; the match source is d_ptr-off. Must have ZXC_PAD_SIZE bytes of overshoot headroom. |
| [in] | off | Resolved (bias-removed) back-reference distance, >= 1. |
| [in] | ml | Match length in bytes (>= ZXC_LZ_MIN_MATCH_LEN). |
Definition at line 432 of file zxc_decompress.c.
References zxc_decode_copy_overlap_run32(), zxc_decode_fill_run(), and zxc_wild_copy32().
Referenced by zxc_decode_copy_match_glo().
|
static |
Exact-size match copy for the tail loops (no overshoot headroom).
The tail/remaining-sequence loops validate against d_end exactly, so the wild-copy ladder above (which overshoots up to ZXC_PAD_SIZE) is off limits there. For overlapping matches this expands the run by doubling: every ZXC_MEMCPY source range ends at or before its destination start, and nothing is written past d_ptr+ml. Since each copied prefix length is a multiple of off, the result is byte-identical to the naive per-byte copy, in O(log(ml/off)) calls instead of O(ml) iterations.
| [in,out] | d_ptr | Output cursor (match source is d_ptr-off). |
| [in] | match_src | Match source, equal to d_ptr-off. |
| [in] | off | Back-reference distance, >= 1. |
| [in] | ml | Match length in bytes. |
Definition at line 503 of file zxc_decompress.c.
|
inlinestatic |
GLO match copy: bounded form when the ml nibble did not saturate.
The test is exact (the escape always yields more) and statically decidable from either predecessor, so jump threading folds it away. GHI uses zxc_decode_copy_match directly - its inline ml reaches 259.
Definition at line 478 of file zxc_decompress.c.
References zxc_decode_copy_match(), zxc_decode_copy_match_short(), and ZXC_GLO_MAX_INLINE_ML.
|
inlinestatic |
Match copy for a length that cannot exceed 32 bytes.
zxc_decode_copy_match without its length ladder, which a bounded ml makes unreachable. Below 32 a full-width copy would read destination bytes not written yet, hence the overlap form.
The 32 is the width of zxc_copy32, not ZXC_PAD_SIZE - they only happen to share a value.
| [in,out] | d_ptr | Output cursor; match source is d_ptr-off. Needs ZXC_PAD_SIZE bytes of overshoot headroom. |
| [in] | off | Resolved back-reference distance, >= 1. |
| [in] | ml | Match length, <= 32 (caller's obligation). |
Definition at line 459 of file zxc_decompress.c.
References zxc_copy32(), zxc_decode_copy_overlap_short(), and zxc_decode_fill_run().
Referenced by zxc_decode_copy_match_glo().
|
inlinestatic |
Copies an ml-byte run of period off (2..31) with 32-byte stores.
Builds the run's first 32 bytes in a register pair, then stores them repeatedly. Nothing is re-shuffled: advancing by a multiple of off keeps the pattern in phase.
Replaced a 16-byte form that reloaded the source every iteration, which for offsets of 17 and up straddled two of its own recent stores and stalled on store forwarding - worth up to 7x on periodic data.
Reading 32 source bytes touches destination bytes not written yet on the smallest offsets. They are never selected (every mask index is < off) and sit inside the ZXC_PAD_SIZE headroom the caller owes.
May overshoot up to 31 bytes past ml, like the 32-byte copy ladder.
| [out] | dst | Output cursor; the run source is dst - off. |
| [in] | off | Back-reference distance, in [2, 31]. |
| [in] | ml | Run length in bytes (>= 1). |
Definition at line 143 of file zxc_decompress.c.
References zxc_copy16(), and zxc_overlap_strides32.
Referenced by zxc_decode_copy_match().
|
inlinestatic |
Overlap copy for a run of period off (2..31) bounded by ml <= 32.
Bounded length buys two things over zxc_decode_copy_overlap_run32(): the loop disappears, and the upper 16 bytes are skipped whenever ml allows - which is most of the time, GLO matches averaging 7 to 11 bytes here.
The lower half never needs the second source register: its mask indices are i % off for i < 16, hence always below 16. Only the upper half can reach past 15, and only when off > 16.
Overshoots to 16 or 32 bytes, so the caller owes ZXC_PAD_SIZE of headroom. Reading 32 source bytes is safe because no mask index reaches dst (all are < off).
| [out] | dst | Output cursor; the run source is dst - off. |
| [in] | off | Back-reference distance, in [2, 31]. |
| [in] | ml | Match length, <= 32. |
Definition at line 238 of file zxc_decompress.c.
Referenced by zxc_decode_copy_match_short().
|
inlinestatic |
Fills an ml-byte single-byte run (LZ offset == 1) with wild stores.
Splats byte into a vector register and emits 32-byte chunks, avoiding a libc memset call on the typically short runs of the hot path. Like the other run copiers it may overshoot up to 31 bytes past ml; the caller must guarantee ZXC_PAD_SIZE bytes of headroom. Falls back to ZXC_MEMSET on non-SIMD builds.
| [out] | dst | Output cursor. |
| [in] | byte | Byte value to replicate. |
| [in] | ml | Run length in bytes (>= 1). |
Definition at line 309 of file zxc_decompress.c.
Referenced by zxc_decode_copy_match(), and zxc_decode_copy_match_short().
|
static |
Definition at line 709 of file zxc_decompress.c.
|
static |
Definition at line 722 of file zxc_decompress.c.
|
static |
Definition at line 736 of file zxc_decompress.c.
| int zxc_decompress_chunk_wrapper | ( | const zxc_cctx_t * | ctx, |
| const uint8_t * | src, | ||
| const size_t | src_sz, | ||
| uint8_t * | dst, | ||
| const size_t | dst_cap, | ||
| const uint64_t | block_index | ||
| ) |
Public no-dict chunk decoder (decompression hot path).
Decompresses one chunk through the runtime ISA dispatch.
Inlines the plain GLO/GHI decoders via zxc_decompress_chunk_wrapper_body with has_dict=0, so it carries no dict code and matches the dict-free build.
Definition at line 1654 of file zxc_decompress.c.
Referenced by zxc_dstream_decompress(), zxc_seek_mt_worker(), zxc_seekable_decompress_range(), and zxc_stream_process().
|
inlinestatic |
Shared chunk-decode body: validates the header, decodes, then verifies the optional checksum.
has_dict and safe are compile-time constants: the no-dict instantiation folds the GLO/GHI selection to the plain (inlinable) decoders, so zxc_decompress_chunk_wrapper carries no dict code and matches the dict-free build; the dict and safe instantiations call the NOINLINE _dict / _safe decoders (the strict-tail safe path never carries a dict).
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed block (header + payload + optional checksum). |
| [in] | src_sz | Size of src in bytes. |
| [out] | dst | Destination buffer for the decoded block. |
| [in] | dst_cap | Capacity of dst in bytes. |
| [in] | block_index | Frame position of the block: the checksum seed. |
| [in] | has_dict | Compile-time flag: 1 = dictionary-aware decoders. |
| [in] | safe | Compile-time flag: 1 = strict-tail safe decoders. |
Definition at line 1591 of file zxc_decompress.c.
| int zxc_decompress_chunk_wrapper_dict | ( | const zxc_cctx_t * | ctx, |
| const uint8_t * | src, | ||
| const size_t | src_sz, | ||
| uint8_t * | dst, | ||
| const size_t | dst_cap, | ||
| const uint64_t | block_index | ||
| ) |
Public dictionary chunk decoder.
Routes through zxc_decompress_chunk_wrapper_body with has_dict=1, which calls the NOINLINE _dict decoders (slower: dict back-refs read the prepended dictionary). Used only when ctx->dict_size != 0.
| [in,out] | ctx | Decompression context (dict prefix in its buffer). |
| [in] | src | Compressed block bytes. |
| [in] | src_sz | Size of src in bytes. |
| [out] | dst | Destination buffer for the decoded block. |
| [in] | dst_cap | Capacity of dst in bytes. |
| [in] | block_index | Frame position of the block: the checksum seed. |
Definition at line 1676 of file zxc_decompress.c.
| int zxc_decompress_chunk_wrapper_safe | ( | const zxc_cctx_t * | ctx, |
| const uint8_t * | src, | ||
| const size_t | src_sz, | ||
| uint8_t * | dst, | ||
| const size_t | dst_cap, | ||
| const uint64_t | block_index | ||
| ) |
Public strict-tail safe chunk decoder (dst_cap == exact decoded size).
Exact-capacity variant for the safe block API; dispatch table only.
Routes through zxc_decompress_chunk_wrapper_body with safe=1, which calls the NOINLINE _safe decoders (no bounce buffer, no tail padding); RAW blocks are copied directly. Dict inputs are not handled here (the caller routes them to the bounce-capable path).
| [in,out] | ctx | Decompression context. |
| [in] | src | Compressed block bytes. |
| [in] | src_sz | Size of src in bytes. |
| [out] | dst | Destination buffer (capacity == exact decoded size). |
| [in] | dst_cap | Capacity of dst in bytes. |
| [in] | block_index | Frame position of the block: the checksum seed. |
Definition at line 1699 of file zxc_decompress.c.
|
static |
Ensures the entropy decode scratch (tok_buffer + pivco_scratch) is available before decoding an entropy section.
Heap contexts defer this scratch to the first entropy section (zxc_cctx_alloc_entropy_scratch allocates it once); static workspaces pre-carve it, making this a no-op. The const cast is sound: every context lives in writable memory (heap allocation or caller workspace) - the decode chain is const only because steady-state decoding never mutates the context.
| [in] | ctx | Decompression context (mutated on the first entropy block). |
Definition at line 704 of file zxc_decompress.c.
|
inlinestatic |
Copies len bytes in 32-byte wild chunks (the zxc_copy32 width).
Writes at least one chunk and may overshoot len by up to 31 bytes, into the caller's ZXC_PAD_SIZE headroom. The tail loop is counted on purpose: a pointer bound costs one more register in the inlined GLO 4x loop, which clang pays by reloading d_floor from the stack on every sequence.
| [out] | dst | Output cursor. |
| [in] | src | Source, disjoint from dst or at least 32 bytes behind it. |
| [in] | len | Bytes to copy, >= 1. |
Definition at line 372 of file zxc_decompress.c.
References zxc_copy32().
Referenced by zxc_decode_copy_literals(), and zxc_decode_copy_match().
|
static |
Store stride for the 32-byte pattern: (32 / off) * off.
Past 16 no second period fits, so the stride is the offset itself and each store's tail gets rewritten by the next one.
Definition at line 117 of file zxc_decompress.c.
Referenced by zxc_decode_copy_overlap_run32().