diff --git a/M17Control.cpp b/M17Control.cpp index 5cb92506..523c133b 100644 --- a/M17Control.cpp +++ b/M17Control.cpp @@ -258,29 +258,12 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) unsigned char frame[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES]; unsigned int errors = conv.decodeData(data + 2U + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES, frame); - // If we have a BER of less than 12, then we consider the audio to be usable - bool valid = errors < 12U; - - if (!valid) { - m_rfFN++; - - frame[0U] = (m_rfFN >> 8) & 0xFFU; - frame[1U] = (m_rfFN >> 0) & 0xFFU; - - if (m_rfState == RS_RF_AUDIO) { - ::memcpy(frame + 2U + 0U, M17_3200_SILENCE, 8U); - ::memcpy(frame + 2U + 8U, M17_3200_SILENCE, 8U); - } else { - ::memcpy(frame + 2U + 0U, M17_1600_SILENCE, 4U); - ::memcpy(frame + 2U + 4U, M17_1600_SILENCE, 4U); - ::memset(frame + 2U + 8U, 0x00U, 8U); - } - } else { - m_rfFN = (frame[0U] << 8) + (frame[1U] << 0); - } + m_rfFN = (frame[0U] << 8) + (frame[1U] << 0); LogDebug("M17, audio: FN: %u, errs: %u/272 (%.1f%%)", m_rfFN & 0x7FFFU, errors, float(errors) / 2.72F); + m_rfFN++; + m_rfBits += 272U; m_rfErrs += errors; @@ -343,7 +326,7 @@ bool CM17Control::writeModem(unsigned char* data, unsigned int len) m_rfLSFn = 0U; // Only check for the EOT marker if the frame has a reasonable BER - if (valid && ((m_rfFN & 0x8000U) == 0x8000U)) { + if ((m_rfFN & 0x8000U) == 0x8000U) { std::string source = m_rfLSF.getSource(); std::string dest = m_rfLSF.getDest(); diff --git a/M17Convolution.cpp b/M17Convolution.cpp index 16911cd5..7b2b02fb 100644 --- a/M17Convolution.cpp +++ b/M17Convolution.cpp @@ -33,7 +33,7 @@ const unsigned int PUNCTURE_LIST_LINK_SETUP[] = { 362U, 369U, 372U, 375U, 378U, 385U, 388U, 391U, 394U, 401U, 404U, 407U, 410U, 417U, 420U, 423U, 430U, 433U, 436U, 439U, 446U, 449U, 452U, 455U, 462U, 465U, 468U, 471U, 478U, 481U, 484U}; -const unsigned int PUNCTURE_LIST_DATA_COUNT = 22U; +const unsigned int PUNCTURE_LIST_DATA_COUNT = 12U; const unsigned int PUNCTURE_LIST_DATA[] = { 11U, 23U, 35U, 47U, 59U, 71U, 83U, 95U, 107U, 119U, 131U, 143U, 155U, 167U, 179U, 191U, 203U, 215U, 227U, 239U, 251U, 263U, @@ -128,6 +128,7 @@ unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned assert(out != NULL); uint8_t temp[500U]; + ::memset(temp, 0x00U, 500U); unsigned int n = 0U; unsigned int index = 0U; @@ -141,9 +142,6 @@ unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned temp[n++] = b ? 2U : 0U; } - for (unsigned int i = 0U; i < 8U; i++) - temp[n++] = 0U; - start(); n = 0U; @@ -154,7 +152,7 @@ unsigned int CM17Convolution::decodeLinkSetup(const unsigned char* in, unsigned decode(s0, s1); } - return chainback(out, 144U) - PUNCTURE_LIST_LINK_SETUP_COUNT; + return chainback(out, 240U) - PUNCTURE_LIST_LINK_SETUP_COUNT; } unsigned int CM17Convolution::decodeData(const unsigned char* in, unsigned char* out) @@ -162,7 +160,8 @@ unsigned int CM17Convolution::decodeData(const unsigned char* in, unsigned char* assert(in != NULL); assert(out != NULL); - uint8_t temp[350U]; + uint8_t temp[300U]; + ::memset(temp, 0x00U, 300U); unsigned int n = 0U; unsigned int index = 0U; @@ -176,20 +175,17 @@ unsigned int CM17Convolution::decodeData(const unsigned char* in, unsigned char* temp[n++] = b ? 2U : 0U; } - for (unsigned int i = 0U; i < 8U; i++) - temp[n++] = 0U; - start(); n = 0U; - for (unsigned int i = 0U; i < 164U; i++) { + for (unsigned int i = 0U; i < 148U; i++) { uint8_t s0 = temp[n++]; uint8_t s1 = temp[n++]; decode(s0, s1); } - return chainback(out, 160U) - PUNCTURE_LIST_DATA_COUNT; + return chainback(out, 144U) - PUNCTURE_LIST_DATA_COUNT; } void CM17Convolution::start() diff --git a/Version.h b/Version.h index da810b91..907a357a 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20210810"; +const char* VERSION = "20210811"; #endif