Skip to content

Instantly share code, notes, and snippets.

@nclack
Created April 23, 2012 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nclack/2473960 to your computer and use it in GitHub Desktop.
Save nclack/2473960 to your computer and use it in GitHub Desktop.
Arithmetic coding 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment