Houston, we have a trunk.
[debian/gnuradio] / gnuradio-core / src / lib / reed-solomon / gen_ccsds_tal.c
1 /* Conversion lookup tables from conventional alpha to Berlekamp's
2  * dual-basis representation. Used in the CCSDS version only.
3  * taltab[] -- convert conventional to dual basis
4  * tal1tab[] -- convert dual basis to conventional
5
6  * Note: the actual RS encoder/decoder works with the conventional basis.
7  * So data is converted from dual to conventional basis before either
8  * encoding or decoding and then converted back.
9  *
10  * Copyright 2002 Phil Karn, KA9Q
11  * May be used under the terms of the GNU General Public License (GPL)
12  */
13 #include <stdio.h>
14 unsigned char Taltab[256],Tal1tab[256];
15
16 static unsigned char tal[] = { 0x8d, 0xef, 0xec, 0x86, 0xfa, 0x99, 0xaf, 0x7b };
17
18 /* Generate conversion lookup tables between conventional alpha representation
19  * (@**7, @**6, ...@**0)
20  *  and Berlekamp's dual basis representation
21  * (l0, l1, ...l7)
22  */
23 int main(){
24   int i,j,k;
25
26   for(i=0;i<256;i++){/* For each value of input */
27     Taltab[i] = 0;
28     for(j=0;j<8;j++) /* for each column of matrix */
29       for(k=0;k<8;k++){ /* for each row of matrix */
30         if(i & (1<<k))
31            Taltab[i] ^= tal[7-k] & (1<<j);
32       }
33     Tal1tab[Taltab[i]] = i;
34   }
35   printf("unsigned char Taltab[] = {\n");
36   for(i=0;i<256;i++){
37     if((i % 16) == 0)
38       printf("\n");
39     printf("0x%02x,",Taltab[i]);
40   }
41   printf("\n};\n\nunsigned char Tal1tab[] = {");
42   for(i=0;i<256;i++){
43     if((i % 16) == 0)
44       printf("\n");
45     printf("0x%02x,",Tal1tab[i]);
46   }
47   printf("\n};\n");
48   exit(0);
49 }
50