Skip to content

WaleedYaser/Arithmetic-Coding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arithmatic Coding

My implementation for Arithmetic Coding algorithm.

Getting Started

You can view testSample.py code to get an idea about how to use the ArithmaticCoding class.

Prerequisites

Basic Arithmetic Coding Algorithm

I have implemented the algorithm from Fundamentals of Multimedia book, the algorithms are Algorithm 7.5, Procedure 7.2, Algorithm 7.6.

Arithmetic Coding Encoder

BEGIN
  low = 0.0; high = 1.0; range = 1.0;
  initialize symbol;     // so symbol != terminator

  while (symbol != terminator)
  {
    get (symbol);
    low = low + range * Range_low(symbol);
    high = low + range * Range_high(symbol);
    range = high - low;
  }
  output a code so that low <= code < high;
END

Generating Codeword for Encoder

BEGIN
  code = 0;
  k = 1;
  while (value(code) < low)
  {
    assign 1 to the kth binary fraction bit;
    if (value(code) > high)
      replace the kth bit by 0;
    k = k + 1;
  }
END

Arithmetic Coding Decoder

BEGIN
  get binary code and convert to decimal value = value(code);
  Do
  {
    find a symbol s so that
      Range_low(s) <= value < Range_high(s);
    output s;
    low = Rang_low(s);
    high = Range_high(s);
    range = high - low;
    value = [value - low] / range;
  }
  Until symbol s is a terminator
END

Notes

I have not handled any exceptions, just the basic algorithm.

References

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

My implementation for Arithmetic Coding algorithm.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages