Add Reed-Solomon user-space decoding lib.

This commit is contained in:
Michal Virgovič
2018-03-19 10:04:48 +01:00
committed by Milan Broz
parent 4e19bc01d5
commit 5e0db46f17
4 changed files with 227 additions and 27 deletions

View File

@@ -25,32 +25,6 @@
#include "rs.h"
/* Special reserved value encoding zero in index form. */
#define A0 (rs->nn)
/* Reed-Solomon codec control block */
struct rs {
int mm; /* Bits per symbol */
int nn; /* Symbols per block (= (1<<mm)-1) */
data_t *alpha_to;/* log lookup table */
data_t *index_of;/* Antilog lookup table */
data_t *genpoly; /* Generator polynomial */
int nroots; /* Number of generator roots = number of parity symbols */
int fcr; /* First consecutive root, index form */
int prim; /* Primitive element, index form */
int iprim; /* prim-th root of 1, index form */
int pad; /* Padding bytes in shortened block */
};
static inline int modnn(struct rs *rs, int x)
{
while (x >= rs->nn) {
x -= rs->nn;
x = (x >> rs->mm) + (x & rs->nn);
}
return x;
}
/* Initialize a Reed-Solomon codec
* symsize = symbol size, bits
* gfpoly = Field generator polynomial coefficients