M17: FrameDecoder: drop stream frames with high BER
In case the number of bit errors detected by the viterbi algorithm in a stream frame are above a given threshold, do not copy its payload. This prevents audio artifacts when data is processed by codec2 decoder.
This commit is contained in:
parent
5fe5cb287b
commit
76ffe2d612
|
|
@ -140,6 +140,9 @@ private:
|
|||
|
||||
///< Maximum allowed hamming distance when determining the frame type.
|
||||
static constexpr uint8_t MAX_SYNC_HAMM_DISTANCE = 4;
|
||||
|
||||
///< Maximum number of corrected bit errors allowed in a stream frame.
|
||||
static constexpr uint16_t MAX_VITERBI_ERRORS = 15;
|
||||
};
|
||||
|
||||
} // namespace M17
|
||||
|
|
|
|||
|
|
@ -155,7 +155,9 @@ void M17FrameDecoder::decodeStream(const std::array<uint8_t, 46> &data)
|
|||
begin += lich.size();
|
||||
std::copy(begin, data.end(), punctured.begin());
|
||||
|
||||
viterbi.decodePunctured(punctured, tmp, DATA_PUNCTURE);
|
||||
// Skip payload copy if BER is too high to avoid audio artifacts
|
||||
uint16_t bitErrs = viterbi.decodePunctured(punctured, tmp, DATA_PUNCTURE);
|
||||
if (bitErrs < MAX_VITERBI_ERRORS)
|
||||
memcpy(&streamFrame.data, tmp.data(), tmp.size());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue