1 /* Stuff common to all the general-purpose Reed-Solomon codecs 2 * Copyright 2004 Phil Karn, KA9Q 3 * May be used under the terms of the GNU Lesser General Public License (LGPL) 4 */ 5 6 /* Reed-Solomon codec control block */ 7 struct rs { 8 int mm; /* Bits per symbol */ 9 int nn; /* Symbols per block (= (1<<mm)-1) */ 10 data_t *alpha_to; /* log lookup table */ 11 data_t *index_of; /* Antilog lookup table */ 12 data_t *genpoly; /* Generator polynomial */ 13 int nroots; /* Number of generator roots = number of parity symbols */ 14 int fcr; /* First consecutive root, index form */ 15 int prim; /* Primitive element, index form */ 16 int iprim; /* prim-th root of 1, index form */ 17 int pad; /* Padding bytes in shortened block */ 18 }; 19 20 static inline int modnn(struct rs *rs,int x){ 21 while (x >= rs->nn) { 22 x -= rs->nn; 23 x = (x >> rs->mm) + (x & rs->nn); 24 } 25 return x; 26 } 27