summaryrefslogtreecommitdiff
path: root/FastDecode.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
committerChristoph Berg <myon@debian.org>2026-09-26 23:24:03 +0200
commit059831534c7e884f0a607ed86b582fd00d821731 (patch)
tree76bcb67a78f8aa2654fd34c2ad801a62136b0170 /FastDecode.cpp
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
New upstream version 3.2.0~rc1+dfsgupstream/3.2.0_rc1+dfsg
Diffstat (limited to 'FastDecode.cpp')
-rw-r--r--FastDecode.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/FastDecode.cpp b/FastDecode.cpp
new file mode 100644
index 00000000..ad60f6e6
--- /dev/null
+++ b/FastDecode.cpp
@@ -0,0 +1,42 @@
+#include "FastDecode.hpp"
+#include "wsjtx_config.h"
+#include "DecDataMutex.hpp"
+
+#include <cstring>
+#include <functional>
+#include <algorithm>
+#include <memory>
+#include <vector>
+#include <QMutexLocker>
+#include <QtConcurrent/QtConcurrentRun>
+
+extern "C" void fast_decode_ (short[], int[], double *, char[], char[], char[],
+ fortran_charlen_t, fortran_charlen_t,
+ fortran_charlen_t);
+
+QFuture<FastDecodeResult> startFastDecode (short const samples[], int const arguments[],
+ double period, char const myCall[],
+ char const hisCall[])
+{
+ FastDecodeResult result;
+ std::copy_n (arguments, result.arguments.size (), result.arguments.begin ());
+ std::array<char, 12> ownCall, dxCall;
+ std::copy_n (myCall, ownCall.size (), ownCall.begin ());
+ std::copy_n (hisCall, dxCall.size (), dxCall.begin ());
+ auto captured = std::make_shared<std::vector<short>> (360000, 0);
+ {
+ QMutexLocker lock {&dec_data_mutex ()};
+ std::copy_n (samples, std::max (0, std::min (360000, arguments[1])),
+ captured->begin ());
+ }
+ return QtConcurrent::run ([=] () mutable {
+ // fast_decode retains Fortran SAVE state between invocations. Independent
+ // sample ownership alone does not make concurrent decoder entry safe.
+ static QMutex decoderMutex;
+ QMutexLocker lock {&decoderMutex};
+ fast_decode_ (captured->data (), result.arguments.data (), &period,
+ result.messages.data (), ownCall.data (), dxCall.data (),
+ fortran_charlen_t (8000), fortran_charlen_t (12), fortran_charlen_t (12));
+ return result;
+ });
+}