From 82c279f13b95a7efbdd29440042931febeded754 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 13 Jun 2021 14:45:44 +0200 Subject: [PATCH] minor cleanup --- decode.cc | 15 ++++++++------- encode.cc | 13 +++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/decode.cc b/decode.cc index d3d333b..dd9509b 100644 --- a/decode.cc +++ b/decode.cc @@ -160,10 +160,11 @@ struct Decoder static const int symbol_len = (1280 * rate) / 8000; static const int filter_len = (((21 * rate) / 8000) & ~3) | 1; static const int guard_len = symbol_len / 8; - static const int code_bits = 64800; - static const int data_bits = code_bits - 12 * 16 - 21600; + 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 code_cols = 432; - static const int cons_cnt = code_bits / Mod::BITS; + static const int cons_cnt = ldpc_bits / Mod::BITS; static const int code_rows = cons_cnt / code_cols; static const int code_off = -216; static const int mls0_off = -126; @@ -191,7 +192,7 @@ struct Decoder CODE::OrderedStatisticsDecoder<255, 71, 4> osddec; CODE::LDPCDecoder ldpcdec; int8_t genmat[255*71]; - int8_t code[code_bits], bint[code_bits]; + int8_t code[ldpc_bits], bint[ldpc_bits]; uint16_t erasures[24]; cmplx head[symbol_len], tail[symbol_len], cons[cons_cnt]; cmplx fdom[symbol_len], tdom[buffer_len], resam[buffer_len]; @@ -389,7 +390,7 @@ struct Decoder for (int i = 0; i < cons_cnt; ++i) Mod::soft(bint+Mod::BITS*i, cons[i], precision); deinterleave(); - int count = ldpcdec(code, code+data_bits+12*16); + int count = ldpcdec(code, code + bch_bits); if (count < 0) std::cerr << "payload LDPC decoding did not converge." << std::endl; if (1) { @@ -411,10 +412,10 @@ struct Decoder value sigma = std::sqrt(np / (2 * sp)); precision = 1 / (sigma * sigma); } - for (int i = 0; i < data_bits+12*16; ++i) + for (int i = 0; i < bch_bits; ++i) CODE::set_le_bit(out, i, code[i] < 0); int ecnt = 0; - for (int i = 0; i < data_bits+12*16; ++i) { + for (int i = 0; i < bch_bits; ++i) { if (!code[i]) { if (ecnt < 24) { erasures[ecnt++] = i; diff --git a/encode.cc b/encode.cc index f3af71e..69123af 100644 --- a/encode.cc +++ b/encode.cc @@ -28,10 +28,11 @@ struct Encoder typedef PhaseShiftKeying<8, cmplx, int8_t> Mod; static const int symbol_len = (1280 * rate) / 8000; static const int guard_len = symbol_len / 8; - static const int code_bits = 64800; - static const int data_bits = code_bits - 12 * 16 - 21600; + 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 code_cols = 432; - static const int cons_cnt = code_bits / Mod::BITS; + static const int cons_cnt = ldpc_bits / Mod::BITS; static const int code_rows = cons_cnt / code_cols; static const int mls0_len = 127; static const int mls0_poly = 0b10001001; @@ -46,7 +47,7 @@ struct Encoder CODE::BoseChaudhuriHocquenghemEncoder<255, 71> bchenc0; CODE::BoseChaudhuriHocquenghemEncoder<65535, 65343> bchenc1; CODE::LDPCEncoder ldpcenc; - int8_t code[code_bits], bint[code_bits]; + int8_t code[ldpc_bits], bint[ldpc_bits]; cmplx fdom[symbol_len]; cmplx tdom[symbol_len]; cmplx guard[guard_len]; @@ -170,9 +171,9 @@ struct Encoder meta_data((call_sign << 8) | 2); pilot_block(); bchenc1(inp, inp+data_bits/8, data_bits); - for (int i = 0; i < data_bits+12*16; ++i) + for (int i = 0; i < bch_bits; ++i) code[i] = nrz(CODE::get_le_bit(inp, i)); - ldpcenc(code, code+data_bits+12*16); + ldpcenc(code, code + bch_bits); interleave(); CODE::MLS seq3(mls3_poly), seq4(mls4_poly); for (int j = 0; j < code_rows; ++j) {