-
Notifications
You must be signed in to change notification settings - Fork 53
/
rs.hh
44 lines (37 loc) · 1.11 KB
/
rs.hh
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
#pragma once
#include <string>
#include <vector>
class RSCodec
{
public:
RSCodec(const std::vector<unsigned int>& roots, unsigned int fcr, unsigned int prim, unsigned int nroots, unsigned int pad=0, unsigned int bits=8);
void encode(std::string& msg);
int decode(const std::string& in, std::string& out, std::vector<unsigned int>* corrections=0);
int getPoly() // the representation as a number
{
return d_gfpoly;
}
~RSCodec();
private:
void* d_rs{0};
unsigned int d_gfpoly{0};
public:
const unsigned int d_N, d_K, d_nroots, d_bits;
};
class RSCodecInt
{
public:
RSCodecInt(const std::vector<unsigned int>& roots, unsigned int fcr, unsigned int prim, unsigned int nroots, unsigned int pad=0, unsigned int bits=8);
void encode(std::vector<unsigned int>& msg);
int decode(const std::vector<unsigned int>& in, std::vector<unsigned int>& out, std::vector<unsigned int>* corrections=0);
int getPoly() // the representation as a number
{
return d_gfpoly;
}
~RSCodecInt();
private:
void* d_rs{0};
unsigned int d_gfpoly{0};
public:
const unsigned int d_N, d_K, d_nroots, d_bits;
};