From 6fc327c3b6ecfa2860bc74f6080730bae0afe736 Mon Sep 17 00:00:00 2001 From: arancormonk <180709949+arancormonk@users.noreply.github.com> Date: Wed, 3 Sep 2025 19:15:27 -0500 Subject: [PATCH] rtl_sdr_fm: avoid sqrt in RMS utility (use power-domain) --- src/rtl_sdr_fm.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp index 2c52443..1906b1e 100644 --- a/src/rtl_sdr_fm.cpp +++ b/src/rtl_sdr_fm.cpp @@ -943,28 +943,27 @@ static inline void audio_lpf_filter(struct demod_state *fm) fm->audio_lpf_state = y; } -long int rms(int16_t *samples, int len, int step) -/* largely lifted from rtl_power */ +long int mean_power(int16_t *samples, int len, int step) +/* DC-corrected mean power (sqrt-free). Returns squared RMS units. */ { int i; - long int rms; - long p, t, s; + int64_t p = 0; + int64_t t = 0; + int64_t s; double dc, err; - p = t = 0L; - for (i=0; i