kopia lustrzana https://github.com/OpenRTX/OpenRTX
Improve runtime performance of M17 Demodulator
Tweaked the exponential moving average alpha factors to improve the reactivity of the M17 demodulator. TG-81pull/68/head
rodzic
5ef145cd39
commit
77aead675a
|
@ -113,7 +113,7 @@ private:
|
||||||
static constexpr size_t M17_INPUT_BUF_SIZE = 2 * M17_FRAME_SAMPLES_24K;
|
static constexpr size_t M17_INPUT_BUF_SIZE = 2 * M17_FRAME_SAMPLES_24K;
|
||||||
static constexpr size_t M17_FRAME_BYTES = M17_FRAME_SYMBOLS / 4;
|
static constexpr size_t M17_FRAME_BYTES = M17_FRAME_SYMBOLS / 4;
|
||||||
static constexpr float conv_stats_alpha = 0.001f;
|
static constexpr float conv_stats_alpha = 0.001f;
|
||||||
static constexpr float qnt_stats_alpha = 0.99995f;
|
static constexpr float qnt_stats_alpha = 0.9f;
|
||||||
static constexpr float conv_threshold_factor = 3.40;
|
static constexpr float conv_threshold_factor = 3.40;
|
||||||
static constexpr size_t M17_BRIDGE_SIZE = M17_SAMPLES_PER_SYMBOL *
|
static constexpr size_t M17_BRIDGE_SIZE = M17_SAMPLES_PER_SYMBOL *
|
||||||
M17_SYNCWORD_SYMBOLS;
|
M17_SYNCWORD_SYMBOLS;
|
||||||
|
|
|
@ -315,6 +315,7 @@ void M17Demodulator::update()
|
||||||
locked = true;
|
locked = true;
|
||||||
isLSF = syncword.lsf;
|
isLSF = syncword.lsf;
|
||||||
offset = syncword.index + 1;
|
offset = syncword.index + 1;
|
||||||
|
frameIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// While we are locked, demodulate available samples
|
// While we are locked, demodulate available samples
|
||||||
|
@ -330,7 +331,7 @@ void M17Demodulator::update()
|
||||||
getQuantizationMax() / 2,
|
getQuantizationMax() / 2,
|
||||||
getQuantizationMin() / 2,
|
getQuantizationMin() / 2,
|
||||||
symbol * 666,
|
symbol * 666,
|
||||||
symbol_index);
|
frameIndex == 0 ? 2300 : symbol_index);
|
||||||
#endif
|
#endif
|
||||||
setSymbol<M17_FRAME_BYTES>(*activeFrame, frameIndex, symbol);
|
setSymbol<M17_FRAME_BYTES>(*activeFrame, frameIndex, symbol);
|
||||||
decoded_syms++;
|
decoded_syms++;
|
||||||
|
@ -341,12 +342,12 @@ void M17Demodulator::update()
|
||||||
std::swap(activeFrame, idleFrame);
|
std::swap(activeFrame, idleFrame);
|
||||||
frameIndex = 0;
|
frameIndex = 0;
|
||||||
// DEBUG: print idleFrame bytes
|
// DEBUG: print idleFrame bytes
|
||||||
//for(size_t i = 0; i < idleFrame->size(); i+=2)
|
for(size_t i = 0; i < idleFrame->size(); i+=2)
|
||||||
//{
|
{
|
||||||
// if (i % 16 == 14)
|
if (i % 16 == 14)
|
||||||
// printf("\r\n");
|
printf("\r\n");
|
||||||
// printf(" %02X%02X", (*idleFrame)[i], (*idleFrame)[i+1]);
|
printf(" %02X%02X", (*idleFrame)[i], (*idleFrame)[i+1]);
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
// If syncword is not valid, lock is lost, accept 2 bit errors
|
// If syncword is not valid, lock is lost, accept 2 bit errors
|
||||||
if (frameIndex == M17_SYNCWORD_SYMBOLS &&
|
if (frameIndex == M17_SYNCWORD_SYMBOLS &&
|
||||||
|
|
|
@ -149,13 +149,13 @@ int main()
|
||||||
syncword = m17Demodulator.nextFrameSync(offset);
|
syncword = m17Demodulator.nextFrameSync(offset);
|
||||||
for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL; i++)
|
for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL; i++)
|
||||||
{
|
{
|
||||||
if ((int) i == syncword.index + 2) {
|
if ((int) i == (syncword.index + 1)) {
|
||||||
if (syncword.lsf)
|
if (syncword.lsf)
|
||||||
detect = -4000;
|
detect = -4000;
|
||||||
else
|
else
|
||||||
detect = 4000;
|
detect = 4000;
|
||||||
syncword = m17Demodulator.nextFrameSync(syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL);
|
syncword = m17Demodulator.nextFrameSync(syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL);
|
||||||
} else if (((int) i % 10) == ((syncword.index + 2) % 10)) {
|
} else if (((int) i % 10) == ((syncword.index + 1) % 10)) {
|
||||||
m17Demodulator.updateQuantizationStats(i);
|
m17Demodulator.updateQuantizationStats(i);
|
||||||
symbol = m17Demodulator.quantize(i) * 1000;
|
symbol = m17Demodulator.quantize(i) * 1000;
|
||||||
detect = 3000;
|
detect = 3000;
|
||||||
|
|
Ładowanie…
Reference in New Issue