forked from fingltd/4mc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4mc-format-spec
36 lines (26 loc) · 1.33 KB
/
4mc-format-spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
=== 4MC FILE FORMAT ===
The 4MC (4 More Compression) file format is composed by a signature,
followed by the file header, followed by one or more compressed
blocks, followed by the index footer:
SIGN + FILE HEADER + BLOCK1 + BLOCK2 + ... + BLOCKN + IDXFOOTER
Each block consists of a block header, with several required
and optional items, followed by compressed data.
The last block is marked as an empty block of size 0 (with full header, so 12 bytes set to 0).
All data is stored in big endian format (network order).
Data is compressed by means of LZ4.
Checksums are calculated by means of XXHASH32.
Header:
MAGIC SIGNATURE: 4 bytes: "4MC\0"
Version: 4 byte (1)
Header checksum: 4 bytes
Blocks:
Uncompressed size: 4 bytes
Compressed size: 4 bytes, if compressed size==uncompressed size, then the data is stored as plain
Checksum: 4 bytes, calculated on the compressed data
Footer:
Footer size: 4 bytes
Footer version: 4 byte (1)
Block index offset: 4 bytes delta offset for each stored block, the delta between offset between previous file position and next block
Footer size: 4 bytes (repeated to be able to read from end of file)
MAGIC SIGNATURE: 4 bytes: "4MC\0"
Footer checksum: 4 bytes (always in XXHASH32)