From bb85f7dde4195bfc0fca9e9c7c2eed0f8694203c Mon Sep 17 00:00:00 2001 From: Antoine Soulier Date: Thu, 6 Jun 2024 17:21:46 -0700 Subject: [PATCH] math: Remove usage of Infinity that leads to undefined beahior using fast-math --- src/fastmath.h | 1 + src/sns.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fastmath.h b/src/fastmath.h index c61ae64..86cbdfa 100644 --- a/src/fastmath.h +++ b/src/fastmath.h @@ -20,6 +20,7 @@ #define __LC3_FASTMATH_H #include +#include #include diff --git a/src/sns.c b/src/sns.c index 0b5aa14..85660d0 100644 --- a/src/sns.c +++ b/src/sns.c @@ -547,12 +547,12 @@ LC3_HOT static void quantize(const float *scf, int lfcb_idx, int hfcb_idx, /* --- Determe shape & gain index --- * Search the Mean Square Error, within (shape, gain) combinations */ - float mse_min = INFINITY; + float mse_min = FLT_MAX; *shape_idx = *gain_idx = 0; for (int ic = 0; ic < 4; ic++) { const struct lc3_sns_vq_gains *cgains = lc3_sns_vq_gains + ic; - float cmse_min = INFINITY; + float cmse_min = FLT_MAX; int cgain_idx = 0; for (int ig = 0; ig < cgains->count; ig++) {