shannon-fano-1.0.0.0: Shannon-fano compression algorithm in Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Codec.Compression.ShannonFano.Internal

Synopsis

Documentation

type Input = ByteString Source #

Simple type alias to distinguish when something is an input or is a coded or compressed Bytestring.

type Table a = [(Word8, a)] Source #

Simple table used as an intermediate structure

split :: Table Float -> (Table Float, Table Float) Source #

Auxiliary split function.

This function splits a probabilities table in half where the sum of the two halfs are as close as possible.

chunksOf :: Int -> ByteString -> [ByteString] Source #

Creates a list of Bytestring chunks.

decode :: ByteString -> ByteString Source #

Takes a compressed Bytestring and converts it into a Bytestring of only 0s and 1s.

compressChunk :: ByteString -> Word8 Source #

Takes a Bytestring of 0s and 1s with length 8 and converts it to a single Word8.

Example: compressChunk "00000001" == 1

compressWithLeftover :: ByteString -> ByteString Source #

The same as compress but adds the size of the last byte to the beginning of the compressed ByteString, since it might occupy less than 8 bits.

decompressWithLeftover :: ByteString -> ByteString Source #

Takes a compressed Bytestring and converts it into a Bytestring of only 0s and 1s, truncating the last byte accordingly, using the information of the last byte's size.