1 /* Configure the RS codec with fixed parameters for CCSDS standard
2  * (255,223) code over GF(256). Note: the conventional basis is still
3  * used; the dual-basis mappings are performed in [en|de]code_rs_ccsds.c
4  *
5  * Copyright 2002 Phil Karn, KA9Q
6  * May be used under the terms of the GNU General Public License (GPL)
7  */
8 #define DTYPE unsigned char
9 
10 #include <gnuradio/fec/api.h>
11 
mod255(int x)12 static inline int mod255(int x)
13 {
14     while (x >= 255) {
15         x -= 255;
16         x = (x >> 8) + (x & 255);
17     }
18     return x;
19 }
20 #define MODNN(x) mod255(x)
21 
22 extern unsigned char CCSDS_alpha_to[];
23 extern unsigned char CCSDS_index_of[];
24 extern unsigned char CCSDS_poly[];
25 
26 #define MM 8
27 #define NN 255
28 #define ALPHA_TO CCSDS_alpha_to
29 #define INDEX_OF CCSDS_index_of
30 #define GENPOLY CCSDS_poly
31 #define NROOTS 32
32 #define FCR 112
33 #define PRIM 11
34 #define IPRIM 116
35 #define A0 (NN)
36 
37 #define ENCODE_RS encode_rs_8
38 #define DECODE_RS decode_rs_8
39 
40 FEC_API void ENCODE_RS(DTYPE* data, DTYPE* parity);
41 FEC_API int DECODE_RS(DTYPE* data, int* eras_pos, int no_eras);