|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Clean-room RAR 5.0 ("method 50") decompressor – LZ + Huffman + filters. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_rar5_dtab_t |
| One canonical Huffman decode table (shared by all five RAR5 alphabets). More... | |
| struct | ra8_rar5_filter_t |
| One pending RAR5 data filter recorded during decode, applied after. More... | |
| struct | ra8_rar5_state |
Typedefs | |
| typedef struct ra8_rar5_state | ra8_rar5_state_t |
Enumerations | |
| enum | ra8_rar5_dims_t : uint16_t { k_ra8_rar5_nc = 306U , k_ra8_rar5_dc = 64U , k_ra8_rar5_ldc = 16U , k_ra8_rar5_rc = 44U , k_ra8_rar5_bc = 20U , k_ra8_rar5_huff_total = 430U , k_ra8_rar5_max_filters = 16U , k_ra8_rar5_refill_bytes = 512U , k_ra8_rar5_delta_scratch = 512U , k_ra8_rar5_old_dist = 4U } |
| Alphabet sizes and fixed scratch dimensions of the RAR5 decoder. More... | |
| enum | ra8_rar5_filter_kind_t : uint8_t { k_ra8_rar5_filter_delta = 0U , k_ra8_rar5_filter_e8 = 1U , k_ra8_rar5_filter_e8e9 = 2U , k_ra8_rar5_filter_arm = 3U } |
| The RAR5 data-filter kinds ra8_rar5_filter_t::type can take. More... | |
Functions | |
| ra8_err_t | ra8_rar5_decompress (const ra8_rar_t *rar, uint64_t data_off, uint64_t pack_size, uint8_t *out, size_t out_cap, uint64_t unp_size, ra8_rar5_state_t *st, size_t *got) |
| Decompress one RAR5-packed member into the caller's output buffer. | |
Clean-room RAR 5.0 ("method 50") decompressor – LZ + Huffman + filters.
The compressed half of the .cbr comic path. ra8_rar_next enumerates a RAR5 member and, when it is packed with a RAR compressor rather than stored verbatim, ra8_rar_extract routes the member through ra8_rar5_decompress instead of the STORE memcpy. This unit reconstructs the original bytes from the RAR 5.0 packed bitstream: a Huffman-coded LZ77 token stream (literals, length/distance matches, repeated-distance matches) followed by the optional RAR5 data filters (delta / x86-E8 / x86-E8E9 / ARM branch).
Definition in file ra8_rar5.h.
| typedef struct ra8_rar5_state ra8_rar5_state_t |
| enum ra8_rar5_dims_t : uint16_t |
Alphabet sizes and fixed scratch dimensions of the RAR5 decoder.
The four LZ alphabets (main / distance / low-distance / repeat-length) plus the bit-length pre-table are the canonical RAR 5.0 code counts; the remaining values bound the caller-owned scratch so no allocation is ever needed. k_ra8_rar5_nc is the largest alphabet and therefore the width of every decode table's symbol array.
Definition at line 76 of file ra8_rar5.h.
| enum ra8_rar5_filter_kind_t : uint8_t |
The RAR5 data-filter kinds ra8_rar5_filter_t::type can take.
Numbered exactly as the 3-bit filter-type field of the packed stream so the decode reads straight into the enum.
Definition at line 137 of file ra8_rar5.h.
|
nodiscard |
Decompress one RAR5-packed member into the caller's output buffer.
Streams the packed bytes at [data_off, data_off + pack_size) through the archive reader, decodes the RAR 5.0 Huffman-coded LZ token stream into out (which is also the LZ sliding window), then replays any filters the stream recorded. Produces exactly unp_size bytes on success. Malformed, truncated, or hostile input is rejected without reading or writing out of bounds – never a crash.
| [in] | rar | Archive bound by ra8_rar_open (non-NULL). |
| [in] | data_off | Absolute offset of the packed member data (< rar->size). |
| [in] | pack_size | Packed member length in bytes (> 0). |
| [out] | out | Destination and LZ window (non-NULL, out_cap writable). |
| [in] | out_cap | Capacity of out in bytes; must be >= unp_size. |
| [in] | unp_size | Expected unpacked length in bytes. |
| [in,out] | st | Caller-owned decoder scratch (non-NULL). |
| [out] | got | Receives bytes written (non-NULL). |
| k_ra8_ok | Member decoded; *got == unp_size. |
| k_ra8_err_null_ptr | A required pointer argument was NULL. |
| k_ra8_err_invalid_state | rar was never bound by ra8_rar_open. |
| k_ra8_err_no_mem | out_cap is smaller than unp_size. |
| k_ra8_err_validation_failed | Malformed / truncated / solid-reference stream. |
rar was populated by ra8_rar_open (version 5). out holds at least out_cap writable bytes. out contents are unspecified.st. Definition at line 776 of file ra8_rar5.c.
References internal_apply_filters(), internal_decode_stream(), internal_decompress_check(), k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag_rar5.
Referenced by ra8_rar_extract().