GNU Radio's SATELLITES Package
ecc.h
Go to the documentation of this file.
1 /* Reed Solomon Coding for glyphs
2  * Copyright Henry Minsky (hqm@alum.mit.edu) 1991-2009
3  *
4  * This software library is licensed under terms of the GNU GENERAL
5  * PUBLIC LICENSE
6  *
7  * RSCODE is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * RSCODE is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Rscode. If not, see <http://www.gnu.org/licenses/>.
19  *
20  * Source code is available at http://rscode.sourceforge.net
21  *
22  * Commercial licensing is available under a separate license, please
23  * contact author for details.
24  *
25  */
26 
27 /****************************************************************
28 
29  Below is NPAR, the only compile-time parameter you should have to
30  modify.
31 
32  It is the number of parity bytes which will be appended to
33  your data to create a codeword.
34 
35  Note that the maximum codeword size is 255, so the
36  sum of your message length plus parity should be less than
37  or equal to this maximum limit.
38 
39  In practice, you will get slooow error correction and decoding
40  if you use more than a reasonably small number of parity bytes.
41  (say, 10 or 20)
42 
43  ****************************************************************/
44 
45 // Modified by Daniel Estevez
46 // Now we take a maximum value MAX_NPAR and the NPAR parameter
47 // is set at runtime
48 #define MAX_NPAR 16
49 
50 /****************************************************************/
51 
52 
53 
54 #define TRUE 1
55 #define FALSE 0
56 
57 typedef unsigned long BIT32;
58 typedef unsigned short BIT16;
59 
60 /* **************************************************************** */
61 
62 /* Maximum degree of various polynomials. */
63 #define MAXDEG (MAX_NPAR*2)
64 
65 /*************************************/
66 /* Encoder parity bytes */
67 extern int pBytes[MAXDEG];
68 
69 /* Decoder syndrome bytes */
70 extern int synBytes[MAXDEG];
71 
72 /* print debugging info */
73 extern int DEBUG;
74 
75 /* Reed Solomon encode/decode routines */
76 void initialize_ecc (int n_par);
77 int check_syndrome (void);
78 void decode_data (unsigned char data[], int nbytes);
79 void encode_data (unsigned char msg[], int nbytes, unsigned char dst[]);
80 
81 /* CRC-CCITT checksum generator */
82 BIT16 crc_ccitt(unsigned char *msg, int len);
83 
84 /* galois arithmetic tables */
85 extern int gexp[];
86 extern int glog[];
87 
88 void init_galois_tables (void);
89 int ginv(int elt);
90 int gmult(int a, int b);
91 
92 
93 /* Error location routines */
94 int correct_errors_erasures (unsigned char codeword[], int csize,int nerasures, int erasures[]);
95 
96 /* polynomial arithmetic */
97 void add_polys(int dst[], int src[]) ;
98 void scale_poly(int k, int poly[]);
99 void mult_polys(int dst[], int p1[], int p2[]);
100 
101 void copy_poly(int dst[], int src[]);
102 void zero_poly(int poly[]);
void decode_data(unsigned char data[], int nbytes)
void encode_data(unsigned char msg[], int nbytes, unsigned char dst[])
void initialize_ecc(int n_par)
int DEBUG
int synBytes[MAXDEG]
void init_galois_tables(void)
int gmult(int a, int b)
int correct_errors_erasures(unsigned char codeword[], int csize, int nerasures, int erasures[])
int check_syndrome(void)
int glog[]
#define MAXDEG
Definition: ecc.h:63
unsigned short BIT16
Definition: ecc.h:58
void mult_polys(int dst[], int p1[], int p2[])
void scale_poly(int k, int poly[])
BIT16 crc_ccitt(unsigned char *msg, int len)
int pBytes[MAXDEG]
int ginv(int elt)
void copy_poly(int dst[], int src[])
void add_polys(int dst[], int src[])
int gexp[]
void zero_poly(int poly[])
unsigned long BIT32
Definition: ecc.h:57