From d0aebf731f0a132b55fa6c99ac7edb3441625de2 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 12 Feb 2026 17:20:49 +0200 Subject: [PATCH 1/9] fix 2433 --- lib_com/options.h | 1 + lib_enc/ivas_qmetadata_enc_fx.c | 70 ++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2c70dd14f..839703c4b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ #define FIX_2271_OOB_INDEXING_IN_PIT_OL2 /* VA: Fix for issue 2271, to silence clang18 */ #define FIX_2273_OOB_INDEXING_IN_PIT_FR4 /* VA: Fix to silence clang on ptr init */ +#define FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* Nokia: Fix to convert non-converted binary operations */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 4753e5276..8276ef55b 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4662,11 +4662,20 @@ static Word16 encode_coherence_indexesDCT0_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + hMetaData->ind_list[indice_coherence + i].value = extract_l( W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else hMetaData->ind_list[indice_coherence + i].value = ( ( idx >> k ) & 65535 ); /* 16 bits */ move16(); +#endif } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + hMetaData->ind_list[indice_coherence + i].value = s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); +#endif + IF( nbits1 > 0 ) { @@ -4687,11 +4696,19 @@ static Word16 encode_coherence_indexesDCT0_fx( FOR( j = i + 1; j < no_idx16 + i; j++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + hMetaData->ind_list[indice_coherence + j].value = extract_l( W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ +#else hMetaData->ind_list[indice_coherence + j].value = ( ( idx1 >> k ) & 65535 ); /* 16 bits */ move16(); +#endif } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + hMetaData->ind_list[indice_coherence + j].value = s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ +#else hMetaData->ind_list[indice_coherence + j].value = ( idx1 & ( ( 1 << k ) - 1 ) ); move16(); +#endif } return add( nbits, nbits1 ); @@ -4967,10 +4984,17 @@ static Word16 encode_spread_coherence_1sf_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMasaMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMasaMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } - +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMasaMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -4992,9 +5016,17 @@ static Word16 encode_spread_coherence_1sf_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMasaMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMasaMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMasaMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE @@ -5193,10 +5225,17 @@ static Word16 encode_surround_coherence_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } - +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -5218,10 +5257,17 @@ static Word16 encode_surround_coherence_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } - +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE @@ -5422,10 +5468,17 @@ static Word16 encode_surround_coherence_hr_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } - +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -5445,10 +5498,17 @@ static Word16 encode_surround_coherence_hr_fx( FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ +#else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ +#endif } - +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE -- GitLab From 0520cd90b6d544260d80913e1a39201612a85584 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Fri, 13 Feb 2026 16:59:21 +0200 Subject: [PATCH 2/9] fix 2433 change ops --- lib_enc/ivas_qmetadata_enc_fx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 7b752fdbe..3d12b92ab 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4669,14 +4669,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = extract_l( W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + i].value = ( ( idx >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l(L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); @@ -4703,14 +4703,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = extract_l( W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + j].value = ( ( idx1 >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + j].value = ( idx1 & ( ( 1 << k ) - 1 ) ); move16(); @@ -4991,13 +4991,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l(L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5023,13 +5023,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5232,13 +5232,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5264,13 +5264,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5475,13 +5475,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5505,13 +5505,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, s_and( extract_l( W_extract_l( idx1 ) ), sub( shl( 1, k ), 1 ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab From 6f241a47eff0cb578d54920607e2c8b743a36da7 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Fri, 13 Feb 2026 17:01:01 +0200 Subject: [PATCH 3/9] fix clang --- lib_enc/ivas_qmetadata_enc_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3d12b92ab..67394df5a 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4676,7 +4676,7 @@ static Word16 encode_coherence_indexesDCT0_fx( #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l(L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); @@ -4997,7 +4997,7 @@ static Word16 encode_spread_coherence_1sf_fx( #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l(L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab From 6feb710b92575cf90ee277770e27f3f88a2db6f3 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 19 Feb 2026 13:19:50 +0200 Subject: [PATCH 4/9] fix 2433 add UWords --- lib_enc/ivas_qmetadata_enc_fx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 67394df5a..e41f6cf92 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -5023,13 +5023,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5232,13 +5232,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5264,13 +5264,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5475,13 +5475,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5505,13 +5505,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab From 89c30a06f2e2243d12726fecd7f1c5d2f9005223 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 19 Feb 2026 13:39:11 +0200 Subject: [PATCH 5/9] fix 2433 add UWords 2 --- lib_enc/ivas_qmetadata_enc_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 9426ba8c6..59138792a 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4667,14 +4667,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + i].value = ( ( idx >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); @@ -4701,14 +4701,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + j].value = ( ( idx1 >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + j].value = ( idx1 & ( ( 1 << k ) - 1 ) ); move16(); @@ -4989,13 +4989,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab From c1d9a94dab3b14984b63285a066b4feba3f555e4 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Tue, 10 Mar 2026 11:54:06 +0200 Subject: [PATCH 6/9] add assert --- lib_enc/ivas_qmetadata_enc_fx.c | 54 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 59138792a..a14e8c3bb 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4663,18 +4663,23 @@ static Word16 encode_coherence_indexesDCT0_fx( move16(); i = 0; move16(); +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ + assert( idx < ( 1 << 62 ) ); + assert( idx1 < ( 1 << 62 ) ); +#endif FOR( i = 0; i < no_idx16 - 1; i++ ) { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + i].value = ( ( idx >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); @@ -4701,14 +4706,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + j].value = ( ( idx1 >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + j].value = ( idx1 & ( ( 1 << k ) - 1 ) ); move16(); @@ -4982,6 +4987,11 @@ static Word16 encode_spread_coherence_1sf_fx( no_idx16 = shr_r( add( nbits_fr, ONE_IN_Q3 ), 4 ); } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ + assert( idx < ( 1 << 62 ) ); + assert( idx1 < ( 1 << 62 ) ); +#endif /* write combined index */ k = nbits_fr; move16(); @@ -4989,13 +4999,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5021,13 +5031,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5223,6 +5233,12 @@ static Word16 encode_surround_coherence_fx( no_idx16 = shr_r( add( nbits_fr, ONE_IN_Q3 ), 4 ); } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ + assert( idx < ( 1 << 62 ) ); + assert( idx1 < ( 1 << 62 ) ); +#endif + /* write combined index */ k = nbits_fr; move16(); @@ -5230,13 +5246,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5262,13 +5278,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5466,6 +5482,12 @@ static Word16 encode_surround_coherence_hr_fx( no_idx16 = add( shr( nbits_fr, 4 ), 1 ); } +#ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC + /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ + assert( idx < ( 1 << 62 ) ); + assert( idx1 < ( 1 << 62 ) ); +#endif + /* write combined index */ k = nbits_fr; move16(); @@ -5473,13 +5495,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5503,13 +5525,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab From 7ab3fe3d4a2e414d61961d8b7a804808fed259e7 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Tue, 10 Mar 2026 13:09:27 +0200 Subject: [PATCH 7/9] fix clang --- lib_enc/ivas_qmetadata_enc_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index a14e8c3bb..a6a4a401d 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -6790,6 +6790,5 @@ void ivas_omasa_encode_masa_to_total_fx( } assert( nb_bits == ( hMetaData->nb_bits_tot - bits_pos ) ); - return; } -- GitLab From 62ed3e17a9f46861385865ee2cf7ad89e19c7ef4 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 12 Mar 2026 12:41:30 +0200 Subject: [PATCH 8/9] change assert on nbits --- lib_enc/ivas_qmetadata_enc_fx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index a6a4a401d..359041cb8 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4665,8 +4665,8 @@ static Word16 encode_coherence_indexesDCT0_fx( move16(); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ - assert( idx < ( 1 << 62 ) ); - assert( idx1 < ( 1 << 62 ) ); + assert( nbits < 63 ); + assert( nbits1 < 63 ); #endif FOR( i = 0; i < no_idx16 - 1; i++ ) { @@ -4989,8 +4989,8 @@ static Word16 encode_spread_coherence_1sf_fx( #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ - assert( idx < ( 1 << 62 ) ); - assert( idx1 < ( 1 << 62 ) ); + assert( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); #endif /* write combined index */ k = nbits_fr; @@ -5235,8 +5235,8 @@ static Word16 encode_surround_coherence_fx( #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ - assert( idx < ( 1 << 62 ) ); - assert( idx1 < ( 1 << 62 ) ); + assert( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); #endif /* write combined index */ @@ -5484,8 +5484,8 @@ static Word16 encode_surround_coherence_hr_fx( #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC /* verify that idx and idx1 can be represented on 63 bits as it has been designed through split outside this function */ - assert( idx < ( 1 << 62 ) ); - assert( idx1 < ( 1 << 62 ) ); + assert( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); #endif /* write combined index */ -- GitLab From 67b9ab884c21123cb6362660a5077d88224f1e20 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 12 Mar 2026 16:00:25 +0200 Subject: [PATCH 9/9] remove cast --- lib_enc/ivas_qmetadata_enc_fx.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 359041cb8..5730d9b84 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4672,14 +4672,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + i].value = ( ( idx >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + i].value = u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); @@ -4706,14 +4706,14 @@ static Word16 encode_coherence_indexesDCT0_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else hMetaData->ind_list[indice_coherence + j].value = ( ( idx1 >> k ) & 65535 ); /* 16 bits */ move16(); #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + hMetaData->ind_list[indice_coherence + j].value = u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else hMetaData->ind_list[indice_coherence + j].value = ( idx1 & ( ( 1 << k ) - 1 ) ); move16(); @@ -4999,13 +4999,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5031,13 +5031,13 @@ static Word16 encode_spread_coherence_1sf_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMasaMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMasaMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5246,13 +5246,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5278,13 +5278,13 @@ static Word16 encode_surround_coherence_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5495,13 +5495,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx, k ) ) ), 16 ); /* ( ( idx >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); #endif @@ -5525,13 +5525,13 @@ static Word16 encode_surround_coherence_hr_fx( { k = sub( k, 16 ); #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( (Word64) idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ + push_next_indice( hMetaData, u_extract_l( (UWord32) W_extract_l( W_shr( idx1, k ) ) ), 16 ); /* ( ( idx1 >> k ) & 65535 ); 16 bits */ #else push_next_indice( hMetaData, ( ( idx1 >> k ) & 65535 ), 16 ); /* 16 bits */ #endif } #ifdef FIX_2433_ARITH_OVERFLOW_IN_QMETA_ENC - push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( (Word64) idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ + push_next_indice( hMetaData, u_extract_l( (UWord32) L_and( W_extract_l( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ #else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); #endif -- GitLab