From ef37ae487c73b49067d807562919d60d8fb586db Mon Sep 17 00:00:00 2001 From: Lauros Pajunen Date: Thu, 21 Aug 2025 12:12:38 +0300 Subject: [PATCH 1/2] Add sanity check for Euler/Quaternion angles for external orientations --- lib_com/ivas_error.h | 7 +++++++ lib_com/options.h | 1 + lib_util/rotation_file_reader.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index a2f893ed78..c6d18125e2 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -134,6 +134,9 @@ typedef enum IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT, IVAS_ERR_NO_FILE_OPEN, IVAS_ERR_SAMPLING_RATE_UNKNOWN, +#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK + IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT, +#endif /*----------------------------------------* * renderer (lib_rend only) * @@ -271,6 +274,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Invalid input format"; case IVAS_ERR_INVALID_INDEX: return "Invalid index"; +#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK + case IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT: + return "Euler angles were detected in the input but only Quaternions are supported"; +#endif default: break; } diff --git a/lib_com/options.h b/lib_com/options.h index 0000a66f49..440b556325 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1348_OVERFLOW /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */ +#define FIX_1370_EXTERNAL_ORIENTATION_CHECK /* Nokia: add sanity check for Euler angles for external orientations */ /* #################### End BE switches ################################## */ diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index 024b083737..bd35e5ac4a 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -183,6 +183,14 @@ ivas_error ExternalOrientationFileReading( *enableExternalOrientation = (int8_t) extOrientationFlag; *enableRotationInterpolation = (int8_t) rotInterpolationFlag; *numFramesToTargetOrientation = (int16_t) nFramesToTarget; +#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK + + /* Only Quaternion orientations are supported, raise an error if Euler angles are detected in the input */ + if ( pQuaternion->w == -3.0f ) + { + return IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT; + } +#endif return IVAS_ERR_OK; } -- GitLab From e1f4bca8470f0c991a5ebc664101b1194fe486ad Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 26 Aug 2025 11:19:19 +0300 Subject: [PATCH 2/2] Minor change in check placement to align better with BASOP code. --- lib_util/rotation_file_reader.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_util/rotation_file_reader.c b/lib_util/rotation_file_reader.c index bd35e5ac4a..6c62290b00 100644 --- a/lib_util/rotation_file_reader.c +++ b/lib_util/rotation_file_reader.c @@ -174,6 +174,14 @@ ivas_error ExternalOrientationFileReading( } ( externalOrientationReader->frameCounter )++; +#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK + + /* Only Quaternion orientations are supported, raise an error if Euler angles are detected in the input */ + if ( w == -3.0f ) + { + return IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT; + } +#endif pQuaternion->w = w; pQuaternion->x = x; @@ -183,14 +191,6 @@ ivas_error ExternalOrientationFileReading( *enableExternalOrientation = (int8_t) extOrientationFlag; *enableRotationInterpolation = (int8_t) rotInterpolationFlag; *numFramesToTargetOrientation = (int16_t) nFramesToTarget; -#ifdef FIX_1370_EXTERNAL_ORIENTATION_CHECK - - /* Only Quaternion orientations are supported, raise an error if Euler angles are detected in the input */ - if ( pQuaternion->w == -3.0f ) - { - return IVAS_ERR_EXTERNAL_ORIENTATION_INVALID_FORMAT; - } -#endif return IVAS_ERR_OK; } -- GitLab