From 9e465f52eef9d2ef61f32039ae3336c93a435c12 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 16 Jun 2015 06:03:22 +0000 Subject: [PATCH] overflow issues with SNR calcs git-svn-id: https://svn.code.sf.net/p/freetel/code@2196 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/cohpsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codec2-dev/src/cohpsk.c b/codec2-dev/src/cohpsk.c index 65ed6f53..a8ec0c22 100644 --- a/codec2-dev/src/cohpsk.c +++ b/codec2-dev/src/cohpsk.c @@ -1108,7 +1108,8 @@ void cohpsk_get_demod_stats(struct COHPSK *coh, struct MODEM_STATS *stats) stats->Nc = COHPSK_NC*ND; assert(stats->Nc <= MODEM_STATS_NC_MAX); - stats->snr_est = 20*log10(coh->sig_rms/(coh->noise_rms+1E-6)); + stats->snr_est = 20*log10((coh->sig_rms+1E-6)/(coh->noise_rms+1E-6)) - 10*log10(3000.0/700.0); + //fprintf(stderr, "sig_rms: %f noise_rms: %f snr_est: %f\n", coh->sig_rms, coh->noise_rms, stats->snr_est); stats->sync = coh->sync; stats->foff = coh->f_est; stats->rx_timing = coh->rx_timing; -- 2.25.1