Imported Upstream version 3.0
[debian/gnuradio] / gnuradio-core / src / lib / reed-solomon / fixed.h
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 static inline int mod255(int x){
11   while (x >= 255) {
12     x -= 255;
13     x = (x >> 8) + (x & 255);
14   }
15   return x;
16 }
17 #define MODNN(x) mod255(x)
18
19 extern unsigned char CCSDS_alpha_to[];
20 extern unsigned char CCSDS_index_of[];
21 extern unsigned char CCSDS_poly[];
22
23 #define MM 8
24 #define NN 255
25 #define ALPHA_TO CCSDS_alpha_to
26 #define INDEX_OF CCSDS_index_of
27 #define GENPOLY CCSDS_poly
28 #define NROOTS 32
29 #define FCR 112
30 #define PRIM 11
31 #define IPRIM 116
32 #define A0 (NN)
33
34 #define ENCODE_RS encode_rs_8
35 #define DECODE_RS decode_rs_8
36
37 void ENCODE_RS(DTYPE *data,DTYPE *parity);
38 int DECODE_RS(DTYPE *data, int *eras_pos, int no_eras);