/////////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2022 Jon Beniston, M7RCE // // // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation as version 3 of the License, or // // (at your option) any later version. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License V3 for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include "testbench.h" #include "algorithms.h" #include "ldpc.h" #include "layered_decoder.h" class LDPCWorker : public QObject { Q_OBJECT public: LDPCWorker(int modcod, int maxTrials, int batchSize, bool shortFrames); ~LDPCWorker(); // Are we busy bool busy() { QMutexLocker locker(&m_mutexIn); return m_dataIn.size() >= BLOCKS; } // Is processed data available? bool dataAvailable() { QMutexLocker locker(&m_mutexOut); return !m_dataOut.isEmpty(); } // Get processed data QByteArray data() { m_mutexOut.lock(); if (m_dataOut.isEmpty()) { m_condOut.wait(&m_mutexOut); } QByteArray data = m_dataOut.takeAt(0); m_mutexOut.unlock(); return data; } public slots: void process(QByteArray data); signals: void finished(); private: QMutex m_mutexIn; QMutex m_mutexOut; QWaitCondition m_condOut; QList m_dataIn; QList m_dataOut; int m_maxTrials; int BLOCKS; int m_codeLen; int m_dataLen; void *m_aligned_buffer; ldpctool::LDPCInterface *m_ldpc; ldpctool::code_type *m_code; ldpctool::simd_type *m_simd; typedef ldpctool::NormalUpdate update_type; //typedef SelfCorrectedUpdate update_type; //typedef MinSumAlgorithm algorithm_type; //typedef OffsetMinSumAlgorithm algorithm_type; typedef ldpctool::MinSumCAlgorithm algorithm_type; //typedef LogDomainSPA algorithm_type; //typedef LambdaMinAlgorithm algorithm_type; //typedef SumProductAlgorithm algorithm_type; ldpctool::LDPCDecoder m_decode; };