ecc.h
Go to the documentation of this file.
/* Reed Solomon Coding for glyphs
* Copyright Henry Minsky (hqm@alum.mit.edu) 1991-2009
*
* This software library is licensed under terms of the GNU GENERAL
* PUBLIC LICENSE
*
* RSCODE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RSCODE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Rscode. If not, see <http://www.gnu.org/licenses/>.
*
* Source code is available at http://rscode.sourceforge.net
*
* Commercial licensing is available under a separate license, please
* contact author for details.
*
*/
/****************************************************************
Below is NPAR, the only compile-time parameter you should have to
modify.
It is the number of parity bytes which will be appended to
your data to create a codeword.
Note that the maximum codeword size is 255, so the
sum of your message length plus parity should be less than
or equal to this maximum limit.
In practice, you will get slooow error correction and decoding
if you use more than a reasonably small number of parity bytes.
(say, 10 or 20)
****************************************************************/
// Modified by Daniel Estevez
// Now we take a maximum value MAX_NPAR and the NPAR parameter
// is set at runtime
#define MAX_NPAR 16
/****************************************************************/
#define TRUE 1
#define FALSE 0
typedef unsigned long BIT32;
typedef unsigned short BIT16;
/* **************************************************************** */
/* Maximum degree of various polynomials. */
#define MAXDEG (MAX_NPAR*2)
/*************************************/
/* Encoder parity bytes */
extern int pBytes[MAXDEG];
/* Decoder syndrome bytes */
extern int synBytes[MAXDEG];
/* print debugging info */
extern int DEBUG;
/* Reed Solomon encode/decode routines */
void initialize_ecc (int n_par);
int check_syndrome (void);
void decode_data (unsigned char data[], int nbytes);
void encode_data (unsigned char msg[], int nbytes, unsigned char dst[]);
/* CRC-CCITT checksum generator */
BIT16 crc_ccitt(unsigned char *msg, int len);
/* galois arithmetic tables */
extern int gexp[];
extern int glog[];
void init_galois_tables (void);
int ginv(int elt);
int gmult(int a, int b);
/* Error location routines */
int correct_errors_erasures (unsigned char codeword[], int csize,int nerasures, int erasures[]);
/* polynomial arithmetic */
void add_polys(int dst[], int src[]) ;
void scale_poly(int k, int poly[]);
void mult_polys(int dst[], int p1[], int p2[]);
void copy_poly(int dst[], int src[]);
void zero_poly(int poly[]);
decode_data
void decode_data(unsigned char data[], int nbytes)
encode_data
void encode_data(unsigned char msg[], int nbytes, unsigned char dst[])
initialize_ecc
void initialize_ecc(int n_par)
DEBUG
int DEBUG
synBytes
int synBytes[MAXDEG]
init_galois_tables
void init_galois_tables(void)
gmult
int gmult(int a, int b)
correct_errors_erasures
int correct_errors_erasures(unsigned char codeword[], int csize, int nerasures, int erasures[])
check_syndrome
int check_syndrome(void)
glog
int glog[]
MAXDEG
#define MAXDEG
Definition: ecc.h:63
BIT16
unsigned short BIT16
Definition: ecc.h:58
mult_polys
void mult_polys(int dst[], int p1[], int p2[])
scale_poly
void scale_poly(int k, int poly[])
crc_ccitt
BIT16 crc_ccitt(unsigned char *msg, int len)
pBytes
int pBytes[MAXDEG]
ginv
int ginv(int elt)
copy_poly
void copy_poly(int dst[], int src[])
add_polys
void add_polys(int dst[], int src[])
gexp
int gexp[]
zero_poly
void zero_poly(int poly[])
BIT32
unsigned long BIT32
Definition: ecc.h:57