This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <vector> | |
// arithmetic coder/decoder by @mmalex based on the wikipedia page https://en.wikipedia.org/wiki/Range_coding as of July 2022 | |
struct encdec_state { | |
typedef uint16_t artype; | |
const static int topshift = sizeof(artype)*8-8; | |
artype low=0,range=~artype(0); |
OlderNewer