AnsCompression
An ANS (Asymmetric Numeral Systems) compression tool.
It uses the range variant.
| Methods |
| static void |
countFrequencies(int[] freq, byte[] data)
Count the frequencies of codes in the data, and increment the target
frequency table.
|
| static void |
countFrequencies(int[] freq, byte[] data)
Count the frequencies of codes in the data, and increment the target
frequency table.
Parameters:
freq - the target frequency table
data - the data
|
| static byte[] |
decode(int[] freq, byte[] data, int length)
Decode the data.
|
| static byte[] |
decode(int[] freq, byte[] data, int length)
Decode the data.
Parameters:
freq - the frequency table (will be scaled)
data - the compressed data
length - the target length
Returns:
the uncompressed result
|
| static byte[] |
encode(int[] freq, byte[] data)
Encode the data.
|
| static byte[] |
encode(int[] freq, byte[] data)
Encode the data.
Parameters:
freq - the frequency table (will be scaled)
data - the source data (uncompressed)
Returns:
the compressed data
|
| static int[] |
generateCumulativeFrequencies(int[] freq)
Generate the cumulative frequency table.
|
| static int[] |
generateCumulativeFrequencies(int[] freq)
Generate the cumulative frequency table.
Parameters:
freq - the source frequency table
Returns:
the cumulative table, with one entry more
|
| static void |
scaleFrequencies(int[] freq, int total)
Scale the frequencies to a new total.
|
| static void |
scaleFrequencies(int[] freq, int total)
Scale the frequencies to a new total. Frequencies of 0 are kept as 0;
larger frequencies result in at least 1.
Parameters:
freq - the (source and target) frequency table
total - the target total (sum of all frequencies)
|
|