aboutsummaryrefslogtreecommitdiffstats
path: root/blocklib/fec/lib/reed-solomon/encode_rs_ccsds.c
blob: 7080b3f4196143c195d1ee060f94a8db7fa505a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* This function wraps around the fixed 8-bit encoder, performing the
 * basis transformations necessary to meet the CCSDS standard
 *
 * Copyright 2002, Phil Karn, KA9Q
 * May be used under the terms of the GNU General Public License (GPL)
 */
#define FIXED
#include "ccsds.h"
#include "fixed.h"

void encode_rs_ccsds(unsigned char* data, unsigned char* parity)
{
    int i;
    unsigned char cdata[NN - NROOTS];

    /* Convert data from dual basis to conventional */
    for (i = 0; i < NN - NROOTS; i++)
        cdata[i] = Tal1tab[data[i]];

    encode_rs_8(cdata, parity);

    /* Convert parity from conventional to dual basis */
    for (i = 0; i < NN - NROOTS; i++)
        parity[i] = Taltab[parity[i]];
}