-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathrs16.hpp
47 lines (39 loc) · 1.56 KB
/
rs16.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _RAR_RS16_
#define _RAR_RS16_
class RSCoder16
{
private:
static const uint gfSize=65535; // Galois field size.
void gfInit(); // Galois field inititalization.
inline uint gfAdd(uint a,uint b); // Addition in Galois field.
inline uint gfMul(uint a,uint b); // Multiplication in Galois field.
inline uint gfInv(uint a); // Inverse element in Galois field.
uint *gfExp; // Galois field exponents.
uint *gfLog; // Galois field logarithms.
void MakeEncoderMatrix();
void MakeDecoderMatrix();
void InvertDecoderMatrix();
#ifdef USE_SSE
#if defined(USE_SSE) && defined(__GNUC__)
__attribute__((target("ssse3")))
#endif
bool SSE_UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
#endif
bool Decoding; // If we are decoding or encoding data.
uint ND; // Number of data units.
uint NR; // Number of Reed-Solomon code units.
uint NE; // Number of erasures.
bool *ValidFlags; // Validity flags for data and ECC units.
uint *MX; // Cauchy based coding or decoding matrix.
uint *DataLog; // Buffer to store data logarithms for UpdateECC.
size_t DataLogSize;
public:
RSCoder16();
~RSCoder16();
bool Init(uint DataCount, uint RecCount, bool *ValidityFlags);
#if 0 // We use only UpdateECC now.
void Process(const uint *Data, uint *Out);
#endif
void UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
};
#endif