blob: fc755030b54c6361f0c55be63b9d16f61671ad1b [file] [log] [blame]
Bill Yi4e213d52015-06-23 13:53:11 -07001/* 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 Lesser General Public License (LGPL)
12 */
13#include <stdio.h>
14#include <stdlib.h>
15
16#define DTYPE unsigned char
17DTYPE Taltab[256],Tal1tab[256];
18
19static DTYPE tal[] = { 0x8d, 0xef, 0xec, 0x86, 0xfa, 0x99, 0xaf, 0x7b };
20
21/* Generate conversion lookup tables between conventional alpha representation
22 * (@**7, @**6, ...@**0)
23 * and Berlekamp's dual basis representation
24 * (l0, l1, ...l7)
25 */
26int main(){
27 int i,j,k;
28
29 for(i=0;i<256;i++){/* For each value of input */
30 Taltab[i] = 0;
31 for(j=0;j<8;j++) /* for each column of matrix */
32 for(k=0;k<8;k++){ /* for each row of matrix */
33 if(i & (1<<k))
34 Taltab[i] ^= tal[7-k] & (1<<j);
35 }
36 Tal1tab[Taltab[i]] = i;
37 }
38 printf("unsigned char Taltab[] = {\n");
39 for(i=0;i<256;i++){
40 if((i % 16) == 0)
41 printf("\n");
42 printf("0x%02x,",Taltab[i]);
43 }
44 printf("\n};\n\nunsigned char Tal1tab[] = {");
45 for(i=0;i<256;i++){
46 if((i % 16) == 0)
47 printf("\n");
48 printf("0x%02x,",Tal1tab[i]);
49 }
50 printf("\n};\n");
51 exit(0);
52}
53