mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
M17 library code cleanup
This commit is contained in:
parent
ac2a45ce88
commit
f00cdc28c9
@ -97,7 +97,7 @@ struct Fsk4Demod
|
||||
dt = ideal_dt - (phase_estimate * (lock ? lock_gain : unlock_gain));
|
||||
t += dt;
|
||||
|
||||
std::tuple<int, float> evm_result = symbol_evm(samples[1]);
|
||||
symbol_evm(samples[1]);
|
||||
int symbol;
|
||||
float evm;
|
||||
std::tie(symbol, evm) = symbol_evm(samples[1]);
|
||||
|
@ -135,12 +135,12 @@ struct LinkSetupFrame
|
||||
bool north = lat_int >= 0;
|
||||
bool east = lon_int >= 0;
|
||||
|
||||
result[2] = (int) abs(lat_int);
|
||||
lat_dec = abs(lat_frac) * 65536.0f;
|
||||
result[2] = (int) std::abs(lat_int);
|
||||
lat_dec = std::abs(lat_frac) * 65536.0f;
|
||||
result[3] = lat_dec >> 8;
|
||||
result[4] = lat_dec & 0xFF;
|
||||
result[5] = (int) abs(lon_int);
|
||||
lon_dec = abs(lon_frac) * 65536.0f;
|
||||
result[5] = (int) std::abs(lon_int);
|
||||
lon_dec = std::abs(lon_frac) * 65536.0f;
|
||||
result[6] = lon_dec >> 8;
|
||||
result[7] = lon_dec & 0xFF;
|
||||
result[8] = (north ? 0 : 1) | ((east ? 0 : 1)<<1) | (1<<2);
|
||||
|
@ -27,7 +27,7 @@ class SlidingDFT
|
||||
static constexpr float kth = float(Frequency) / float(SampleRate);
|
||||
|
||||
// We'd like this to be static constexpr, but std::exp is not a constexpr.
|
||||
const ComplexType coeff_;
|
||||
ComplexType coeff_;
|
||||
std::array<float, N> samples_;
|
||||
ComplexType result_{0,0};
|
||||
size_t index_ = 0;
|
||||
|
@ -16,7 +16,7 @@ namespace modemm17
|
||||
template <size_t N>
|
||||
struct SymbolEvm
|
||||
{
|
||||
using filter_type = BaseIirFilter<float, N>;
|
||||
using filter_type = BaseIirFilter<N>;
|
||||
using symbol_t = int;
|
||||
using result_type = std::tuple<symbol_t, float>;
|
||||
|
||||
@ -42,7 +42,7 @@ struct SymbolEvm
|
||||
symbol_t symbol;
|
||||
float evm;
|
||||
|
||||
sample = std::min(3.0, std::max(-3.0, sample));
|
||||
sample = std::min(3.0f, std::max(-3.0f, sample));
|
||||
|
||||
if (sample > 2)
|
||||
{
|
||||
@ -65,7 +65,7 @@ struct SymbolEvm
|
||||
evm = (sample + 3) * 0.333333;
|
||||
}
|
||||
|
||||
if (erasure_limit_ and (abs(evm) > *erasure_limit_)) symbol = 0;
|
||||
if (erasure_limit_ and (std::abs(evm) > erasure_limit_)) symbol = 0;
|
||||
|
||||
evm_ = filter_(evm);
|
||||
|
||||
@ -79,7 +79,7 @@ SymbolEvm<N> makeSymbolEvm(
|
||||
float erasure_limit = 0.0f
|
||||
)
|
||||
{
|
||||
return std::move(SymbolEvm<float, N>(std::move(filter), erasure_limit));
|
||||
return std::move(SymbolEvm<N>(std::move(filter), erasure_limit));
|
||||
}
|
||||
|
||||
} // modemm17
|
||||
|
@ -146,9 +146,7 @@ auto llr(float sample)
|
||||
template <size_t M, typename T, size_t N, typename U, size_t IN>
|
||||
auto depunctured(std::array<T, N> puncture_matrix, std::array<U, IN> in)
|
||||
{
|
||||
if (M % N != 0) {
|
||||
return;
|
||||
}
|
||||
static_assert(M % N == 0, "M must be an integer multiple of N");
|
||||
|
||||
std::array<U, M> result;
|
||||
size_t index = 0;
|
||||
|
@ -94,7 +94,7 @@ constexpr auto makeCost(Trellis_ trellis)
|
||||
template <typename Trellis_, size_t LLR_ = 2>
|
||||
struct Viterbi
|
||||
{
|
||||
static_assert(LLR_ < 7); // Need to be < 7 to avoid overflow errors.
|
||||
static_assert(LLR_ < 7, "Need to be < 7 to avoid overflow errors");
|
||||
|
||||
static constexpr size_t K = Trellis_::K;
|
||||
static constexpr size_t k = Trellis_::k;
|
||||
@ -162,7 +162,7 @@ struct Viterbi
|
||||
template <size_t IN, size_t OUT>
|
||||
size_t decode(std::array<int8_t, IN> const& in, std::array<uint8_t, OUT>& out)
|
||||
{
|
||||
static_assert(sizeof(history_) >= IN / 2);
|
||||
static_assert(sizeof(history_) >= IN / 2, "Invalid size");
|
||||
|
||||
constexpr auto MAX_METRIC = std::numeric_limits<typename metrics_t::value_type>::max() / 2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user