0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 {
0013 struct rs_codec *rs = rsc->codec;
0014 int i, j, pad;
0015 int nn = rs->nn;
0016 int nroots = rs->nroots;
0017 uint16_t *alpha_to = rs->alpha_to;
0018 uint16_t *index_of = rs->index_of;
0019 uint16_t *genpoly = rs->genpoly;
0020 uint16_t fb;
0021 uint16_t msk = (uint16_t) rs->nn;
0022
0023
0024 pad = nn - nroots - len;
0025 if (pad < 0 || pad >= nn)
0026 return -ERANGE;
0027
0028 for (i = 0; i < len; i++) {
0029 fb = index_of[((((uint16_t) data[i])^invmsk) & msk) ^ par[0]];
0030
0031 if (fb != nn) {
0032 for (j = 1; j < nroots; j++) {
0033 par[j] ^= alpha_to[rs_modnn(rs, fb +
0034 genpoly[nroots - j])];
0035 }
0036 }
0037
0038 memmove(&par[0], &par[1], sizeof(uint16_t) * (nroots - 1));
0039 if (fb != nn) {
0040 par[nroots - 1] = alpha_to[rs_modnn(rs,
0041 fb + genpoly[0])];
0042 } else {
0043 par[nroots - 1] = 0;
0044 }
0045 }
0046 return 0;
0047 }