Crates.io | rzcobs |
lib.rs | rzcobs |
version | 0.1.2 |
source | src |
created_at | 2021-04-26 22:19:30.689945 |
updated_at | 2021-05-31 18:58:24.267745 |
description | Reverse-Zerocompressing-COBS encoding |
homepage | |
repository | https://github.com/Dirbaio/rzcobs |
max_upload_size | |
id | 389886 |
size | 24,885 |
Reverse-Zerocompressing-COBS encoding (rzCOBS) is a variant of rCOBS which aditionally compresses messages known to contain many zero bytes.
Standard COBS/rCOBS encoding:
00000000 => end of frame
nnnnnnnn => output n-1 bytes from stream, output 0x00
11111111 => output 254 bytes from stream
rzCOBS encoding:
00000000 => end of frame
0xxxxxxx => foreach x from LSB to MSB: if x=0 output 1 byte from stream, if x=1 output 0x00
1nnnnnnn => output n+7 bytes from stream, output 0x00
11111111 => output 134 bytes from stream
Zero-compression is achieved by splitting the input in chunks of 7 bytes and encoding in a bitfield which are zeros, and then transmitting only the non-zero bytes. If there are hore than 7 non-zero bytes in a row, encoding works COBS-like, where the number of non-zero bytes is emitted. The maximum overhead is therefore ceil(n/134) bytes, for a message of n bytes.
When a message is encoded and then decoded, the result is the original message, with up to 6 zero bytes appended. Higher layer protocols must be able to deal with these appended zero bytes.
This work is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.