2次发布

0.1.2 2021年5月31日
0.1.1 2021年4月26日

#2060 in 嵌入式开发


2 crates中使用

MIT/Apache

13KB
190

rzcobs

Documentation

反向零压缩-COBS编码(rzCOBS)是rCOBS的变体,它还会压缩已知包含许多零字节的消息。

标准COBS/rCOBS编码

00000000 => end of frame
nnnnnnnn => output n-1 bytes from stream, output 0x00
11111111 => output 254 bytes from stream

rzCOBS编码

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

零压缩是通过将输入分成7字节的块并在位域中编码来实现的,这些位域是零字节,然后只传输非零字节。如果一行中有超过7个非零字节,编码则像COBS一样工作,其中会发射非零字节的数量。因此,最大开销是ceil(n/134)字节,对于n字节的消息。

当消息被编码然后解码时,结果是原始消息,并附加了最多6个零字节。高层协议必须能够处理这些附加的零字节。

许可

本作品受以下任一许可协议的许可:

任选其一。

贡献

除非你明确声明,否则根据Apache-2.0许可协议定义的,你提交给工作的任何有意贡献,都应按照上述方式双重许可,而不附加任何额外条款或条件。

无运行时依赖