Nugget
Bare-metal libraries and examples for the original PlayStation
Loading...
Searching...
No Matches
lz4stream.h
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2026 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29#include <stdint.h>
30
31/* LZ4 block decoder fed one input byte at a time. Output goes straight to its
32 destination and earlier output is the match history, so consecutive blocks
33 written to one buffer can reference each other (up to 64 KiB back). A match
34 is copied as its length bytes arrive, so no single input byte produces more
35 than 255 bytes of output. */
36
37struct Lz4Stream {
38 uint8_t *out;
39 uint8_t *base;
41 uint16_t offset;
42 uint8_t token;
43 uint8_t state;
44};
45
46enum {
50};
51
52/* LZ4STREAM_TRUSTED drops the checks for a malformed stream (a match reaching
53 before the start, a zero offset, a block ending mid-sequence), for when the
54 encoder is known good; feed and end then always return LZ4S_OK. */
55
56/* Start a stream writing at dest. Matches may not reach before dest. */
57void lz4StreamInit(struct Lz4Stream *s, void *dest);
58/* Feed one byte of the current block. */
59int lz4StreamFeed(struct Lz4Stream *s, uint8_t b);
60/* End the current block; the next byte fed starts a new one. Fails if the
61 block stopped in the middle of a sequence. */
62int lz4StreamEndBlock(struct Lz4Stream *s);
uint8_t b
Definition gte-depthcue.c:39
void lz4StreamInit(struct Lz4Stream *s, void *dest)
Definition lz4stream.c:38
int lz4StreamFeed(struct Lz4Stream *s, uint8_t b)
Definition lz4stream.c:43
int lz4StreamEndBlock(struct Lz4Stream *s)
Definition lz4stream.c:106
@ LZ4S_ETRUNCATED
Definition lz4stream.h:49
@ LZ4S_EBADOFFSET
Definition lz4stream.h:48
@ LZ4S_OK
Definition lz4stream.h:47
char * s
Definition string.c:48
Definition lz4stream.h:37
uint32_t count
Definition lz4stream.h:40
uint8_t * out
Definition lz4stream.h:38
uint16_t offset
Definition lz4stream.h:41
uint8_t * base
Definition lz4stream.h:39
uint8_t token
Definition lz4stream.h:42
uint8_t state
Definition lz4stream.h:43
void uint32_t(classId, spec)