Arithmetic coder implementation