Skip to content

Latest commit

 

History

History
95 lines (73 loc) · 2.03 KB

README.md

File metadata and controls

95 lines (73 loc) · 2.03 KB

Huffman Compression

Codacy Badge

Usage

huffman [options] source [target]

Options:

-u uncompress file

-z compress file (by default)

-r rename output (should be used with target specified, ${source}.huff by default)

Examples:

huffman -u zip.huff

huffman -zr code.txt code.huff

Details

.huff File Formatting

Dictionary Size

8bit(char)

File Structure:

Header Data

Header Structure:

Header
tree size node 1 node 2 ... node n
huff code length huff code block 1 huff code block 2 ... margin part for last block huff code block (m+7)/8 source code
n-1 (8bit) m(8bit) 8bit 8bit -m mod8 bit m mod8 bit 8bit

Data Structure:

Data
huffman bitstream alignment alignment size
a bit a(8bit)

Acknowledgement

First submitted by Catoverflow, as experiment homework for data structure class :3