00001
00002
00003
00004
00005
00006
00007 #define DTYPE unsigned char
00008
00009
00010 struct rs {
00011 unsigned int mm;
00012 unsigned int nn;
00013 unsigned char *alpha_to;
00014 unsigned char *index_of;
00015 unsigned char *genpoly;
00016 unsigned int nroots;
00017 unsigned char fcr;
00018 unsigned char prim;
00019 unsigned char iprim;
00020 };
00021
00022 static inline int modnn(struct rs *rs,int x){
00023 while (x >= rs->nn) {
00024 x -= rs->nn;
00025 x = (x >> rs->mm) + (x & rs->nn);
00026 }
00027 return x;
00028 }
00029 #define MODNN(x) modnn(rs,x)
00030
00031 #define MM (rs->mm)
00032 #define NN (rs->nn)
00033 #define ALPHA_TO (rs->alpha_to)
00034 #define INDEX_OF (rs->index_of)
00035 #define GENPOLY (rs->genpoly)
00036 #define NROOTS (rs->nroots)
00037 #define FCR (rs->fcr)
00038 #define PRIM (rs->prim)
00039 #define IPRIM (rs->iprim)
00040 #define A0 (NN)
00041
00042 #define ENCODE_RS encode_rs_char
00043 #define DECODE_RS decode_rs_char
00044 #define INIT_RS init_rs_char
00045 #define FREE_RS free_rs_char
00046
00047 void ENCODE_RS(void *p,DTYPE *data,DTYPE *parity);
00048 int DECODE_RS(void *p,DTYPE *data,int *eras_pos,int no_eras);
00049 void *INIT_RS(unsigned int symsize,unsigned int gfpoly,unsigned int fcr,
00050 unsigned int prim,unsigned int nroots);
00051 void FREE_RS(void *p);
00052
00053
00054
00055
00056