1 /* Reed Solomon Coding for glyphs
2  *
3  * (c) Henry Minsky (hqm@ua.com), Universal Access Inc.  (1991-1996)
4  *
5  *
6  */
7 
8 /****************************************************************
9 
10   Below is NPAR, the only compile-time parameter you should have to
11   modify.
12 
13   It is the number of parity bytes which will be appended to
14   your data to create a codeword.
15 
16   Note that the maximum codeword size is 255, so the
17   sum of your message length plus parity should be less than
18   or equal to this maximum limit.
19 
20   In practice, you will get slooow error correction and decoding
21   if you use more than a reasonably small number of parity bytes.
22   (say, 10 or 20)
23 
24   ****************************************************************/
25 #ifndef _ECC_H_
26 #define _ECC_H_
27 #define NPAR 64
28 
29 /****************************************************************/
30 
31 #define TRUE 1
32 #define FALSE 0
33 
34 typedef unsigned long BIT32;
35 typedef unsigned short BIT16;
36 
37 /* **************************************************************** */
38 
39 /* Maximum degree of various polynomials. */
40 #define MAXDEG (NPAR*2)
41 
42 /*************************************/
43 /* Encoder parity bytes */
44 extern int pBytes[MAXDEG];
45 
46 /* Decoder syndrome bytes */
47 extern int synBytes[MAXDEG];
48 
49 /* print debugging info */
50 extern int RS_DEBUG;
51 
52 /* Reed Solomon encode/decode routines */
53 void initialize_ecc (void);
54 int check_syndrome (void);
55 void decode_data (unsigned char data[], int nbytes);
56 void encode_data (unsigned char msg[], int nbytes, unsigned char dst[]);
57 
58 
59 /* galois arithmetic tables */
60 extern int gexp[];
61 extern int glog[];
62 
63 void init_galois_tables (void);
64 int ginv(int elt);
65 int gmult(int a, int b);
66 
67 
68 /* Error location routines */
69 int correct_errors_erasures (unsigned char codeword[], int csize,int nerasures, int erasures[]);
70 
71 /* polynomial arithmetic */
72 void add_polys(int dst[], int src[]) ;
73 void scale_poly(int k, int poly[]);
74 void mult_polys(int dst[], int p1[], int p2[]);
75 
76 void copy_poly(int dst[], int src[]);
77 void zero_poly(int poly[]);
78 #endif //_ECC_H_
79