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