From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:LZ4" |
|---|
| claim | "The LZ4 frame header is magic (uint32 LE), FLG, BD, then the optional 8-byte content size (FLG bit 3), the optional 4-byte dictionary ID (FLG bit 0) and the header checksum byte HC: 7 to 19 bytes. FLG bits 7-6 are the version (01), bit 5 block independence, 4 block checksum, 3 content size, 2 content checksum, 1 reserved, 0 dictionary ID; BD bits 6-4 are the block maximum size ID, all other BD bits reserved." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:LZ4" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "LZ4_frame_header" |
|---|
| size_min | 7 |
|---|
| size_max | 19 |
|---|
| fields | | offset | 0 |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "magic" |
|---|
| notes | "0x184D2204" |
|---|
|
| offset | 4 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "FLG" |
|---|
| bits | | bit | "0" |
|---|
| name | "dict_id_flag" |
|---|
| notes | "Dict-ID field present" |
|---|
|
| bit | "1" |
|---|
| name | "reserved" |
|---|
| notes | "must be 0" |
|---|
|
| bit | "2" |
|---|
| name | "content_checksum_flag" |
|---|
| notes | "XXH32 of the content after the EndMark" |
|---|
|
| bit | "3" |
|---|
| name | "content_size_flag" |
|---|
| notes | "uint64 content size at offset 6" |
|---|
|
| bit | "4" |
|---|
| name | "block_checksum_flag" |
|---|
| notes | "XXH32 after every block" |
|---|
|
| bit | "5" |
|---|
| name | "block_independence" |
|---|
| notes | "0 = blocks may copy from the previous 64 KiB" |
|---|
|
| bit | "6-7" |
|---|
| name | "version" |
|---|
| notes | "must be 01" |
|---|
|
|
|---|
|
| offset | 5 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "BD" |
|---|
| bits | |
| bit | "4-6" |
|---|
| name | "block_max_size_id" |
|---|
| notes | "4 = 64 KiB, 5 = 256 KiB, 6 = 1 MiB, 7 = 4 MiB" |
|---|
|
|
|
|---|
|
| offset | 6 |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "HC_or_optional" |
|---|
| notes | "without optional fields: the header checksum; else content size (8 bytes, if FLG bit 3), then dict ID (4 bytes, if FLG bit 0), then HC" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "documentation" |
|---|
| detail | "Frame Descriptor: FLG, BD, (Content Size), (Dictionary ID), HC; FLG and BD bit tables" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "doc/lz4_Frame_format.md" |
|---|
| lines | "123-218" |
|---|
|
| type | "source" |
|---|
| detail | "LZ4F_getFrameInfo header parsing: blockChecksumFlag = (FLG>>4)&1, blockMode = (FLG>>5)&1, contentSizeFlag = (FLG>>3)&1, contentChecksumFlag = (FLG>>2)&1, dictIDFlag = FLG&1, reserved bit 1 and BD bit 7 rejected" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "lib/lz4frame.c" |
|---|
| lines | "1450-1495" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "tests/goldenSamples/dictID.bin (FLG 61, BD 40, dict ID 0xD1C7, HC 69: an 11-byte header) and the pierrec/lz4 reference frames parse with these fields in the Python codec on this wiki." |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Frame header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T17:53:41.612Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T12:11:54.845Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read doc/lz4_Frame_format.md at aa78757 lines 123-218: FLG bit table (7-6 version, 5 B.Indep, 4 B.Checksum, 3 C.Size, 2 C.Checksum, 1 reserved, 0 DictID), BD bits 6-4 max size (4=64KB..7=4MB), content size 8 bytes LE then 4-byte Dict-ID then HC; descriptor 3-15 bytes + 4 magic = 7-19." |
|---|
|
|
|---|