1 /* Reed-Solomon encoder
2 * Copyright 2002, Phil Karn, KA9Q
3 * May be used under the terms of the GNU General Public License (GPL)
19 DTYPE *data, DTYPE *bb){
21 struct rs *rs = (struct rs *)p;
26 memset(bb,0,NROOTS*sizeof(DTYPE));
28 for(i=0;i<NN-NROOTS;i++){
29 feedback = INDEX_OF[data[i] ^ bb[0]];
30 if(feedback != A0){ /* feedback term is non-zero */
32 /* This line is unnecessary when GENPOLY[NROOTS] is unity, as it must
33 * always be for the polynomials constructed by init_rs()
35 feedback = MODNN(NN - GENPOLY[NROOTS] + feedback);
38 bb[j] ^= ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])];
41 memmove(&bb[0],&bb[1],sizeof(DTYPE)*(NROOTS-1));
43 bb[NROOTS-1] = ALPHA_TO[MODNN(feedback + GENPOLY[0])];