From 4c50cdde835cbafc926176b5274ca85aa94efcb2 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 19 Jun 2026 10:59:34 +0200 Subject: [PATCH 1/2] [fix] promote math in Euler2Quat() to double to reduce platform dependent differences --- lib_com/ivas_rotation_com.c | 15 +++++++++++++++ lib_com/options.h | 1 + 2 files changed, 16 insertions(+) diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index 9ce3c3b24..c24d8d6c0 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -56,6 +56,20 @@ void Euler2Quat( IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ) { +#ifdef FIX_FLOAT_1607_SINF_ROT_COM + /* use double precision to avoid platform divergence + BOTH the trig functions and the multiplications need to be in double */ + double cr = cos( (double) roll * 0.5 ); + double sr = sin( (double) roll * 0.5 ); + double cp = cos( (double) pitch * 0.5 ); + double sp = sin( (double) pitch * 0.5 ); + double cy = cos( (double) yaw * 0.5 ); + double sy = sin( (double) yaw * 0.5 ); + quat->w = (float) ( cr * cp * cy + sr * sp * sy ); + quat->x = (float) ( sr * cp * cy - cr * sp * sy ); + quat->y = (float) ( sr * cp * sy + cr * sp * cy ); + quat->z = (float) ( cr * cp * sy - sr * sp * cy ); +#else float cr = cosf( roll * 0.5f ); float sr = sinf( roll * 0.5f ); float cp = cosf( pitch * 0.5f ); @@ -66,6 +80,7 @@ void Euler2Quat( quat->x = sr * cp * cy - cr * sp * sy; quat->y = sr * cp * sy + cr * sp * cy; quat->z = cr * cp * sy - sr * sp * cy; +#endif return; } diff --git a/lib_com/options.h b/lib_com/options.h index a33f3986f..bdec34168 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,7 @@ #define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */ #define FIX_FLOAT_1600_OMASA_WRONG_RENDER_PATH /* Nokia: float issue 1600: fix initialization condition of stereo type detection for OMASA */ +#define FIX_FLOAT_1607_SINF_ROT_COM /* FhG: float issue 1607: MLD sensitive to usage of sinf in Euler2Quat() */ /* ##################### End NON-BE switches ########################### */ -- GitLab From 25fbaccb81b80adce45af1270563e4ba81075842 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Fri, 19 Jun 2026 11:08:55 +0200 Subject: [PATCH 2/2] clang-format --- lib_com/ivas_rotation_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ivas_rotation_com.c b/lib_com/ivas_rotation_com.c index c24d8d6c0..f522d9312 100644 --- a/lib_com/ivas_rotation_com.c +++ b/lib_com/ivas_rotation_com.c @@ -57,7 +57,7 @@ void Euler2Quat( ) { #ifdef FIX_FLOAT_1607_SINF_ROT_COM - /* use double precision to avoid platform divergence + /* use double precision to avoid platform divergence BOTH the trig functions and the multiplications need to be in double */ double cr = cos( (double) roll * 0.5 ); double sr = sin( (double) roll * 0.5 ); -- GitLab