From b71926062d4c3fe8847f92add98242f79445ac01 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Tue, 1 Jul 2025 22:53:14 +0200 Subject: [PATCH] use 16 bit LLRs --- decode.cc | 11 ++--------- psk.hh | 6 ++++++ qam.hh | 8 ++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/decode.cc b/decode.cc index f9b5e9b..18989dc 100644 --- a/decode.cc +++ b/decode.cc @@ -34,12 +34,8 @@ namespace DSP { using std::abs; using std::min; using std::cos; using std::sin; template struct Decoder { - typedef int8_t code_type; -#ifdef __AVX2__ - typedef SIMD mesg_type; -#else - typedef SIMD mesg_type; -#endif + typedef int16_t code_type; + typedef SIMD mesg_type; typedef DSP::Const Const; static const int guard_len = rate / 100; static const int symbol_len = guard_len * 16; @@ -387,11 +383,8 @@ struct Decoder np += norm(error); } value precision = sp / np; - // precision = 8; value snr = DSP::decibel(precision); std::cerr << " " << snr; - if (std::is_same::value && precision > 32) - precision = 32; for (int i = 0; i < tone_count; ++i) { if (i % block_length == poff) continue; diff --git a/psk.hh b/psk.hh index f20e3bc..efaabbc 100644 --- a/psk.hh +++ b/psk.hh @@ -27,6 +27,8 @@ struct PhaseShiftKeying<2, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } @@ -66,6 +68,8 @@ struct PhaseShiftKeying<4, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } @@ -112,6 +116,8 @@ struct PhaseShiftKeying<8, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } diff --git a/qam.hh b/qam.hh index 7715e3e..4efbf9c 100644 --- a/qam.hh +++ b/qam.hh @@ -36,6 +36,8 @@ struct QuadratureAmplitudeModulation<16, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } @@ -90,6 +92,8 @@ struct QuadratureAmplitudeModulation<64, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } @@ -148,6 +152,8 @@ struct QuadratureAmplitudeModulation<256, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; } @@ -210,6 +216,8 @@ struct QuadratureAmplitudeModulation<1024, TYPE, CODE> value = std::nearbyint(value); if (std::is_same::value) value = std::min(std::max(value, -127), 127); + if (std::is_same::value) + value = std::min(std::max(value, -32767), 32767); return value; }