Arithcode

Arithmetic coding in C

View the Project on GitHub nclack/arithcode

Arithmetic Coding

by @nclack.

Introduction

Implementation after Amir Said's Algorithms 22-29(1). This was mostly a learning exercise. It hasn't been optimized.

API Documentation

Features

Example

void encode()
{ unsigned char *input, *output=0;      // input and output buffer
  size_t countof_input, countof_output; // number of symbols in input and output buffer
  float *cdf=0;
  size_t nsym;                          // number of symbols in the input alphabet
  // somehow load the data into input array
  cdf_build(&cdf,&nsym,input,countof_input);
  encode_u1_u8(                         // encode unsigned chars to a string of bits (1 bit per output symbol)
    (void**)&out,&countof_output,
            input, countof_input,
              cdf, nsym);
  // do something with the output
  free(out);
  free(cdf);
}

References

  Said, A. "Introduction to Arithmetic Coding - Theory and Practice."
  Hewlett Packard Laboratories Report: 2004-2076.