General Structure of LZ4 Frame format
MagicNb | F. Descriptor | Data Block | (...) | EndMark | C. Checksum |
4 bytes | 3-15 bytes | 4 bytes | 0-4 bytes |
Magic Number
4 Bytes, Little endian format. Value : 0x184D2204
EndMark
0x00000000
Frame Descriptor
3 to 15 Bytes, to be detailed in its own paragraph, as it is the most important part of the spec.
FLG | BD | (Content Size) | (Dictionary ID) | HC |
1 byte | 1 byte | 0 - 8 bytes | 0 - 4 bytes | 1 byte |
FLG byte
BitNb | 7-6 | 5 | 4 | 3 | 2 | 1 | 0 |
FieldName | Version | B.Indep | B.Checksum | C.Size | C.Checksum | Reserved | DictID |
C.Size, DictID 表示是否存在Content Size , Dictionary ID
B.Checksum 表示每个block 是否包含checksum
Content checksum flag 是否启用EndMark后面的checksum
Data Blocks
Block Size | data | (Block Checksum) |
4 bytes | 0 - 4 bytes |
Block Size
This field uses 4-bytes, format is little-endian.
LZ4 就是直接利用lz77替换之后编码, 不使用huffman
Data 压缩块由多个序列组成,
序列快的压缩,解压过程参考