Internal implementation of LZ4 frame compression and decompression. More...
Classes | |
| class | xxhash32_accumulator |
| Incremental XXH32 accumulator for streamed LZ4 content checksums. More... | |
Functions | |
| std::uint32_t | rotate_left (std::uint32_t value, std::uint8_t count) noexcept |
| Rotates a 32-bit value left without compiler-specific intrinsics. | |
| std::uint32_t | read_word (std::span< std::byte const > input, std::size_t offset) noexcept |
| Reads an unchecked little-endian word from a known-valid range. | |
| std::uint32_t | xxhash32 (std::span< std::byte const > input, std::uint32_t seed=0U) noexcept |
| Computes XXH32 as required by the LZ4 frame format. | |
| void | append_extended_length (std::vector< std::byte > &output, std::size_t length) |
| Encodes an extended LZ4 literal or match length. | |
| std::vector< std::byte > | compress_block (std::span< std::byte const > input, std::int32_t level) |
| Compresses one independent LZ4 block. | |
| std::size_t | read_extended_length (std::span< std::byte const > input, std::size_t &position, std::size_t initial) |
| Reads an LZ4 extended length while checking block bounds. | |
| template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator> | |
| output_iterator | compress (input_iterator first, sentinel last, output_iterator output, compression_options const &options) |
| Compresses an iterator range as an LZ4 frame. | |
| template<std::input_iterator input_iterator, std::sentinel_for< input_iterator > sentinel, typename output_iterator> | |
| output_iterator | decompress (input_iterator first, sentinel last, output_iterator output, decompression_options const &options) |
| Decompresses one or more LZ4 frames. | |
Internal implementation of LZ4 frame compression and decompression.
|
inline |
Encodes an extended LZ4 literal or match length.
| output | Block buffer receiving extension bytes. |
| length | Amount beyond the token's base length. |
Definition at line 185 of file lz4.hpp.
Referenced by compress_block().
| output_iterator rpnx::compression::lz4_codec::compress | ( | input_iterator | first, |
| sentinel | last, | ||
| output_iterator | output, | ||
| compression_options const & | options ) |
Compresses an iterator range as an LZ4 frame.
| input_iterator | Single-pass byte iterator. |
| sentinel | Sentinel for first. |
| output_iterator | Destination byte iterator. |
| first | First source byte. |
| last | Sentinel past the source. |
| output | Destination iterator. |
| options | Compression level from 0 through 12. |
Definition at line 336 of file lz4.hpp.
References compress_block(), rpnx::compression::invalid_option, rpnx::compression::compression_options::level, rpnx::compression::lz4_frame, rpnx::compression::implementation::to_byte(), rpnx::compression::implementation::write_byte(), and xxhash32().
|
inlinenodiscard |
Compresses one independent LZ4 block.
| input | Uncompressed block containing at most 64 KiB. |
| level | Search level from 0 through 12. |
Definition at line 201 of file lz4.hpp.
References append_extended_length(), and read_word().
Referenced by compress().
| output_iterator rpnx::compression::lz4_codec::decompress | ( | input_iterator | first, |
| sentinel | last, | ||
| output_iterator | output, | ||
| decompression_options const & | options ) |
Decompresses one or more LZ4 frames.
| input_iterator | Single-pass byte iterator. |
| sentinel | Sentinel for first. |
| output_iterator | Destination byte iterator. |
| first | First compressed byte. |
| last | Sentinel past the compressed input. |
| output | Destination iterator. |
| options | Output limit and concatenated-frame policy. |
Definition at line 401 of file lz4.hpp.
References rpnx::compression::decompression_options::allow_concatenated_streams, rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::empty(), rpnx::compression::invalid_data, rpnx::compression::lz4_frame, rpnx::compression::decompression_options::maximum_output_size, rpnx::compression::output_limit_exceeded, rpnx::compression::implementation::byte_reader< input_iterator, sentinel >::read(), read_extended_length(), rpnx::compression::trailing_data, rpnx::compression::unsupported_feature, rpnx::compression::lz4_codec::xxhash32_accumulator::update(), rpnx::compression::lz4_codec::xxhash32_accumulator::value(), rpnx::compression::implementation::write_byte(), and xxhash32().
|
inlinenodiscard |
Reads an LZ4 extended length while checking block bounds.
| input | Encoded block. |
| position | Current byte position, advanced past extension bytes. |
| initial | Length nibble from the token. |
| compression_error | If the extension is truncated or overflows size_t. |
Definition at line 298 of file lz4.hpp.
References rpnx::compression::invalid_data, and rpnx::compression::lz4_frame.
Referenced by decompress().
|
inlinenodiscardnoexcept |
Reads an unchecked little-endian word from a known-valid range.
| input | Byte range containing at least four bytes at offset. |
| offset | Position of the first byte. |
Definition at line 43 of file lz4.hpp.
Referenced by compress_block(), rpnx::compression::lz4_codec::xxhash32_accumulator::update(), rpnx::compression::lz4_codec::xxhash32_accumulator::value(), and xxhash32().
|
inlinenodiscardnoexcept |
Rotates a 32-bit value left without compiler-specific intrinsics.
| value | Value to rotate. |
| count | Rotation distance in the range 1–31. |
Definition at line 32 of file lz4.hpp.
Referenced by rpnx::compression::lz4_codec::xxhash32_accumulator::value(), and xxhash32().
|
inlinenodiscardnoexcept |
Computes XXH32 as required by the LZ4 frame format.
| input | Bytes to hash. |
| seed | XXH32 seed. |
Definition at line 54 of file lz4.hpp.
References read_word(), and rotate_left().
Referenced by compress(), and decompress().