summaryrefslogtreecommitdiff
path: root/controller/fw/src/ldpc_wrapper.cpp
blob: da63343dbf7947954329bb1181032f36b3cc68ff (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdlib.h>
#include <algorithm>
#include <cstdint>
#include <cmath>

#include "ldpc/generic.hh"
#include "ldpc/layered_decoder.hh"

static const int DEFAULT_TRIALS = 25;

struct DVB_S2_TABLE_C9
{
	static const int M = 360;
	static const int N = 16200;
	static const int K = 13320;
	static const int LINKS_MIN_CN = 15;
	static const int LINKS_MAX_CN = 19;
	static const int LINKS_TOTAL = 49319;
	static const int DEG_MAX = 13;
	static const int DEG[];
	static const int LEN[];
	static const int POS[];
};

const int DVB_S2_TABLE_C9::DEG[] = {
    13, 3, 0
};

const int DVB_S2_TABLE_C9::LEN[] = {
    1, 36, 0
};

const int DVB_S2_TABLE_C9::POS[] = {
    3,	2409,	499,	1481,	908,	559,	716,	1270,	333,	2508,	2264,	1702,	2805,
    4,	2447,	1926,
    5,	414,	1224,
    6,	2114,	842,
    7,	212,	573,
    0,	2383,	2112,
    1,	2286,	2348,
    2,	545,	819,
    3,	1264,	143,
    4,	1701,	2258,
    5,	964,	166,
    6,	114,	2413,
    7,	2243,	81,
    0,	1245,	1581,
    1,	775,	169,
    2,	1696,	1104,
    3,	1914,	2831,
    4,	532,	1450,
    5,	91,	974,
    6,	497,	2228,
    7,	2326,	1579,
    0,	2482,	256,
    1,	1117,	1261,
    2,	1257,	1658,
    3,	1478,	1225,
    4,	2511,	980,
    5,	2320,	2675,
    6,	435,	1278,
    7,	228,	503,
    0,	1885,	2369,
    1,	57,	483,
    2,	838,	1050,
    3,	1231,	1990,
    4,	1738,	68,
    5,	2392,	951,
    6,	163,	645,
    7,	2644,	1704,
};

extern "C" {

    int ldpc_decode(float *symbols, int trials) {
        if (trials < 0)
            trials = DEFAULT_TRIALS;

        LDPCDecoder<float, SumProductAlgorithm<float, SelfCorrectedUpdate<float>>, LDPC<DVB_S2_TABLE_C9>> decoder;
        return decoder.run(symbols, symbols+decoder.K, trials, 1);
    }

}