Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
reedsolomon.h
Go to the documentation of this file.
1
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/* Set one of these to enable encoder/decoder debugging and error checking,
19 * at the expense of speed */
20/* #undef DEBUG 1*/
21/* #undef DEBUG 2*/
22#undef DEBUG
23
24/* To select the CCSDS standard (255,223) code, define CCSDS. This
25 * implies standard values for MM, KK, B0 and PRIM.
26 */
27/* #undef CCSDS 1*/
28#undef CCSDS
29#ifndef CCSDS
30
31/* Otherwise, leave CCSDS undefined and set the parameters below:
32 *
33 * Set MM to be the size of each code symbol in bits. The Reed-Solomon
34 * block size will then be NN = 2**M - 1 symbols. Supported values are
35 * defined in rs.c.
36 */
37#define MM 8 /* Symbol size in bits */
38
39/*
40 * Set KK to be the number of data symbols in each block, which must be
41 * less than the block size. The code will then be able to correct up
42 * to NN-KK erasures or (NN-KK)/2 errors, or combinations thereof with
43 * each error counting as two erasures.
44 */
45#define KK 207 /* Number of data symbols per block */
46
47/* Set B0 to the first root of the generator polynomial, in alpha form, and
48 * set PRIM to the power of alpha used to generate the roots of the
49 * generator polynomial. The generator polynomial will then be
50 * @**PRIM*B0, @**PRIM*(B0+1), @**PRIM*(B0+2)...@**PRIM*(B0+NN-KK)
51 * where "@" represents a lower case alpha.
52 */
53#define B0 1 /* First root of generator polynomial, alpha form */
54#define PRIM 1 /* power of alpha used to generate roots of generator poly */
55#define STANDARD_ORDER
56
57/* If you want to select your own field generator polynomial, you'll have
58 * to edit that in rs.c.
59 */
60
61#else /* CCSDS */
62/* Don't change these, they're CCSDS standard */
63#define MM 8
64#define KK 223
65#define B0 112
66#define PRIM 11
67#endif
68
69#define NN ((1 << MM) - 1)
70
71#if MM <= 8
72typedef unsigned char dtype;
73#else
74typedef unsigned int dtype;
75#endif
76
77/* Reed-Solomon encoding
78 * data[] is the input block, parity symbols are placed in bb[]
79 * bb[] may lie past the end of the data, e.g., for (255,223):
80 * encode_rs(&data[0],&data[223]);
81 */
82int encode_rs(dtype data[], dtype bb[]);
83
84/* Reed-Solomon erasures-and-errors decoding
85 * The received block goes into data[], and a list of zero-origin
86 * erasure positions, if any, goes in eras_pos[] with a count in no_eras.
87 *
88 * The decoder corrects the symbols in place, if possible and returns
89 * the number of corrected symbols. If the codeword is illegal or
90 * uncorrectible, the data array is unchanged and -1 is returned
91 */
92int eras_dec_rs(dtype data[], int eras_pos[], int no_eras);
93
94#ifdef __cplusplus
95}
96#endif