.BZ2
Bzip2 compressed file
Introduction
Bzip2 compresses a single file. Julian Seward released it in 1996. It sorts each block
of data with the Burrows–Wheeler transform, which groups similar text together, and then
codes the result with move-to-front, run-length and Huffman coding. It compresses
better than gzip but more slowly, and has largely
given way to xz. A tar archive compressed with it is
named .tar.bz2.
Software
Structure
The file starts with BZh and a digit from 1 to
9 giving the block size in units of 100,000 bytes. After that the file is a
stream of bits, not bytes: blocks start at any bit position.
0HeaderBZhand the block size digit4 bytes4Blocks each starts with the 48-bit marker31 41 59 26 53 59and a CRCrepeated…End of stream the 48-bit marker17 72 45 38 50 90and a CRC of the whole file, padded to a whole byte80 bits
The block marker is the start of pi and the end marker is the start of the square root of pi, written in hexadecimal digits. Several bzip2 streams can be joined end to end, and the result decompresses as one file.