use the DVB recommended T=10 BCH code

This commit is contained in:
Ahmet Inan 2021-07-21 17:15:47 +02:00
commit 8d5d7fc0c2
3 changed files with 12 additions and 12 deletions

View file

@ -3,10 +3,10 @@
Quick start:
Create file ```uncoded.dat``` with ```43008``` bits of random data:
Create file ```uncoded.dat``` with ```43040``` bits of random data:
```
dd if=/dev/urandom of=uncoded.dat bs=1 count=5376
dd if=/dev/urandom of=uncoded.dat bs=1 count=5380
```
Encode file ```uncoded.dat``` to ```encoded.wav``` [WAV](https://en.wikipedia.org/wiki/WAV) audio file with 8000 Hz sample rate, 16 bits and only 1 (real) channel:

View file

@ -162,7 +162,7 @@ struct Decoder
static const int guard_len = symbol_len / 8;
static const int ldpc_bits = 64800;
static const int bch_bits = ldpc_bits - 21600;
static const int data_bits = bch_bits - 12 * 16;
static const int data_bits = bch_bits - 10 * 16;
static const int mod_min = 2;
static const int mod_max = 3;
static const int cons_max = ldpc_bits / mod_min;
@ -187,12 +187,12 @@ struct Decoder
CODE::CRC<uint16_t> crc0;
typedef CODE::GaloisField<16, 0b10000000000101101, uint16_t> GF;
GF gf;
CODE::BoseChaudhuriHocquenghemDecoder<24, 1, 65343, GF> bchdec1;
CODE::BoseChaudhuriHocquenghemDecoder<20, 1, 65375, GF> bchdec1;
CODE::OrderedStatisticsDecoder<255, 71, 4> osddec;
CODE::LDPCDecoder<DVB_T2_TABLE_A3, 1> ldpcdec;
int8_t genmat[255*71];
int8_t code[ldpc_bits], bint[ldpc_bits];
uint16_t erasures[24];
uint16_t erasures[20];
cmplx head[symbol_len], tail[symbol_len], cons[cons_max];
cmplx fdom[symbol_len], tdom[buffer_len], resam[buffer_len];
value cfo_rad, sfo_rad;
@ -478,10 +478,10 @@ struct Decoder
int ecnt = 0;
for (int i = 0; i < bch_bits; ++i) {
if (!code[i]) {
if (ecnt < 24) {
if (ecnt < 20) {
erasures[ecnt++] = i;
} else {
std::cerr << "payload LDPC produced more than 24 erasures." << std::endl;
std::cerr << "payload LDPC produced more than 20 erasures." << std::endl;
return;
}
}
@ -548,7 +548,7 @@ int main(int argc, char **argv)
std::cerr << "Couldn't open file \"" << output_name << "\" for writing." << std::endl;
return 1;
}
const int data_len = code_len - (12 * 16 + 21600) / 8;
const int data_len = code_len - (10 * 16 + 21600) / 8;
CODE::Xorshift32 scrambler;
for (int i = 0; i < data_len; ++i)
output_data[i] ^= scrambler();

View file

@ -30,7 +30,7 @@ struct Encoder
static const int guard_len = symbol_len / 8;
static const int ldpc_bits = 64800;
static const int bch_bits = ldpc_bits - 21600;
static const int data_bits = bch_bits - 12 * 16;
static const int data_bits = bch_bits - 10 * 16;
static const int mls0_len = 127;
static const int mls0_poly = 0b10001001;
static const int mls1_len = 255;
@ -42,7 +42,7 @@ struct Encoder
DSP::FastFourierTransform<4*symbol_len, cmplx, 1> bwd4;
CODE::CRC<uint16_t> crc0;
CODE::BoseChaudhuriHocquenghemEncoder<255, 71> bchenc0;
CODE::BoseChaudhuriHocquenghemEncoder<65535, 65343> bchenc1;
CODE::BoseChaudhuriHocquenghemEncoder<65535, 65375> bchenc1;
CODE::LDPCEncoder<DVB_T2_TABLE_A3> ldpcenc;
int8_t code[ldpc_bits], bint[ldpc_bits];
cmplx fdom[symbol_len], fdom4[4*symbol_len];
@ -199,7 +199,7 @@ struct Encoder
0b10000000000101101, 0b10000000101110011, 0b10000111110111101,
0b10101101001010101, 0b10001111100101111, 0b11111011110110101,
0b11010111101100101, 0b10111001101100111, 0b10000111010100001,
0b10111010110100111, 0b10011101000101101, 0b10001101011100011}),
0b10111010110100111}),
oper_mode(oper_mode)
{
switch (oper_mode) {
@ -337,7 +337,7 @@ int main(int argc, char **argv)
return 1;
}
const int code_len = 64800 / 8;
const int data_len = code_len - (12 * 16 + 21600) / 8;
const int data_len = code_len - (10 * 16 + 21600) / 8;
uint8_t *input_data = new uint8_t[code_len];
for (int i = 0; i < data_len; ++i)
input_data[i] = input_file.get();