/huffman-coding

A C++ compression program based on Huffman's lossless compression algorithm and decoder.

Primary LanguageC++MIT LicenseMIT

Huffman Coding

MIT License linkedin open issues closed issues

Self-made C++ file archiver and archive extractor programs based on Huffman's lossless compression algorithm

Table of Contents

How does it work?

You can check out documentation inside Compressor.cpp and Decompressor.cpp files to help you understand Huffman's algorithm's inner workings.

Compressor:

The Compressor is a 2-pass program. What I mean by this is that the Compressor reads input files twice.

In the first pass, the program counts usage frequency of every unique byte and creates a weighted translation tree for every used unique byte inversely proportional to its usage frequency and then writes this transformation info to the compressed file for decompression purposes

In the second pass, the program translates input files according to the translation tree and writes it to the newly created compressed file

Decompressor:

The Decompressor is a 1-pass program: The Decompressor first reads translation info and creates a binary tree from it. After this process is done, it uses this binary translation tree to decode the rest of the file

How to use it?

  1. Compile with make using your favourate shell:
make all
  1. After running make, you can use archive command below to compress the file you want:
  • To compress one file use:
./archive {{filename}}
  • To compress multiple files use:
./archive {{filename1}} {{filename2}} ...
  1. And to decompress a compressed file, use the extract command below:
./extract {{filename}}

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Rudresh Dixit - 00rudreshdixit@gmail.com

Project Link: https://github.com/shie-ld/huffman-coding