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