2 Copyright (C) Arturo San Emeterio Campos 1999. All rights reserved.
3 Permission is granted to make verbatim copies of this file for private
4 use only. There is ABSOLUTELY NO WARRANTY. Use it at your OWN RISK.
6 This file is: "range.h"
7 Email: arturo@arturocampos.com
8 Web: http://www.arturocampos.com
10 Declarations for the coder.
16 unsigned long low, range, help;
17 unsigned char byte_buffer;
22 void range_coder_init(rangecoder *rc, FILE *stream); //coding routines
23 void range_coder_encode(rangecoder *rc,unsigned long tot_f, unsigned long lt_f,unsigned long sy_f);
24 void range_coder_renormalize(rangecoder *rc);
25 void range_coder_flush(rangecoder *rc);
26 void range_decoder_init(rangecoder *rc, FILE *stream);//decoding routines
27 unsigned long range_decoder_decode(rangecoder *rc, unsigned long tot_f);
28 void range_decoder_update(rangecoder *rc, unsigned long tot_f, unsigned long lt_f,unsigned long sy_f);
29 void range_decoder_renormalize(rangecoder *rc);
32 typedef unsigned long code_value;
34 #define Top_value ((code_value)1 << (CODE_BITS-1))
35 #define SHIFT_BITS (CODE_BITS - 9)
36 #define EXTRA_BITS ((CODE_BITS-2) % 8 + 1)
37 #define Bottom_value (Top_value >> 8)
38 #define outbyte(cod,x) putc(x,stdout)
39 #define inbyte(cod) getc(stdin)