1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00

ChirpChat demod: FT decoding: try symbol shifts

This commit is contained in:
f4exb 2024-04-06 10:51:52 +02:00
parent 8961e1a353
commit 9c72d4fd14
2 changed files with 84 additions and 5 deletions

View File

@ -54,16 +54,40 @@ void ChirpChatDemodDecoderFT::decodeSymbols(
return;
}
float *lls = new float[mags.size()*nbSymbolBits]; // bits log likelihoods (>0 for 0, <0 for 1)
std::fill(lls, lls+mags.size()*nbSymbolBits, 0.0);
// float *lls = new float[mags.size()*nbSymbolBits]; // bits log likelihoods (>0 for 0, <0 for 1)
// std::fill(lls, lls+mags.size()*nbSymbolBits, 0.0);
FT8::FT8Params params;
FT8::FT8::soft_decode_mags(params, mags, nbSymbolBits, lls);
// FT8::FT8::soft_decode_mags(params, mags, nbSymbolBits, lls);
int r174[174];
std::string comments;
payloadParityStatus = (int) ChirpChatDemodSettings::ParityOK;
payloadCRCStatus = false;
std::vector<std::vector<float>> magsp = mags;
if (FT8::FT8::decode(lls, r174, params, 0, comments) == 0)
qDebug("ChirpChatDemodDecoderFT::decodeSymbols: try decode with symbol shift 0");
int res = decodeWithShift(params, magsp, nbSymbolBits, r174, comments);
if (res == 0)
{
std::vector<std::vector<float>> magsn = mags;
int shiftcount = 0;
while ((res == 0) && (shiftcount < 7))
{
qDebug("ChirpChatDemodDecoderFT::decodeSymbols: try decode with symbol shift %d", shiftcount + 1);
res = decodeWithShift(params, magsp, nbSymbolBits, r174, comments, 1);
if (res == 0)
{
qDebug("ChirpChatDemodDecoderFT::decodeSymbols: try decode with symbol shift -%d", shiftcount + 1);
res = decodeWithShift(params, magsn, nbSymbolBits, r174, comments, -1);
}
shiftcount++;
}
}
if (res == 0)
{
if (comments == "LDPC fail")
{
@ -108,4 +132,45 @@ void ChirpChatDemodDecoderFT::decodeSymbols(
}
}
int ChirpChatDemodDecoderFT::decodeWithShift(
FT8::FT8Params& params,
std::vector<std::vector<float>>& mags,
int nbSymbolBits,
int *r174,
std::string& comments,
int shift
)
{
if (shift > 0)
{
for (unsigned int si = 0; si < mags.size(); si++)
{
for (int bini = (1<<nbSymbolBits) - 1; bini > 0; bini--)
{
float x = mags[si][bini - 1];
mags[si][bini - 1] = mags[si][bini];
mags[si][bini] = x;
}
}
}
if (shift < 0)
{
for (unsigned int si = 0; si < mags.size(); si++)
{
for (int bini = 0; bini < (1<<nbSymbolBits) - 1; bini++)
{
float x = mags[si][bini + 1];
mags[si][bini + 1] = mags[si][bini];
mags[si][bini] = x;
}
}
}
float *lls = new float[mags.size()*nbSymbolBits]; // bits log likelihoods (>0 for 0, <0 for 1)
std::fill(lls, lls+mags.size()*nbSymbolBits, 0.0);
FT8::FT8::soft_decode_mags(params, mags, nbSymbolBits, lls);
return FT8::FT8::decode(lls, r174, params, 0, comments);
}
#endif // HAS_FT8

View File

@ -21,6 +21,10 @@
#include <vector>
#include <string>
namespace FT8 {
class FT8Params;
}
class ChirpChatDemodDecoderFT
{
public:
@ -39,10 +43,20 @@ public:
std::string& call1, //!< 1st callsign or shorthand
std::string& call2, //!< 2nd callsign
std::string& loc, //!< locator, report or shorthand
bool& reply , //!< true if message is a reply report
bool& reply, //!< true if message is a reply report
int& payloadParityStatus,
bool& payloadCRCStatus
);
private:
static int decodeWithShift(
FT8::FT8Params& params,
std::vector<std::vector<float>>& mags,
int nbSymbolBits,
int *r174,
std::string& comments,
int shift = 0
);
};