From 368dbcd86a598980cc3c7466df1213451e828a33 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:39:53 +0100 Subject: [PATCH 1/5] fixed calculation of energy (EnergyL_16) in SWB_BWE_decoding --- lib_com/prot_fx.h | 6 ++---- lib_com/swb_bwe_com_fx.c | 21 +++++---------------- lib_dec/swb_bwe_dec.c | 4 ++-- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0e829e59b..93d695a49 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -388,8 +388,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl, /* i : extension layer of last frame */ - Word16 element_mode /* i : element mode */ + const Word16 last_extl /* i : extension layer of last frame */ ); void time_envelop_shaping_fx( @@ -2719,8 +2718,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl, /* i : extension layer of last frame */ - Word16 element_mode /* i : element mode */ + const Word16 last_extl /* i : extension layer of last frame */ ); void time_envelop_shaping_fx( diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index dd0c8aa30..32e19d0b2 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1377,8 +1377,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl, /* i : extension layer of last frame */ - Word16 element_mode /* i : element mode */ + const Word16 last_extl /* i : extension layer of last frame */ ) { Word16 n_freq, n_band, L, L_swb_norm; @@ -1457,7 +1456,7 @@ void SWB_BWE_decoding_fx( #ifdef BASOP_NOGLOB EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #else - EnergyL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ + EnergyL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #endif } calc_normal_length_fx( ACELP_CORE, core_dec_freq, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_syn ); @@ -1581,22 +1580,12 @@ void SWB_BWE_decoding_fx( exp = norm_s( SWB_FENV ); tmp = div_s( shl( 1, sub( 14, exp ) ), SWB_FENV ); /*Q(29-exp) */ L_tmp = Mult_32_16( L_energy, tmp ); /*Q(1+29-exp+1)->Q(15-exp) */ - IF( EQ_16( element_mode, EVS_MONO ) ) - { -#ifdef BASOP_NOGLOB - Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); -#else - EnergyL_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); -#endif - } - ELSE - { + #ifdef BASOP_NOGLOB - EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ + Energy_16 = round_fx_sat(L_shl_sat(L_tmp, add(exp, 4))); /* Q3 */ #else - Energy_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */ + Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ #endif - } test(); IF( NE_16( last_extl, SWB_BWE ) && NE_16( last_extl, FB_BWE ) ) diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index 90a2a0130..eb43d0677 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -473,11 +473,11 @@ Word16 swb_bwe_dec_fx32( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode ); + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); } ELSE { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode ); + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); } test(); -- GitLab From 83e95148f37c8f278022f1d96378eedcd26a74a8 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:35:58 +0100 Subject: [PATCH 2/5] fixed function call arguments --- lib_dec/swb_bwe_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index f2d51f26c..bedf8b81c 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1071,13 +1071,13 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, - &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode ); + &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); } ELSE { SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, - st_fx->last_extl, st_fx->element_mode ); + st_fx->last_extl); } test(); -- GitLab From e56f4afd9bd3b0456cf18030804220509aa99259 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Fri, 6 Dec 2024 09:44:49 +0100 Subject: [PATCH 3/5] clang format --- lib_dec/swb_bwe_dec.c | 4 ++-- lib_dec/swb_bwe_dec_fx.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib_dec/swb_bwe_dec.c b/lib_dec/swb_bwe_dec.c index eb43d0677..1dcc5c111 100644 --- a/lib_dec/swb_bwe_dec.c +++ b/lib_dec/swb_bwe_dec.c @@ -473,11 +473,11 @@ Word16 swb_bwe_dec_fx32( IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); } ELSE { - SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); + SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); } test(); diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index bedf8b81c..cd30df7c3 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -1071,13 +1071,12 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/ IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) { SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, - &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl); + &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); } ELSE { SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, - &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, - st_fx->last_extl); + &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl ); } test(); -- GitLab From 7f35ca87e98ede5d07e9494d5443e32f75543428 Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:24:28 +0100 Subject: [PATCH 4/5] clang format --- lib_com/prot_fx.h | 4 ++-- lib_com/swb_bwe_com_fx.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 93d695a49..40086183d 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -388,7 +388,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl /* i : extension layer of last frame */ + const Word16 last_extl /* i : extension layer of last frame */ ); void time_envelop_shaping_fx( @@ -2718,7 +2718,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl /* i : extension layer of last frame */ + const Word16 last_extl /* i : extension layer of last frame */ ); void time_envelop_shaping_fx( diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 32e19d0b2..e71b589b6 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1377,7 +1377,7 @@ void SWB_BWE_decoding_fx( Word16 *prev_weight, /* i/o: excitation weight value of last frame */ const Word16 extl, /* i : extension layer */ Word16 Q_syn, - const Word16 last_extl /* i : extension layer of last frame */ + const Word16 last_extl /* i : extension layer of last frame */ ) { Word16 n_freq, n_band, L, L_swb_norm; @@ -1456,7 +1456,7 @@ void SWB_BWE_decoding_fx( #ifdef BASOP_NOGLOB EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #else - EnergyL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ + EnergyL_16 = round_fx(L_shl(L_tmp, sub(exp, 12))); /* Q3 */ #endif } calc_normal_length_fx( ACELP_CORE, core_dec_freq, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_syn ); @@ -1513,8 +1513,8 @@ void SWB_BWE_decoding_fx( L_tmp = L_mult_sat( SWB_signal[n_freq], SWB_signal[n_freq] ); /*Q31 */ energy = L_add_sat( energy, L_shr( L_tmp, 6 ) ); /*Q25 */ #else - L_tmp = L_mult( SWB_signal[n_freq], SWB_signal[n_freq] ); /*Q31 */ - energy = L_add( energy, L_shr( L_tmp, 6 ) ); /*Q25 */ + L_tmp = L_mult( SWB_signal[n_freq], SWB_signal[n_freq] ); /*Q31 */ + energy = L_add( energy, L_shr( L_tmp, 6 ) ); /*Q25 */ #endif } @@ -1584,7 +1584,7 @@ void SWB_BWE_decoding_fx( #ifdef BASOP_NOGLOB Energy_16 = round_fx_sat(L_shl_sat(L_tmp, add(exp, 4))); /* Q3 */ #else - Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ + Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ #endif test(); -- GitLab From 21a8b6e4bce4580840d64b7466d5e572b3478e5d Mon Sep 17 00:00:00 2001 From: mave2802 <59919483+mave2802@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:31:38 +0100 Subject: [PATCH 5/5] clang format --- lib_com/swb_bwe_com_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index e71b589b6..bd22e7e42 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -1456,7 +1456,7 @@ void SWB_BWE_decoding_fx( #ifdef BASOP_NOGLOB EnergyL_16 = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #else - EnergyL_16 = round_fx(L_shl(L_tmp, sub(exp, 12))); /* Q3 */ + EnergyL_16 = round_fx( L_shl( L_tmp, sub( exp, 12 ) ) ); /* Q3 */ #endif } calc_normal_length_fx( ACELP_CORE, core_dec_freq, mode, extl, &L_swb_norm, prev_L_swb_norm, Q_syn ); @@ -1582,9 +1582,9 @@ void SWB_BWE_decoding_fx( L_tmp = Mult_32_16( L_energy, tmp ); /*Q(1+29-exp+1)->Q(15-exp) */ #ifdef BASOP_NOGLOB - Energy_16 = round_fx_sat(L_shl_sat(L_tmp, add(exp, 4))); /* Q3 */ + Energy_16 = round_fx_sat( L_shl_sat( L_tmp, add( exp, 4 ) ) ); /* Q3 */ #else - Energy_16 = round_fx(L_shl(L_tmp, add(exp, 4))); /*Q3 */ + Energy_16 = round_fx( L_shl( L_tmp, add( exp, 4 ) ) ); /*Q3 */ #endif test(); -- GitLab