36 static pthread_mutex_t
RSECC_mutex = PTHREAD_MUTEX_INITIALIZER;
41 #define SYMBOL_SIZE (8)
42 #define symbols ((1U << SYMBOL_SIZE) - 1)
43 static const unsigned int proot = 0x11d;
46 #define min_length (2)
47 #define max_length (30)
48 #define max_generatorSize (max_length)
67 if(b & (symbols + 1)) {
87 for(i = 0; i < length; i++) {
90 for(j = i; j > 0; j--) {
96 for(i = 0; i <= length; i++) {
103 int RSECC_encode(
size_t data_length,
size_t ecc_length,
const unsigned char *data,
unsigned char *ecc)
106 unsigned char feedback;
121 memset(ecc, 0, ecc_length);
131 for(i = 0; i < data_length; i++) {
132 feedback =
aindex[data[i] ^ ecc[0]];
134 for(j = 1; j < ecc_length; j++) {
135 ecc[j] ^=
alpha[(
unsigned int)(feedback + gen[ecc_length - j]) %
symbols];
138 memmove(&ecc[0], &ecc[1], ecc_length - 1);
140 ecc[ecc_length - 1] =
alpha[(
unsigned int)(feedback + gen[0]) %
symbols];
142 ecc[ecc_length - 1] = 0;
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
static void RSECC_init(void)
static void RSECC_initLookupTable(void)
static unsigned char generator[max_length-min_length+1][max_generatorSize+1]
static const unsigned int proot
static unsigned char aindex[symbols+1]
static unsigned char alpha[symbols+1]
#define max_generatorSize
int RSECC_encode(size_t data_length, size_t ecc_length, const unsigned char *data, unsigned char *ecc)
static void generator_init(size_t length)
static pthread_mutex_t RSECC_mutex
static unsigned char generatorInitialized[max_length-min_length+1]