From 844527b3e3f44ae7c4c9e5fd36b72af5c6ba5a33 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Jun 2024 13:57:16 +0530 Subject: [PATCH 1/2] Fix for issue 754: Concealment artifacts at 48kbps stereo --- lib_com/tcx_utils_fx.c | 4 ++-- lib_dec/FEC_HQ_phase_ecu_fx.c | 8 ++++---- lib_dec/er_dec_acelp_fx.c | 4 ++-- lib_dec/er_dec_tcx_fx.c | 18 +++++++++--------- lib_dec/gaus_dec_fx.c | 6 +++--- lib_dec/ivas_spar_decoder.c | 4 +--- lib_enc/cod_uv_fx.c | 6 +++--- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 1932730ac..74149f2be 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1787,7 +1787,7 @@ void tcx_noise_filling( win = add( win, 1 ); } - seed = own_random2_fx( seed ); + Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); move32(); @@ -1952,7 +1952,7 @@ void tcx_noise_filling_with_shift( Word16 nrm = 31; - seed = own_random2_fx( seed ); + Random( &seed ); Q[i] = L_mult0( mult( seed, fac_ns ), win ); IF( Q[i] ) { diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index bd6d018a6..8e7c7b99d 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2383,7 +2383,7 @@ static void ivas_subst_spec_fx( IF( NE_16( ph_dith, 0 ) ) { Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ - *seed = own_random2_fx( *seed ); /* in Q0 */ + Random( seed ); /* in Q0 */ acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ @@ -2782,9 +2782,9 @@ static void subst_spec_fx( move16(); IF( ph_dith != 0 ) { - Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ - *seed = own_random2_fx( *seed ); /* in Q0 */ - acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ + Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ + Random( seed ); /* in Q0 */ + acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ diff --git a/lib_dec/er_dec_acelp_fx.c b/lib_dec/er_dec_acelp_fx.c index 11ada1141..eec1d3be8 100644 --- a/lib_dec/er_dec_acelp_fx.c +++ b/lib_dec/er_dec_acelp_fx.c @@ -490,7 +490,7 @@ void con_acelp_fx( l = add( st->L_frame, sub( l_fir_fer, 1 ) ); FOR( i = 0; i < l; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise_buf[i] = tmpSeed; /*Q0*/ move16(); } @@ -500,7 +500,7 @@ void con_acelp_fx( l = add( add( st->L_frame, shr( st->L_frame, 1 ) ), sub( l_fir_fer, 1 ) ); FOR( ; i < l; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise_buf[i] = tmpSeed; /*Q0*/ move16(); } diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index e51721c82..fa30326ca 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -692,7 +692,7 @@ void con_tcx_fx( tmp_loop = add( L_frame, L_FIR_FER2 - 1 ); FOR( i = 0; i < tmp_loop; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise[i] = shr( tmpSeed, noise_e ); move16(); } @@ -702,7 +702,7 @@ void con_tcx_fx( tmp_loop = add( add( L_frame, shr( L_frame, 1 ) ), shl( L_FIR_FER2, 1 ) ); FOR( ; i < tmp_loop; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise[i] = shr( tmpSeed, noise_e ); move16(); } @@ -1622,7 +1622,7 @@ void con_tcx_ivas_fx( tmpSeed1 = *noise_seed; noise = buf; - noise_e = 1; + noise_e = 2; move16(); e = 0; move16(); @@ -1640,8 +1640,8 @@ void con_tcx_ivas_fx( FOR( i = 0; i < add( L_frame, L_FIR_FER2 - 1 ); i++ ) { - random1 = own_random2_fx( tmpSeed1 ); - random2 = own_random2_fx( tmpSeed1 ); + random1 = Random( &tmpSeed1 ); + random2 = Random( &tmpSeed1 ); noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); move16(); } @@ -1655,8 +1655,8 @@ void con_tcx_ivas_fx( FOR( ; i < add( add( L_frame, shr( L_frame, 1 ) ), 2 * L_FIR_FER2 ); i++ ) { - random1 = own_random2_fx( tmpSeed1 ); - random2 = own_random2_fx( tmpSeed1 ); + random1 = Random( &tmpSeed1 ); + random2 = Random( &tmpSeed1 ); noise[i] = add( shr( random1, noise_e ), shr( mult( alpha_coh, random2 ), noise_e ) ); move16(); } @@ -1673,7 +1673,7 @@ void con_tcx_ivas_fx( tmp_loop = add( L_frame, L_FIR_FER2 - 1 ); FOR( i = 0; i < tmp_loop; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise[i] = shr( tmpSeed, noise_e ); move16(); } @@ -1683,7 +1683,7 @@ void con_tcx_ivas_fx( tmp_loop = add( add( L_frame, shr( L_frame, 1 ) ), shl( L_FIR_FER2, 1 ) ); FOR( ; i < tmp_loop; i++ ) { - tmpSeed = own_random2_fx( tmpSeed ); + Random( &tmpSeed ); noise[i] = shr( tmpSeed, noise_e ); move16(); } diff --git a/lib_dec/gaus_dec_fx.c b/lib_dec/gaus_dec_fx.c index ae394105d..0dec8dbf6 100644 --- a/lib_dec/gaus_dec_fx.c +++ b/lib_dec/gaus_dec_fx.c @@ -268,13 +268,13 @@ void gaus_L2_dec( move16(); FOR( i = 0; i < L_SUBFR; i++ ) { - seed = own_random2_fx( seed ); + Random( &seed ); tmp32 = L_mac( 0, seed, 1 << 9 ); - seed = own_random2_fx( seed ); + Random( &seed ); tmp32 = L_mac( tmp32, seed, 1 << 9 ); - seed = own_random2_fx( seed ); + Random( &seed ); code[i] = mac_r( tmp32, seed, 1 << 9 ); move16(); } diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index acb58e751..f18e474e4 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -883,9 +883,7 @@ static int16_t ivas_parse_spar_header( static Word16 get_random_number_fx( Word16 *seed ) { - Word16 x = own_random2_fx( *seed ); - *seed = x; - return x; + return Random( seed ); } #else static float get_random_number( diff --git a/lib_enc/cod_uv_fx.c b/lib_enc/cod_uv_fx.c index 5ebfe4840..bf20ecfd0 100644 --- a/lib_enc/cod_uv_fx.c +++ b/lib_enc/cod_uv_fx.c @@ -47,13 +47,13 @@ void gauss_L2_fx( /*Generate white gaussian noise using central limit theorem method (N only 4 as E_util_random is not purely uniform)*/ FOR( i = 0; i < L_SUBFR; i++ ) { - *seed_acelp = own_random2_fx( *seed_acelp ); + Random( seed_acelp ); tmp32 = L_mac( 0, *seed_acelp, 1 << 9 ); - *seed_acelp = own_random2_fx( *seed_acelp ); + Random( seed_acelp ); tmp32 = L_mac( tmp32, *seed_acelp, 1 << 9 ); - *seed_acelp = own_random2_fx( *seed_acelp ); + Random( seed_acelp ); code[i] = mac_r( tmp32, *seed_acelp, 1 << 9 ); move16(); } -- GitLab From a9f77f0f062a8131a7f882752fddcc279e881e70 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Wed, 12 Jun 2024 14:00:02 +0530 Subject: [PATCH 2/2] clang formatting changes --- lib_dec/FEC_HQ_phase_ecu_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/FEC_HQ_phase_ecu_fx.c b/lib_dec/FEC_HQ_phase_ecu_fx.c index 8e7c7b99d..e43cf7f25 100644 --- a/lib_dec/FEC_HQ_phase_ecu_fx.c +++ b/lib_dec/FEC_HQ_phase_ecu_fx.c @@ -2382,9 +2382,9 @@ static void ivas_subst_spec_fx( move16(); IF( NE_16( ph_dith, 0 ) ) { - Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ - Random( seed ); /* in Q0 */ - acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ + Xph = *pCorrPhase; /* in Q16. 2*PI is not included. */ + Random( seed ); /* in Q0 */ + acc = L_mult( *seed, ph_dith ); /* N.B. ph_dith[i] is in Q15, i.e., in between 0 and 1.0 (2*PI not included) */ acc = L_shr( acc, PHASE_DITH_SCALE_SHIFT ); Xph = L_add( Xph, acc ); /* in Q16. */ -- GitLab