From 8c2e6ed4333a9918038ba25a282e6d2009f6338c Mon Sep 17 00:00:00 2001 From: pabr Date: Thu, 13 Jul 2017 11:45:58 +0200 Subject: [PATCH] cstnl_receiver: Handle overflows to improve timing recovery at low SNR --- src/leansdr/sdr.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/leansdr/sdr.h b/src/leansdr/sdr.h index 2f0486c..8a11f93 100644 --- a/src/leansdr/sdr.h +++ b/src/leansdr/sdr.h @@ -399,7 +399,20 @@ namespace leansdr { s_angle phase_error; }; inline result *lookup(float I, float Q) { - // float-to-s8 saturates on some platorms, which is good. + // Handling of overflows beyond the lookup table: + // - For BPSK/QPSK/8PSK we only care about the phase, + // so the following is fine. + // - For amplitude modulations this is not appropriate. + // However, if there is enough noise to cause overflow, + // demodulation would probably fail anyway. + // + // Comment-out for better throughput at high SNR. +#if 1 + while ( I<-128 || I>127 || Q<-128 || Q>127 ) { + I *= 0.5; + Q *= 0.5; + } +#endif return &lut[(u8)(s8)I][(u8)(s8)Q]; } inline result *lookup(int I, int Q) {