From 15ba25a996e96fb5e6424a01054359cc345f52e6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 8 Dec 2025 15:51:15 -0500 Subject: [PATCH 01/12] First trial at harmonisation of the GSC --- lib_com/gs_gains_fx.c | 22 +++- lib_com/gs_noisefill_fx.c | 9 +- lib_com/options.h | 9 +- lib_com/pred_lt4_fx.c | 5 + lib_com/prot_fx.h | 7 +- lib_enc/acelp_core_enc_fx.c | 4 + lib_enc/enc_gen_voic_fx.c | 5 +- lib_enc/enc_pit_exc_fx.c | 155 +++++++++++++++++++----- lib_enc/eval_pit_contr_fx.c | 19 ++- lib_enc/gs_enc_fx.c | 234 ++++++++++++++++++++++++++++++------ lib_enc/prot_fx_enc.h | 7 +- 11 files changed, 400 insertions(+), 76 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8e29f34bd..baf83fe31 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -285,6 +285,10 @@ void Ener_per_band_comp_fx( const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag /* i : flag of highest band */ +#ifdef HARM_GSC_ENC_PART3 + , + const Word16 L_frame /* i : frame length */ +#endif ) { const Word16 *pt_fx; @@ -311,10 +315,23 @@ void Ener_per_band_comp_fx( move16(); pt_fx += 32; } - +#ifdef HARM_GSC_ENC_PART3 + IF( EQ_16( L_frame, L_FRAME16k ) ) + { + y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ + move16(); +#ifdef FIX_BUG_IN_IVAS_GSC + pt_fx += 32; + y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ +#else + y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ +#endif + move16(); + } +#endif return; } - +//#ifndef HARM_GSC_ENC_PART3 void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -360,6 +377,7 @@ void Ener_per_band_comp_ivas_fx( return; } +//#endif HARM_GSC_ENC_PART3 /*-------------------------------------------------------------------* diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 8489cd66d..3c2f5bf95 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -801,12 +801,19 @@ void highband_exc_dct_in_fx( test(); IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) ) { +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); +#else Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0 ); +#endif } ELSE { +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); +#else Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1 ); - +#endif IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) ) { FOR( i = L_FRAME - 16; i < L_FRAME; i++ ) diff --git a/lib_com/options.h b/lib_com/options.h index e9b94dbad..217a7137e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -87,7 +87,11 @@ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ #define FIX_BASOP_2201_HARMONIZE_HRTF_FILE_READER_CREND /* OR : Fix issue basop 2201 hrtf_file_reader crend differs between basop ivas-main and ivas-float-update */ #define FIX_2245_INIT_FD_CNG_EVS /* Dolby/VA: Issue 2245: initialize FD CNG with EVS-type of init function */ - +#define HARM_GSC_ENC /* VA: Harmonization of EVS and IVAS GSC code */ +#define HARM_GSC_ENC_PART2 +#define HARM_GSC_ENC_PART3 +#define HARM_GSC_ENC_PART4 +#define BE_COMPL_RED /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ @@ -97,7 +101,8 @@ #define FIX_2015_PREMPH_SAT_ALT_PART2 /* VA: Add missing scaling factor to be passed to AVQ_cod() */ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ - +//#define FIX_EVS_LR_PG_BUG /* VA: EVS bug on how the lowrate pitch gain is compared to threshold, not used in IVAS */ +//#define FIX_BUG_IN_IVAS_GSC /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index cc7e544e8..14040bb21 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -58,9 +58,14 @@ void pred_lt4_ivas_fx( FOR( i = 0; i < nb_coef; i++ ) { /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ +#ifdef BE_COMPL_RED s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */ s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */ +#else + s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */ + s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */ +#endif c1 += up_sample; c2 += up_sample; } diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index bf24d493e..26deee30a 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1758,7 +1758,12 @@ void Ener_per_band_comp_fx( Word16 y_gain4[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc_diff, const Word16 Mband, /* i : Max band */ - const Word16 Eflag ); + const Word16 Eflag +#ifdef HARM_GSC_ENC_PART3 + , + const Word16 L_frame /* i : frame length */ +#endif +); void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index ff4c684e8..855616e72 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1371,7 +1371,11 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ +#ifndef HARM_GSC_ENC_PART3 encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); +#else + encod_audio_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); +#endif } ELSE { diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index bfe50a588..023c816f2 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -275,8 +275,11 @@ void encod_gen_voic_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ +#ifndef FIX_EVS_LR_PG_BUG hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ - +#else + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit_fx ) ); /* Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif*/ +#endif /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 200c22a1a..4dffa8511 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -81,7 +81,11 @@ void enc_pit_exc_fx( Word16 g_corr[10]; /* ACELP correlation values + gain pitch */ Word16 clip_gain, i; /* LSF clip gain and LP flag */ const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ - Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ +#ifdef HARM_GSC_ENC + Word16 cn1[PIT_EXC_L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ +#else + Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ +#endif Word16 *pt_pitch; /* pointer to floating pitch */ Word16 L_subfr; Word16 cum_gpit, gpit_tmp; @@ -103,7 +107,9 @@ void enc_pit_exc_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - +#ifdef HARM_GSC_ENC + Word16 q_h1 = 0; +#endif /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -236,7 +242,12 @@ void enc_pit_exc_fx( p_Aq = Aq; pt_pitch = pitch_buf; /* pointer to the pitch buffer */ shift_wsp = add( Q_new, shift ); - +#ifdef HARM_GSC_ENC + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + shift_wsp = sub( shift_wsp, 1 ); + } +#endif FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_subfr ) { @@ -249,11 +260,25 @@ void enc_pit_exc_fx( Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */ - Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ +#ifdef HARM_GSC_ENC + IF ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */ + Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ +#ifdef HARM_GSC_ENC + } + ELSE + { + find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + q_h1 = sub( 14, norm_s( h1[0] ) ); + Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ + } +#endif /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */ @@ -265,13 +290,27 @@ void enc_pit_exc_fx( *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ - +#ifdef HARM_GSC_ENC + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ // TVTODO to be check if it would still be BE when moved above + } +#endif /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ - - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); - +#ifdef HARM_GSC_ENC + IF ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); +#ifdef HARM_GSC_ENC + } + ELSE + { + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + } +#endif /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder @@ -292,7 +331,11 @@ void enc_pit_exc_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ +#ifndef FIX_EVS_LR_PG_BUG hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ +#else + hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ +#endif gpit_tmp = gain_pit; move16(); /*Q14*/ @@ -319,29 +362,49 @@ void enc_pit_exc_fx( } ELSE IF( use_fcb == 2 ) { - /*-----------------------------------------------------------------* - * Innovation encoding - *-----------------------------------------------------------------*/ - - inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); - +#ifdef HARM_GSC_ENC + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + /*-----------------------------------------------------------------* + * Innovation encoding + *-----------------------------------------------------------------*/ + + inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); +#ifdef HARM_GSC_ENC + } + ELSE + { + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); + } +#endif /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, - st_fx->element_mode ); + st_fx->element_mode ); } ELSE { /*-----------------------------------------------------------------* * Innovation & gain encoding *-----------------------------------------------------------------*/ - - inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); - +#ifdef HARM_GSC_ENC + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); +#ifdef HARM_GSC_ENC + } + ELSE + { + inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); + } +#endif /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ @@ -356,8 +419,19 @@ void enc_pit_exc_fx( gcode16 = round_fx_sat( Lgcode ); IF( use_fcb != 0 ) { - hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ - move16(); +#ifdef HARM_GSC_ENC + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ +#ifdef HARM_GSC_ENC + } + ELSE + { + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ + } +#endif + move16(); } ELSE { @@ -371,7 +445,18 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ +#ifdef HARM_GSC_ENC + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ +#ifdef HARM_GSC_ENC + } + ELSE + { + Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ + } +#endif Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ @@ -385,7 +470,18 @@ void enc_pit_exc_fx( Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ +#ifdef HARM_GSC_ENC + IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + { +#endif + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ +#ifdef HARM_GSC_ENC + } + ELSE + { + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ + } +#endif move16(); } @@ -532,7 +628,7 @@ void enc_pit_exc_fx( return; } - +#ifndef HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ @@ -1013,3 +1109,4 @@ void enc_pit_exc_ivas_fx( return; } +#endif diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index b9ea2d49e..7a371ed43 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -88,8 +88,16 @@ Word16 Pit_exc_contribution_len_fx( Mbands_loc = MBANDS_LOC; move16(); } - - minimum_fx( pitch_buf, nb_subfr, &low_pit ); +#ifdef HARM_GSC_ENC_PART2 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); // This should be the only version if #2253 is included in #1292 + } + ELSE +#endif + { + minimum_fx( pitch_buf, nb_subfr, &low_pit ); + } exp1 = norm_s( low_pit ); tmp = shl( low_pit, exp1 ); tmp_dec = 12800; @@ -381,7 +389,11 @@ Word16 Pit_exc_contribution_len_fx( set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k ); /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ +#ifdef HARM_GSC_ENC_PART2 + FOR ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) +#else for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) +#endif { delete_indice( hBstr, i ); } @@ -416,7 +428,7 @@ Word16 Pit_exc_contribution_len_fx( return last_pit_bin; } - +#ifndef HARM_GSC_ENC_PART2 Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */ Encoder_State *st_fx, /* i/o: state structure */ const Word16 *dct_res, /* i : DCT of residual Q_new*/ @@ -785,3 +797,4 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher return last_pit_bin; } +#endif \ No newline at end of file diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index f3e85bd29..a2cb74837 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -60,7 +60,9 @@ void encod_audio_fx( GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; - +#ifdef HARM_GSC_ENC_PART3 + Word16 Q_exc; +#endif m_mean = 0; move16(); tmp_nb_bits_tot = 0; @@ -70,8 +72,18 @@ void encod_audio_fx( move16(); T0_frac_tmp = 0; move16(); - Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */ - hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0; +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); + Copy_Scale_sig( &hLPDmem->mem_w0, &hGSCEnc->mem_w0_tmp_fx, 1, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); + } + ELSE +#endif + { + Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */ + hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0; + } move16(); Es_pred = 0; move16(); @@ -81,7 +93,13 @@ void encod_audio_fx( * Encode GSC attack flag (used to reduce possible pre-echo) * Encode GSC SWB speech flag *---------------------------------------------------------------*/ - +#ifdef HARM_GSC_ENC_PART3 + test(); + IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 ) + { + push_indice( hBstr, IND_GSC_IVAS_SP, st_fx->GSC_IVAS_mode, 2 ); + } +#endif IF( attack_flag > 0 ) { push_indice( hBstr, IND_GSC_ATTACK, 1, 1 ); @@ -338,8 +356,13 @@ void encod_audio_fx( /* add 5 bits for noisiness */ tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); } - +#ifdef HARM_GSC_ENC_PART3 + Q_exc = Q_new; + move16(); + gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); +#else gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, Q_new ); +#endif /*--------------------------------------------------------------------------------------* * iDCT transform @@ -347,12 +370,25 @@ void encod_audio_fx( edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); - /*--------------------------------------------------------------------------------------* - * Remove potential pre-echo in case an onset has been detected - *--------------------------------------------------------------------------------------*/ - - pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ + Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); + /*--------------------------------------------------------------------------------------* + * Remove potential pre-echo in case an onset has been detected + *--------------------------------------------------------------------------------------*/ + pre_echo_att_ivas_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_exc, st_fx->last_coder_type, st_fx->L_frame ); + } + ELSE +#endif + { + /*--------------------------------------------------------------------------------------* + * Remove potential pre-echo in case an onset has been detected + *--------------------------------------------------------------------------------------*/ + pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); + } /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ @@ -383,14 +419,22 @@ void encod_audio_fx( /*--------------------------------------------------------------------------------------* * Updates *--------------------------------------------------------------------------------------*/ - - hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) ); + } + ELSE +#endif + { + hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; + } move16(); Copy( exc_wo_nf, exc, st_fx->L_frame ); return; } - +#ifndef HARM_GSC_ENC_PART3 void encod_audio_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 speech[], /* i : input speech Q_new */ @@ -772,6 +816,7 @@ void encod_audio_ivas_fx( return; } +#endif /*================================================================================*/ /* FUNCTION : void gsc_enc_fx () */ /*--------------------------------------------------------------------------------*/ @@ -807,7 +852,12 @@ void gsc_enc_fx( Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *tmp_noise, /* o : noise energy Q2*/ - Word16 Q_exc ) +#ifndef HARM_GSC_ENC_PART3 + Word16 Q_exc +#else + Word16 *Q_exc +#endif + ) { Word16 y2_filt[L_FRAME16k]; Word16 exc_diffQ[L_FRAME16k]; @@ -820,7 +870,11 @@ void gsc_enc_fx( Word16 concat_in[L_FRAME16k]; Word16 concat_out[L_FRAME16k]; Word16 max_ener_band[MBANDS_GN_BITALLOC16k], j; +#ifndef HARM_GSC_ENC_PART3 Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; +#else + Word16 Ener_per_bd_iQ[MBANDS_GN16k]; +#endif Word16 last_bin, mean_gain; Word16 bitallocation_band[MBANDS_GN_BITALLOC16k]; Word16 bitallocation_exc[2]; @@ -831,7 +885,10 @@ void gsc_enc_fx( Word16 seed_init; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; - +#ifdef HARM_GSC_ENC_PART3 + Word32 L_tmp; + Word16 max_eq; +#endif set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -876,9 +933,11 @@ void gsc_enc_fx( tmp_band = hGSCEnc->mem_last_pit_band; move16(); } - +#ifndef HARM_GSC_ENC_PART3 Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ ); - +#else + Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1 , st_fx->L_frame ); +#endif /*--------------------------------------------------------------------------------------* * Gain quantizaion *--------------------------------------------------------------------------------------*/ @@ -901,21 +960,32 @@ void gsc_enc_fx( { i--; } - - mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ ); - - *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ + { + mean_gain = gsc_gainQ_ivas_fx( hBstr, st_fx->element_mode, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); + } + ELSE +#endif + { + mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ ); + } + *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ - +#ifndef HARM_GSC_ENC_PART3 bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - Q_tmp = Q_exc; +#else + bands_and_bit_alloc_ivas_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, + st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); + Q_tmp = *Q_exc; +#endif move16(); IF( bit == 0 ) { @@ -923,10 +993,22 @@ void gsc_enc_fx( } ELSE { - tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, - gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ - bit = sub( bit, tmp ); +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could probably be harmonized */ + { + Word16 Q_concat = Q12; + move16(); + bit = sub( bit, pvq_core_enc_ivas_fx( hBstr, concat_in, concat_out, &Q_concat, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ) ); + } + ELSE +#endif + { + tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, + gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ + bit = sub( bit, tmp ); + } + } /* write unused bits */ WHILE( bit > 0 ) @@ -941,6 +1023,31 @@ void gsc_enc_fx( last_bin = 0; move16(); set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k ); +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ + { + max_eq = 0; + move16(); + + test(); + test(); + test(); + test(); + IF( ( ( ( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) || LT_32( st_fx->core_brate, 6000 ) ) && LE_16( st_fx->coder_type, UNVOICED ) ) || GE_16( st_fx->GSC_IVAS_mode, 1 ) ) + { + j = emaximum_fx( Q12, concat_out, shl( nb_subbands, 4 ), &L_tmp ); + IF( LE_16( add( abs_s( concat_out[j] ), 41 /* 0.01f in Q12 */ ), ONE_IN_Q12 ) ) + { + max_eq = 32767; /* Q15 */ + move16(); + } + ELSE + { + max_eq = div_s( ONE_IN_Q12, add( abs_s( concat_out[j] ), 41 /* 0.01f in Q12 */ ) ); /* Q15 */ + } + } + } +#endif FOR( j = 0; j < nb_subbands; j++ ) { @@ -962,7 +1069,7 @@ void gsc_enc_fx( { IF( concat_out[j] > 0 ) { - seed_init = extract_l( L_shl( seed_init, 3 ) ); + seed_init = extract_l( L_shl( seed_init, 3 ) ); /* TV if not BE, could because of IVAS way of doing here !!!! */ } IF( concat_out[j] < 0 ) { @@ -997,19 +1104,74 @@ void gsc_enc_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ - +#ifdef HARM_GSC_ENC_PART3 + test(); + test(); + test(); + IF( GE_16( st_fx->GSC_IVAS_mode, 1 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) ) + { + FOR( i = 64; i < st_fx->L_frame; i++ ) + { + exc_diffQ[i] = mult( exc_diffQ[i], max_eq ); /* Q12 */ + move16(); + } + } + ELSE IF( LT_16( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) ) + { + FOR( i = 0; i < L_FRAME; i++ ) + { + exc_diffQ[i] = mult( exc_diffQ[i], max_eq ); /* Q12 */ + move16(); + } + } + ELSE +#endif { freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame ); } - /*--------------------------------------------------------------------------------------* - * Estimate noise level - *--------------------------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ + { + Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in ); + IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ) + { + Scale_sig( hGSCEnc->last_exc_dct_in_fx, st_fx->L_frame, sub( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ); /* Q_exc_new */ + hGSCEnc->Q_last_exc_dct_in = Q_exc_new; + move16(); + } + ELSE + { + Scale_sig( exc_dct_in, st_fx->L_frame, sub( Q_exc_new, *Q_exc ) ); /* Q_exc_new */ + *Q_exc = Q_exc_new; + move16(); + } + /*--------------------------------------------------------------------------------------* + * Estimate noise level + *--------------------------------------------------------------------------------------*/ + highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, + st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q12, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, - &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); + } + ELSE /* TV highband_exc_dct_in_fx can probably be harmonized !!! */ +#endif + { + /*--------------------------------------------------------------------------------------* + * Estimate noise level + *--------------------------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 + highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, + &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, *Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); +#else + highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, + &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); +#endif + } exc_dct_in[0] = 0; move16(); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index feaefcf53..a271bcded 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -862,7 +862,12 @@ void gsc_enc_fx( Word16 *lsf_new, /* i : ISFs at the end of the frame */ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise, /* o : noise energy */ - Word16 Q_exc ); +#ifndef HARM_GSC_ENC_PART3 + Word16 Q_exc +#else + Word16 *Q_exc +#endif +); void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ -- GitLab From 31c8476cd01ebd8cae6ed182474505c1b8f0f770 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 08:22:13 -0500 Subject: [PATCH 02/12] fixing BE issue --- lib_com/options.h | 1 - lib_enc/enc_pit_exc_fx.c | 128 ++++++++++++++++++++++----------------- lib_enc/gs_enc_fx.c | 4 +- 3 files changed, 74 insertions(+), 59 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 217a7137e..6890f9880 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,6 @@ #define HARM_GSC_ENC /* VA: Harmonization of EVS and IVAS GSC code */ #define HARM_GSC_ENC_PART2 #define HARM_GSC_ENC_PART3 -#define HARM_GSC_ENC_PART4 #define BE_COMPL_RED /* #################### End BE switches ################################## */ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 4dffa8511..4e5aefcdf 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -82,7 +82,7 @@ void enc_pit_exc_fx( Word16 clip_gain, i; /* LSF clip gain and LP flag */ const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ #ifdef HARM_GSC_ENC - Word16 cn1[PIT_EXC_L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ + Word16 cn[PIT_EXC_L_SUBFR]; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ #else Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ #endif @@ -231,12 +231,16 @@ void enc_pit_exc_fx( * ACELP subframe loop *------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC + set16_fx( cn, 0, PIT_EXC_L_SUBFR ); +#else cn = NULL; if ( EQ_16( L_subfr, L_SUBFR ) ) { cn = cn1; move16(); } +#endif p_Aw = Aw; p_Aq = Aq; @@ -261,16 +265,7 @@ void enc_pit_exc_fx( Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ #ifdef HARM_GSC_ENC - IF ( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { -#endif - find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, - res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); - Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */ - Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ -#ifdef HARM_GSC_ENC - } - ELSE + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); @@ -278,7 +273,15 @@ void enc_pit_exc_fx( q_h1 = sub( 14, norm_s( h1[0] ) ); Copy_Scale_sig( h1, h2, L_subfr, sub( 11, q_h1 ) ); /*Q11*/ } + ELSE #endif + { + find_targets_fx( speech, hLPDmem->mem_syn, i_subfr, &hLPDmem->mem_w0, p_Aq, + res, L_subfr, p_Aw, st_fx->preemph_fac, xn, cn, h1 ); + Copy_Scale_sig( h1, h2, L_subfr, -2 ); /* Q13 */ + Scale_sig( h1, L_subfr, add( 1, shift ) ); /* set h1[] in Q14 with scaling for convolution */ + } + /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn, L_subfr, shift ); /* Q_new - 1 + shift */ @@ -300,17 +303,16 @@ void enc_pit_exc_fx( * Find adaptive exitation *-----------------------------------------------------------------*/ #ifdef HARM_GSC_ENC - IF ( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#endif - pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); -#ifdef HARM_GSC_ENC + pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } ELSE +#endif { - pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); + pred_lt4( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); } -#endif + /*-----------------------------------------------------------------* * Gain clipping test to avoid unstable synthesis on frame erasure * or in case of floating point encoder & fixed p. decoder @@ -332,7 +334,16 @@ void enc_pit_exc_fx( /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ #ifndef FIX_EVS_LR_PG_BUG - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ +#ifdef HARM_GSC_ENC + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ + } + ELSE +#endif + { + hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ + } #else hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ #endif @@ -363,23 +374,21 @@ void enc_pit_exc_fx( ELSE IF( use_fcb == 2 ) { #ifdef HARM_GSC_ENC - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); + } + ELSE +#endif { -#endif /*-----------------------------------------------------------------* * Innovation encoding *-----------------------------------------------------------------*/ inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); -#ifdef HARM_GSC_ENC - } - ELSE - { - inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); } -#endif /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ @@ -392,25 +401,29 @@ void enc_pit_exc_fx( * Innovation & gain encoding *-----------------------------------------------------------------*/ #ifdef HARM_GSC_ENC - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) - { -#endif - inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, - gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); -#ifdef HARM_GSC_ENC - } - ELSE + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift, Q_new ); } + ELSE #endif + { + inov_encode_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, + gain_pit, cn, exc, h2, hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, L_SUBFR, shift ); + } + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC + gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, + &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#else gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, L_FRAME, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); +#endif } gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit, st_fx->clip_var_fx ); @@ -420,18 +433,16 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { #ifdef HARM_GSC_ENC - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#endif - hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ -#ifdef HARM_GSC_ENC + hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ } ELSE +#endif { - hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ + hLPDmem->tilt_code = Est_tilt2( &exc[i_subfr], gain_pit, code, Lgcode, &voice_fac, shift ); /* Q15 */ } -#endif - move16(); + move16(); } ELSE { @@ -446,23 +457,30 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { #ifdef HARM_GSC_ENC - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#endif - Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ -#ifdef HARM_GSC_ENC + Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ } ELSE +#endif { - Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ + Ltmp = L_mult( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ } -#endif Ltmp = L_shl_sat( Ltmp, add( 5, shift ) ); /* Q15 + Q_new + shift */ Ltmp = L_negate( Ltmp ); Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ +#ifdef HARM_GSC_ENC + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + { + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ + } + ELSE +#endif + { + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ + } move16(); } ELSE @@ -471,17 +489,15 @@ void enc_pit_exc_fx( Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ #ifdef HARM_GSC_ENC - IF( EQ_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { -#endif - hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ -#ifdef HARM_GSC_ENC + hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ } ELSE +#endif { - hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ + hLPDmem->mem_w0 = round_fx_sat( Ltmp ); /*Q_new-1 */ } -#endif move16(); } @@ -628,7 +644,7 @@ void enc_pit_exc_fx( return; } -#ifndef HARM_GSC_ENC +#if 1//ndef HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index a2cb74837..873d3dad1 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -887,7 +887,7 @@ void gsc_enc_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; #ifdef HARM_GSC_ENC_PART3 Word32 L_tmp; - Word16 max_eq; + Word16 max_eq = 0; #endif set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -1116,7 +1116,7 @@ void gsc_enc_fx( move16(); } } - ELSE IF( LT_16( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) ) + ELSE IF( LT_32( st_fx->core_brate, ACELP_7k20 ) && EQ_16( st_fx->GSC_noisy_speech, 1 ) && LE_16( st_fx->coder_type, UNVOICED ) ) { FOR( i = 0; i < L_FRAME; i++ ) { -- GitLab From 17dc22a422730914abd1ef9c9644228ed06f0d63 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Tue, 9 Dec 2025 17:35:17 -0500 Subject: [PATCH 03/12] fix BE issue --- lib_com/options.h | 3 ++- lib_com/pred_lt4_fx.c | 6 ------ lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/gs_enc_fx.c | 16 ++++++++++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6890f9880..72ed27e59 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,7 +90,8 @@ #define HARM_GSC_ENC /* VA: Harmonization of EVS and IVAS GSC code */ #define HARM_GSC_ENC_PART2 #define HARM_GSC_ENC_PART3 -#define BE_COMPL_RED +#define HARM_GSC_ENC_PART4 + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/pred_lt4_fx.c b/lib_com/pred_lt4_fx.c index 14040bb21..57b45095c 100644 --- a/lib_com/pred_lt4_fx.c +++ b/lib_com/pred_lt4_fx.c @@ -58,14 +58,8 @@ void pred_lt4_ivas_fx( FOR( i = 0; i < nb_coef; i++ ) { /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/ -#ifdef BE_COMPL_RED s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */ s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */ -#else - s64 = W_mac_32_16( s64, ( *c1 ), *x1-- ); /* Q_exc + Q32 */ - s64 = W_mac_32_16( s64, ( *c2 ), *x2++ ); /* Q_exc + Q32 */ - -#endif c1 += up_sample; c2 += up_sample; } diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 855616e72..f7c7fb58a 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1371,7 +1371,7 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ -#ifndef HARM_GSC_ENC_PART3 +#ifndef HARM_GSC_ENC_PART4 encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); #else encod_audio_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 873d3dad1..f670db476 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -888,6 +888,7 @@ void gsc_enc_fx( #ifdef HARM_GSC_ENC_PART3 Word32 L_tmp; Word16 max_eq = 0; + Word16 Q_concat = Q_PVQ_OUT; #endif set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -964,13 +965,14 @@ void gsc_enc_fx( IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { mean_gain = gsc_gainQ_ivas_fx( hBstr, st_fx->element_mode, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); + *tmp_noise = mult( mean_gain, 20480 ); // 20480 => 10 in Q11 } ELSE #endif { mean_gain = gsc_gainQ_fx( hBstr, /*st_fX->element_mode, st_fx->idchan,IVAS_CODE*/ Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth /*, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate*/ ); + *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ } - *tmp_noise = mult_r( 320, mean_gain ); /*10 in Q5 lp_gainc in Q3 */ move16(); /*--------------------------------------------------------------------------------------* @@ -996,7 +998,7 @@ void gsc_enc_fx( #ifdef HARM_GSC_ENC_PART3 IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could probably be harmonized */ { - Word16 Q_concat = Q12; + Q_concat = Q12; move16(); bit = sub( bit, pvq_core_enc_ivas_fx( hBstr, concat_in, concat_out, &Q_concat, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ) ); } @@ -1005,7 +1007,7 @@ void gsc_enc_fx( { tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); - Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_PVQ_OUT, Q_tmp ) ); /* Q_PVQ_OUT */ + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_concat, Q_tmp ) ); /* Q_PVQ_OUT */ bit = sub( bit, tmp ); } @@ -1127,7 +1129,7 @@ void gsc_enc_fx( ELSE #endif { - freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_PVQ_OUT, st_fx->L_frame ); + freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_concat /*Q12 or Q10*/, st_fx->L_frame ); } #ifdef HARM_GSC_ENC_PART3 IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ @@ -1264,9 +1266,11 @@ void gsc_enc_ivas_fx( tmp_band = hGSCEnc->mem_last_pit_band; } move16(); - +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame ); +#else Ener_per_band_comp_ivas_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame ); - +#endif /*--------------------------------------------------------------------------------------* * Gain quantizaion *--------------------------------------------------------------------------------------*/ -- GitLab From 2877f54c7de4a19e0453df937d4d0b5adad43aff Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 10:56:10 -0500 Subject: [PATCH 04/12] more code reduction --- lib_com/gs_gains_fx.c | 4 +- lib_com/gs_inact_switching_fx.c | 15 ++++- lib_com/gs_noisefill_fx.c | 13 +++- lib_com/gs_preech_fx.c | 108 +++++++++++++++++++++--------- lib_com/prot_fx.h | 12 ++-- lib_dec/gs_dec_fx.c | 6 +- lib_dec/ivas_td_low_rate_dec_fx.c | 5 +- lib_enc/enc_pit_exc_fx.c | 2 +- lib_enc/gs_enc_fx.c | 79 ++++++++++------------ lib_enc/ivas_td_low_rate_enc_fx.c | 10 ++- lib_enc/prot_fx_enc.h | 16 +++-- 11 files changed, 169 insertions(+), 101 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index baf83fe31..1f8ada033 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -331,7 +331,7 @@ void Ener_per_band_comp_fx( #endif return; } -//#ifndef HARM_GSC_ENC_PART3 +#ifndef HARM_GSC_ENC_PART3 void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ @@ -377,7 +377,7 @@ void Ener_per_band_comp_ivas_fx( return; } -//#endif HARM_GSC_ENC_PART3 +#endif /*-------------------------------------------------------------------* diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 0829a934d..99ebb0841 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -77,8 +77,11 @@ void Inac_switch_ematch_fx( test(); IF( ( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) ) ) && bfi == 0 ) { +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); +#else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); - +#endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) { @@ -91,8 +94,11 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for GC and VC frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); +#else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); - +#endif /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) { @@ -104,8 +110,11 @@ void Inac_switch_ematch_fx( { /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); +#else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); - +#endif /* More agressive smoothing in the first 50 frames */ pt_exc = dct_exc_tmp; move16(); diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 3c2f5bf95..ebd0d04ca 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -636,7 +636,7 @@ static void envelop_modify_fx( return; } - +#ifndef HARM_GSC_ENC_PART3 void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -1017,7 +1017,7 @@ void highband_exc_dct_in_fx( return; } - +#endif void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -1183,12 +1183,19 @@ void highband_exc_dct_in_ivas_fx( test(); IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) ) { +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); +#else Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); +#endif } ELSE { +#ifdef HARM_GSC_ENC_PART3 + Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); +#else Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); - +#endif test(); IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) ) { diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index bee644b0e..cc993475b 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -58,6 +58,10 @@ void pre_echo_att_fx( const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ +#ifdef HARM_GSC_ENC_PART3 + , + const Word16 element_mode /* i : Current IVAS element mode*/ +#endif ) { Word32 etmp_fx; @@ -69,7 +73,9 @@ void pre_echo_att_fx( Word16 tmp, n1, n2, exp, frac1, frac2; Word32 etmp1_fx; Word16 att_len; - +#ifdef HARM_GSC_ENC_PART3 + Word16 etmp_e, tmp_e; +#endif test(); IF( gsc_attack_flag_fx > 0 && EQ_16( last_coder_type, AUDIO ) ) /*gsc_attack_flag_fx does not get set for all the test cases */ { @@ -108,33 +114,53 @@ void pre_echo_att_fx( IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ - L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ - L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ - tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ - L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ - etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ - - etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ - /* Find the correction factor and apply it before the attack */ - /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ - /* = isqrt(etmp/(*Last_frame_ener)) */ - etmp_fx = L_max( etmp_fx, 1 ); - *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); - move32(); - n1 = norm_l( etmp_fx ); - n2 = norm_l( *Last_frame_ener_fx ); - - n1 = sub( n1, 1 ); - exp = sub( n1, n2 ); - - frac1 = round_fx( L_shl( etmp_fx, n1 ) ); - frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); - L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ - L_tmp = L_shr( L_tmp, exp ); /* add exponent */ - - L_tmp = Isqrt( L_tmp ); - ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */ +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ + { + etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); + etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) ); + etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01; (exp = etmp_e) */ + etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) ); + tmp_e = add( tmp_e, sub( etmp_e, 31 ) ); + etmp_e = tmp_e; + move16(); + /* Find the correction factor and apply it before the attack */ + tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1; denominator Q = 31 - tmp_e */ + tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */ + tmp = Sqrt16( tmp, &tmp_e ); + ratio_fx = shr_sat( tmp, sub( 2, tmp_e ) ); /* Q13 */ + } + ELSE +#endif + { + L_tmp = sum32_fx( finc_fx, attack_pos_fx ); /*Q1 */ + L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */ + tmp = round_fx( Isqrt( L_tmp1 ) ); /*Q15 */ + L_tmp = L_shr( L_tmp, 2 ); /*Q1 ; ATT_SEG_LEN=4 */ + etmp_fx = Mult_32_16( L_tmp, tmp ); /*Q1 */ + + etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */ + /* Find the correction factor and apply it before the attack */ + /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/ + /* = isqrt(etmp/(*Last_frame_ener)) */ + etmp_fx = L_max( etmp_fx, 1 ); + *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 ); + move32(); + n1 = norm_l( etmp_fx ); + n2 = norm_l( *Last_frame_ener_fx ); + + n1 = sub( n1, 1 ); + exp = sub( n1, n2 ); + + frac1 = round_fx( L_shl( etmp_fx, n1 ) ); + frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) ); + L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */ + L_tmp = L_shr( L_tmp, exp ); /* add exponent */ + + L_tmp = Isqrt( L_tmp ); + ratio_fx = round_fx( L_shl( L_tmp, 9 ) ); /* Q13 */ + } /* Pre-echo atttenuation should never increase the energy */ ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */ FOR( i = 0; i < attack_pos_fx * ATT_SEG_LEN; i++ ) @@ -152,17 +178,32 @@ void pre_echo_att_fx( /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ - - etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ - etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ - *Last_frame_ener_fx = etmp_fx; - move32(); /*2*Q_new+1*/ +#ifdef HARM_GSC_ENC_PART3 + IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ + { + Word16 exp_etmp = sub( 15, Q_new ); + etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ + etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ + IF( EQ_16( L_frame, L_FRAME16k ) ) + { + etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ + } + *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/ + } + ELSE +#endif + { + etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */ + etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/ + *Last_frame_ener_fx = etmp_fx; + move32(); /*2*Q_new+1*/ + } } return; } - +#ifndef HARM_GSC_ENC_PART3 void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ @@ -267,3 +308,4 @@ void pre_echo_att_ivas_fx( return; } +#endif \ No newline at end of file diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 26deee30a..07b77a0da 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1799,8 +1799,12 @@ void pre_echo_att_fx( const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ +#ifdef HARM_GSC_ENC_PART3 + , + const Word16 element_mode /* i : Current IVAS element mode*/ +#endif ); - +#ifndef HARM_GSC_ENC_PART3 void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ @@ -1809,7 +1813,7 @@ void pre_echo_att_ivas_fx( const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ ); - +#endif void tcx_get_windows_mode1( const Word16 left_mode, /* i: overlap mode of left window half */ const Word16 right_mode, /* i: overlap mode of right window half */ @@ -5038,7 +5042,7 @@ void freq_dnw_scaling_fx( Word16 Qx, /* Q format of fy_norm*/ const Word16 L_frame /* i : frame length */ ); - +#ifndef HARM_GSC_ENC_PART3 void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -5070,7 +5074,7 @@ void highband_exc_dct_in_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); - +#endif void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 5564dc1b8..627a10361 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -495,9 +495,11 @@ void decod_audio_fx( /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ - +#ifdef HARM_GSC_ENC_PART3 + pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame, 0 ); +#else pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame ); - +#endif /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 32b5b3f87..e54de3c78 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -158,8 +158,11 @@ void tdm_low_rate_dec_fx( * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 + pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame, 0 ); +#else pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame ); - +#endif /*--------------------------------------------------------------------------------------* * Update BWE excitation diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 4e5aefcdf..1e1d8cd73 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -644,7 +644,7 @@ void enc_pit_exc_fx( return; } -#if 1//ndef HARM_GSC_ENC +#ifndef HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index f670db476..4b3a85a9f 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -375,20 +375,16 @@ void encod_audio_fx( { Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); - /*--------------------------------------------------------------------------------------* - * Remove potential pre-echo in case an onset has been detected - *--------------------------------------------------------------------------------------*/ - pre_echo_att_ivas_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_exc, st_fx->last_coder_type, st_fx->L_frame ); } - ELSE #endif - { - /*--------------------------------------------------------------------------------------* - * Remove potential pre-echo in case an onset has been detected - *--------------------------------------------------------------------------------------*/ - - pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); - } + /*--------------------------------------------------------------------------------------* + * Remove potential pre-echo in case an onset has been detected + *--------------------------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 + pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame, st_fx->element_mode ); +#else + pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); +#endif /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ @@ -643,10 +639,13 @@ void encod_audio_ivas_fx( Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new ); push_indice( hBstr, IND_ES_PRED, indice, nb_bits ); } - +#ifdef HARM_GSC_ENC + enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, + &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); +#else enc_pit_exc_ivas_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); - +#endif /*---------------------------------------------------------------* * DCT transform *---------------------------------------------------------------*/ @@ -718,11 +717,14 @@ void encod_audio_ivas_fx( /*---------------------------------------------------------------* * Find and encode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ - +#ifdef HARM_GSC_ENC + last_pit_bin = Pit_exc_contribution_len_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new ); +#else #ifndef FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH last_pit_bin = Pit_exc_contribution_len_ivas_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new ); #else last_pit_bin = Pit_exc_contribution_len_ivas_fx( st_fx, dct_res, dct_epit, pitch_buf, &hGSCEnc->pit_exc_hangover, Q_new ); +#endif #endif IF( last_pit_bin == 0 ) @@ -760,8 +762,11 @@ void encod_audio_ivas_fx( Word16 Q_exc = Q_new; move16(); +#ifdef HARM_GSC_ENC_PART3 + gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); +#else gsc_enc_ivas_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); - +#endif /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ @@ -849,7 +854,11 @@ void gsc_enc_fx( const Word16 Diff_len, const Word16 bits_used, const Word16 nb_subfr, +#ifndef HARM_GSC_ENC_PART3 Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ +#else + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ +#endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *tmp_noise, /* o : noise energy Q2*/ #ifndef HARM_GSC_ENC_PART3 @@ -978,7 +987,7 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ -#ifndef HARM_GSC_ENC_PART3 +#ifndef HARM_GSC_ENC_PART3 // TV todo, check if BE with EVS bit alloc bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); @@ -1071,7 +1080,7 @@ void gsc_enc_fx( { IF( concat_out[j] > 0 ) { - seed_init = extract_l( L_shl( seed_init, 3 ) ); /* TV if not BE, could because of IVAS way of doing here !!!! */ + seed_init = extract_l( L_shl( seed_init, 3 ) ); } IF( concat_out[j] < 0 ) { @@ -1147,40 +1156,22 @@ void gsc_enc_fx( *Q_exc = Q_exc_new; move16(); } - /*--------------------------------------------------------------------------------------* - * Estimate noise level - *--------------------------------------------------------------------------------------*/ - highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, - st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q12, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - } - ELSE /* TV highband_exc_dct_in_fx can probably be harmonized !!! */ #endif - { + /*--------------------------------------------------------------------------------------* + * Estimate noise level + *--------------------------------------------------------------------------------------*/ + highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, + st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q12, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - /*--------------------------------------------------------------------------------------* - * Estimate noise level - *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 - highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, - &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, *Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#else - highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, - &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -#endif - } exc_dct_in[0] = 0; move16(); return; } - +#ifndef HARM_GSC_ENC_PART3 void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ Word16 res_dct_in_fx[], @@ -1470,7 +1461,7 @@ void gsc_enc_ivas_fx( return; } - +#endif /*======================================================================*/ /* FUNCTION : edyn_fx() */ /*----------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 21fa71312..4192a260e 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -114,8 +114,11 @@ void tdm_low_rate_enc( Word16 Q_exc = Q_new; move16(); +#ifdef HARM_GSC_ENC_PART3 + gsc_enc_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); +#else gsc_enc_ivas_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); - +#endif /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ @@ -128,8 +131,11 @@ void tdm_low_rate_enc( * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 + pre_echo_att_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame, st->element_mode ); +#else pre_echo_att_ivas_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame ); - +#endif /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index a271bcded..4dce23839 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -859,7 +859,11 @@ void gsc_enc_fx( const Word16 Diff_len, const Word16 bits_used, const Word16 nb_subfr, +#ifndef HARM_GSC_ENC_PART3 Word16 *lsf_new, /* i : ISFs at the end of the frame */ +#else + const Word16 *lsf_new, /* i : ISFs at the end of the frame */ +#endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise, /* o : noise energy */ #ifndef HARM_GSC_ENC_PART3 @@ -868,7 +872,7 @@ void gsc_enc_fx( Word16 *Q_exc #endif ); - +#ifndef HARM_GSC_ENC_PART3 void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ Word16 res_dct_in_fx[], /* i : dct of residual signal */ @@ -880,7 +884,7 @@ void gsc_enc_ivas_fx( Word16 *exc_wo_nf_fx, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise_fx, /* o : long-term noise energy */ Word16 *Q_exc ); - +#endif void LPDmem_enc_init_fx( LPD_state_HANDLE hLPDmem /* i/o: LP memories */ ); @@ -4007,7 +4011,7 @@ void enc_pit_exc_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 Q_new, Word16 shift ); - +#ifndef HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ @@ -4027,7 +4031,7 @@ void enc_pit_exc_ivas_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 Q_new, Word16 shift ); - +#endif /* o : bin where pitch contribution is significant */ Word16 Pit_exc_contribution_len_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -4037,7 +4041,7 @@ Word16 Pit_exc_contribution_len_fx( const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); - +#ifndef HARM_GSC_ENC_PART2 /* o : bin where pitch contribution is significant */ Word16 Pit_exc_contribution_len_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -4049,7 +4053,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( #endif Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); - +#endif Word16 pvq_core_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ -- GitLab From 5c6ae803d2ec45020dce07ea94a7980fad2aa530 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 12:05:28 -0500 Subject: [PATCH 05/12] fix EVS be issue --- lib_enc/gs_enc_fx.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 4b3a85a9f..b8a4fa7ca 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -855,18 +855,18 @@ void gsc_enc_fx( const Word16 bits_used, const Word16 nb_subfr, #ifndef HARM_GSC_ENC_PART3 - Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ + Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ #else - const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ + const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ #endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *tmp_noise, /* o : noise energy Q2*/ #ifndef HARM_GSC_ENC_PART3 - Word16 Q_exc + Word16 Q_exc #else - Word16 *Q_exc + Word16 *Q_exc #endif - ) +) { Word16 y2_filt[L_FRAME16k]; Word16 exc_diffQ[L_FRAME16k]; @@ -946,7 +946,7 @@ void gsc_enc_fx( #ifndef HARM_GSC_ENC_PART3 Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ ); #else - Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1 , st_fx->L_frame ); + Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1, st_fx->L_frame ); #endif /*--------------------------------------------------------------------------------------* * Gain quantizaion @@ -1161,10 +1161,16 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Estimate noise level *--------------------------------------------------------------------------------------*/ +#ifdef HARM_GSC_ENC_PART3 highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q12, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - + st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); +#else + highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, + &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, + hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); +#endif exc_dct_in[0] = 0; move16(); -- GitLab From a1ce1b34bd42cea8635ca5706c2231a9ff4a801a Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 13:23:02 -0500 Subject: [PATCH 06/12] fix clang --- lib_com/gs_gains_fx.c | 6 +++--- lib_com/gs_preech_fx.c | 4 ++-- lib_com/prot_fx.h | 10 +++++----- lib_enc/enc_pit_exc_fx.c | 8 ++++---- lib_enc/eval_pit_contr_fx.c | 8 ++++---- lib_enc/gs_enc_fx.c | 17 ++++++++--------- lib_enc/prot_fx_enc.h | 4 ++-- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 1f8ada033..9777b6330 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -286,8 +286,8 @@ void Ener_per_band_comp_fx( const Word16 Mband, /* i : Max band */ const Word16 Eflag /* i : flag of highest band */ #ifdef HARM_GSC_ENC_PART3 - , - const Word16 L_frame /* i : frame length */ + , + const Word16 L_frame /* i : frame length */ #endif ) { @@ -377,7 +377,7 @@ void Ener_per_band_comp_ivas_fx( return; } -#endif +#endif /*-------------------------------------------------------------------* diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index cc993475b..09119c646 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -183,7 +183,7 @@ void pre_echo_att_fx( { Word16 exp_etmp = sub( 15, Q_new ); etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */ - etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ + etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/ IF( EQ_16( L_frame, L_FRAME16k ) ) { etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/ @@ -308,4 +308,4 @@ void pre_echo_att_ivas_fx( return; } -#endif \ No newline at end of file +#endif diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 07b77a0da..be8459a84 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1758,11 +1758,11 @@ void Ener_per_band_comp_fx( Word16 y_gain4[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc_diff, const Word16 Mband, /* i : Max band */ - const Word16 Eflag + const Word16 Eflag #ifdef HARM_GSC_ENC_PART3 - , - const Word16 L_frame /* i : frame length */ -#endif + , + const Word16 L_frame /* i : frame length */ +#endif ); void Ener_per_band_comp_ivas_fx( @@ -1802,7 +1802,7 @@ void pre_echo_att_fx( #ifdef HARM_GSC_ENC_PART3 , const Word16 element_mode /* i : Current IVAS element mode*/ -#endif +#endif ); #ifndef HARM_GSC_ENC_PART3 void pre_echo_att_ivas_fx( diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 1e1d8cd73..928112c33 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -86,7 +86,7 @@ void enc_pit_exc_fx( #else Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ #endif - Word16 *pt_pitch; /* pointer to floating pitch */ + Word16 *pt_pitch; /* pointer to floating pitch */ Word16 L_subfr; Word16 cum_gpit, gpit_tmp; Word32 Local_BR, Pitch_BR; @@ -337,7 +337,7 @@ void enc_pit_exc_fx( #ifdef HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { - hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ + hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ } ELSE #endif @@ -380,7 +380,7 @@ void enc_pit_exc_fx( gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift, Q_new ); } ELSE -#endif +#endif { /*-----------------------------------------------------------------* * Innovation encoding @@ -393,7 +393,7 @@ void enc_pit_exc_fx( * Gain encoding *-----------------------------------------------------------------*/ gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, - st_fx->element_mode ); + st_fx->element_mode ); } ELSE { diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 7a371ed43..a2683d6d6 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -88,10 +88,10 @@ Word16 Pit_exc_contribution_len_fx( Mbands_loc = MBANDS_LOC; move16(); } -#ifdef HARM_GSC_ENC_PART2 +#ifdef HARM_GSC_ENC_PART2 IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { - minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); // This should be the only version if #2253 is included in #1292 + minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); // This should be the only version if #2253 is included in #1292 } ELSE #endif @@ -390,7 +390,7 @@ Word16 Pit_exc_contribution_len_fx( /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ #ifdef HARM_GSC_ENC_PART2 - FOR ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) + FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) #else for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) #endif @@ -797,4 +797,4 @@ Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin wher return last_pit_bin; } -#endif \ No newline at end of file +#endif diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index b8a4fa7ca..e9bee8b2b 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -371,9 +371,9 @@ void encod_audio_fx( edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); #ifdef HARM_GSC_ENC_PART3 - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { - Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ + Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); } #endif @@ -641,7 +641,7 @@ void encod_audio_ivas_fx( } #ifdef HARM_GSC_ENC enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, - &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); + &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); #else enc_pit_exc_ivas_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); @@ -987,14 +987,14 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ -#ifndef HARM_GSC_ENC_PART3 // TV todo, check if BE with EVS bit alloc +#ifndef HARM_GSC_ENC_PART3 // TV todo, check if BE with EVS bit alloc bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); Q_tmp = Q_exc; #else - bands_and_bit_alloc_ivas_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, - st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); + bands_and_bit_alloc_ivas_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, + st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); Q_tmp = *Q_exc; #endif move16(); @@ -1019,7 +1019,6 @@ void gsc_enc_fx( Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_concat, Q_tmp ) ); /* Q_PVQ_OUT */ bit = sub( bit, tmp ); } - } /* write unused bits */ WHILE( bit > 0 ) @@ -1080,7 +1079,7 @@ void gsc_enc_fx( { IF( concat_out[j] > 0 ) { - seed_init = extract_l( L_shl( seed_init, 3 ) ); + seed_init = extract_l( L_shl( seed_init, 3 ) ); } IF( concat_out[j] < 0 ) { @@ -1163,7 +1162,7 @@ void gsc_enc_fx( *--------------------------------------------------------------------------------------*/ #ifdef HARM_GSC_ENC_PART3 highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, - st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #else highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 4dce23839..51d3716c9 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -860,9 +860,9 @@ void gsc_enc_fx( const Word16 bits_used, const Word16 nb_subfr, #ifndef HARM_GSC_ENC_PART3 - Word16 *lsf_new, /* i : ISFs at the end of the frame */ + Word16 *lsf_new, /* i : ISFs at the end of the frame */ #else - const Word16 *lsf_new, /* i : ISFs at the end of the frame */ + const Word16 *lsf_new, /* i : ISFs at the end of the frame */ #endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise, /* o : noise energy */ -- GitLab From 1973b15a716d125926db261f83f2d3317ef5e4f2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 14:02:11 -0500 Subject: [PATCH 07/12] Combine switches and clean-up --- lib_com/gs_gains_fx.c | 11 ++----- lib_com/gs_inact_switching_fx.c | 6 ++-- lib_com/gs_noisefill_fx.c | 10 +++---- lib_com/gs_preech_fx.c | 10 +++---- lib_com/options.h | 7 +---- lib_com/prot_fx.h | 8 ++--- lib_dec/gs_dec_fx.c | 2 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 +- lib_enc/acelp_core_enc_fx.c | 2 +- lib_enc/enc_gen_voic_fx.c | 5 +--- lib_enc/enc_pit_exc_fx.c | 36 ++++++++++------------ lib_enc/eval_pit_contr_fx.c | 6 ++-- lib_enc/gs_enc_fx.c | 50 +++++++++++++++---------------- lib_enc/ivas_td_low_rate_enc_fx.c | 4 +-- lib_enc/prot_fx_enc.h | 10 +++---- 15 files changed, 76 insertions(+), 93 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 9f348b667..877bb4f1f 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -284,7 +284,7 @@ void Ener_per_band_comp_fx( const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ const Word16 Eflag /* i : flag of highest band */ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC , const Word16 L_frame /* i : frame length */ #endif @@ -314,23 +314,18 @@ void Ener_per_band_comp_fx( move16(); pt_fx += 32; } -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( EQ_16( L_frame, L_FRAME16k ) ) { y_gain4_fx[j + 2] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ move16(); -#ifdef FIX_BUG_IN_IVAS_GSC - pt_fx += 32; - y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 32, Q_exc, -1 ); /*Q12*/ -#else y_gain4_fx[j + 3] = Comp_band_log_ener( pt_fx, 64, Q_exc, -1 ); /*Q12*/ -#endif move16(); } #endif return; } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void Ener_per_band_comp_ivas_fx( const Word16 exc_diff_fx[], /* i : target signal Q_exc_diff */ Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index 99ebb0841..e1094c9f7 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -77,7 +77,7 @@ void Inac_switch_ematch_fx( test(); IF( ( EQ_16( coder_type, AUDIO ) || ( EQ_16( coder_type, UNVOICED ) && EQ_16( tdm_low_rate_mode, 1 ) ) ) && bfi == 0 ) { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); @@ -94,7 +94,7 @@ void Inac_switch_ematch_fx( /* Find spectrum and energy per band for GC and VC frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); @@ -110,7 +110,7 @@ void Inac_switch_ematch_fx( { /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index ebd0d04ca..96e349a05 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -636,7 +636,7 @@ static void envelop_modify_fx( return; } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -801,7 +801,7 @@ void highband_exc_dct_in_fx( test(); IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) ) { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); #else Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0 ); @@ -809,7 +809,7 @@ void highband_exc_dct_in_fx( } ELSE { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1 ); @@ -1183,7 +1183,7 @@ void highband_exc_dct_in_ivas_fx( test(); IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) ) { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); #else Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add( last_bin, 1 ), 0, L_frame ); @@ -1191,7 +1191,7 @@ void highband_exc_dct_in_ivas_fx( } ELSE { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index 68f10834f..d99d08d48 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -57,7 +57,7 @@ void pre_echo_att_fx( const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC , const Word16 element_mode /* i : Current IVAS element mode*/ #endif @@ -72,7 +72,7 @@ void pre_echo_att_fx( Word16 tmp, n1, n2, exp, frac1, frac2; Word32 etmp1_fx; Word16 att_len; -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Word16 etmp_e, tmp_e; #endif test(); @@ -113,7 +113,7 @@ void pre_echo_att_fx( IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 ) { /* Find the average energy before the attack */ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { etmp_fx = sum32_fx( finc_fx, attack_pos_fx ); @@ -177,7 +177,7 @@ void pre_echo_att_fx( /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { Word16 exp_etmp = sub( 15, Q_new ); @@ -202,7 +202,7 @@ void pre_echo_att_fx( return; } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ diff --git a/lib_com/options.h b/lib_com/options.h index d0af39de3..7e519488b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -88,10 +88,7 @@ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ #define FIX_2252_SCALING_SAVE_HB_SYNTH /* VA: issue 2252: fix use-of-uninit-value in save_hb_synth_fx[] scaling in FOA decoding with bitstream that starts with an SID */ #define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ -#define HARM_GSC_ENC /* VA: Harmonization of EVS and IVAS GSC code */ -#define HARM_GSC_ENC_PART2 -#define HARM_GSC_ENC_PART3 -#define HARM_GSC_ENC_PART4 +#define FIX_1904_HARM_GSC_ENC /* VA: #1904 Harmonization of EVS and IVAS GSC code */ /* #################### End BE switches ################################## */ @@ -102,8 +99,6 @@ #define FIX_1461_CNG_BW_SWITCHING /* Eri: float issue 1461: Stereo parameters are not updated when SID/NODATA forces BW to stay the same */ #define FIX_2041_SPECTRAL_GAPS_FOR_INACTIVE_FRAMES /* FhG: Using rounding in multiplication to improve precision in cngNoiseLevel[] */ #define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/ -//#define FIX_EVS_LR_PG_BUG /* VA: EVS bug on how the lowrate pitch gain is compared to threshold, not used in IVAS */ -//#define FIX_BUG_IN_IVAS_GSC /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index be8459a84..0f037dfea 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1759,7 +1759,7 @@ void Ener_per_band_comp_fx( const Word16 Q_exc_diff, const Word16 Mband, /* i : Max band */ const Word16 Eflag -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC , const Word16 L_frame /* i : frame length */ #endif @@ -1799,12 +1799,12 @@ void pre_echo_att_fx( const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ const Word16 L_frame /* i : Frame length Q0*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC , const Word16 element_mode /* i : Current IVAS element mode*/ #endif ); -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void pre_echo_att_ivas_fx( Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/ @@ -5042,7 +5042,7 @@ void freq_dnw_scaling_fx( Word16 Qx, /* Q format of fy_norm*/ const Word16 L_frame /* i : frame length */ ); -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 627a10361..c3b66c965 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -495,7 +495,7 @@ void decod_audio_fx( /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame, 0 ); #else pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame ); diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 0cb7c6b69..2a1a2e71b 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -156,7 +156,7 @@ void tdm_low_rate_dec_fx( * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame, 0 ); #else pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, attack_flag, st->Q_exc, st->last_coder_type, st->L_frame ); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index f7c7fb58a..0596b2f2d 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1371,7 +1371,7 @@ ivas_error acelp_core_enc_ivas_fx( ELSE IF( EQ_16( st->coder_type, AUDIO ) || ( st->coder_type == INACTIVE && st->inactive_coder_type_flag ) ) { /* AUDIO and INACTIVE frames (coded by GSC technology) */ -#ifndef HARM_GSC_ENC_PART4 +#ifndef FIX_1904_HARM_GSC_ENC encod_audio_ivas_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); #else encod_audio_fx( st, inp, Aw, Aq, res_fx, syn_fx, exc_fx, pitch_buf, voice_factors_fx, bwe_exc_fx, attack_flag, lsf_new_fx, &tmp_noise_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf_fx, Q_new, 0 ); diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index 023c816f2..bfe50a588 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -275,11 +275,8 @@ void encod_gen_voic_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/ -#ifndef FIX_EVS_LR_PG_BUG hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ -#else - hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit_fx ) ); /* Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif*/ -#endif + /*-----------------------------------------------------------------* * Transform domain contribution encoding - active frames *-----------------------------------------------------------------*/ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index 928112c33..ad4356f6e 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -81,7 +81,7 @@ void enc_pit_exc_fx( Word16 g_corr[10]; /* ACELP correlation values + gain pitch */ Word16 clip_gain, i; /* LSF clip gain and LP flag */ const Word16 *p_Aw, *p_Aq; /* pointer to LP filter coefficient vector */ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC Word16 cn[PIT_EXC_L_SUBFR]; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ #else Word16 cn1[L_SUBFR], *cn; /* (Used only when L_subfr == L_SUBFR) Target vector in residual domain */ @@ -107,7 +107,7 @@ void enc_pit_exc_fx( BSTR_ENC_HANDLE hBstr = st_fx->hBstr; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC Word16 q_h1 = 0; #endif /*------------------------------------------------------------------* @@ -231,7 +231,7 @@ void enc_pit_exc_fx( * ACELP subframe loop *------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC set16_fx( cn, 0, PIT_EXC_L_SUBFR ); #else cn = NULL; @@ -246,7 +246,7 @@ void enc_pit_exc_fx( p_Aq = Aq; pt_pitch = pitch_buf; /* pointer to the pitch buffer */ shift_wsp = add( Q_new, shift ); -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { shift_wsp = sub( shift_wsp, 1 ); @@ -264,7 +264,7 @@ void enc_pit_exc_fx( Copy( &res[i_subfr], &exc[i_subfr], L_subfr ); /* Q_new */ /* condition on target (compared to float) has been put outside the loop */ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { find_targets_ivas_fx( speech, hGSCEnc->mem_syn_tmp_fx, i_subfr, &hGSCEnc->mem_w0_tmp_fx, p_Aq, @@ -293,7 +293,7 @@ void enc_pit_exc_fx( *pt_pitch = pit_encode_fx( hBstr, st_fx->acelp_cfg.pitch_bits, Pitch_BR, 0, st_fx->L_frame, Pitch_CT, &pitch_limit_flag, i_subfr, exc, L_subfr, st_fx->pitch, &T0_min, &T0_max, T0, T0_frac, h1, xn, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, st_fx->element_mode, Q_new ); /* Q6 */ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ // TVTODO to be check if it would still be BE when moved above @@ -302,7 +302,7 @@ void enc_pit_exc_fx( /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { pred_lt4_ivas_fx( &exc[i_subfr], &exc[i_subfr], *T0, *T0_frac, L_subfr + 1, L_pitch_inter4_2, L_INTERPOL2, PIT_UP_SAMP ); @@ -333,8 +333,7 @@ void enc_pit_exc_fx( } /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit;*/ -#ifndef FIX_EVS_LR_PG_BUG -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ @@ -344,9 +343,6 @@ void enc_pit_exc_fx( { hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/ } -#else - hSpMusClas->lowrate_pitchGain = mac_r_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 3277, gain_pit ); /* Q14*Q16(0.1) + Q15 -> Q15 Q14*Q15 + Q14 -> Q14 lowrate_pitchGain is compared to Q14 in sp_music_classif */ -#endif gpit_tmp = gain_pit; move16(); /*Q14*/ @@ -373,7 +369,7 @@ void enc_pit_exc_fx( } ELSE IF( use_fcb == 2 ) { -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { inov_encode_ivas_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, @@ -400,7 +396,7 @@ void enc_pit_exc_fx( /*-----------------------------------------------------------------* * Innovation & gain encoding *-----------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { inov_encode_ivas_fx( st_fx, Local_BR, 0, st_fx->L_frame, st_fx->last_L_frame, LOCAL_CT, WB, 1, i_subfr, -1, p_Aq, @@ -417,7 +413,7 @@ void enc_pit_exc_fx( * Gain encoding *-----------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC gain_enc_mless_fx( hBstr, st_fx->acelp_cfg.gains_mode, st_fx->element_mode, st_fx->L_frame, i_subfr, -1, xn, y1, shift_wsp, y2, code, Es_pred, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, clip_gain ); #else @@ -432,7 +428,7 @@ void enc_pit_exc_fx( gcode16 = round_fx_sat( Lgcode ); IF( use_fcb != 0 ) { -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hLPDmem->tilt_code = est_tilt_ivas_fx( &exc[i_subfr], gain_pit, code, gain_code, &voice_fac, Q_new, L_subfr, 0 ); /* Q15 */ @@ -456,7 +452,7 @@ void enc_pit_exc_fx( IF( use_fcb != 0 ) { -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { Ltmp = L_mult0( gcode16, y2[L_subfr - 1] ); /* Q10 + Q_new */ @@ -471,7 +467,7 @@ void enc_pit_exc_fx( Ltmp = L_mac_sat( Ltmp, xn[L_subfr - 1], 16384 ); /* Q_new + Q15 + shift */ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + Q15 + shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ @@ -488,7 +484,7 @@ void enc_pit_exc_fx( Ltmp = L_mult( xn[L_subfr - 1], 16384 ); /* Q_new + 14 -shift */ Ltmp = L_msu_sat( Ltmp, y1[L_subfr - 1], gain_pit ); /* Q_new + 14 -shift */ Ltmp = L_shl_sat( Ltmp, sub( 1, shift ) ); /* Q_new + 15 */ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { hGSCEnc->mem_w0_tmp_fx = round_fx_sat( Ltmp ); /*Q_new-1 */ @@ -644,7 +640,7 @@ void enc_pit_exc_fx( return; } -#ifndef HARM_GSC_ENC +#ifndef FIX_1904_HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 3c89d7968..94a0e9c2a 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -88,7 +88,7 @@ Word16 Pit_exc_contribution_len_fx( Mbands_loc = MBANDS_LOC; move16(); } -#ifdef HARM_GSC_ENC_PART2 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { minimum_fx( pitch_buf, shr( st_fx->L_frame, 6 ), &low_pit ); // This should be the only version if #2253 is included in #1292 @@ -389,7 +389,7 @@ Word16 Pit_exc_contribution_len_fx( set16_fx( pitch_buf, shl( L_SUBFR, 6 ), NB_SUBFR16k ); /* pitch contribution useless - delete all previously written indices belonging to pitch contribution */ -#ifdef HARM_GSC_ENC_PART2 +#ifdef FIX_1904_HARM_GSC_ENC FOR( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) #else for ( i = TAG_ACELP_SUBFR_LOOP_START; i < TAG_ACELP_SUBFR_LOOP_END; i++ ) @@ -428,7 +428,7 @@ Word16 Pit_exc_contribution_len_fx( return last_pit_bin; } -#ifndef HARM_GSC_ENC_PART2 +#ifndef FIX_1904_HARM_GSC_ENC Word16 Pit_exc_contribution_len_ivas_fx( /* o : bin where pitch contribution is significant */ Encoder_State *st_fx, /* i/o: state structure */ const Word16 *dct_res, /* i : DCT of residual Q_new*/ diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 8817eec05..7fa52ec4e 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -60,7 +60,7 @@ void encod_audio_fx( GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Word16 Q_exc; #endif m_mean = 0; @@ -72,7 +72,7 @@ void encod_audio_fx( move16(); T0_frac_tmp = 0; move16(); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { Copy_Scale_sig( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M, sub( sub( Q_new, 1 ), hLPDmem->q_mem_syn ) ); @@ -93,7 +93,7 @@ void encod_audio_fx( * Encode GSC attack flag (used to reduce possible pre-echo) * Encode GSC SWB speech flag *---------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC test(); IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 ) { @@ -356,7 +356,7 @@ void encod_audio_fx( /* add 5 bits for noisiness */ tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); } -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Q_exc = Q_new; move16(); gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); @@ -370,7 +370,7 @@ void encod_audio_fx( edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ @@ -380,7 +380,7 @@ void encod_audio_fx( /*--------------------------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame, st_fx->element_mode ); #else pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); @@ -415,7 +415,7 @@ void encod_audio_fx( /*--------------------------------------------------------------------------------------* * Updates *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { Copy_Scale_sig( &hGSCEnc->mem_w0_tmp_fx, &hLPDmem->mem_w0, 1, sub( hLPDmem->q_mem_syn, sub( Q_new, 1 ) ) ); @@ -430,7 +430,7 @@ void encod_audio_fx( return; } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void encod_audio_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 speech[], /* i : input speech Q_new */ @@ -639,7 +639,7 @@ void encod_audio_ivas_fx( Es_pred_enc_fx( &Es_pred, &indice, st_fx->L_frame, res, st_fx->voicing_fx, nb_bits, 0, Q_new ); push_indice( hBstr, IND_ES_PRED, indice, nb_bits ); } -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC enc_pit_exc_fx( st_fx, speech, Aw, Aq, Es_pred, res, synth, exc, &T0_tmp, &T0_frac_tmp, pitch_buf, nb_subfr, &hGSCEnc->lt_gpitch_fx, &saved_bit_pos, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new, shift ); #else @@ -717,7 +717,7 @@ void encod_audio_ivas_fx( /*---------------------------------------------------------------* * Find and encode the last band where the adaptive (pitch) contribution is significant *---------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC +#ifdef FIX_1904_HARM_GSC_ENC last_pit_bin = Pit_exc_contribution_len_fx( st_fx, dct_res, dct_epit, pitch_buf, nb_subfr, &hGSCEnc->pit_exc_hangover, Q_new ); #else last_pit_bin = Pit_exc_contribution_len_ivas_fx( st_fx, dct_res, dct_epit, pitch_buf, &hGSCEnc->pit_exc_hangover, Q_new ); @@ -758,7 +758,7 @@ void encod_audio_ivas_fx( Word16 Q_exc = Q_new; move16(); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC gsc_enc_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); #else gsc_enc_ivas_fx( st_fx, dct_res, dct_epit, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf, tmp_noise, &Q_exc ); @@ -850,14 +850,14 @@ void gsc_enc_fx( const Word16 Diff_len, const Word16 bits_used, const Word16 nb_subfr, -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ #else const Word16 *lsf_new, /* i : ISFs at the end of the frame Qx2.56*/ #endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill Q_exc*/ Word16 *tmp_noise, /* o : noise energy Q2*/ -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Word16 Q_exc #else Word16 *Q_exc @@ -875,7 +875,7 @@ void gsc_enc_fx( Word16 concat_in[L_FRAME16k]; Word16 concat_out[L_FRAME16k]; Word16 max_ener_band[MBANDS_GN_BITALLOC16k], j; -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Word16 Ener_per_bd_iQ[MBANDS_GN_BITALLOC16k]; #else Word16 Ener_per_bd_iQ[MBANDS_GN16k]; @@ -890,7 +890,7 @@ void gsc_enc_fx( Word16 seed_init; GSC_ENC_HANDLE hGSCEnc = st_fx->hGSCEnc; BSTR_ENC_HANDLE hBstr = st_fx->hBstr; -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Word32 L_tmp; Word16 max_eq = 0; Word16 Q_concat = Q_PVQ_OUT; @@ -939,7 +939,7 @@ void gsc_enc_fx( tmp_band = hGSCEnc->mem_last_pit_band; move16(); } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ ); #else Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1, st_fx->L_frame ); @@ -966,7 +966,7 @@ void gsc_enc_fx( { i--; } -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { mean_gain = gsc_gainQ_ivas_fx( hBstr, st_fx->element_mode, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); @@ -983,7 +983,7 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ -#ifndef HARM_GSC_ENC_PART3 // TV todo, check if BE with EVS bit alloc +#ifndef FIX_1904_HARM_GSC_ENC bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); @@ -1000,7 +1000,7 @@ void gsc_enc_fx( } ELSE { -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could probably be harmonized */ { Q_concat = Q12; @@ -1029,7 +1029,7 @@ void gsc_enc_fx( last_bin = 0; move16(); set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k ); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { max_eq = 0; @@ -1110,7 +1110,7 @@ void gsc_enc_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC test(); test(); test(); @@ -1135,7 +1135,7 @@ void gsc_enc_fx( { freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_concat /*Q12 or Q10*/, st_fx->L_frame ); } -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in ); @@ -1156,7 +1156,7 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Estimate noise level *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); @@ -1172,7 +1172,7 @@ void gsc_enc_fx( return; } -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ Word16 res_dct_in_fx[], @@ -1258,7 +1258,7 @@ void gsc_enc_ivas_fx( tmp_band = hGSCEnc->mem_last_pit_band; } move16(); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame ); #else Ener_per_band_comp_ivas_fx( exc_diff_fx, Ener_per_bd_iQ_fx, *Q_exc, MBANDS_GN, 1, st->L_frame ); diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 78a903f03..d8ba56752 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -112,7 +112,7 @@ void tdm_low_rate_enc( Word16 Q_exc = Q_new; move16(); -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC gsc_enc_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); #else gsc_enc_ivas_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); @@ -129,7 +129,7 @@ void tdm_low_rate_enc( * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ -#ifdef HARM_GSC_ENC_PART3 +#ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame, st->element_mode ); #else pre_echo_att_ivas_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame ); diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index 97ba3cb4a..d2fe6542b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -859,20 +859,20 @@ void gsc_enc_fx( const Word16 Diff_len, const Word16 bits_used, const Word16 nb_subfr, -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Word16 *lsf_new, /* i : ISFs at the end of the frame */ #else const Word16 *lsf_new, /* i : ISFs at the end of the frame */ #endif Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */ Word16 *tmp_noise, /* o : noise energy */ -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC Word16 Q_exc #else Word16 *Q_exc #endif ); -#ifndef HARM_GSC_ENC_PART3 +#ifndef FIX_1904_HARM_GSC_ENC void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ Word16 res_dct_in_fx[], /* i : dct of residual signal */ @@ -4011,7 +4011,7 @@ void enc_pit_exc_fx( const Word16 tdm_Pri_pitch_buf[], /* i : primary channel pitch buffer Q6*/ Word16 Q_new, Word16 shift ); -#ifndef HARM_GSC_ENC +#ifndef FIX_1904_HARM_GSC_ENC void enc_pit_exc_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ const Word16 *speech, /* i : Input speech Q_new-1*/ @@ -4041,7 +4041,7 @@ Word16 Pit_exc_contribution_len_fx( const Word16 nb_subfr, /* i : Number of subframe considered Q0*/ Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); -#ifndef HARM_GSC_ENC_PART2 +#ifndef FIX_1904_HARM_GSC_ENC /* o : bin where pitch contribution is significant */ Word16 Pit_exc_contribution_len_ivas_fx( Encoder_State *st_fx, /* i/o: state structure */ -- GitLab From 535f1bca97955d58a37177a94fb20148aff8c2d2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 10 Dec 2025 14:17:34 -0500 Subject: [PATCH 08/12] fix clang --- lib_enc/gs_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 7fa52ec4e..a70fcd54b 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -983,7 +983,7 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ -#ifndef FIX_1904_HARM_GSC_ENC +#ifndef FIX_1904_HARM_GSC_ENC bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, st_fx->GSC_noisy_speech, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); -- GitLab From 9ea5d5d8f7a678737729d705621ef19fe2305e7f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 Dec 2025 10:37:28 +0100 Subject: [PATCH 09/12] editorial improvements --- lib_com/gs_gains_fx.c | 22 +++++++----- lib_com/gs_inact_switching_fx.c | 4 +++ lib_com/gs_noisefill_fx.c | 7 ++++ lib_com/gs_preech_fx.c | 6 ++-- lib_com/prot_fx.h | 12 ++++--- lib_dec/gs_dec_fx.c | 14 +++++++- lib_dec/ivas_td_low_rate_dec_fx.c | 5 +-- lib_enc/enc_pit_exc_fx.c | 10 ++++-- lib_enc/eval_pit_contr_fx.c | 3 ++ lib_enc/gs_enc_fx.c | 60 +++++++++++++++++++++++++------ lib_enc/ivas_td_low_rate_enc_fx.c | 3 ++ lib_enc/prot_fx_enc.h | 3 ++ 12 files changed, 118 insertions(+), 31 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 877bb4f1f..87aa64ec8 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -260,21 +260,24 @@ void Comp_and_apply_gain_ivas_fx( /* _ None */ /*========================================================================*/ -static Word16 Comp_band_log_ener( /* o : Band gain Q12 */ - const Word16 *pt_fx, /* i : Dct input Q_sc */ - const Word16 Len, /* i : Lenght en energy accumulation */ - const Word16 Q_sc, /* i : scaling of input */ - const Word16 E_sc /* i : Additional scaling factor for energy */ +/* o : Band gain Q12 */ +static Word16 Comp_band_log_ener( + const Word16 *pt_fx, /* i : Dct input Q_sc */ + const Word16 Len, /* i : Lenght en energy accumulation */ + const Word16 Q_sc, /* i : scaling of input */ + const Word16 E_sc /* i : Additional scaling factor for energy */ ) { Word32 L_tmp; Word16 e_tmp, f_tmp, tmp16, ener_exp; + L_tmp = Calc_Energy_Autoscaled( pt_fx, Q_sc, Len, &ener_exp ); e_tmp = norm_l( L_tmp ); f_tmp = Log2_norm_lc( L_shl( L_tmp, e_tmp ) ); e_tmp = sub( sub( add( 30, E_sc ), e_tmp ), ener_exp ); L_tmp = Mpy_32_16( e_tmp, f_tmp, 19728 ); /* Q16 */ /*log10(2) in Q17 */ tmp16 = round_fx( L_shl( L_tmp, 12 - 2 ) ); /* Q12 -1 is to compensate Q17 */ + return tmp16; } @@ -283,10 +286,11 @@ void Ener_per_band_comp_fx( Word16 y_gain4_fx[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc, /* i : frame length */ const Word16 Mband, /* i : Max band */ - const Word16 Eflag /* i : flag of highest band */ #ifdef FIX_1904_HARM_GSC_ENC - , - const Word16 L_frame /* i : frame length */ + const Word16 Eflag, /* i : flag of highest band */ + const Word16 L_frame /* i : frame length */ +#else + const Word16 Eflag /* i : flag of highest band */ #endif ) { @@ -314,6 +318,7 @@ void Ener_per_band_comp_fx( move16(); pt_fx += 32; } + #ifdef FIX_1904_HARM_GSC_ENC IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -323,6 +328,7 @@ void Ener_per_band_comp_fx( move16(); } #endif + return; } #ifndef FIX_1904_HARM_GSC_ENC diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index e1094c9f7..a8d2aa682 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -82,6 +82,7 @@ void Inac_switch_ematch_fx( #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif + /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) { @@ -99,6 +100,7 @@ void Inac_switch_ematch_fx( #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif + /* reset long-term energy per band */ FOR( i = 0; i < MBANDS_GN; i++ ) { @@ -110,11 +112,13 @@ void Inac_switch_ematch_fx( { /* Find spectrum and energy per band for inactive frames */ edct_16fx( exc2, dct_exc_tmp, L_frame, 5, element_mode ); + #ifdef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #else Ener_per_band_comp_ivas_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1, L_frame ); #endif + /* More agressive smoothing in the first 50 frames */ pt_exc = dct_exc_tmp; move16(); diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 96e349a05..da38ca09d 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1018,6 +1018,8 @@ void highband_exc_dct_in_fx( return; } #endif + + void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -1175,11 +1177,13 @@ void highband_exc_dct_in_ivas_fx( { Apply_NoiseFill_fx( exc_diffQ, seed_tcx, noisepb, Diff_len, last_bin, coder_type, mfreq_bindiv, Qexc_diffQ ); } + /*--------------------------------------------------------------------------------------* * Quantize average gain * Subtract Q averaged gain * VQ of remaining gain per band *--------------------------------------------------------------------------------------*/ + test(); IF( EQ_32( core_brate, ACELP_8k00 ) && NE_16( bwidth, NB ) ) { @@ -1196,6 +1200,7 @@ void highband_exc_dct_in_ivas_fx( #else Ener_per_band_comp_ivas_fx( exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1, L_frame ); #endif + test(); IF( LT_16( nb_subfr, 4 ) && LT_16( L_frame, L_FRAME16k ) ) { @@ -1209,9 +1214,11 @@ void highband_exc_dct_in_ivas_fx( } } } + /*--------------------------------------------------------------------------------------* * Check potential energy excitation overshoot *--------------------------------------------------------------------------------------*/ + IF( bfi ) { test(); diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c index d99d08d48..28092088e 100644 --- a/lib_com/gs_preech_fx.c +++ b/lib_com/gs_preech_fx.c @@ -56,10 +56,11 @@ void pre_echo_att_fx( const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ #ifdef FIX_1904_HARM_GSC_ENC - , + const Word16 L_frame, /* i : Frame length Q0*/ const Word16 element_mode /* i : Current IVAS element mode*/ +#else + const Word16 L_frame /* i : Frame length Q0*/ #endif ) { @@ -177,6 +178,7 @@ void pre_echo_att_fx( /*-------------------------------------------------------* * In normal cases, just compute the energy of the frame *-------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( element_mode, EVS_MONO ) ) /* This could be harmonized with EVS, but won't be BE */ { diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 0f037dfea..ae445e504 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1758,10 +1758,11 @@ void Ener_per_band_comp_fx( Word16 y_gain4[], /* o : Energy per band to quantize Q12 */ const Word16 Q_exc_diff, const Word16 Mband, /* i : Max band */ - const Word16 Eflag #ifdef FIX_1904_HARM_GSC_ENC - , + const Word16 Eflag, const Word16 L_frame /* i : frame length */ +#else + const Word16 Eflag #endif ); @@ -1798,10 +1799,11 @@ void pre_echo_att_fx( const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) Q0*/ const Word16 Q_new, const Word16 last_coder_type, /* i : Last coding mode Q0*/ - const Word16 L_frame /* i : Frame length Q0*/ #ifdef FIX_1904_HARM_GSC_ENC - , + const Word16 L_frame /* i : Frame length Q0*/, const Word16 element_mode /* i : Current IVAS element mode*/ +#else + const Word16 L_frame /* i : Frame length Q0*/ #endif ); #ifndef FIX_1904_HARM_GSC_ENC @@ -1814,6 +1816,7 @@ void pre_echo_att_ivas_fx( const Word16 L_frame /* i : Frame length Q0*/ ); #endif + void tcx_get_windows_mode1( const Word16 left_mode, /* i: overlap mode of left window half */ const Word16 right_mode, /* i: overlap mode of right window half */ @@ -5075,6 +5078,7 @@ void highband_exc_dct_in_fx( const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); #endif + void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index c3b66c965..06301938d 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -241,6 +241,7 @@ void decod_audio_fx( nbits = 4; /* Q0 */ move16(); } + test(); IF( LT_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->coder_type != INACTIVE ) { @@ -276,6 +277,7 @@ void decod_audio_fx( Diff_len = mfreq_loc_div_25[pit_band_idx]; /* Q0 */ move16(); } + hGSCDec->Last_GSC_pit_band_idx = pit_band_idx; /* Q0 */ move16(); @@ -283,11 +285,13 @@ void decod_audio_fx( * Decode adaptive (pitch) excitation contribution * Reset unvaluable part of the adaptive (pitch) excitation contribution *--------------------------------------------------------------------------------------*/ + IF( GT_16( pit_band_idx, BAND1k2 ) ) { /*---------------------------------------------------------------* * Decode adaptive (pitch) excitation contribution *---------------------------------------------------------------*/ + test(); test(); test(); @@ -351,6 +355,7 @@ void decod_audio_fx( /*---------------------------------------------------------------* * DCT transform *---------------------------------------------------------------*/ + edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode ); /*---------------------------------------------------------------* @@ -469,7 +474,6 @@ void decod_audio_fx( } } - Word16 Q_exc_old = st_fx->Q_exc; move16(); gsc_dec_fx( st_fx, dct_epit, pit_band_idx, Diff_len, tmp_nb_bits_tot, nb_subfr, st_fx->coder_type, &last_bin, lsf_new, exc_wo_nf, &st_fx->Q_exc ); @@ -486,20 +490,24 @@ void decod_audio_fx( Scale_sig( bwe_exc - PIT16k_MAX * 2, ( PIT16k_MAX + ( L_FRAME16k + 1 ) + L_SUBFR16k ) * 2, Q_exc_old ); /* Q_exc_old */ } } + /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); + /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame, 0 ); #else pre_echo_att_fx( &hGSCDec->Last_frame_ener_fx, exc, gsc_attack_flag, st_fx->Q_exc, st_fx->last_coder_type, st_fx->L_frame ); #endif + /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ @@ -532,6 +540,7 @@ void decod_audio_fx( return; } + /*==========================================================================*/ /* FUNCTION : void gsc_dec_fx () */ /*--------------------------------------------------------------------------*/ @@ -597,6 +606,7 @@ void gsc_dec_fx( /*--------------------------------------------------------------------------------------* * Initialization *--------------------------------------------------------------------------------------*/ + bit = bits_used; move16(); @@ -862,6 +872,7 @@ void gsc_dec_fx( return; } + /*-------------------------------------------------------------------* * GSC_dec_init() * @@ -893,5 +904,6 @@ void GSC_dec_init_fx( hGSCDec->Last_frame_ener_fx = MAX_32; move32(); + return; } diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 2a1a2e71b..8c2893934 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -103,10 +103,6 @@ void tdm_low_rate_dec_fx( attack_flag = 0; move16(); - move16(); - move16(); - move16(); - move16(); /*--------------------------------------------------------------------------------------* * GSC decoder *--------------------------------------------------------------------------------------*/ @@ -152,6 +148,7 @@ void tdm_low_rate_dec_fx( Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], NULL, st->hGSCDec->last_exc_dct_in_fx, L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); } + /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ diff --git a/lib_enc/enc_pit_exc_fx.c b/lib_enc/enc_pit_exc_fx.c index ad4356f6e..2d5902bc3 100644 --- a/lib_enc/enc_pit_exc_fx.c +++ b/lib_enc/enc_pit_exc_fx.c @@ -109,7 +109,9 @@ void enc_pit_exc_fx( LPD_state_HANDLE hLPDmem = st_fx->hLPDmem; #ifdef FIX_1904_HARM_GSC_ENC Word16 q_h1 = 0; + move16(); #endif + /*------------------------------------------------------------------* * Initialization *------------------------------------------------------------------*/ @@ -252,6 +254,7 @@ void enc_pit_exc_fx( shift_wsp = sub( shift_wsp, 1 ); } #endif + FOR( i_subfr = 0; i_subfr < st_fx->L_frame; i_subfr += L_subfr ) { @@ -299,9 +302,11 @@ void enc_pit_exc_fx( Scale_sig( h1, L_subfr, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ // TVTODO to be check if it would still be BE when moved above } #endif + /*-----------------------------------------------------------------* * Find adaptive exitation *-----------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -385,11 +390,12 @@ void enc_pit_exc_fx( inov_encode_fx( st_fx, st_fx->core_brate, 0, st_fx->L_frame, st_fx->last_L_frame, GENERIC, st_fx->bwidth, 0, i_subfr, -1, p_Aq, gain_pit, cn, exc, h2, st_fx->hLPDmem->tilt_code, *pt_pitch, xn2, code, y2, &unbits_PI, 2 * L_SUBFR, shift ); } + /*-----------------------------------------------------------------* * Gain encoding *-----------------------------------------------------------------*/ - gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, - st_fx->element_mode ); + + gain_enc_lbr_fx( st_fx->hBstr, st_fx->acelp_cfg.gains_mode, GENERIC, i_subfr, xn, y1, shift_wsp, y2, code, &gain_pit, &gain_code, &gain_inov, &norm_gain_code, g_corr, gc_mem, gp_mem, clip_gain, 2 * L_SUBFR, st_fx->element_mode ); } ELSE { diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index 94a0e9c2a..dae547e35 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -88,6 +88,7 @@ Word16 Pit_exc_contribution_len_fx( Mbands_loc = MBANDS_LOC; move16(); } + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -98,6 +99,7 @@ Word16 Pit_exc_contribution_len_fx( { minimum_fx( pitch_buf, nb_subfr, &low_pit ); } + exp1 = norm_s( low_pit ); tmp = shl( low_pit, exp1 ); tmp_dec = 12800; @@ -400,6 +402,7 @@ Word16 Pit_exc_contribution_len_fx( delete_indice( hBstr, IND_ES_PRED ); } + IF( LT_32( st_fx->core_brate, CFREQ_BITRATE ) ) { IF( LT_32( st_fx->core_brate, ACELP_9k60 ) ) diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index a70fcd54b..347a00c08 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -63,6 +63,7 @@ void encod_audio_fx( #ifdef FIX_1904_HARM_GSC_ENC Word16 Q_exc; #endif + m_mean = 0; move16(); tmp_nb_bits_tot = 0; @@ -72,6 +73,7 @@ void encod_audio_fx( move16(); T0_frac_tmp = 0; move16(); + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -83,8 +85,9 @@ void encod_audio_fx( { Copy( hLPDmem->mem_syn, hGSCEnc->mem_syn_tmp_fx, M ); /* hLPDmem->q_mem_syn */ hGSCEnc->mem_w0_tmp_fx = hLPDmem->mem_w0; + move16(); } - move16(); + Es_pred = 0; move16(); @@ -93,6 +96,7 @@ void encod_audio_fx( * Encode GSC attack flag (used to reduce possible pre-echo) * Encode GSC SWB speech flag *---------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC test(); IF( NE_16( st_fx->element_mode, EVS_MONO ) && st_fx->idchan == 0 ) @@ -109,7 +113,6 @@ void encod_audio_fx( push_indice( hBstr, IND_GSC_ATTACK, 0, 1 ); } - test(); test(); test(); @@ -122,9 +125,11 @@ void encod_audio_fx( { push_indice( hBstr, IND_GSC_SWB_SPEECH, st_fx->GSC_noisy_speech, 1 ); } + /*---------------------------------------------------------------* * Find and encode the number of subframes *---------------------------------------------------------------*/ + test(); IF( GE_32( st_fx->core_brate, ACELP_9k60 ) && LE_32( st_fx->core_brate, ACELP_13k20 ) ) { @@ -138,6 +143,7 @@ void encod_audio_fx( } } } + test(); test(); test(); @@ -208,6 +214,7 @@ void encod_audio_fx( push_indice( hBstr, IND_HF_NOISE, nb_subfr_flag, 1 ); } } + test(); if ( EQ_16( st_fx->L_frame, L_FRAME16k ) && EQ_16( nb_subfr, NB_SUBFR ) ) { @@ -251,11 +258,14 @@ void encod_audio_fx( /*---------------------------------------------------------------* * DCT transform *---------------------------------------------------------------*/ + edct_16fx( exc, dct_epit, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( res, dct_res, st_fx->L_frame, 7, st_fx->element_mode ); + /*---------------------------------------------------------------* * Calculate energy dynamics *---------------------------------------------------------------*/ + Lm_mean = L_deposit_l( 0 ); FOR( i = 7; i < 15; i++ ) { @@ -343,12 +353,12 @@ void encod_audio_fx( tmp_nb_bits_tot = hBstr->nb_bits_tot; move16(); - if ( st_fx->extl_brate > 0 ) { /* subtract 1 bit for TBE/BWE BWE flag (bit counted in extl_brate) */ tmp_nb_bits_tot = sub( tmp_nb_bits_tot, 1 ); } + test(); test(); if ( EQ_16( st_fx->coder_type, INACTIVE ) && LE_32( st_fx->core_brate, ACELP_9k60 ) && st_fx->idchan == 0 ) @@ -356,6 +366,7 @@ void encod_audio_fx( /* add 5 bits for noisiness */ tmp_nb_bits_tot = add( tmp_nb_bits_tot, 5 ); } + #ifdef FIX_1904_HARM_GSC_ENC Q_exc = Q_new; move16(); @@ -370,6 +381,7 @@ void encod_audio_fx( edct_16fx( dct_epit, exc, st_fx->L_frame, 7, st_fx->element_mode ); edct_16fx( exc_wo_nf, exc_wo_nf, st_fx->L_frame, 7, st_fx->element_mode ); + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -377,17 +389,21 @@ void encod_audio_fx( Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); } #endif + /*--------------------------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *--------------------------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame, st_fx->element_mode ); #else pre_echo_att_fx( &hGSCEnc->Last_frame_ener_fx, exc, attack_flag, Q_new, st_fx->last_coder_type, st_fx->L_frame ); #endif + /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ + IF( st_fx->hBWE_TD != NULL ) { IF( EQ_16( st_fx->L_frame, L_FRAME16k ) ) @@ -415,6 +431,7 @@ void encod_audio_fx( /*--------------------------------------------------------------------------------------* * Updates *--------------------------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { @@ -424,12 +441,15 @@ void encod_audio_fx( #endif { hLPDmem->mem_w0 = hGSCEnc->mem_w0_tmp_fx; + move16(); } - move16(); + Copy( exc_wo_nf, exc, st_fx->L_frame ); return; } + + #ifndef FIX_1904_HARM_GSC_ENC void encod_audio_ivas_fx( Encoder_State *st_fx, /* i/o: State structure */ @@ -842,7 +862,6 @@ void encod_audio_ivas_fx( /* _None */ /*================================================================================*/ - void gsc_enc_fx( Encoder_State *st_fx, /* i/o: State structure */ Word16 res_dct_in[], /* i : dct of residual signal Q_exc*/ @@ -894,7 +913,10 @@ void gsc_enc_fx( Word32 L_tmp; Word16 max_eq = 0; Word16 Q_concat = Q_PVQ_OUT; + move16(); + move16(); #endif + set16_fx( inpulses_fx, 0, NB_SFM ); set16_fx( imaxpulse_fx, 0, NB_SFM ); @@ -929,6 +951,7 @@ void gsc_enc_fx( * This improves the stability of the differnece spectrum since the spectral shape of the * residual signal is less suseptible to rapid changes than the difference spectrum *--------------------------------------------------------------------------------------*/ + IF( Diff_len == 0 ) { tmp_band = 0; @@ -939,14 +962,17 @@ void gsc_enc_fx( tmp_band = hGSCEnc->mem_last_pit_band; move16(); } + #ifndef FIX_1904_HARM_GSC_ENC Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, Q_exc, MBANDS_GN, 1 /*, st_fx->L_frame IVAS_CODE*/ ); #else Ener_per_band_comp_fx( exc_diff, Ener_per_bd_iQ, *Q_exc, MBANDS_GN, 1, st_fx->L_frame ); #endif + /*--------------------------------------------------------------------------------------* * Gain quantizaion *--------------------------------------------------------------------------------------*/ + i = 0; move16(); WHILE( LT_16( i, SIZE_BRATE_INTERMED_TBL ) ) @@ -983,6 +1009,7 @@ void gsc_enc_fx( /*--------------------------------------------------------------------------------------* * Frequency encoder *--------------------------------------------------------------------------------------*/ + #ifndef FIX_1904_HARM_GSC_ENC bands_and_bit_alloc_fx( hGSCEnc->cor_strong_limit, hGSCEnc->noise_lev, st_fx->core_brate, Diff_len, bit, &bit, Ener_per_bd_iQ, max_ener_band, bits_per_bands, &nb_subbands, exc_diff, concat_in, &pvq_len, st_fx->coder_type, st_fx->bwidth, @@ -994,6 +1021,7 @@ void gsc_enc_fx( Q_tmp = *Q_exc; #endif move16(); + IF( bit == 0 ) { set16_fx( concat_out, 0, L_FRAME16k ); @@ -1012,10 +1040,12 @@ void gsc_enc_fx( { tmp = pvq_core_enc_fx( hBstr, concat_in, concat_out, &Q_tmp, bit, nb_subbands, gsc_sfm_start, gsc_sfm_end, gsc_sfm_size, bits_per_bands, NULL, inpulses_fx, imaxpulse_fx, ACELP_CORE ); + Scale_sig( concat_out, gsc_sfm_end[nb_subbands - 1], sub( Q_concat, Q_tmp ) ); /* Q_PVQ_OUT */ bit = sub( bit, tmp ); } } + /* write unused bits */ WHILE( bit > 0 ) { @@ -1023,12 +1053,14 @@ void gsc_enc_fx( push_indice( hBstr, IND_UNUSED, 0, i ); bit = sub( bit, i ); } + /* Reorder Q bands */ seed_init = 0; move16(); last_bin = 0; move16(); set16_fx( bitallocation_band, 0, MBANDS_GN_BITALLOC16k ); + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { @@ -1110,6 +1142,7 @@ void gsc_enc_fx( * Find x pulses between 1.6-3.2kHz to code in the spectrum of the residual signal * Gain is based on the inter-correlation gain between the pulses found and residual signal *--------------------------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC test(); test(); @@ -1135,6 +1168,7 @@ void gsc_enc_fx( { freq_dnw_scaling_fx( hGSCEnc->cor_strong_limit, st_fx->coder_type, hGSCEnc->noise_lev, st_fx->core_brate, exc_diffQ, Q_concat /*Q12 or Q10*/, st_fx->L_frame ); } + #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ { @@ -1153,9 +1187,11 @@ void gsc_enc_fx( } } #endif + /*--------------------------------------------------------------------------------------* * Estimate noise level *--------------------------------------------------------------------------------------*/ + #ifdef FIX_1904_HARM_GSC_ENC highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, @@ -1166,6 +1202,7 @@ void gsc_enc_fx( hGSCEnc->last_exc_dct_in_fx, &hGSCEnc->last_ener_fx, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_PVQ_OUT, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #endif + exc_dct_in[0] = 0; move16(); @@ -1463,6 +1500,8 @@ void gsc_enc_ivas_fx( return; } #endif + + /*======================================================================*/ /* FUNCTION : edyn_fx() */ /*----------------------------------------------------------------------*/ @@ -1484,10 +1523,11 @@ void gsc_enc_ivas_fx( /* _ None */ /*=======================================================================*/ -static Word16 edyn_fx( /* o : ratio of max to mean */ - const Word16 *vec, /* i : input vector Qnew*/ - const Word16 lvec, /* i : length of input vector */ - Word16 Qnew ) +/* o : ratio of max to mean */ +static Word16 edyn_fx( + const Word16 *vec, /* i : input vector Qnew*/ + const Word16 lvec, /* i : length of input vector */ + Word16 Qnew ) { Word16 j = 0; Word16 dyn; @@ -1533,6 +1573,7 @@ static Word16 edyn_fx( /* o : ratio of max to mean */ dyn = 1280; /* 10.0f in Q7 */ move16(); } + return dyn; /* Q7 */ } @@ -1578,6 +1619,5 @@ void GSC_enc_init_fx( hGSCEnc->past_dyn_dec = 0; move16(); - return; } diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index d8ba56752..cdcc684a2 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -112,11 +112,13 @@ void tdm_low_rate_enc( Word16 Q_exc = Q_new; move16(); + #ifdef FIX_1904_HARM_GSC_ENC gsc_enc_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); #else gsc_enc_ivas_fx( st, dct_res_fx, dct_epit_fx, last_pit_bin, tmp_nb_bits_tot, nb_subfr, lsf_new, exc_wo_nf_fx, tmp_noise, &Q_exc ); #endif + /*--------------------------------------------------------------------------------------* * iDCT transform *--------------------------------------------------------------------------------------*/ @@ -134,6 +136,7 @@ void tdm_low_rate_enc( #else pre_echo_att_ivas_fx( &st->hGSCEnc->Last_frame_ener_fx, exc_fx, attack_flag, Q_exc, st->last_coder_type, st->L_frame ); #endif + /*--------------------------------------------------------------------------------------* * Update BWE excitation *--------------------------------------------------------------------------------------*/ diff --git a/lib_enc/prot_fx_enc.h b/lib_enc/prot_fx_enc.h index d2fe6542b..13d11e72b 100644 --- a/lib_enc/prot_fx_enc.h +++ b/lib_enc/prot_fx_enc.h @@ -872,6 +872,7 @@ void gsc_enc_fx( Word16 *Q_exc #endif ); + #ifndef FIX_1904_HARM_GSC_ENC void gsc_enc_ivas_fx( Encoder_State *st, /* i/o: State structure */ @@ -4032,6 +4033,7 @@ void enc_pit_exc_ivas_fx( Word16 Q_new, Word16 shift ); #endif + /* o : bin where pitch contribution is significant */ Word16 Pit_exc_contribution_len_fx( Encoder_State *st_fx, /* i/o: state structure */ @@ -4051,6 +4053,7 @@ Word16 Pit_exc_contribution_len_ivas_fx( Word16 *hangover, /* i : hangover for the time contribution switching Q0*/ Word16 Qnew ); #endif + Word16 pvq_core_enc_fx( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ Word16 coefs_norm[], /* i/o: normalized coefficients to encode */ -- GitLab From c73e3650d9844476d3989fcb764148a372cf60ac Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 07:47:35 -0500 Subject: [PATCH 10/12] addresssing comments --- lib_com/gs_noisefill_fx.c | 4 ++++ lib_com/prot_fx.h | 5 ++--- lib_dec/gs_dec_fx.c | 9 +++++++-- lib_enc/gs_enc_fx.c | 8 ++++---- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index da38ca09d..a23ddb343 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1020,7 +1020,11 @@ void highband_exc_dct_in_fx( #endif +#ifdef FIX_1904_HARM_GSC_ENC +void highband_exc_dct_in_fx( +#else void highband_exc_dct_in_ivas_fx( +#endif const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ Word16 last_bin, /* i : last bin of bit allocation */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1c7374ec7..a25acbe91 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5047,7 +5047,6 @@ void freq_dnw_scaling_fx( Word16 Qx, /* Q format of fy_norm*/ const Word16 L_frame /* i : frame length */ ); -#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -5079,8 +5078,7 @@ void highband_exc_dct_in_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#endif - +#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -5112,6 +5110,7 @@ void highband_exc_dct_in_ivas_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); +#endif void lsf_dec_bfi( const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */ diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index 06301938d..d7748bccd 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -860,12 +860,17 @@ void gsc_dec_fx( /*--------------------------------------------------------------------------------------* * Estimate noise level *--------------------------------------------------------------------------------------*/ - +#ifdef FIX_1904_HARM_GSC_ENC + highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, + &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, + hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, + st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); +#else highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); - +#endif exc_dct_in[0] = 0; move16(); diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index 347a00c08..af8d7d6e4 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -385,7 +385,7 @@ void encod_audio_fx( #ifdef FIX_1904_HARM_GSC_ENC IF( NE_16( st_fx->element_mode, EVS_MONO ) ) { - Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, tbc */ + Scale_sig( exc, st_fx->L_frame, sub( Q_new, Q_exc ) ); /* TV This could probably be removed, but won't be BE */ Scale_sig( exc_wo_nf, st_fx->L_frame, sub( Q_new, Q_exc ) ); } #endif @@ -993,7 +993,7 @@ void gsc_enc_fx( i--; } #ifdef FIX_1904_HARM_GSC_ENC - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ { mean_gain = gsc_gainQ_ivas_fx( hBstr, st_fx->element_mode, st_fx->idchan, Ener_per_bd_iQ, Ener_per_bd_iQ, brate_intermed_tbl[i], st_fx->coder_type, st_fx->bwidth, st_fx->L_frame, st_fx->tdm_LRTD_flag, st_fx->core_brate ); *tmp_noise = mult( mean_gain, 20480 ); // 20480 => 10 in Q11 @@ -1170,7 +1170,7 @@ void gsc_enc_fx( } #ifdef FIX_1904_HARM_GSC_ENC - IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be mathematically BE */ + IF( NE_16( st_fx->element_mode, EVS_MONO ) ) /* This could be harmonized, but won't be BE */ { Word16 Q_exc_new = s_min( *Q_exc, hGSCEnc->Q_last_exc_dct_in ); IF( NE_16( Q_exc_new, hGSCEnc->Q_last_exc_dct_in ) ) @@ -1193,7 +1193,7 @@ void gsc_enc_fx( *--------------------------------------------------------------------------------------*/ #ifdef FIX_1904_HARM_GSC_ENC - highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, + highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #else -- GitLab From fe5854d98ef763a732ab30cad30e3c81e3fd093e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 08:11:43 -0500 Subject: [PATCH 11/12] fix clang --- lib_dec/gs_dec_fx.c | 6 +++--- lib_enc/gs_enc_fx.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/gs_dec_fx.c b/lib_dec/gs_dec_fx.c index d7748bccd..c10306bc8 100644 --- a/lib_dec/gs_dec_fx.c +++ b/lib_dec/gs_dec_fx.c @@ -862,9 +862,9 @@ void gsc_dec_fx( *--------------------------------------------------------------------------------------*/ #ifdef FIX_1904_HARM_GSC_ENC highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, - &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, - hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, - st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); + &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, + hGSCDec->last_exc_dct_in_fx, &hGSCDec->last_ener_fx, hGSCDec->last_bitallocation_band, bitallocation_exc, st_fx->bfi, coder_type, + st_fx->bwidth, exc_wo_nf, Qexc_diffQ, Q_exc, st_fx->GSC_noisy_speech, hGSCDec->lt_ener_per_band_fx, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #else highband_exc_dct_in_ivas_fx( st_fx->core_brate, mfreq_bindiv_loc, *last_bin, Diff_len, hGSCDec->noise_lev, pit_band_idx, exc_diffQ, &hGSCDec->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, diff --git a/lib_enc/gs_enc_fx.c b/lib_enc/gs_enc_fx.c index af8d7d6e4..b2800da5b 100644 --- a/lib_enc/gs_enc_fx.c +++ b/lib_enc/gs_enc_fx.c @@ -1194,8 +1194,8 @@ void gsc_enc_fx( #ifdef FIX_1904_HARM_GSC_ENC highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ /* Q12 */, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in /* Q_exc */, - st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, - st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); + st_fx->last_coder_type, bitallocation_band, lsf_new /* x2.56 */, hGSCEnc->last_exc_dct_in_fx /* Q_exc */, &hGSCEnc->last_ener_fx /* Q0 */, hGSCEnc->last_bitallocation_band, bitallocation_exc, 0, st_fx->coder_type, + st_fx->bwidth, exc_wo_nf, Q_concat, Q_exc, st_fx->GSC_noisy_speech, NULL, st_fx->L_frame, st_fx->element_mode, st_fx->GSC_IVAS_mode ); #else highband_exc_dct_in_fx( st_fx->core_brate, mfreq_bindiv_loc, last_bin, Diff_len, hGSCEnc->noise_lev, tmp_band, exc_diffQ, &hGSCEnc->seed_tcx, Ener_per_bd_iQ, nb_subfr, exc_dct_in, st_fx->last_coder_type, bitallocation_band, lsf_new, -- GitLab From a8b5b65595ff9e22f8064ca223f8befaa7057be8 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 15 Dec 2025 08:31:03 -0500 Subject: [PATCH 12/12] fix function definition --- lib_com/prot_fx.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a25acbe91..577451b04 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -5047,6 +5047,7 @@ void freq_dnw_scaling_fx( Word16 Qx, /* Q format of fy_norm*/ const Word16 L_frame /* i : frame length */ ); +#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -5078,7 +5079,6 @@ void highband_exc_dct_in_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); -#ifndef FIX_1904_HARM_GSC_ENC void highband_exc_dct_in_ivas_fx( const Word32 core_brate, /* i : core bitrate */ const Word16 *mfreq_bindiv, /* i : bin per bands tables */ @@ -5110,6 +5110,38 @@ void highband_exc_dct_in_ivas_fx( const Word16 element_mode, /* i : IVAS element mode */ const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ ); +#else +void highband_exc_dct_in_fx( + const Word32 core_brate, /* i : core bitrate */ + const Word16 *mfreq_bindiv, /* i : bin per bands tables */ + Word16 last_bin, /* i : last bin of bit allocation */ + Word16 Diff_len, /* i : number of bin before cut-off frequency */ + Word16 noise_lev, /* i : pulses dynamic */ + Word16 pit_band_idx, /* i : bin position of the cut-off frequency */ + Word16 *exc_diffQ, /* i : frequency coefficients of per band */ + Word16 *seed_tcx, /* i : Seed for noise */ + Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */ + Word16 nb_subfr, /* i : Number of subframe considered */ + Word16 *exc_dct_in, /* o : dct of residual signal */ + Word16 last_coder_type, /* i : coding type of last frame */ + Word16 *bitallocation_band, /* i : bit allocation flag of each band */ + const Word16 *lsf_new, /* i : LSFs at the end of the frame */ + Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */ + Word16 *last_ener, /* i : frequency energy of last frame */ + Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */ + Word16 *bitallocation_exc, /* i : flag of decoded coefficients */ + Word16 bfi, /* i : bad frame indicator */ + const Word16 coder_type, /* i : coder type */ + Word16 bwidth, + Word16 *exc_wo_nf, /* o : temporal excitation (in f domain) without noisefill */ + Word16 Qexc_diffQ, + Word16 *Q_exc, + const Word16 GSC_noisy_speech, + Word16 *lt_ener_per_band_fx, /* i/o: Average per band energy */ + const Word16 L_frame, /* i : frame length */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 GSC_IVAS_mode /* i : GSC IVAS mode */ +); #endif void lsf_dec_bfi( -- GitLab