diff --git a/lib_com/options.h b/lib_com/options.h index 693d4ad466d025233458c2c63ae5b4f33cdc273c..0ca54bb9d223be91729e1bc748f92d85570df50b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -101,6 +101,7 @@ #define FIX_2346_DUPLICATED_IGF_FUNCTIONS /* FhG: basop issue 2346: Review potentially duplicated IGF functions */ #define FIX_1525_UNINIT_FORMAT_SWITCHING_DEC /* VA: float issue 1525: fix reading of uninitialized memory in format switching at the decoder */ #define HARMONIZE_2446_CON_TCX_FX /* FhG: basop issue: 2446 harmonization of function con_tcx_fx() */ +#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 2d96066366245984b287673dbaec0fe3a29b5c93..5730d9b846bc6b1f69cd5bfdab4792c371c7f6a8 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -4663,14 +4663,28 @@ 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( nbits < 63 ); + assert( nbits1 < 63 ); +#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 */ +#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 ) ); */ +#else hMetaData->ind_list[indice_coherence + i].value = ( idx & ( ( 1 << k ) - 1 ) ); move16(); +#endif + IF( nbits1 > 0 ) { @@ -4691,11 +4705,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 = 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( 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(); +#endif } return add( nbits, nbits1 ); @@ -4965,16 +4987,28 @@ 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( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); +#endif /* write combined index */ k = nbits_fr; move16(); FOR( i = 0; i < no_idx16 - 1; i++ ) { 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 */ +#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 ) ); */ +#else push_next_indice( hMasaMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -4996,9 +5030,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, 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( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMasaMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE @@ -5191,16 +5233,29 @@ 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( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); +#endif + /* write combined index */ k = nbits_fr; move16(); FOR( i = 0; i < no_idx16 - 1; i++ ) { 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 */ +#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 ) ); */ +#else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -5222,10 +5277,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, 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( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE @@ -5420,16 +5482,29 @@ 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( nbits_fr < 63 ); + assert( nbits_fr1 < 63 ); +#endif + /* write combined index */ k = nbits_fr; move16(); FOR( i = 0; i < no_idx16 - 1; i++ ) { 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 */ +#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 ) ); */ +#else push_next_indice( hMetaData, ( idx & ( ( 1 << k ) - 1 ) ), k ); +#endif IF( nbits_fr1 > 0 ) { @@ -5449,10 +5524,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, 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( idx1 ), L_sub( L_shl( 1, k ), 1 ) ) ), k ); /* ( idx1 & ( ( 1 << k ) - 1 ) ); */ +#else push_next_indice( hMetaData, ( idx1 & ( ( 1 << k ) - 1 ) ), k ); +#endif } } ELSE @@ -6708,6 +6790,5 @@ void ivas_omasa_encode_masa_to_total_fx( } assert( nb_bits == ( hMetaData->nb_bits_tot - bits_pos ) ); - return; }