From e2c4d115eb353ef9aa4d329c76f436e5d7aa7e52 Mon Sep 17 00:00:00 2001 From: Dmitry Yakovlev Date: Mon, 4 Nov 2024 13:00:08 +0300 Subject: [PATCH] Bugfix for SNR function to free the calculation array. --- CHANGELOG.md | 1 + modules/support/snr/float/dsps_snr_f32.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a91934e..2e1abd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed +- Bugfix for SNR calculation: free array in case of error - Bugfix for determinant calculation in mat.cpp ### Added diff --git a/modules/support/snr/float/dsps_snr_f32.cpp b/modules/support/snr/float/dsps_snr_f32.cpp index 04e3670..b05c954 100644 --- a/modules/support/snr/float/dsps_snr_f32.cpp +++ b/modules/support/snr/float/dsps_snr_f32.cpp @@ -66,11 +66,11 @@ float dsps_snr_f32(const float *input, int32_t len, uint8_t use_dc) } } + delete[] temp_array; noise_power += std::numeric_limits::min(); if (noise_power < max * 0.00000000001) { return 192; } - delete[] temp_array; float snr = max / noise_power; float result = 10 * log10(max / noise_power) - 2; // 2 - window correction ESP_LOGI(TAG, "SNR = %f, result=%f dB", snr, result);