Skip to content
a fast range coder in C++, using SSE
C++ Python Perl
Branch: master
Clone or download
This branch is 6 commits ahead of kazuho:master.

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
python fixed a bug causing incorrect reconstructions of very short sequences Feb 9, 2020
t move misc. files to t/ Oct 20, 2010
README.md add readme with example Oct 3, 2019
range_coder.hpp fixed a bug causing incorrect reconstructions of very short sequences Feb 9, 2020
setup.py fixed a bug causing incorrect reconstructions of very short sequences Feb 9, 2020

README.md

Installation

pip install range-coder

Example

from range_coder import RangeEncoder, RangeDecoder, prob_to_cum_freq

data = [2, 0, 1, 0, 0, 0, 1, 2, 2]
prob = [0.5, 0.2, 0.3]

# convert probabilities to cumulative integer frequency table
cumFreq = prob_to_cum_freq(prob, resolution=128)

# encode data
encoder = RangeEncoder(filepath)
encoder.encode(data, cumFreq)
encoder.close()

# decode data
decoder = RangeDecoder(filepath)
dataRec = decoder.decode(len(data), cumFreq)
decoder.close()
You can’t perform that action at this time.