BZIP2 (.bz2)

Block-sorting compression format.

Overview

A bzip2 stream begins with BZh and a block size digit (1-9, in units of 100 kB). Each block starts with the magic 0x314159265359 and a block CRC; the stream ends with 0x177245385090 and a combined CRC. Blocks are compressed with a Burrows-Wheeler transform, move-to-front, run-length coding and Huffman coding.

Where it is used

  • Compressed source tarballs and Unix backups.

History

  • Created by Julian Seward in 1996.

Status today

  • Declining use in favor of xz and zstd, but still common.

Structures read by the implementation

Offsets are in bytes from the start of the buffer named in each heading. Field names are taken from the implementation and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.

No fixed-offset structures were found in the implementation.

Constants

General Bzip2Decoder

NameValueTypeNotes
BlockMagic0x314159265359ulong
EndMagic0x177245385090ulong
OutputChunk65536int
GroupSize50int

Implementation limits reader

ClassNameValueNotes
Bzip2CarverMinOutputForPartial4096
Bzip2DecoderMaxGroups6
Bzip2DecoderMaxAlphabet258
Bzip2DecoderMaxCodeLength20
Bzip2DecoderMaxSelectors18002
Structures and constants were extracted from: Carving/Plugins/Compressed/Bzip2Carver.cs, Carving/Plugins/Compressed/Bzip2Decoder.cs, Modules/FileSystems/Bzip2ArchiveModule.cs. Prose sections are a summary from public sources; verify details before relying on them.