An lzip file is one or more members one after another, with nothing between them. This page follows the “File format” and “Stream format” chapters of the lzip manual. Numbers are little-endian.
Fields
| Offset | Size | Name | Description |
|---|---|---|---|
0 | 4 | ID string | 4C 5A 49 50, LZIP. |
4 | 1 | VN | Version, 1. |
5 | 1 | DS | Coded dictionary size. |
6 | … | LZMA stream | See stream. Ends with the end-of-stream marker. |
| end − 20 | 4 | CRC32 | CRC-32 of the uncompressed data (the ZIP and gzip CRC). |
| end − 16 | 8 | Data size | Size of the uncompressed data. |
| end − 8 | 8 | Member size | Size of the whole member, header and trailer included. |
Because each member ends with its own size, a tool can step backwards through a file from its end, member by member, and check every one against the data it holds.
Coded dictionary size
| Bits | Meaning |
|---|---|
| 0 to 4 | Base-2 logarithm of the base size, 12 to 29. |
| 5 to 7 | Numerator, 0 to 7, of a fraction of the base size, in sixteenths, to subtract from it. |
Dictionary size = 2bits 0–4 − (bits 5–7) × 2bits 0–4 / 16,
from 4 KiB to 512 MiB. Example: D3 is 219 − 6 × 215 =
512 KiB − 192 KiB = 320 KiB.
Stream
The data is an LZMA stream, coded as described on LZMA coding, with fixed parameters: lc 3, lp 0 and pb 2 (the manual calls it LZMA-302eos). Its first byte is always 0. It always ends with the end-of-stream marker: a match with distance 232 − 1 and length 2. The marker and the member size together let a decoder check that the stream is whole.
Multimember files and limits
- A multimember file has no size limit. Each member holds up to 16 EiB − 1 bytes of data, and a member is at most 2 PiB.
- Empty members (data size 0) are not allowed in a multimember file.
- Data after the last member is not part of the format and is normally ignored.
Zero bytes can be added safely; so can text, if its first four bytes differ from
LZIPin each position and it has no zero bytes. Mixing the two should be avoided unless lziprecover adds them.
Example
4C 5A 49 50 "LZIP"
01 version 1
0C DS: 2^12 = 4 KiB dictionary
00 … LZMA stream, ending with the end-of-stream marker
xx xx xx xx CRC32 of the data
05 00 00 00 00 00 00 00 data size 5
xx xx xx xx xx xx xx xx member size