From 05834211383ae98e37c7a58f2ffec792e57d57af Mon Sep 17 00:00:00 2001 From: soyer Date: Sat, 19 Apr 2025 02:39:04 +0200 Subject: [PATCH] add saturation for arm_float_to_q23 neon implementation (#845) altough vcvtq_n_s32_f32 does a saturation, but for 32 bits. We need saturation for 24 bits. --- src/arm_float_to_q23.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arm_float_to_q23.c b/src/arm_float_to_q23.c index 4f77e2a..8eb21be 100644 --- a/src/arm_float_to_q23.c +++ b/src/arm_float_to_q23.c @@ -22,6 +22,10 @@ void arm_float_to_q23(const float32_t * pSrc, q23_t * pDst, uint32_t blockSize) cvt = vcvtq_n_s32_f32(inV, 23); + /* saturate */ + cvt = vminq_s32(cvt, vdupq_n_s32(0x007fffff)); + cvt = vmaxq_s32(cvt, vdupq_n_s32(0xff800000)); + vst1q_s32(pDst, cvt); pDst += 4; pIn += 4;