From cd7f0c16c4effecf2345fb740ce7e617a1471485 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 6 Apr 2024 10:46:39 +0200 Subject: [PATCH] FT8: implement Gray decoding when decoding from magnitudes --- ft8/ft8.cpp | 29 ++++++++++++++++++++++++++++- ft8/ft8.h | 5 +++++ sdrbench/test_ft8protocols.cpp | 3 ++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index a64911f60..a3c6a8397 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -1233,6 +1233,32 @@ std::vector> FT8::un_gray_code_r(const std::vector> FT8::un_gray_code_r_gen(const std::vector> &mags) +{ + if (mags.size() == 0) { + return mags; + } + + std::vector> magsa(mags.size()); + int nsyms = mags.front().size(); + + for (unsigned int si = 0; si < mags.size(); si++) + { + magsa[si].resize(nsyms); + + for (int bini = 0; bini < nsyms; bini++) + { + int grayi = bini ^ (bini >> 1); + magsa[si][bini] = mags[si][grayi]; + } + } + + return magsa; +} + // // normalize levels by windowed median. // this helps, but why? @@ -1919,6 +1945,7 @@ void FT8::soft_decode_mags(FT8Params& params, const std::vector>& mags, int nbSymbolBits, float ll174[]); + // + // Generic Gray decoding for magnitudes (floats) + // + static std::vector> un_gray_code_r_gen(const std::vector> &mags); + private: // // reduce the sample rate from arate to brate. diff --git a/sdrbench/test_ft8protocols.cpp b/sdrbench/test_ft8protocols.cpp index b5cdc4d41..573259c75 100644 --- a/sdrbench/test_ft8protocols.cpp +++ b/sdrbench/test_ft8protocols.cpp @@ -322,7 +322,8 @@ void TestFT8Protocols::testSoftDecode(const QStringList& argElements) } symbol = symbol % symbolSize; - magSymbols[symbol] += 0.01; + symbol = symbol ^(symbol >> 1); // Gray code + magSymbols[symbol] += 0.015; mags.push_back(magSymbols); }