Giter VIP home page Giter VIP logo

huffman_coding's Introduction

Adaptive Huffman coding in C++

Bits and pieces used

  • Vitter algorithm,
  • Own BitArray implementation (extensible array of bits implemented as a template over numeric types),
  • Own LinkList implementation as a template,
  • Own progress printer (simple ASCII one),
  • CLI11 command line options parser,
  • Google Test for testing BitArray class,
  • Extracts from Wikipedia as test data.

Dependencies

  • CLI11 - header-only, provided with this project,
  • Google Test - needs to be installed locally.

Limitations

  • Can't be used with binary files (uses null byte as terminating symbol, can be improved of course).

Usage

Quick test run

$ make -j4 runtests

Help

$ ./main --help                                         
Adaptive Huffman coding compressor/decompressor
Usage: ./main [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -p,--pack Excludes: --unpack
                              Pack/compress
  -u,--unpack Excludes: --pack
                              Unpack/decompress
  -s,--source TEXT REQUIRED   Source/input file
  -d,--destination TEXT REQUIRED
                              Destination/output file

no action specified, use exactly one of pack/unpack options

Encode

$ ./main --pack -s txt/5-passages-head_10M.txt -d out.bin

Decode

$ ./main --unpack -s out.bin -d decoded.txt

Results

Effective for files as small as 1 KiB:

encoding: txt/1-passages-head_1K.tsv --> out.bin
[####################################################################################################] 100% done
bytes input 1024 output 709
size reduction 30.76%
took 0.00s

Sample run for 10MB:

encoding: txt/5-passages-head_10M.txt --> out.bin
[####################################################################################################] 100% done
bytes input 10485760 output 6774613
size reduction 35.39%
took 0.85s

huffman_coding's People

Contributors

mrjake222 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.