00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ARITH_H
00022 #define ARITH_H
00023
00024 #include "buff.h"
00025
00026 #define PREC_TOTAL 32
00027 #define PREC_INTER ((2 * PREC_TOTAL) / 3)
00028 #define PREC_PROBA (PREC_TOTAL - PREC_INTER)
00029
00030 typedef struct {
00031 unsigned long min, max;
00032 unsigned long * prob;
00033 } distrib_t;
00034
00035 #define distrib_get_proba(d, i) ((d).prob[(i) - (d).min])
00036
00037 typedef struct code_arith {
00038 int compteur;
00039 unsigned long min, max;
00040 struct buff * buffer;
00041 } * arith_t;
00042
00043 arith_t arith_init(struct buff * b);
00044 int coder(int i, distrib_t d, arith_t state);
00045 int coder_uniforme(unsigned long i, unsigned long n, arith_t state);
00046 int coder_bin_fin(int i, arith_t state);
00047 int decoder(distrib_t d, int * lettre, arith_t state);
00048 unsigned long decoder_uniforme(unsigned long n, unsigned long * lettre, arith_t state);
00049 int decoder_bin_fin(arith_t state);
00050 int tester_fin(arith_t state);
00051 int tester_compteur(arith_t state);
00052
00053 #endif // ARITH_H