File: rscodec.h

package info (click to toggle)
solvespace 3.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,960 kB
  • sloc: cpp: 122,491; ansic: 11,375; javascript: 1,919; sh: 89; xml: 44; makefile: 25
file content (69 lines) | stat: -rw-r--r-- 2,617 bytes parent folder | download | duplicates (6)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/******************************************************************************
**  libDXFrw - Library to read/write DXF files (ascii & binary)              **
**                                                                           **
**  Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com         **
**                                                                           **
**  This library is free software, licensed under the terms of the GNU       **
**  General Public License as published by the Free Software Foundation,     **
**  either version 2 of the License, or (at your option) any later version.  **
**  You should have received a copy of the GNU General Public License        **
**  along with this program.  If not, see <http://www.gnu.org/licenses/>.    **
******************************************************************************/

/**
 * Reed-Solomon codec
 * Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff
 *
 * Original code:
 * This program may be freely modified and/or given to whoever wants it.
 *  A condition of such distribution is that the author's contribution be
 *  acknowledged by his name being left in the comments heading the program,
 *  however no responsibility is accepted for any financial or other loss which
 *  may result from some unforseen errors or malfunctioning of the program
 *  during use.
 *                                Simon Rockliff, 26th June 1991
 */



#ifndef RSCODEC_H
#define RSCODEC_H
/**
mm: RS code over GF(2^4)
nn: nn= (2^mm) - 1   length of codeword
tt: number of errors that can be corrected
kk: kk = nn-2*tt
pp: irreducible polynomial coeffts, pp [mm] send as int
*/
class RScodec {
public:
    RScodec(unsigned int pp, int mm, int tt);

    ~RScodec();
//    bool encode(int *data, int *parity);
//    int decode(int *recd);
    bool encode(unsigned char *data, unsigned char *parity);
    int decode(unsigned char *data);
    bool isOkey(){return isOk;}
    const unsigned int* indexOf() {return index_of;}
    const int* alphaTo() {return alpha_to;}

private:
    void RSgenerate_gf(unsigned int pp);
    void RSgen_poly();
    int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc, int* z, int* err, int* reg, int bb);


private:
    int mm; //RS code over GF(2^4)
    int tt; //number of errors that can be corrected
    int nn; //(2^mm) - 1   length of codeword
    int kk; //nn-2*tt length of original data

    int *gg;
    bool isOk;
    unsigned int *index_of;
    int *alpha_to;
};

#endif // RSCODEC_H